summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/xhci.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Move per HC polling code to the stack.mpi2017-03-101-30/+3
| | | | | | | | | This code contains a use-after-free which be addressed in an upcoming diff. This fix xhci(4) polling mode. ok kettenis@
* Remove superfluous DMA synchronization now that the stack is doing it formpi2016-11-081-4/+1
| | | | | | all HCs. ok patrick@
* Fix some bus_dmamap_sync(9) calls.mpi2016-10-031-17/+40
| | | | | | | | | Do not fold multiple DMA synchronizations into one when chaining TRBs as the ring might wrap. Add missing "READ" transfer direction from the HC to host when applicable. From Marius Strobl.
* Remove a hack now that the USB stack correctly set the maximum packetmpi2016-09-211-9/+3
| | | | | | size based on the device speed. Tested by and ok jsg@, mlarkin@
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-4/+3
| | | | | | | | | | | | | | | | | | | | | | 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);
* Do not change the status of a transfer before giving it back to thempi2015-12-021-7/+7
| | | | | | | | | | stack. Unbreak polling mode when the host Babbles because a reset of the ring is necessary and xhci_waitintr() stops polling as soon as the xfer status changed. Problem reported by and ok krw@
* Unconnected xhci(4) super speed ports may come up with the XHCI_PS_WRC,kettenis2015-11-291-1/+8
| | | | | | | | | | | | indicating a warm reset has happened. Communicate this as UPS_C_BH_PORT_RESET to the upper layers and make uhub(4) clear this bit such that we receive further connection status change notifications. Make sure we only do this for super speed (USB 3.0) hubs as high speed (USB 2.0) hubs use the same bit for UPS_C_PORT_L1. Make hotplugging USB 3.0 devices work on my MacBookPro12,1. ok mpi@
* Mark xhci_intr() as IPL_MPSAFE since it only schedules a soft-interrupt.mpi2015-11-021-5/+1
| | | | ok visa@
* Do not trust the hardware when it says that the number of remainingmpi2015-07-121-1/+4
| | | | | | bytes to transfer is superior to the length of the transfer. Found by krw@ with an ETRON controller.
* Clear root hub's "port link state".mpi2015-06-291-1/+2
| | | | | | | | Allow to re-plug USB3 devices on the root hub withtout going through a suspend/resume cycle (or rebooting) with Intel ICH7 xHCI as found the hardway by sobrado@. Debugging help from M.A.R. Osorio, tested by sobrado@
* Make xhci(4)'s root hub report the same status bits as physical USB3 hubs.mpi2015-06-221-6/+14
| | | | | | | | | | There's not bit to indicate the speed of a USB3.0 device attached to a hub port so do not abuse the PORT_TEST bit. Instead make the xhci(4) root hub report the PORT_POWER_SS bit when appropriate and use it to determin the speed of a new device. While here make the root hub report the link state and config error, from FreeBSD.
* Improve the controller state check in xhci_resetmikeb2015-05-271-2/+3
| | | | From FreeBSD, OK mpi
* Do not truncate possible remaining transfer length.mpi2015-04-191-2/+3
| | | | Reported by Takahiro HAYASHI on bugs@, thanks!
* Do not try to stop and reset endpoints if USB transfers are abortedmpi2015-01-211-2/+4
| | | | | | | | | | | because the HC has been shut down (during suspend/hibernate) or removed (PCIe card). In both cases the hardware wont complete the commands, resulting in timeouts. Instead just do the software part of the abort process. Unbreak suspend/resume with USB a device connected to xhci(4) as reported by Fabian Raetz on bugs@.
* Do not trust the content of event TRBs coming from the hardware andmpi2015-01-181-10/+18
| | | | maintain a list of possibly submitted commands.
* Complete synchronous abort method modeled after the existing ones.mpi2015-01-181-6/+83
| | | | | | | | | | Because our USB stack wants the aborted xfer to be removed from the pipe during abort(), we have to sleep in the abort function. Regarding the xHCI process, when a TD is being aborted, we simply stop the endpoint and then move the dequeue pointer past its last TRB. This is fairly simple for the moment since only one xfer can be pending on a given pipe.
* Since we are no longer resetting rings when a Babble or Stall conditionmpi2015-01-181-40/+30
| | | | | | | | | is detected, simply keep track of the faulty xfer instead of completing all the pending ones. Fix a race condition where we could end up aborting a freshly enqueued xfer when two different threads are submitting control transfers (i.e. usbdevs(8) and a kernel driver).
* Split the consumer & producer logic into two different functions inmpi2015-01-171-30/+48
| | | | | | order to read last TRB of the event ring. Fix a bug introduced in r1.1.
* Properly unwind from a failure in usbd_dma_contig_alloc(). Callingkettenis2015-01-091-14/+16
| | | | | | | bus_dmamap_unload(9) on a map that failed to load is a bad idea and causes panics on some architectures (such as sparc64). ok mpi@
* Prevent a race condition upon resume by adding a supplementary delay.mpi2015-01-051-1/+5
| | | | | | | | | This is a workaround needed at least by Renesas controllers. I didn't find any documentation about this issue and I guess other open source xHCI implementations do not see this race because they do much more work upon resume. Thanks to Remi Locherer for reporting this issue on bugs@.
* Only set the status of a completed xfer just before giving it back tompi2015-01-041-13/+12
| | | | | | | the stack. This will allow stricter checks when aborting transfers. While here update a comment about short transfer and multi-TRB TD since bulk transfers can also use a chain now.
* When chaining TRBs, calculate the TD Size as described in sectionmpi2015-01-021-12/+36
| | | | | | | | | | 4.11.2.4 instead of using one TRB per packet. Also make sure that it is not greater than 31. While here be paranoid about xfer buffer crossing a 64k boundary and use a supplementary TRB in such case. Fix a problem with uplcom(4) on Intel xHCI reported by jasper@.
* Various transfer improvements/fixes.mpi2014-12-211-29/+75
| | | | | | | | | | | | | | | | | Chain TRBs when submitting bulk or interrupt transfers with a length bigger than the Maxium Packet Size of the endpoint. Append a supplementary TRB if a zero length packet is required. While here, set the flags of each TRB at once. Even if this driver implementation fills the first TRB of a chain last, be safe and make sure the hardware wont miss any flag. Note that with this change, DMA sync operations might not cover the whole chain, just like for control transfers, if the ring is starting over. Previous version of this diff tested by Peter N. M. Hansteen, thanks!
* Use a bitmask when dumping TRB flags. No change in !XHCI_DEBUG.mpi2014-12-211-3/+4
|
* Use <sys/endian.h> instead of <machine/endian.h>guenther2014-12-191-2/+2
| | | | ok dlg@ mpi@ bcook@ millert@ miod@
* Stop using usb_{alloc,free}mem() for the rings and internal structures.mpi2014-12-151-106/+169
| | | | | | | | | | | | Since xhci(4) does not allocate memory for its rings in interrupt context, it has no use for the free lists offered by the USB memory allocator. Using bus_dmamem_alloc(9) and friends also allows us to respect the boundary requirement for the various structures specified in Table 54. While here make use of defines for every alignment and boundary requirements which are different than a page size.
* When resetting an endpoint do not purge the ring. Instead set thempi2014-12-081-22/+12
| | | | | dequeue pointer past the last enqueued TRB and let xhci_xfer_done() properly accounts free TRBs.
* No point in setting the Interrupt-on Short Packet bit on OUT endpoint.mpi2014-11-241-4/+5
| | | | | As explained in section 4.11.7 it should be used when a device is allowed to supply less data than the provided buffer space.
* In debug mode, print more information when a transfer is aborted and usempi2014-11-241-10/+12
| | | | a different index value for a chained TRB and a freed one.
* Be less verbose when opening a pipe and print the endpoint & slotmpi2014-11-231-25/+14
| | | | when submitting a command. No change for non-XHCI_DEBUG kernel.
* Two fixes to make Qemu and VMware xHCI implementations work:mpi2014-11-161-5/+12
| | | | | | | | | 1. Always unmask the slot context for the "Set Address" command. 2. Use the right spl when submitting a transfer to prevent from setting up a timer on an already completed xfer. Analyzed with and ok jsg@
* Do not reset the base address of the control endpoint's ring whenmpi2014-11-111-2/+3
| | | | | | | | the second "Set Address" command is issued. This would lead the HC to reprocess TRBs corresponding to completed transfers. This was the cause of the "xhci0: NULL xfer pointer" message that could be seen after attaching a device and reported by naddy@.
* Support USB 1.x devices below external hubs.mpi2014-11-101-1/+29
| | | | | This code is violating various layers of abstraction, just like ehci(4) does. Transaction translators need a bit more love.
* Apparently xhci(4) also needs a hook to set the address of a device.mpi2014-11-101-41/+85
| | | | | | | | | Some Low/Full speed devices do not like to get a SET_ADDRESS command before we have read (some bits of) their device descriptor. So change the attach logic to issue two "Device Address" command with a BSR dance. This should fix the "device problem, disabling port" error seen on root hubs with some Low/Full speed devices, reported by miod@.
* When a pipe is closed, clear the memory of the corresponding enpointmpi2014-11-091-2/+2
| | | | | | context, not the whole array of endpoints. Yeah, pointers are hard. Fix a panic reported by Dimitris Papastamos on tech@
* Document how the Slot States transitions described in section 4.5.3 ofmpi2014-11-071-39/+64
| | | | | | xHCI specification r1.1 are handled in this implementation. This is a bit tricky because our bus interface is pipe-oriented. Hopefully this will help other people squash the remaining bugs in this area.
* Prevent a race when submitting a command by using the appropriate splmpi2014-11-071-9/+13
| | | | | | protection. Fix a panic reported by Patrick Wildt.
* Use the correct default MaxPacketSize for Full Speed devices and make themmpi2014-11-011-3/+3
| | | | work with xhci(4).
* If an event is dequeued just/right after a device is detached, its pipesmpi2014-10-311-2/+11
| | | | might be NULL. Prevent from crashing in this case 8)
* Enable timeouts, just in case(tm).mpi2014-10-311-30/+7
| | | | | | | | Even if it's very handy to know where a thread is sleeping in order to debug HC drivers, users might not like to have to restart their machine if a transfer timed and nothing will wakeup the discovery thread. Note that I still haven't seen any hardware timeout in all my tests.
* Do not use void * for pointer artithmetics, it's a GNU extension, frommpi2014-10-301-3/+3
| | | | Patrick Wildt.
* Do not enable interrupts before attaching usb(4), fix a panic when anmpi2014-10-301-4/+1
| | | | | | | Express Card is plugged with USB devices on it. While here do not print an unitialized error value if xhci_init() fails, from Patrick Wildt.
* Calculate the Route String when attaching a new device. This is stillmpi2014-10-301-13/+29
| | | | | | | not enough to attach Super Speed devices below USB 3 hubs, but we're getting there. While here reset `acten` when re-enqueuing an interrupt transfers.
* Only synchronize used TRBs and not the full ring when sending a controlmpi2014-10-051-9/+13
| | | | transfer. While here remove/fix other XXXs.
* Do not mark the pipe as halted when the HC reports a (split) transactionmpi2014-10-051-1/+5
| | | | | error. Makes Intel Series 7 controllers happy and no longer report an illegal context state transition when detaching devices.
* Wait until a read control transfer is really completed before passingmpi2014-10-041-5/+24
| | | | | | | | | | | | | | | | | | it to the stack when a Short Transfer condition is reported. In this dummy implementation the ``Event Data TRB'' of a read control transfer is the only TRB that can trigger an interrupt without being the last TRB of a transfer. This is done in order to report the remaining length of a short transfer. But when that happens, we want to wait until all Transfer TRBs are completed before passing the xfer to the stack. Note that clearing the ISP and IOC flags in all Transfer TRBs like it is specified in 4.10.1.1.1 might not work in our cases because the HC has most of the time already processed all Transfer TRBs when the driver dequeues the events in the softinterrupt path. While here, use the right spl protection when aborting a xfer.
* Allow new devices to get an address when XHCI_DEBUG is defined.mpi2014-08-301-2/+2
|
* Merge xhci_device_setup() into xhci_pipe_init() there's no reason tompi2014-08-101-34/+24
| | | | | have a separate function anymore, it is just a wrapper around the "set address" command.
* Since USB xfer pools are accessed in interrupt context, initialize themmpi2014-08-101-1/+2
| | | | with the correct ipl to prevent your CPU from locking against itself.
* Set and check for XFER_BUSY in the common methods instead of doing itmpi2014-08-101-19/+3
| | | | in every HC driver.