If we have a non-ISOC endpoint, we will not have a Link TRB
pointing to the beginning of the TRB pool. On such endpoints,
we don't want to let the driver wrap around the TRB pool
otherwise controller will hang waiting for a valid TRB.
Cc: stable@vger.kernel.org
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
We always return zero instead of the id we found.
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/core.c and drivers/usb/dwc3/dwc3-omap.c
included 'linux/module.h' twice, remove the duplicates.
Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This patch enables to use devm_xxx functions during probing driver.
The devm_xxx series functions are able to release resource when the
driver is detatched. We can remove several codes to release resources
in the probe function.
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Adds Exynos Specific Glue layer to support USB peripherals
on Samsung Exynos5 chips.
[ balbi@ti.com : prevent compilation of Exynos glue layer
on platforms which don't provide clk API implementation ]
Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
this will get rid of a useless memcpy on
IRQ handling, thus improving driver performance.
Tested with OMAP5430 running g_mass_storage on
SuperSpeed and HighSpeed.
Note that we are removing the little endian access
of the TRB and all accesses will be in System endianness,
if there happens to be a system in BE, bit 12 of GSBUSCFG0
should be set so that HW does byte invariant BE accesses
when fetching TRBs.
Signed-off-by: Felipe Balbi <balbi@ti.com>
When host requests us to enter a test mode,
we cannot directly enter the test mode before
Status Phase is completed, otherwise the core
will never be able to deliver the Status ZLP
to host, because it has already entered the
requested Test Mode.
In order to fix the error, we move the actual
start of Test Mode right after we receive
Transfer Complete event of the status phase.
Signed-off-by: Gerard Cauvy <g-cauvy1@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
When implementing the USB2 testmode support via debugfs,
Felipe has committed a mistake when counting the number
of letters of some of the strings, resulting on an off
by one error which prevented some of the Test modes to
be entered properly.
This patch, fixes that mistake.
Signed-off-by: Gerard Cauvy <g-cauvy1@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Those transfer types are generally high bandwidth, so we
want to optimize transfers with those endpoints.
For that, databook suggests allocating 3 * wMaxPacketSize
of FIFO. Let's do that.
Signed-off-by: Felipe Balbi <balbi@ti.com>
debugfs APIs will return NULL if it fails
to create the file/directory we ask it to
create.
Instead of checking for IS_ERR(ptr) we must
check for !ptr.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Convert our platform_data usage to OF property,
keep the legacy pdata for a while until the complete
conversion is done.
Signed-off-by: Felipe Balbi <balbi@ti.com>
When we set Run/Stop bit, we also move the
core to Rx.Detect state so that USB3 handshake
can start from a known location.
Signed-off-by: Felipe Balbi <balbi@ti.com>
We need to dynamically re-size TxFifos for the
cases where default values will not do.
While at that, we create a simple function which,
for now, will just allocate one full packet fifo
space for each of the enabled endpoints.
This can be improved later in order to allow for
better throughput by allocating more space for
endpoints which could make good use of that like
isochronous and bulk.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Mass Storage gadget will take some time to handle
the SetConfiguration request, but even on those
cases we should move to CONFIGURED state.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Only bit 3 of the event status bitfield is valid
and the others should not be considered.
Make sure SW matches documentation on that case
to avoid bogus debugging prints which would
confuse an engineer.
Signed-off-by: Felipe Balbi <balbi@ti.com>
This is very useful for low level link testing where
we might not have a USB Host stack, only a scope to
verify signal integrity.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Most link changes will, of course, happen with
the help of a matching host HW, but in some cases
we might want to debug very low level details about
the link and exposing this to debugfs sounds like
a good plan.
This is a preparation for such setup.
Signed-off-by: Felipe Balbi <balbi@ti.com>
This is very useful for low level Link Testing where
we might not have a USB Host stack, only a scope to
verify signal integrity.
Signed-off-by: Felipe Balbi <balbi@ti.com>
There are some situations were we might need to
enable USB Test Modes without having access to a
Host stack. In such situations we cannot rely
solely on USB Control Messages to enable test
features.
For those cases, we will also allow test mode
to be enabled via debugfs and this patch is a
preparation for that.
Signed-off-by: Felipe Balbi <balbi@ti.com>
num_sgs contains the number of sgs assigned by the gadget.
num_mapped_sgs contains the number of mapped sgs which may differ from
the gadget's values. For dma_unmap_sg() we have to provide the value
which was returned by dma_map_sg().
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
commit 34c60a7 (usb: dwc3: ep0: tidy up Pending
Request handling) introduced a compile warning
by leaving an unused variable.
This patch fixes that warning:
drivers/usb/dwc3/ep0.c: In function ‘__dwc3_gadget_ep0_queue’:
drivers/usb/dwc3/ep0.c:129:8: warning: unused variable ‘type’
[-Wunused-variable]
Signed-off-by: Felipe Balbi <balbi@ti.com>
The way our code was written, we should never have
a DWC3_EP_PENDING_REQUEST flag set out of a Data Phase
and the code in __dwc3_gadget_ep0_queue() did not
reflect that situation properly.
Tidy up that case to avoid any possible mistakes
when starting requests for IRQs which are long
gone.
Cc: stable@vger.kernel.org
Signed-off-by: Felipe Balbi <balbi@ti.com>
This resolves the conflict in the arch/arm/mach-s3c64xx/s3c6400.c file,
and it fixes the build error in the arch/x86/kernel/microcode_core.c
file, that the merge did not catch.
The microcode_core.c patch was provided by Stephen Rothwell
<sfr@canb.auug.org.au> who was invaluable in the merge issues involved
with the large sysdev removal process in the driver-core tree.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Glue needs to be freed on exiting the function in an error case.
Furthermore, pci, which is the first argument to the probe function should
not be freed before leaveing the function, as it is reused at the call
site. So the free of pci is changed to free glue instead.
A simplified version of the semantic match that finds the problem is as
follows: (http://coccinelle.lip6.fr)
// <smpl>
@r exists@
local idexpression x;
statement S;
identifier f1;
position p1,p2;
expression *ptr != NULL;
@@
x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
when != if (...) { <+...x...+> }
x->f1
...>
(
return \(0\|<+...x...+>\|ptr\);
|
return@p2 ...;
)
@script:python@
p1 << r.p1;
p2 << r.p2;
@@
print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
According to USB 3.0 Specification Table 9-22, if
bmAttributes [4:0] are set to zero, it means "no
streams supported", but the way this helper was
defined on Linux, we will *always* have one stream
which might cause several problems.
For example on DWC3, we would tell the controller
endpoint has streams enabled and yet start transfers
with Stream ID set to 0, which would goof up the host
side.
While doing that, convert the macro to an inline
function due to the different checks we now need.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
add support for SG lists on dwc3 driver. With
this we can e.g. use VFS layer's SG lists on
storage gadgets so that we can start bigger
transfers and improve throughput.
Signed-off-by: Felipe Balbi <balbi@ti.com>
the LST bit is to be set on the last of a series
of consecutive TRBs. We had a workaround for a
problem where data would get corrupted but that
doesn't happen anymore. It's likely that it was
caused by some FPGA instability during development
phase.
Signed-off-by: Felipe Balbi <balbi@ti.com>
After a bus reset, we should move our state to
Default, in order to be able to re-enumerate again.
I only managed to trigger this problem with g_ether
by removing the cable after a few transfers had been
completed.
Signed-off-by: Felipe Balbi <balbi@ti.com>
All our revision macros are defined with the entire
32-bits which we read from GSNPSID register, so we
must cache all 32-bits properly rather than masking
the top 16-bits.
This will fix all revision checks we have on current
driver.
Signed-off-by: Felipe Balbi <balbi@ti.com>
There is a very small possibility (previously unimagined
by us) that the whole Mass Storage delayed status happens
rather early, before we even get our XferNotReady event.
In that case, we will be queueing a request to ep0 while
we're still on Setup Phase and we would be waiting for
another usb_ep_queue() forever.
Handle such cases by clearing dwc->delayed_status so that
we start control status from the next XferNotReady like
there was no wait for Delayed Status.
Tested against Linux 3.2-rc3 and USB30CV tool from USB-IF
(on a Windows XP with USB3 PCIe card).
Signed-off-by: Felipe Balbi <balbi@ti.com>
ep->max_streams is a mere hint to the gadget
driver that 'ep' supports stream handling. Using
that as a decision variable for enabling streams
was my worst brain-fart to date.
Instead, we should check from the Superspeed
Endpoint Companion Descriptor if the endpoint
has requested streams. For that we need a little
re-factoring but it is now correct.
Debugged-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
previous commit fixed part of it but it was still
calling usb_ep_queue() from IRQ context without
loosing locks. That cannot be done otherwise we will
have a recursive locking.
Also, we need to assign the 'dep' pointer on
dwc->ep0_usb_req otherwise we will have a NULL
pointer dereference on dwc3_map_buffer_to_dma().
Signed-off-by: Felipe Balbi <balbi@ti.com>
Instead of special functions and shortcuts for sending our internal
answers to the host we started doing what the gadget does and used the
public API for this. Since we only were using a few fields the
usb_request was enough. Later added the list handling in order to
synchronize the host / gadget events and now we require to have the
dwc3_request struct around our usb_request or else we touch memory that
does not belong to us. So this patch does this.
Reported-by: Partha Basak <p-basak2@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
We mask the correct bits within the wrong register. The power
optimization mode is stored hwparam1 register and not in hwparam0.
Reported-by: Partha Basak <p-basak2@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
the new module_platform_driver macro is a helper
for modules which just register and unregister the
platform_driver. It allows us to delete a few
duplicated lines.
Signed-off-by: Felipe Balbi <balbi@ti.com>
DWC3 revisions <1.88a have an issue which would
case a missing Disconnect event if cable is
disconnected while there's a Setup packet
pending the FIFO.
Signed-off-by: Felipe Balbi <balbi@ti.com>
DWC3 revisions <1.90a have an issue which would cause
a missing USB3 Reset event. In such cases, it's
suggested that we follow the steps of a normal
USB3 Reset on Connection Done Event.
Signed-off-by: Felipe Balbi <balbi@ti.com>
RTL revisions <1.83a have an issue where, depending
on the link partner, the USB link might do multiple
entry/exit of low power states before a transfer
takes place causing degraded throughput.
The suggested workaround is to clear bits
12:9 of DCTL register if we see a transition
from U1|U2 to U0 and only re-enable that on
a transfer complete IRQ and we have no pending
transfers on any of the enabled endpoints.
Signed-off-by: Felipe Balbi <balbi@ti.com>
This patch avoids the compiler spitting out the following warning:
|drivers/usb/dwc3/gadget.c:1304: warning: 'trb' is used uninitialized \
in this function
This is only uninitialized if the list of to-cleanup TRBs is empty which
should not be the case because we call this functions once a transfer
completed so it should be on list.
In order to make the warning disappear we return early. This should
never happen and the WARN_ON_ONCE(1) is there in case it happens
so we can investigate what went wrong.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>