History log of /haiku/src/add-ons/kernel/bus_managers/usb/usb_private.h
Revision Date Author Comments
# bd904169 31-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

USB: Do not wait for first explore in Stack constructor.

Following various refactors, at the point the Stack object is created,
there are no bus managers yet, so exploring will find nothing.


# 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>


# 7c18d58f 27-May-2023 Jérôme Duval <jerome.duval@gmail.com>

usb: explore on BusManager::Start()

registering new devices requires the device_manager lock. The explore thread would wait
that the initial device scan is over to register devices.

Change-Id: I46529ab0926f349023f06ada3411979c0950dfcf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6475
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 2c08dd5b 22-Dec-2022 Jérôme Duval <jerome.duval@gmail.com>

bus/USB.h: header for usb device items

Change-Id: Ic36733af169948f54d7d938dfab1cb5aeb34ab9a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5956
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
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>


# 3f7abfc9 03-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

usb: trigger the explore thread when a bus is added

this helps to find the boot disk, otherwise it can happen that the usb disk driver
misses a bus to explore.

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


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

usb: add an interface for usb controllers using the new driver API

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


# 8d046e26 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Split WaitForUnbusy from Object::PutUSBID.

In a few instances, we need to not wait for objects to become unbusy
during ID puts because we expect they still will be, e.g. in the case
of Control pipes with submitted transfers that are still running. There,
we need to put the ID, cancel transfers, and only then wait for the
object to become unbusy.

Technically, this is a functional change, but at least in practice
it will have little real-world effect, for two reasons:

1. The DefaultPipe's Busy flag is basically never updated (the Device's
busy flag is generally used instead), so it will virtually never be
"busy".

2. Most devices have no Control endpoints besides that default one.

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


# 2f496b30 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Make Pipe::CancelQueuedTransfers virtual and add a ControlPipe variant.

Control pipes have internal structures to wait for queued requests.
When force-cancelling queued transfers, the callbacks will not be called,
and so such transfers would be left hanging until the timeout occurred
or the destructor destroys the semaphore and mutex.

This probably will not fix any hang-related tickets, though, as force
cancellation is pretty much only used during device/pipe teardown.

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


# bc7fd433 20-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Rename Transfer::VectorLength to Transfer::FragmentLength.

It did not return the length of the vectors, but only the current
fragment's worth of vectors. It also modified the fFragmented flag,
which really should have been set in SetVectors in the first place.

As everything seemed to call IsFragmented after VectorLength,
this is not a behavioral change.


# 5ee91867 09-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Track object busy-ness and wait for an unbusy state before teardown.

This reverts and replaces hrev53141, hrev53200~1, and hrev53888.

Two years ago (in hrev53141), I added checks to validate that Devices
were not in the process of being torn down before using them, to fix
a race condition KDL. Further logic was added in hrev53200~1 and in
hrev53888 for Pipes.

Well, upon closer inspection following the reports of #16794 et al.,
it appears upon closer inspection there were still two more race
conditions lurking in there: the first between Get and InitCheck, and
the second between InitCheck and use.

To resolve both of these, a new atomic "busy" flag is added to objects,
which is incremented before unlocking the objects array, and then
waited on before actually proceeding with teardown.

The older checks about initialization status are now superfluous
and are removed in favor of an earlier PutUSBID() invocation in Device.

While #16794 was fixed by hrev55429, some of those or related KDLs
might have been caused by these races. This also re-resolves #15115,
along with #14949 and #15710.

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


# 83825112 16-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

USB: Rework Device deinitialization and destruction.

* Destroy interfaces and endpoints before deleting the default pipe,
as all of these may actually use the default pipe at any time
while they are alive.

* Remove the default pipe and then ourselves from the stack before
deleting the default pipe, as it also may be used at any time.

May help with some of the open tickets about USB stack KDLs.


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

USB: Clarify that BusManagers do not really have usb_ids.

Instead their IDs are indexes into the stack, and are used primarily
for TRACE*() printing, so move the getter function into a "protected"
block and rename the variable appropriately.


# 1e02632b 17-Feb-2020 Augustin Cavalier <waddlesplash@gmail.com>

USB: Detach pipes from the stack before tearing down their state.

This way, it is now actually impossible to submit a request to a
pipe that is in the process of being destroyed, solving several
race conditions.

Should fix the remaining KDL in #15710.


# 6e2bbbb1 12-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Rename USB_SPEED_SUPER to USB_SPEED_SUPERSPEED.

