From 9446af6d294f5e63406732d2edab62b4401cbb9e Mon Sep 17 00:00:00 2001 From: t Date: Tue, 10 Nov 2026 18:12:17 -0400 Subject: [PATCH] xhci capture: record WHAT is on each connected port, so a plugged drive is distinguishable from the KVM (engine#823) The capture counts ports that report `connect`, which is the right primary evidence for #823 -- but on this board the count is ambiguous, and the first run of the new section says exactly why: ``` bus 3 port 2: 1d6b:0104 product=USB Emulation Device manufacturer=JetKVM speed=480Mbps bus 3 port 5: 0e8d:0717 product=Wireless_Device manufacturer=MediaTek Inc. speed=480Mbps bus 4 port 1: dcba:4321 product=PID-KKK manufacturer=MID-SSS speed=5000Mbps ``` Three ports report `connect` and **none of them is a storage device a person plugged in**: a JetKVM's USB-emulation dongle (HID + audio + emulated mass storage), the internal Bluetooth radio, and a device whose vendor/product are `dcba:4321` -- a placeholder vendor id, i.e. emulation again. A reader looking at "3 port(s) with connect" would reasonably conclude the rear/Type-C ports work, which is the opposite of this issue's report. So the capture now writes `connected-ids.txt` from sysfs (idVendor:idProduct, product, manufacturer, speed, per connected port) and prints it in the VERDICT above the per-bus count. The one physical action this issue waits on -- plug a known drive and read the VERDICT -- then has a decisive answer instead of a port count: the drive the owner plugs in appears with its own ids, and anything else in that list is identified as what it is. Verified: `bash -n` clean; a run on this board writes the three lines above; the awk that feeds it resolves `bus 3 port 2` and `bus 4 port 1` from a synthetic `ports.txt` (so the section is not vacuous on a machine without a KVM); nothing in the capture writes outside its outdir. Refs #823, #1606, #1679. --- tools/xhci_boot_capture.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/xhci_boot_capture.sh b/tools/xhci_boot_capture.sh index cc7992eeb..2e7b33db7 100755 --- a/tools/xhci_boot_capture.sh +++ b/tools/xhci_boot_capture.sh @@ -109,6 +109,25 @@ done lspci -vv 2>/dev/null | awk '/USB controller/{p=1} p{print} p&&/^$/{p=0}' > "$out/lspci-usb.txt" lsusb -t > "$out/lsusb-tree.txt" 2>&1 + +# engine#823: a port with "connect" is only evidence if the reader can tell WHAT is on it. This box carries a JetKVM +# ("USB Emulation Device": HID + audio + mass storage in one composite) and a device whose descriptors read +# `MID-SSS`/`PID-KKK` -- both look like a plugged drive to a port count, and neither answers this issue. So record the +# identity of every connected port, from sysfs, next to the port state: a real drive the owner plugs in is then +# distinguishable by its own idVendor:idProduct and product string rather than by trust. +: > "$out/connected-ids.txt" +while read -r bus port; do + dev="/sys/bus/usb/devices/${bus}-${port}" + [ -d "$dev" ] || continue + vid=$(cat "$dev/idVendor" 2>/dev/null); pid=$(cat "$dev/idProduct" 2>/dev/null) + prod=$(cat "$dev/product" 2>/dev/null); man=$(cat "$dev/manufacturer" 2>/dev/null) + spd=$(cat "$dev/speed" 2>/dev/null) + printf 'bus %s port %s: %s:%s product=%s manufacturer=%s speed=%sMbps\n' \ + "$bus" "$port" "${vid:-????}" "${pid:-????}" "${prod:-?}" "${man:-?}" "${spd:-?}" >> "$out/connected-ids.txt" +done < "$out/connected-ids.txt" dmesg > "$out/dmesg-full.txt" 2>&1 grep -iE 'xhci|usb|acpi.*(usb|UCSI)|pcieport|AER' "$out/dmesg-full.txt" > "$out/dmesg-filtered.txt" 2>&1 @@ -129,6 +148,9 @@ done total=$(wc -l < "$out/controllers.txt") echo " $awake of $total in D0" echo + echo "== what is on each connected port (a plugged drive must be identifiable here, engine#823)" + sed 's/^/ /' "$out/connected-ids.txt" + echo echo "== ports seen with a device attached (connect), per bus" awk '/^== bus/{b=$3} /port [0-9]+:.*connect/{c[b]++} END{for (k in c) printf " bus %s: %s port(s) with connect\n", k, c[k]}' "$out/ports.txt" echo