History log of /haiku/src/add-ons/kernel/busses/usb/xhci.h
Revision Date Author Comments
# 629f071b 27-Feb-2024 X512 <danger_mail@list.ru>

pci: extend MSI interrupt vector number to 32 bits

Also increase MSI message data size to 32 bits according to PCIe spec.

Remove 0xff check for MSI interrupts because it is potentially valid
interrupt vector number. Reject 0xff only for legacy pin interrupts.

- MSI-X supports up to 2048 interrupts per device that do not fit to
`uint8`.

- Non-x86 systems may use separate interrupt vector ranges for
hard-wired interrupts and MSI interrupts so `uint8` is not enough to
represent all of them.

Change-Id: Iaf9ffb197ec23db0f97ffe3ea756d28d7bfc8705
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7433
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# f4e363ee 31-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Report ring overrun/underrun (isochronous errors) back to drivers.

Since transfer status is reported via the packet descriptors, we
can report the endpoint status through the callback status.

Reduces syslog spam when using the USB audio driver.


# 94d33dcb 22-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Rework _LinkDescriptorForPipe to avoid double-links.

The previous logic would link from the end of the ring to the start,
and the TRB there would always itself be a link TRB. Now, we avoid this
by linking back to the start from within the TD segments, and putting
the "Event Data" TRB there.

May help with some problems.

Change-Id: I92c4e135ee28c8c89646594a99fb40ee0d6c4484


# 55a46882 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Support physical-vector bulk requests.

Introduce a new utility method, "generic_memcpy", which takes
generic_addr_t plus indications of whether these specify virtual or
physical addresses (and potentially user addresess) and calls the
appropriate memcpy variant depending.

All bus drivers adjusted to support this at once. We don't actually
take advantage of the physical addresses in any way (yet), as USB
controllers have some pretty specific requirements that would have
to be carefully validated to use these directly.

All bus drivers tested and confirmed to still be working.

Change-Id: I66326667e148091147bb2b3d0843a26fb7e5bda6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6479
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 99626c29 29-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Use generic_io_vec in Transfer.

Prepares the way for actual physical-address request support,
which is not yet wired up.

Change-Id: I1b2d04a31e334a79b8361280fa0f3a5fbdb43d2b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6478
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e6ce95c5 10-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: register device nodes for hubs and devices

the device identifier is the USBID. no actual interface to be used by drivers.

Change-Id: I9fd1fdab0d02f1b82380c619b39bc3a12a9e2333
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5736
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3d0c08ef 28-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

xhci: switch to the new driver API

keep the stack loaded when no bus is found

Change-Id: Ic2cf640ead7d94152651cea86a7977caa0920163
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5708
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 6ae7f1f1 07-Dec-2021 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Consolidate xhci_device cleanup routine and use it in AllocateDevice.

This also fixes a leak of slots when initializing devices failed.
Fixes #16323, although there is some other underlying problem
which led to that error in the first place.


# b3683d8a 17-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Get rid of the PortSlots array and use ControllerCookie in FreeDevice.

This array was introduced by korli in hrev44089~1 (2012). It "mapped"
ports to slots using a device's HubPort, and then used this value in
FreeDevice() to locate the xhci_device struct in question.

Well, when there are non-root hubs in use, the HubPort values can
of course collide, leading us to tear down the wrong device in many
circumstances. This appears to have been the true cause of #16794,
and probably also #16878 and #17266, and maybe even some others.


# f20f5569 15-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: The root hub address is always 1.

AllocateAddress() is the pre-USB3 way of doing things;
as we never use it anywhere else and it is specific to
each BusManager, we always just got 1, which is what
the root hub will always be anyway.

Additionally, clarify the logic in _InsertEndpointForPipe
that is special-casing the root hub.

No functional change intended.


# 37db8e9a 24-May-2021 Alexander von Gluck IV <kallisti5@unixzen.com>

xhci: Enhance endpoint state handling

* Expands on previous change to no enter a stopped
state on an endpoint teardown.
* Doorbells could re-awaken the port in a stopped state

Change-Id: Ib5d9c89c4b721ea36ca22aaaf3ff92760a3ec2ff
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3996
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 53d03234 20-May-2021 Alexander von Gluck IV <kallisti5@unixzen.com>

xhci: Check endpoint state before stop

