f79954e2bc
Cross-referenced with Linux 7.1 drivers/usb/core/hub.c:
- hub_port_debounce() (line 4698): 25ms-step debounce algorithm
with 100ms stable threshold, 2000ms timeout per USB 2.0 §7.1.7.3
- hub_port_connect_change() (line 5055): connect/disconnect dispatch
- hub_irq() / port_event(): interrupt-driven change detection
PortState enum (replaces ad-hoc bool tracking):
Disconnected → DebouncingConnect → Connected → Active → Disconnected
Debounce: stable_start timestamp, 4x 25ms checks for 100ms
stable window. Connection drop during debounce → reset.
Timeout after 2000ms → warn + remove.
Phase-based main loop:
Phase 1: scan controllers/ports → detect new connections
Phase 2: debounce + state transitions per port
- DebouncingConnect: check stability against stable_start
- Connected: read descriptors → find_driver → spawn
- Active: check driver exit (try_wait) + disconnect detection
Phase 3: cleanup (remove disconnected, time out stale debounces)
Driver re-enumeration on crash: Active → Connected transition
on driver exit re-triggers descriptor read + spawn.
read_port_connected() uses XhciClientHandle open success as
connectivity check (lighter than full descriptor read).