nuttx/drivers/usbhost
Justin Hammond 18c834b7d3 drivers/usbhost: Release the xHCI slot when enumeration fails.
A device slot is a finite controller resource: HCSPARAMS1 reports how many
exist and Enable Slot fails with No Slots Available once they are gone.
Two paths took one and returned without giving it back.

xhci_device_init() enables a slot before initialising the transfer ring,
the slot context and the device address, and each of those returned
directly on failure.  It also treated a slot number larger than the
controller supports as success, since Enable Slot itself had succeeded.

xhci_enumerate() is the larger leak: the device is addressed by the time
usbhost_enumerate() runs, so a device whose descriptor cannot be read, or
that no class driver claims, leaves the slot held.  That path clears
hport->connected so the port is retried, taking another slot each time.

Release the slot on both paths with xhci_device_deinit(), which issues
Disable Slot, clears the DCBAA entry and resets the context.  The endpoint
ring is left allocated; xhci_ring_init() reuses an existing one.

Tested on an EIC7700X board with a device no class driver claims, so the
port retries indefinitely: previously the eighth attempt failed with
completion code 9 and the controller enumerated nothing further on either
port; now 1104 consecutive attempts produced no slot failure.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-09-20 22:28:07 +08:00
..
CMakeLists.txt drivers/usbhost: Separate the xHCI driver from the PCI bus. 2026-08-18 09:35:23 -03:00
hid_parser.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
Kconfig drivers/usbhost: Separate the xHCI driver from the PCI bus. 2026-08-18 09:35:23 -03:00
Make.defs drivers/usbhost: Separate the xHCI driver from the PCI bus. 2026-08-18 09:35:23 -03:00
usbhost_bthci.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_cdcacm.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_cdcecm.c drivers/usbhost/usbhost_cdcecm.c: Converted CDC-ECM to lower half 2026-05-06 06:20:03 +08:00
usbhost_cdcmbim.c drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
usbhost_composite.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_composite.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
usbhost_devaddr.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_drivers.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_enumerate.c usbhost: Report each device as it is enumerated. 2026-08-09 02:09:47 +08:00
usbhost_findclass.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_ft232r.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_hidkbd.c drivers/usbhost: Do not unregister a HID keyboard that never registered. 2026-08-09 20:57:41 +08:00
usbhost_hidmouse.c drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
usbhost_hub.c arch/arm/src/stm32h5/stm32_usbdrdhost.c: Fixed Hub support 2026-04-19 14:24:40 +08:00
usbhost_max3421e.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_registerclass.c drivers/usbhost: Refuse to register the same class driver twice. 2026-08-08 14:55:34 -03:00
usbhost_registry.c drivers/usbhost: Use small lock to protect usbhost common function 2025-12-13 12:39:48 +08:00
usbhost_registry.h drivers/usbhost: Use small lock to protect usbhost common function 2025-12-13 12:39:48 +08:00
usbhost_skeleton.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_storage.c drivers/usbhost: Register the partitions on a mass storage device. 2026-08-08 14:40:52 -03:00
usbhost_trace.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_waiter.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbhost_xboxcontroller.c drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
usbhost_xhci.c drivers/usbhost: Release the xHCI slot when enumeration fails. 2026-09-20 22:28:07 +08:00
usbhost_xhci.h drivers/usbhost: Describe devices to an xHCI controller correctly. 2026-09-20 22:28:07 +08:00
usbhost_xhci_pci.c drivers/usbhost: Separate the xHCI driver from the PCI bus. 2026-08-18 09:35:23 -03:00
usbhost_xhci_trace.c drivers/usbhost: Correct the xHCI controller name in a trace string. 2026-08-08 14:55:00 -03:00
usbhost_xhci_trace.h drivers/usbhost: Define the xHCI endpoint-allocation trace. 2026-08-08 14:55:00 -03:00