Repository navigation
Conversation
Power the root hub ports, reset every connected port, then Enable Slot, Address Device and read the Device Descriptor of each device over EP0 control transfers, logging its VID/PID and class. Device Contexts and EP0 rings stay allocated for the controller's lifetime because the controller keeps pointers to them; the control transfer data buffer is per-device and persistent so a timed-out transfer can never DMA into freed memory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: nokosaaan <[email protected]>
|
Could you make the timeout recovery safe before continuing to the next port? drain_events() only removes events that are already available. A timed-out command can still complete afterward, while command() accepts the next Command Completion event without checking its command TRB pointer. For example, if Address Device for port A times out and completes while port B is waiting for Enable Slot, B could accept A’s completion and use the wrong slot ID. The subsequent Address Device call could then consume B’s Enable Slot completion and release its Input Context before the controller has finished using it. wait_transfer() has a similar issue because it does not match the completion to the expected slot, endpoint, or TRB. Please match completions to their submitted operations and keep DMA buffers alive until those operations are known to be complete. Alternatively, stop enumeration after a timeout and safely quiesce the controller before releasing the associated resources or proceeding. Could you also add a regression test with two connected ports and a completion delayed beyond the polling timeout, verifying that the late event cannot complete the next operation or cause premature buffer release? This is a concern from code inspection, not a runtime-reproduced failure. |
Description
Enumerate devices attached to the root hub ports of the xHCI controller brought up in #737. For each connected device, the driver now issues Enable Slot and Address Device, then reads its Device Descriptor and logs the VID/PID and class. No class driver is attached yet; that comes in the PL2303 / CDC-ACM follow-ups.
What this PR does:
HcCore::control()builds the TRBs from a typedSetupPacketand tolerates a Short Packet on the data stage.Changed files:
pcie/usb/xhci/mod.rs,regs.rs(port register and TRB definitions),ring.rs(Transfer Ring alias andslot_id()).Related links
How was this PR tested?
scripts/ci.shpasses on my machine.make qemu-x86_64(controller only, as added in feat(usb): xHCI host controller bring-up (polled) #737): the No-Op succeeds, thenno device found at boot, and the kernel boots to the shell.make qemu-x86_64's arguments plus-device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 -netdev user,id=un0 -device usb-net,netdev=un0,bus=xhci.0. All three devices are enumerated:-device qemu-xhci, there is no xHCI output and boot is unchanged.Notes for reviewers
UsbDeviceis therefore always kept inManuallyDrop, which leaks about 12 KiB per device at boot, once.-device usb-kbd,bus=xhci.0toQEMU_X86_ARGS, so thatmake qemu-x86_64exercises enumeration by default. Let me know if you prefer that.