For consistency's sake with the others.


# b1ea5557 12-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

USB: Remove USB_SPEED_WIRELESS.

It doesn't belong after SUPER, as it's really an extension of USB 2.0
(Linux puts it after HIGHSPEED indeed, as "USB 2.5".) If we eventually
want to support it, we can add it there.


# 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.


# ce0ef8c8 07-Aug-2018 Augustin Cavalier <waddlesplash@gmail.com>

USB: Remove BeOSCompatibility.h and associated cruft.


# b62bb24f 30-Jan-2016 Michael Lotz <mmlr@mlotz.ch>

USB: Force spec mandated control pipe max packet sizes.

While the USB descriptors are specifically built in such a way that it's
always possible to correctly query the max packet size, some devices
unfortunatley use bogus values in their descriptors and rely on the
stack to use the mandated values.

This fixes USB devices in VirtualBox when EHCI emulation is used. This
really is a bug in their descriptor emulation though.


# 159aa93b 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Generalize logic for debug transfers used within KDL.

Pull debug transfer methods into the base BusManager class and
implement them for UHCI and EHCI. This makes it possible to have a
single debugger command installed by the USB stack instead of HCI
specific ones.


# 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>


# 578558b4 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


# 334c06ae 01-Dec-2013 Jérôme Duval <jerome.duval@gmail.com>

usb: enforce wMaxPacketSize on high speed bulk endpoints.

* according to the USB 2.0 specification.


# 827c7224 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Implement debounce sequence according to USB 2.0 specs.

This replaces waiting a fixed time of 300ms for the device power to
stabilize. In the ideal case this reduces the boot time by 200ms per
connected device (including internal hubs).

This is very similar to what Linux implements and we use the same time
values. An interval of 25ms is used to check for connection state
changes, the stable time is at least 100ms as per the USB specs and the
whole process times out after 1.5 seconds.


# d8b4cfc9 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# 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.


# 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


# 0e76cf0b 31-Mar-2011 Jérôme Duval <korli@users.berlios.de>

added some hub ports information to listusb


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


# 38fc536e 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Some more constness.


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


# 19b8f8a0 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Cleanup and some added constness.


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


# cc9f959d 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Rename usbspec_p.h to usbspec_private.h and fix header guards.


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


# 853e6be8 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

* Rename usb_p.h to usb_private.h.
* Some automatic whitespace cleanup.


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


# 159aa93b31cb5d926ef4939a16419e7d02979b1c 31-Aug-2014 Michael Lotz <mmlr@mlotz.ch>

USB: Generalize logic for debug transfers used within KDL.

Pull debug transfer methods into the base BusManager class and
implement them for UHCI and EHCI. This makes it possible to have a
single debugger command installed by the USB stack instead of HCI
specific ones.


# 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>


# 578558b439867f563d44d168a29223f76d6bb23e 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


# 334c06ae65a0cafcf647aef9f96d2b9b1f59c66e 01-Dec-2013 Jérôme Duval <jerome.duval@gmail.com>

usb: enforce wMaxPacketSize on high speed bulk endpoints.

* according to the USB 2.0 specification.


# 827c7224a0aa44530aa8dfe11ec12c0e58bcb054 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Implement debounce sequence according to USB 2.0 specs.

This replaces waiting a fixed time of 300ms for the device power to
stabilize. In the ideal case this reduces the boot time by 200ms per
connected device (including internal hubs).

This is very similar to what Linux implements and we use the same time
values. An interval of 25ms is used to check for connection state
changes, the stable time is at least 100ms as per the USB specs and the
whole process times out after 1.5 seconds.


# d8b4cfc9829119291e68cfe0152c239fd8850b3d 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# 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.


# 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


# 0e76cf0b69324e071618d5a7105d1084d2a27550 31-Mar-2011 Jérôme Duval <korli@users.berlios.de>

added some hub ports information to listusb


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


# 38fc536e0525ec97d60d4bdd29dbe68e4b17ec13 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Some more constness.


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


# 19b8f8a080715fe6c3062b97770144a0c4886f38 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Cleanup and some added constness.


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


# cc9f959d8b7f501c488918df8dd0469443263438 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Rename usbspec_p.h to usbspec_private.h and fix header guards.


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


# 853e6be8ca7117d62f497d539aa044adc2fdf573 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

* Rename usb_p.h to usb_private.h.
* Some automatic whitespace cleanup.


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