summaryrefslogtreecommitdiff
path: root/drivers/usb/dwc3/gadget.c
AgeCommit message (Collapse)Author
2017-04-14usb: dwc3: gadget: make cache-maintenance on event buffers more robustPhilipp Tomsich
Merely using dma_alloc_coherent does not ensure that there is no stale data left in the caches for the allocated DMA buffer (i.e. that the affected cacheline may still be dirty). The original code was doing the following (on AArch64, which translates a 'flush' into a 'clean + invalidate'): # during initialisation: 1. allocate buffers via memalign => buffers may still be modified (cached, dirty) # during interrupt processing 2. clean + invalidate buffers => may commit stale data from a modified cacheline 3. read from buffers This could lead to garbage info being written to buffers before reading them during even-processing. To make the event processing more robust, we use the following sequence for the cache-maintenance: # during initialisation: 1. allocate buffers via memalign 2. clean + invalidate buffers (we only need the 'invalidate' part, but dwc3_flush_cache() always performs a 'clean + invalidate') # during interrupt processing 3. read the buffers (we know these lines are not cached, due to the previous invalidation and no other code touching them in-between) 4. clean + invalidate buffers => writes back any modification we may have made during event processing and ensures that the lines are not in the cache the next time we enter interrupt processing Note that with the original sequence, we observe reproducible (depending on the cache state: i.e. running dhcp/usb start before will upset caches to get us around this) issues in the event processing (a fatal synchronous abort in dwc3_gadget_uboot_handle_interrupt on the first time interrupt handling is invoked) when running USB mass storage emulation on our RK3399-Q7 with data-caches on. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-04-14usb: dwc3: ensure consistent types for dwc3_flush_cachePhilipp Tomsich
The dwc3_flush_cache() call was declared and used inconsistently: * The declaration assumed 'int' for addresses (a potential issue when running in a LP64 memory model). * The invocation cast the address to 'long'. This change ensures that both the declaration and usage of this function consistently uses 'uintptr_t' for correct behaviour even when the allocated buffers (to be flushed) reside outside of the lower 32bits of memory. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-02-26usb: dwc3: gadget: Remove unused header inclusionVincent Tinelli
Remove sys_proto.h inclusion which is not used by the driver. Signed-off-by: Vincent Tinelli <vincent.tinelli@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2016-01-25bug.h: move BUILD_BUG_* defines to include/linux/bug.hMasahiro Yamada
BUILD_BUG_* macros have been defined in several headers. It would be nice to collect them in include/linux/bug.h like Linux. This commit is cherry-picking useful macros from include/linux/bug.h of Linux 4.4. I did not import BUILD_BUG_ON_MSG() because it would not work if it is used with include/common.h in U-Boot. I'd like to postpone it until the root cause (the "error()" macro in include/common.h causes the name conflict with "__attribute__((error()))") is fixed. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2015-11-03usb: dwc3: Fix warnings on 64-bit buildsMichal Simek
Change aritmentics to use 64bit types to be compatible with 64bit builds. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2015-04-14usb: dwc3: Correct clean up code for requestsLukasz Majewski
For u-boot dwc3 driver the scatter gather list support has been removed from original linux code. It is correct, since we try to send one request at a time. However, the cleanup left spurious break, which caused early exit from loop at dwc3_cleanup_done_reqs() function. As a result the dwc3_gadget_giveback() wasn't called and caused USB Mass Storage to hang. This commit removes this problem and refactor the code to remove superfluous do { } while(1) loop. Test HW: Odroid XU3 (with ./test/ums/ums_gadget_test.sh) Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: gadget: Set non EP0 max packet limit to 512BLukasz Majewski
Commit "drivers/dwc3: add a workaround for too small OUT requests" sets max packet for OUT requests when transfer is smaller. Until this change the default maxpacket for non EP0 EPs was 1024. This is too much, since UMS LBA size is 512B Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: gadget: Set all ctrl fields of Transfer Control Blocks (TRB) to ↵Lukasz Majewski
be LST It turned out that current dwc3 gadget code is preparing multiple TRBs for a transfer. Unfortunately, when multiple requests are in the same queue, only for the last one the LST (last) ctrl bit is set. Due to that dwc3 HW executes all TRBs up till the one marked as last. Unfortunately, UMS requires call of ->complete callback after any send TRB. This is the reason for "hangs" in executing UMS. This code simplifies this situation and set each TRB's ctrl field bit to be last (LST bit). Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: optimize interrupt loopMarek Szyprowski
There is no point in calling dwc3_thread_interrupt() if no event is pending. There is also no point in flushing event cache in EVERY loop iteration. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
2015-04-14usb: dwc3: add a workaround for too small OUT requestsMarek Szyprowski
DWC3 hangs on OUT requests smaller than maxpacket size, so HACK the request length to be at least equal to maxpacket size. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
2015-04-14usb: dwc3: Remove BIT(x) macro from DWC3's gadget codeLukasz Majewski
The BIT() macro is used only in those places, so it is reasonable to replace it by a constant value. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: Add chained TRB support for ep0Kishon Vijay Abraham I
dwc3 can do only max packet aligned transfers. So in case request length is not max packet aligned and is bigger than DWC3_EP0_BOUNCE_SIZE two chained TRBs is required to handle the transfer. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14dwc3: flush the buffers before using itKishon Vijay Abraham I
In the linux kernel, non cacheable buffers are used. However in uboot since there are no APIs to allocate non cacheable memory, all the buffers should be flushed before using it. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
2015-04-14usb: dwc3: gadget: make dwc3 gadget build in ubootKishon Vijay Abraham I
Did a bunch of things to get dwc3/gadget.c compile in u-boot without build errors and warnings *) Changed the included header files to that used in u-boot. *) Used dma_alloc_coherent and dma_free_coherent APIs of u-boot *) removed sg support *) remove jiffies and used a simple while loop *) removed irq support and added a function to call these interrupt handler. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: remove pm related operations from dwc3 driverKishon Vijay Abraham I
Removed all pm related operations including pm_runtime APIs, suspend/resume hooks as support for these are not present in u-boot. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: remove trace_* APIs from dwc3 driverKishon Vijay Abraham I
Removed most of the trace_* APIs from dwc3 driver since tracepoints are not supported in u-boot. Replaced some of the trace_* API with dev_dbg/dev/vdbg. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Review-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: Modify the file headers to u-boot formatKishon Vijay Abraham I
Modified the file header to the format that is used in u-boot. Also included in the header, the commit in linux kernel from which each of these files are added. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14usb: dwc3: add dwc3 folder from linux kernel to u-bootKishon Vijay Abraham I
Added dwc3 folder from linux kernel 3.19-rc1 (97bf6af1f9) to u-boot. This will be adapted to work with u-boot in the following patches. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>