udev: PCI bridges as parents, USB interfaces, the controller's own address, and the attributes lsusb reads

PCI devices now nest under the bridge they sit behind (from each bridge's
secondary..subordinate window), so a controller behind a root port is where
Linux would put it. USB interfaces (1-5:1.0) are directories with class,
number, a driver link and a uevent with INTERFACE= and a MODALIAS, announced
after the drivers have been offered the device and removed before it. The xHCI
driver tells the USB core its PCI address when it comes up, replacing the guess
that bus N was the Nth controller. Devices and root hubs carry version,
bMaxPacketSize0, bNumInterfaces, bmAttributes and the rest; lsusb -t from
Alpine's usbutils now draws the tree.

Checked on q35 with an xHCI behind a pcie-root-port and a USB keyboard on each
controller. Plain lsusb still fails: libusb wants usbfs, and refuses a kernel
that calls itself 0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EVRhxi9zpdW2uDUN4FVcao
This commit is contained in:
Nexoniarz 2026-10-26 17:54:13 +01:00
commit d650ff433b
6 changed files with 461 additions and 42 deletions

View file

@ -1677,7 +1677,7 @@ xhci_probe(struct pci_dev *d)
// Number the bus and announce its root hub before the first port can be
// scanned, so `usbN` is in /sys, and udev knows of it, ahead of anything
// plugged into it.
usb_bus_add(x);
usb_bus_add(x, d->bus, d->slot, d->func);
// Now, and only now, turn interrupts on. The order is: claim the line
// (which unmasks it and sets level/active-low), clear anything the