* As per the spec, the only exit from an endpoint in a halt
state is to issue a restart command. (restart puts the endpoint
into a stop state.. it's named poorly)

Change-Id: I4a1a556374ad7f564a562d995d1a2e29230a50c3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3959
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 913f009e 19-Jul-2020 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Add a few comments and remove the documentation file.

The documentation file (which PulkoMandy only merged today) was created
over a year ago from a short conversation I had with him, and by now
a lot of its information is already outdated or has been merged into
comments in the driver already (specifically, the notes at the end about
error messages no longer apply as there are different ones, and the
bugs causing those errors have since been fixed.)

A few of the statements in it were not noted in the driver, though,
so I have added those as comments.


# 41e5cf01 17-Feb-2020 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Remove unnecessary xhci_device::state field.

It was only actually used to determine if a device was disabled
or not, which can be determined by checking the "slot" field
is "0" instead, as 0 is an invalid slot number.

No functional change (intended.)


# 0981cb86 31-Dec-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Rework TRB size handling.

There is a section of the spec that dictates how TRBs need to be
sized within a TD, and we were not following that. This should
bring us into compliance.

See inline comments for more details.


# 6a2133b1 16-Jun-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Overhaul endpoint ring logic.

The changes in this commit are large but also subtle, so
an explanation of how they came to be seems to make sense:

Earlier today I tried booting Haiku on QEMU under USB3 ... and
discovered that it didn't work, with the "Operation timed out"
message from in usb_disk upon failing a data transfer. Indeed,
turning on tracing showed no event was being posted for the
transfer. So, I downloaded QEMU's source code, turned on XHCI
debugging, and began tracing what was going on.

Eventually I determined by adding more and more printfs into QEMU's
XHCI implementation that what was occuring was that it was evaluating
a Link TRB, hitting an empty TRB, and then deciding that the TD (aka.,
the "run" of TRBs) was not ready to be consumed, and bailing.

In fact, that very condition (a link TRB leading to an empty TRB)
is precisely what _LinkDescriptorForPipe did before this commit.
We allocate only a small (8 before this commit, 16 + 1 after this
commit) TRB ring for each *endpoint*, and larger ones on a per-*transfer*
basis; and just write Link TRBs onto the Endpoint ring pointing to
the transfer TD, and then one at the end of each transfer TD leading
back to the endpoint ring.

The reason this occured inside usb_disk, and not earlier (e.g.
during descriptor fetching), is that QEMU has special logic around
determining transfer lengths of control transfers which made it
not perform the "TRB valid?" check after evaluating the Link TRB.
So, being implementation-defined behavior, I am guessing that
this same problem was also the cause of boot failures on real
hardware.

This also means that the problem was essentially a race condition,
as if we posted another transfer to the ring before it evaluated
the TRB, it would always work.

The solution of course is to put some valid TRB at the end of
every transfer on the Endpoint ring. A "no-op" would have done
the job (well, maybe not, it appears QEMU does not implement "no-op"
TRBs for some reason), but there was another feature of XHCI
that we did not take advantage of: Event Data TRBs. These provide
the "total transferred length" as well as the status, instead of
the "remaining length" of the final TRB.

This of course required refactoring the use of the CHAIN bit
and the IOC bit (namely, more or less all TRBs save the Event Data
get the CHAIN bit set, and none save Event Data get the IOC bit.)

There was also an update to the XHCI spec since I've last committed here,
so the new comments are in reference to the "XHCI 1.2" spec. (I'll
eventually find time to update the old ones.)

Fixes booting from USB3 on QEMU, and most likely also on
bare metal, where it at least got to usb_disk (it does
not seem to fix the case where usb_disk does not even start.) Whew!


# 086528f6 16-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB & XHCI: Refactor endpoint initialization to support SuperSpeed better.

SuperSpeed (USB3) devices have a "companion descriptor" along with the
endpoint descriptors that describes certain other attributes they have,
which are important for the controller to schedule transfers properly.
Previously we were just using USB2 values; now we are properly using USB3
ones.

Tested on an Intel Lynx Point controller. As far as I can tell, no
regressions, but #15000 is not fixed anyway.


# 49f507c4 15-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Remove unused parameter to ConfigureEndpoint.

No functional change intended.


# e6a55c69 09-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Miscellaneous tweaks and cleanups.

* Check "endpoint == NULL" instead of the ID for this pipe; as
_InsertEndpointForPipe will have already done the check for us.
* Store the endpoint's ID (our internal ID) in the structure, and
then move the doorbell-ring into _LinkDescriptorForPipe. Now all
variables named "id" are actually that, and not the endpoint number
(which is "id + 1".)
* Return actual statuses in NotifyPipeChange, among other tweaks.
* All things which set the usb_request_data structure also set data,
so we can just use ReadDescriptor to do copies like normal, simplifying
the finish-transfers code.

No (major) functional change intended.


# 3131c130 08-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Implement the debug transfer hooks.

This requires a bit of massaging around the locking code. Probably
we shouldn't be able to do this, and there should be a "mutex_unlock_etc"
for use in interrupt contexts, but at present there is not.

This makes it possible to use XHCI-attached keyboards from within KDL!


# 9bdd88eb 08-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Granularize locking.

This is not so important now (though it is a mild performance improvement
when running transfers during commands), but it will be when the debug
transfer hooks are implemented, as we will need to use these to determine
if it is safe to queue and poll for transfers or not.


# 187a2c6c 08-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Completely overhaul endpoint configuration logic.

The code as it was before was very hard to follow and incorrect in
a number of corner cases, as well as not being very clear about what
the TODOs were.

It now follows the spec much more closely (especially in interval
computation) and contains more details on where it is still lacking.

This probably does not fix much (if anything) as is, but it paves the
way for future isochronous support.


# 2df34466 04-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Allocate one physical chunk for all buffers if possible.

Besides calling the allocator fewer times, this also helps break up
the size classes we are allocating chunks from, reducing memory pressure.

As most transfers are smaller than 128KB, this is a major performance
optimization for them.


# bae7f6d5 04-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Completely rewrite Transfer Descriptor and related logic.

This is essentially a complete rewrite of the way TDs work, and a
significant change to how "normal" requests are submitted. In summation:
* There is now no such thing as a "descriptor chain". This was a concept
mostly carried over from EHCI and previous controllers that does not
really map to XHCI properly, as one "transfer descriptor" can contain
as many TRBs as are necessary to complete the transfer.

What we were really doing before was setting up multiple TRB sequences
owned by our xhci_td structure, and then linking them together with the
CHAIN bit set on each TRB, which in XHCI terms is *one* descriptor,
not multiple ones as we had it, and we were allocating the same amount
of memory anyway, so we might as well do it all in one structure.

So now xhci_td does not have a fixed size of TRBs, but rather a dynamic
one, and thus also a dynamic number of buffers. As part of this refactor,
xhci_td is now a data structure for our own use only, and so it is allocated
from the normal heap instead of as physical memory, and TRBs separately.
* Removing the distinction between "descriptor" and "descriptor chain" greatly
simplifies quite a lot of logic related to transfer handling, especially
in WriteDescriptor and ReadDescriptor, which no longer need to handle
writing to buffers across xhci_td boundaries.
* There is now a proper split between "trb_count" and "trb_used". The former
is the actual number of TRBs allocated in the data structure; the latter
is the number presently used in said data structure. This clarifies
quite a lot of code.

As part of this refactor, a number of other related issues were also cleaned up:
* TRB buffer sizes are now hard-coded to be 4x the Max Packet Size for the
given pipe. Previously they were 64KB, which is much larger than the spec
suggests. As we now size them exactly this way, we can set the endpoint's
Average TRB Length to this value also, which allows the controller to
better schedule transfers for us. This logic can probably be cleaned up
further in the future, even.
* We now write the "TD Size" field of Normal transfers (i.e. packet count,
not TRB count) properly, as it is now much easier to compute based on
our new TRB sizing logic.
* We now record the Max Packet Size for the endpoint in the endpoint
structure. (This will probably be more useful when we are dealing
with isochronous transfers later on.)
* Write the last cycle bit in _LinkDescriptorForPipe after everything else
has been written. This probably does not affect anything too seriously,
but it is technically more correct.
* Added section & page references to the specification in various comments.
* Added more error checking where applicable.

Some things still to be done that I noticed while working on this change:
* When we use a single large buffer and manually segment it rather than
calling AllocateChunk() for each one, there is a massive performance
gain (I saw 50MB/s -> 95MB/s in testing on some USB devices.) However,
we can't do this unconditionally, as the stack doesn't allocate physical
chunks larger than 32 * B_PAGE_SIZE, which is a problem for some filesystems
which can read/write in chunks of 1MB. I'll implement this in a later commit.
* Setting the IOC bit on the last TRB in a transfer is acceptable to find
out when the transfer is finished, but it isn't enough to get a proper
tally of how much data was transfered. This is what Event Status TRBs
are for; we should implement them.
* _LinkDescriptorForPipe has an overflow condition. I'll fix that in the
next commit.

Tested on a ThinkPad E550 (Intel Broadwell) with usb_disk and usb_hid.


# 10230c7a 04-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Reorder some functions and tweak class definition.

No functional change intended (some methods are now private,
but nothing outside this class used them, so no change.)


# 8fa626d0 16-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

XHCI: Refactor register area access and handling.

* Don't bother aligning the PCI memory addresses; they will already
be aligned, and even if by some mystery they aren't, map_physical_memory
should be able to handle that. This greatly simplifies the code.
* Use one pointer and then four different offset fields instead of four
different pointers. This is what DragonFlyBSD and FreeBSD do; it's
a negligible loss in performance (or none at all, depending on arch
and compiler) as it requires only one more add, and greatly clarifies
the code as to what's going on.
* Remove (both previously and now) unused fields from the header.
* Compute runtime and doorbell register offsets correctly (there
was a missing bitmask.) This is how it's done on FreeBSD and
DragonFlyBSD.
* Actually write the high bits of the DMA addresses. Checked against
FreeBSD and DragonFlyBSD.
* Tweak error message.

Possibly fixes the "invalid bus space memory access" crash, but
I don't have any hardware that occurs on so I couldn't check.

Tested in VMware, VirtualBox, and on a ThinkPad E550 (Broadwell).


# bd234de1 07-Sep-2018 Alexander von Gluck IV <kallisti5@unixzen.com>

xhci: Turn OpsReg waits into common function

Change-Id: I52ada3447b638db07622fa51746e75ce6cce7a46
Reviewed-on: https://review.haiku-os.org/518
Reviewed-by: Alexander von Gluck IV <kallisti5@unixzen.com>


# 96ef28f8 07-May-2018 Murai Takashi <tmurai01@gmail.com>

xhci: Remove unnecessary parentheses

Remove unnecessary parentheses in declaration of
'trbs' pointed out by gcc8.

Change-Id: I87d043866929d1a7f56ce97aa3667c91eeed52e0


# 4d5934a2 02-Aug-2017 Jérôme Duval <jerome.duval@gmail.com>

xhci: handle 64 bytes context structures.

* it shouldn't harm controllers with 32-bytes context size.


# deb50a89 28-Mar-2017 Alexander von Gluck IV <kallisti5@unixzen.com>

xhci: Cleanup tracing, add trb ring dump

* Cleanup trace output. Don't print hex without 0x prefix.


# 8a12a74e 27-Jul-2016 Jérôme Duval <jerome.duval@gmail.com>

XHCI: fix KDL for transfers using more than 1TD.

* TD chains were broken, any transfer above ~1MB would trigger a KDL.
* _LinkDescriptorForPipe() links the last TD of the chain instead of the first.
* Still buggy: the transfer ring can still block and transfers then fail.
* Enable TRB_3_ISP_BIT where appropriate (Interrupt on Short Packet).
* Also fix WriteDescriptorChain() and ReadDescriptorChain() for multiple-TD chains.


# 936696c7 30-Jun-2016 Jérôme Duval <jerome.duval@gmail.com>

XHCI: fix handling of transfer events.

* previously processing of transfer began when an event on the transfer descriptor happened. Now wait until the last TRB to be processed to process and free the descriptor. Chains are probably not handled correcly yet, but usual transfers happen on a single TD.
* use a specific link pointer for transfer descriptor chains.
* tested on VirtualBox passthrough with mounting an external SSD enclosure. It doesn't scale well with SMP: 1CPU ~115MB/s, 2CPU ~65MB/s, 4 CPU ~50MB/s.
* whitelist controller Intel product ID 0x1e31 (found on VB5).


# 9ff90257 18-Jun-2016 Murai Takashi <tmurai01@gmail.com>

XHCI: Increase fScratchpadCount size

* To fix clang's '-Wtautological-constant-out-of-range-compare' warnings in xhci.cpp.
* by korli: adjust trace print macro.
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# f91361e0 02-Aug-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI: Even more fixes.

* Fix Endpoint Context Initialisation (Refer xHCI v1.1 - 6.2.3)
* Fix Interval Calculation (Refer xHCI v1.1 - 6.2.3.6 , USB 2.0 - 9.6.6 page 271)
* Fix MaxBurst, MaxPacketSize Calculation (Refer xHCI v1.1 - 6.2.3.5, USB 2.0 - 9.6.6 page 271)
* Fix MaxESITPayload Calculation (Refer xHCI v1.1 - 4.14.2)
* Remove Link TRBs as they were never being used
* Increase Number of TRBs per endpoint (to utilise the whole area allocated for Device TRBs)
* Fix usage of XHCI_MAX_ENDPOINTS (most of the checks were failing at corner cases)
* Some coding style fixes.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Before this patch, writes to USB disks on XHCI in VirtualBox (which emulates
an Intel C210) stalled or failed. After this patch, they apparently work,
although I got mixed results - a BFS disk seemed to work perfectly, a FAT32
one also seemed to work OK but after a reboot there was data corruption. USB
mouse is still as busted as ever.


# 2bc202c4 23-Nov-2015 Jérôme Duval <jerome.duval@gmail.com>

XHCI USB: Add port routing for Intel WildcatPoint LP USB.

* from FreeBSD.


# 17aa359b 28-Jun-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI USB: Fixes.

* Add support for hubs in AllocateDevice().
* Prevent page fault in FinishTransfers().
* Set fCapabilityLength
* Correct in BIOS ownership code
* Fix context errors in _InsertEndpointForPipe().
* Update constants according to latest Specification (v1.1)
* Fix SMI code (reference
http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
* Fix Memory/Device-Slot leaks.
* Fix area allocation for TRBs.
* Fix for Intel Lynx Point and Panther Point chipsets. Also move init
of xhci before ehci, to switch USB 2.0 ports before the ehci module
discovers them.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 96adf3ff 30-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

XHCI USB: add MSI support

* similar to OHCI support by mmlr.
* interrupt handler is removed on destruction.


# b9a31d3e 26-Jun-2013 Jérôme Duval <jerome.duval@gmail.com>

xhci: 64bit fixes.

* some coding style fixes.
* adjustments to make use of phys_addr_t where needed.


# 411272ad 03-Jun-2012 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on xHCI bus driver

* added a thread to handle events, locking wasn't easy in an interrupt
handler
* the td struct can now track several buffers instead of just one.
* use Transfer::Data*() instead of Vector*() for the time being
until support for fragmented transfers is done
* added CreateDescriptorChain, WriteDescriptorChain and ReadDescriptorChain,
chained tds not working yet though.
* added a mutex lock per enabled endpoint, lock when touching the endpoint
transfer ring.
* correctly configure interval and average trb length for endpoint contexts.
* interrupt transfers seem to work on real hardware
* xhci qemu driver doesn't advance ring dequeue pointers on link trbs, thus
accessing freed trbs that could already be reused, leading to crash.


# 77a7e76c 02-May-2012 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on xHCI bus driver, testing on emulation.

* Initial testing with QEmu emulation works with interrupt/bulk,
testing on real hardware still not working. Small bulk requests work
OK, not bigger ones (for instance it can't load the MediaPlayer
application at 800KB).
* QEmu doesn't support byte read in the MMIO space, switch to double word.
* added SubmitNormalRequest() for interrupt and bulk endpoints.
* AllocateDevice(): fixed the physical address of the link TRB pointing
to the beginning of the ring.
* _InsertEndpointForPipe(): setup context for non-default endpoints
on creation. This should get the device to the configured state.
* _UnlinkDescriptorForPipe(): the next pointer wasn't null after unlinking.
* HandleTransferComplete(): add descriptor to a list to be processed by the
finisher thread.
* FinishThread(): process finished transfers and call the callback,
then free the TRB.


# 2b31b4a8 01-May-2012 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on xHCI bus driver.

* added more traces, coding style
* added xhci_td, xhci_endpoint structs.
* SubmitRequest: this links a 3-stage TD control request into
the endpoint ring.
* _InsertEndpointForPipe: when a pipe is created, configure the
endpoint and set up the controller cookie.
* CreateDescriptor and FreeDescriptor: allocates memory for a TD.
* _LinkDescriptorForPipe: link a TD in an endpoint ring.
* _UnlinkDescriptorForPipe: unlink a TD
* AllocateDevice:
slot number zero isn't valid.
stick the slot number to the device struct.
configure the default endpoint before calling SetAddress.
address is found in the device context instead of the input context.
device address passed to the USB stack has to begin with 1.
* Ring:
check for invalid slot/endpoint combination.
ring the slot doorbell instead of the doorbell 0.
* Root hub: fixed USB version.
* HandleTransferComplete: finds out the TD which submitted a
transfer.


# 319a3798 22-Dec-2011 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on XHCI bus driver.

* USB Core:
Hub: pass more correct speed, port and address for USB3 devices.
Transfer: doesn't care for bandwidth computation for super speed.
BusManager: Make AllocateDevice() and FreeDevice() virtual, XHCI needs to setup
a slot and an address for the device.
Add USB_SPEED_WIRELESS usb_speed definition.
Add USB2.0 erratum definition and some USB3 definitions
* XHCI:
Find outs which port supports SuperSpeed or not.
Override AllocateDevice() to configure slot and address for a connected device.
Override FreeDevice() to free ressources associated to a slot.
Add context struct definitions.


# d11be975 15-Dec-2011 Jérôme Duval <jerome.duval@gmail.com>

XHCI improvements

* remove the xhci cmd complete thread
* creation of the scratchpad area
* wait for running status after starting the controller
* increase delays on controller reset (250ms instead of 100ms)
* use of SpinLocker from AutoLock.h
* add a DoCommand() method to queue a command, ring and wait for the event
response
* add a method for each command
* XHCI_PORTSC macro was off 1 port
* add definitions for TRB types, Completion Codes.


# d6e4f54f 29-Jul-2011 Jérôme Duval <korli@users.berlios.de>

Patch by Jian Chiang as part of his GSoc Project (coding style fixes by myself):
* xhci controller start operation
* command ring and event ring initialization
* No-Op Command test and real xhci irq handle
* xhci root hub support
* add Super Speed enumeration and xhci_rh.cpp into jamfile


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42511 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 18451a0c 30-Mar-2011 Jérôme Duval <korli@users.berlios.de>

Added skeleton XHCI driver by Jian Chiang, based on the specs and the EHCI driver.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41142 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 17aa359b5df69f658b4b33e29546c9fb2f0cfce3 28-Jun-2014 Akshay Jaggi <akshay1994.leo@gmail.com>

XHCI USB: Fixes.

* Add support for hubs in AllocateDevice().
* Prevent page fault in FinishTransfers().
* Set fCapabilityLength
* Correct in BIOS ownership code
* Fix context errors in _InsertEndpointForPipe().
* Update constants according to latest Specification (v1.1)
* Fix SMI code (reference
http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
* Fix Memory/Device-Slot leaks.
* Fix area allocation for TRBs.
* Fix for Intel Lynx Point and Panther Point chipsets. Also move init
of xhci before ehci, to switch USB 2.0 ports before the ehci module
discovers them.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 96adf3ffad2c81bd60876fff16f8768e2c035c9f 30-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

XHCI USB: add MSI support

* similar to OHCI support by mmlr.
* interrupt handler is removed on destruction.


# b9a31d3e18c1f6f1ad49d6d2ebfa5cfa7d7b2cb8 26-Jun-2013 Jérôme Duval <jerome.duval@gmail.com>

xhci: 64bit fixes.

* some coding style fixes.
* adjustments to make use of phys_addr_t where needed.


# 411272adfd60dcab0a42879cc617b59d9c333ca3 03-Jun-2012 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on xHCI bus driver

* added a thread to handle events, locking wasn't easy in an interrupt
handler
* the td struct can now track several buffers instead of just one.
* use Transfer::Data*() instead of Vector*() for the time being
until support for fragmented transfers is done
* added CreateDescriptorChain, WriteDescriptorChain and ReadDescriptorChain,
chained tds not working yet though.
* added a mutex lock per enabled endpoint, lock when touching the endpoint
transfer ring.
* correctly configure interval and average trb length for endpoint contexts.
* interrupt transfers seem to work on real hardware
* xhci qemu driver doesn't advance ring dequeue pointers on link trbs, thus
accessing freed trbs that could already be reused, leading to crash.


# 77a7e76cc13ba10f354d1cf43467b612149e04ab 02-May-2012 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on xHCI bus driver, testing on emulation.

* Initial testing with QEmu emulation works with interrupt/bulk,
testing on real hardware still not working. Small bulk requests work
OK, not bigger ones (for instance it can't load the MediaPlayer
application at 800KB).
* QEmu doesn't support byte read in the MMIO space, switch to double word.
* added SubmitNormalRequest() for interrupt and bulk endpoints.
* AllocateDevice(): fixed the physical address of the link TRB pointing
to the beginning of the ring.
* _InsertEndpointForPipe(): setup context for non-default endpoints
on creation. This should get the device to the configured state.
* _UnlinkDescriptorForPipe(): the next pointer wasn't null after unlinking.
* HandleTransferComplete(): add descriptor to a list to be processed by the
finisher thread.
* FinishThread(): process finished transfers and call the callback,
then free the TRB.


# 2b31b4a88cdcc94b3db80cd453b9fd366420873c 01-May-2012 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on xHCI bus driver.

* added more traces, coding style
* added xhci_td, xhci_endpoint structs.
* SubmitRequest: this links a 3-stage TD control request into
the endpoint ring.
* _InsertEndpointForPipe: when a pipe is created, configure the
endpoint and set up the controller cookie.
* CreateDescriptor and FreeDescriptor: allocates memory for a TD.
* _LinkDescriptorForPipe: link a TD in an endpoint ring.
* _UnlinkDescriptorForPipe: unlink a TD
* AllocateDevice:
slot number zero isn't valid.
stick the slot number to the device struct.
configure the default endpoint before calling SetAddress.
address is found in the device context instead of the input context.
device address passed to the USB stack has to begin with 1.
* Ring:
check for invalid slot/endpoint combination.
ring the slot doorbell instead of the doorbell 0.
* Root hub: fixed USB version.
* HandleTransferComplete: finds out the TD which submitted a
transfer.


# 319a3798bc05579e8be813c2524bc89864bae489 22-Dec-2011 Jérôme Duval <jerome.duval@gmail.com>

Work in progress on XHCI bus driver.

* USB Core:
Hub: pass more correct speed, port and address for USB3 devices.
Transfer: doesn't care for bandwidth computation for super speed.
BusManager: Make AllocateDevice() and FreeDevice() virtual, XHCI needs to setup
a slot and an address for the device.
Add USB_SPEED_WIRELESS usb_speed definition.
Add USB2.0 erratum definition and some USB3 definitions
* XHCI:
Find outs which port supports SuperSpeed or not.
Override AllocateDevice() to configure slot and address for a connected device.
Override FreeDevice() to free ressources associated to a slot.
Add context struct definitions.


# d11be9757252d31dfc4d9cdbc6ec17737c30c217 15-Dec-2011 Jérôme Duval <jerome.duval@gmail.com>

XHCI improvements

* remove the xhci cmd complete thread
* creation of the scratchpad area
* wait for running status after starting the controller
* increase delays on controller reset (250ms instead of 100ms)
* use of SpinLocker from AutoLock.h
* add a DoCommand() method to queue a command, ring and wait for the event
response
* add a method for each command
* XHCI_PORTSC macro was off 1 port
* add definitions for TRB types, Completion Codes.


# d6e4f54f2de4c76fbfbe85fc348a8fde8c296dc6 29-Jul-2011 Jérôme Duval <korli@users.berlios.de>

Patch by Jian Chiang as part of his GSoc Project (coding style fixes by myself):
* xhci controller start operation
* command ring and event ring initialization
* No-Op Command test and real xhci irq handle
* xhci root hub support
* add Super Speed enumeration and xhci_rh.cpp into jamfile


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42511 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 18451a0c360c0db068891588dc0f6d97c5ee9cb9 30-Mar-2011 Jérôme Duval <korli@users.berlios.de>

Added skeleton XHCI driver by Jian Chiang, based on the specs and the EHCI driver.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41142 a95241bf-73f2-0310-859d-f6bbb57e9c96