summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/xhci.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Add support for non-root hubs now that uhub(4) can deal with them. Formpi2014-08-091-12/+16
| | | | | | the moment only Super and High Speed devices are properly recognized. Some TT love is required for Full and Low speed devices.
* Make sure asynchronous commands do not race with synchronous ones.mpi2014-08-081-9/+19
| | | | | | | | Since asynchronous commands can be submitted from interrupt context it was possible to race with a process waiting for the completion of a previously submitted command. So stop relying on the per-softc TRB pointer for asynchronous commands and simply get the address of the command TRB from the event TRB.
* Improve the logic to determine the maximum endpoint service interfacempi2014-08-081-14/+31
| | | | | time payload. Super speed companion descriptor are still not used but at least we can properly initialize super speed interrupt pipes.
* Implement polling.mpi2014-08-081-2/+16
|
* Even if the endpoint it reseted before the stack gets informed that ampi2014-08-081-2/+5
| | | | | transfer stalled, report that a stall happen because umass(4) relies on this behavior...
* Remove redundant mask check in the interrupt routine.pirofti2014-07-111-3/+2
| | | | | | We return earlier if the interrupt is masked. Discussed with and okay mpi@
* Always assign the device address found by the USB stack even if itmpi2014-07-101-5/+2
| | | | | | | | | | | | | | does not match the hardware address. This change only matters for xHCI buses where the controller assigns device addresses. But it is the simplest way to comply with the stack requirement of assigning the first `logical' address to the root hub device. Device addresses are not much used anyway and a cleanup will follow to avoid possible confusions. This makes usbdevs(8) correctly report devices connected to xhci(4).
* Now that the stack handles properly the xhci(4) way of setting anmpi2014-07-091-43/+47
| | | | | | | | address, kill some no longer true comments and create a proper function to assign an address. For the moment, an address is assigned when setting up a slot for a new device.
* Handle the stall condition just like the bable one since in both casesmpi2014-05-211-6/+1
| | | | | | | | | | | | the ring is halted. Do not bother reporting USBD_STALLED to the stack like other HC drivers do since the endpoint is automatically reseted. What is the point of this error apart from making sure driver authors will forget to call usbd_clear_endpoint_stall_async() correctly? The Renesas uPD720202 xHCI, provided by Stefan Wollny, now works as expected.
* Format string fixes for XHCI_DEBUG.mpi2014-05-201-11/+11
|
* Plug an xfer leak when detaching root hubs.mpi2014-05-091-8/+4
| | | | | | | | | This leak is similar to the public xfer leak #1 that was affecting device interrupt pipes except that root hubs are rarely detached. Note that this xfer is never associated to any TD and is just used to indicate that some of the HC ports has changed status, so there is no need to flag it as "done" before completing it.
* Get rid of the per-softc freelist of transfer descriptors and use ampi2014-04-291-24/+24
| | | | | | per-driver pool(9) instead. With inputs from mikeb@
* Use the `use_polling' hack to make sure usb_delay_ms() will notmpi2014-04-071-1/+5
| | | | | | | | call tsleep(9) on resume. deraadt@ pointed that this not needed for powerdown since `cold' is set. Another approach would be to call delay() directly in the reset functions, but let stay coherent with the other HC drivers.
* XHCI -> xHCI to be consistent with device names.mpi2014-04-031-2/+2
|
* Do not declare a struct as const if we write to it, fix build on sparc64mpi2014-03-281-2/+2
| | | | reported by brad@.
* If a command is submitted when the hardware is already gone, it willmpi2014-03-281-7/+7
| | | | | | obviously time out. That is what happen when pipes are closed after unplugging an xhci(4) express card for example. In such case, make sure the command TRB is reset.