public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* XHCI debug device is not detected after debug target enables it
@ 2025-09-22  3:23 Marek Marczykowski-Górecki
  2025-09-22 13:39 ` Mathias Nyman
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Marczykowski-Górecki @ 2025-09-22  3:23 UTC (permalink / raw)
  To: linux-usb

[-- Attachment #1: Type: text/plain, Size: 3347 bytes --]

Hi,

I have a setup where XHCI console is used to debug Xen on a laptop.
There are two system involved:
1. SUT - an x86 laptop running Xen, and configured to expose
console over XHCI debug capability
2. debugger - Raspberry Pi 4B to which the debug cable is connected and
where the console can be accessed

The XHCI debug cable is a simple USB3 A-A cable, with D+, D- and Vbus
pins cut. When SUT isn't configured to serve debug console (for
example during boot while in firmware), debugger complains about
connected device, like this:

    usb usb2-port2: config error
    usb usb2-port2: Cannot enable. Maybe the USB cable is bad?
    usb usb2-port2: Cannot enable. Maybe the USB cable is bad?
    usb usb2-port2: Cannot enable. Maybe the USB cable is bad?
    usb usb2-port2: Cannot enable. Maybe the USB cable is bad?
    usb usb2-port2: attempt power cycle
    usb usb2-port2: Cannot enable. Maybe the USB cable is bad?
    usb usb2-port2: Cannot enable. Maybe the USB cable is bad?
    usb usb2-port2: unable to enumerate USB device
    usb usb2-port2: config error

This is expected, as two USB hosts are connected together here. But once
Xen starts and configures XHCI debug console, it's supposed to be
detected as ttyUSB0. When it works, it looks like this:

    usb 2-2: new SuperSpeed USB device number 11 using xhci_hcd
    usb 2-2: LPM exit latency is zeroed, disabling LPM.
    usb 2-2: New USB device found, idVendor=1d6b, idProduct=0010, bcdDevice= 0.00
    usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 2-2: Product: Debug console
    usb 2-2: Manufacturer: Xen
    usb 2-2: SerialNumber: 0
    usb_debug 2-2:1.0: xhci_dbc converter detected
    usb 2-2: xhci_dbc converter now attached to ttyUSB0

This worked fine with 5.15.92 (from Raspberry Pi fork) on debugger. It
also works fine with RPi debugger replaced with another x86 box
(regardless of the kernel version). But after updating RPi to 6.6.78
(also RPi fork) it stopped working. Updating further to 6.12.48 (RPi) or
even 6.16.7 (vanilla) didn't fixed it either. I didn't test vanilla
5.15, but I find it unlikely it worked only due to some RPi patch
before.

When it's broken, SUT waits for the XHCI to enter "configured" state,
IIUC in this loop:
https://gitlab.com/xen-project/xen/-/blob/staging/xen/drivers/char/xhci-dbc.c?ref_type=heads#L864

There are two options to fix it in this state:
- unplugging the cable and plugging it back
- _reading_ /sys/bus/usb/devices/usb2/2-0:1.0/usb2-port2/disable

In the latter case, kernel prints this (note the first line):

    xhci_hcd 0000:01:00.0: port 2-2 resume PLC timeout
    usb 2-2: new SuperSpeed USB device number 11 using xhci_hcd
    usb 2-2: LPM exit latency is zeroed, disabling LPM.
    usb 2-2: New USB device found, idVendor=1d6b, idProduct=0010, bcdDevice= 0.00
    usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 2-2: Product: Debug console
    usb 2-2: Manufacturer: Xen
    usb 2-2: SerialNumber: 0
    usb_debug 2-2:1.0: xhci_dbc converter detected
    usb 2-2: xhci_dbc converter now attached to ttyUSB0

I can 100% reliably reproduce the issue on warm reboot. On cold boot
usually it works.

Any ideas?

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-22 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22  3:23 XHCI debug device is not detected after debug target enables it Marek Marczykowski-Górecki
2025-09-22 13:39 ` Mathias Nyman
2025-09-22 14:17   ` Marek Marczykowski-Górecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox