summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/dwc2 (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Rename bNumInterface to bNumInterfaces to fix build on arm64.kurt2021-01-281-2/+2
|
* Move the responsibility of syncing the data buffers from the USBpatrick2020-04-031-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stack into the USB controller driver, since not all of the xfers actually use DMA and some invalidations might even be harmful. The important part is to sync before handing the buffer to the controller, and to sync on a successful transfer before handing it back to the USB stack. For isoc transfers it's easier to sync the complete length of the transfer, since the buffer to flush is not filled in a contiguous fashion. For dwc2 there's a common point which takes care of the start of transfers from or to devices, where we can make sure that our buffers are synced. On completion, there's a common point before handing it off to the USB stack. For ehci there are three places which take care of the start of transfers from or to devices, where one already does the sync, while the two other places still need the sync. There are two completion handler (isoc and non-isoc), where one already has a comment asking for the need of a sync. The done handler for intr xfers does a sync that is not needed anymore after adding the sync in the completion handler. For ohci there are three places which take care of the start of transfers from or to devices, where all of them were still in need of the sync. For completion, there is one place for isoc xfers and two places for handling successful generic xfers. For uhci there are two places which take care of the start of transfers from or to device, where all of them were still in need of the sync. For completion, there is one handler for both isoc and non-isoc xfers where syncs need to occur. For xhci there are three places which take care of the start of transfers from or to device, where all of them were still in need of the sync. For completion, there is one handler for isoc and one for non-isoc xfers where syncs need to occur. With this we can revert the workaround that implicitly allocated buffers are COHERENT, since now control transfers fulfilled by the driver code (instead of the controller doing DMA) are not flushed into oblivion anymore. Tested by Janne Johansson with dwc2 (octeon) Tested by kettenis@ with xhci(4) (octeon) Tested by patrick@ with ehci(4) on a Cubox-i (armv7) Tested by patrick@ with xhci(4) on an i.MX8MQ (arm64) Tested by tobhe@ with dwc2 on a rPi 3b (arm64) ok kettenis@
* Instead of passing the flags as part of a struct that's supposed to bepatrick2020-03-213-12/+8
| | | | | | | filled by the callee, change the usb_allocmem() API to take another argument for the flags. ok mpi@
* Switch USB to use non-coherent buffers for data transfers. Sincepatrick2020-03-193-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the import in '99 all buffers allocated using usb_allocmem() have been mapped COHERENT. On some ARM SoCs, where the USB controller is not coherent with the caches, this means the buffers were mapped uncached. This drastically reduces the performance, especially on reads. We already added cache syncs before and after USB transfers, but so far those have essentially been no-ops. Since other drivers make use of the same allocation code, and those haven't been proven to have correct syncs, we can't just remove the COHERENT flag. This splits the allocation into coherent and non-coherent blocks. All drivers who call usb_allocmem() themselves now pass a flag to show they require coherent blocks. Onced verified that they also work fine without coherent, or once they have been refactored, we can remove this again. On a ure(4) connected to an i.MX8MQ, the receive performance is 10x as fast as before. The Raspberry Pi's ethernet receive speed doubled. Debugged using dt(4) Original diff from Marius Strobl Feedback from kettenis@ Tested on an i.MX8MQ (arm64) by patrick@ Tested on a Raspberry Pi (arm64) by tobhe@ Tested on an ERL (octeon) by Janne Johansson ok mpi@ gerhard@ tobhe@
* Convert infinite sleeps to tsleep_nsec(9).mpi2019-11-271-2/+2
| | | | ok bluhm@
* Use non-blocking allocation in dwc2_allocx() to makevisa2019-03-141-2/+6
| | | | | | | | | the routine safe to use in soft interrupt context. This fixes an assertwaitok() panic reported by Abel Abraham Camarillo Ojeda. OK mpi@
* Add missing bus powered bit, from aalm@mpi2019-03-111-2/+2
|
* If you use sys/param.h, you don't need sys/types.hderaadt2017-09-085-10/+5
|
* EPROTO is now in sys/errno.hotto2017-09-051-2/+1
|
* kill RCSID macros; discussed with millertderaadt2017-06-297-40/+7
|
* Check the validity of the `qtd' pointer after each interrupt casevisa2017-06-201-11/+57
| | | | | | | | | | and bail out if the pointer has become invalid. This prevents use-after-free memory accesses that corrupted the dwc2qtd pool. This fix improves stability on the Raspberry Pi 3. From Linux commit dc8730846948e517169f630826cd2c97615f5ee8 OK kettenis@
* Replace remaining SPLUSBCHECK by a splsoftassert(IPL_SOFTUSB).mpi2017-05-151-2/+2
| | | | USB is the last real user of IPL_SOFTNET.
* Rename Debugger() into db_enter().mpi2017-04-301-2/+2
| | | | | | | Using a name with the 'db_' prefix makes it invisible from the dynamic profiler. ok deraadt@, kettenis@, visa@
* Partially revert previous mallocarray conversions that containdhill2017-04-111-7/+7
| | | | | | | | | constants. The consensus is that if both operands are constant, we don't need mallocarray. Reminded by tedu@ ok deraadt@
* Convert some malloc(9) to mallocarray(9)dhill2017-04-092-9/+9
| | | | ok deraadt@
* Fix a use-after-free when sending root hub control transfers.mpi2017-03-101-2/+2
| | | | | | | | | | | *_root_ctrl_start() routines are synchronous and all end up calling usb_transfer_complete() in the non-error case. After calling this function it is unsafe to dereference ``xfer'' since the transfer callback has been called. So returning USBD_IN_PROGRESS is wrong in this case since transfers are always completed at this point. So return USBD_NORMAL_COMPLETION or the corresponding error code if something wrong happen.
* Move per HC polling code to the stack.mpi2017-03-101-47/+1
| | | | | | | | | This code contains a use-after-free which be addressed in an upcoming diff. This fix xhci(4) polling mode. ok kettenis@
* Remove an unnecessary NULL pointer check.visa2017-02-161-7/+4
| | | | OK stsp@
* Align mutex IPL with the interrupt handler's priority.visa2017-02-151-2/+2
| | | | Spotted by stsp@; OK jmatthew@
* Replace dummy mutex asserts with real ones.visa2017-02-124-9/+7
| | | | OK stsp@
* Prefer <sys/endian.h> to <machine/endian.h>guenther2017-02-041-2/+2
| | | | ok visa@
* In dwctwo(4), fix an off-by-one in frame interval calculation.stsp2017-01-291-3/+3
| | | | | Fix stolen from Linux commit 9ed04d976146cf10dfa4c71171434af7c0348747 ok visa@
* Remove unused functions.kettenis2016-09-242-59/+2
| | | | ok jmatthew@, visa@
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-7/+4
| | | | | | | | | | | | | | | | | | | | | | the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
* Drop unused goto label.visa2015-12-231-4/+3
|
* Remove two error-on-NULL conditions for allocations that can't fail.mmcc2015-12-182-11/+2
| | | | ok visa@
* Properly cancel any pending USB abort task when aborting a transfervisa2015-09-031-2/+13
| | | | | | | and skip completed transfers in dwc2_abort_xfer(). This fixes some timeout-related crashes. Feedback and ok mpi@
* Remove the abort_task field in struct dwc2_xfer. There is an identicalvisa2015-09-032-8/+5
| | | | | | field in struct usbd_xfer which is part of dwc2_xfer. ok mpi@
* Remove sc->sc_lock and add several splusb()'s in dwc2, to avoid avisa2015-09-032-88/+15
| | | | | | | possible lock recursion panic on transfer timeout. The lock is not needed yet because the USB stack is not MP-safe. ok mpi@, "makes sense" jasper@
* Convert list_head lists into TAILQs and LISTs and fix up header includesjmatthew2015-06-2810-184/+189
| | | | | | so we can build dwc2 without extra stuff. tested by several edgerouter lite owners, ok jasper@
* Revert previous. uvideo checks the transfered length of every frame andmpi2015-06-261-5/+5
| | | | | | this break some devices. As found the hardway by Hugo Sastre via sobrado@
* Do not update frame lengths to reflect what has really been transferedmpi2015-06-221-5/+5
| | | | | | | | when an isochronous transfer is done. Frame lengths are just input values and no driver mess with them. ok ratchov@, jmatthew@
* rearrange delayed_work to avoid the use of container_of while leaving it injmatthew2015-06-085-22/+23
| | | | | | more or less the same shape. ok uebayasi@
* refuse to do polled isochronous transfers, as other usb controller drivers dojmatthew2015-06-081-4/+5
| | | | requested by mpi@
* Ensure polled bulk, control and interrupt transfers actually poll, fixingjmatthew2015-06-081-9/+6
| | | | | | panics on shutdown with various usb sticks. ok mpi@
* Let it compile.mpi2015-03-191-5/+5
|
* Abort tasks are run in their own thead, that's why they need a specialmpi2015-03-191-2/+2
| | | | type, from Patrick Wildt.
* Use the same workaround as ehci(4) and ohci(4) in setaddr() to deal withmpi2015-03-191-1/+26
| | | | half configured control pipe, from Patrick Wildt.
* Handle (poll) HCD interrupt right after initialization to immediately markuebayasi2015-02-141-1/+4
| | | | ports as enabled/connected.
* Fix typos.uebayasi2015-02-122-8/+8
|
* Provide interface for external DMA address configuration.uebayasi2015-02-126-12/+53
|
* Remove a stray ;.uebayasi2015-02-121-2/+2
|
* Move register accessor macros to saner place.uebayasi2015-02-122-7/+9
|
* De-static for backtracing, but using #define to not change indent (for now).uebayasi2015-02-129-275/+279
|
* Simplify debug ifdefs.uebayasi2015-02-121-2/+2
|
* Don't panic even if parent port doesn't exist.uebayasi2015-02-121-3/+5
|
* - Fix thinko about struct usbd_xfer allocation.uebayasi2015-02-112-10/+9
| | | | - Use bus_dma_tag_t held in struct usbd_bus.
* Fix debug build, etc.uebayasi2015-02-112-20/+23
|
* Catch up with the new taskq_create(9) API.uebayasi2015-02-112-5/+5
|
* Adjust usb(9) API differences to at least compile.uebayasi2015-02-106-65/+82
|