Skip to content

Conversation

@RealityAnomaly
Copy link

Skips detaching USB devices when S0ix is enabled using the qubes_exp_pm_use_suspend kernel parameter. Since this parameter prevents drivers from detaching from the host controller, there's no reason to detach devices. This also makes resume from suspend significantly faster as USB devices are available immediately.

Skips detaching USB devices when S0ix is enabled using the qubes_exp_pm_use_suspend kernel parameter.
Since this parameter prevents drivers from detaching from the host controller, there's no reason to detach devices.
This also makes resume from suspend significantly faster as USB devices are available immediately.
@RealityAnomaly
Copy link
Author

Actually, I think this might be invalid because vhci_hcd doesn't want to suspend with an active connection. I'm marking this as draft while I look into it...

@RealityAnomaly RealityAnomaly marked this pull request as draft August 23, 2025 18:22
@marmarek
Copy link
Member

There may still be an issue similar to the original one, but this time about device suspend, not disconnect. Specifically, vhci_hcd trying to suspend the USB device, while sys-usb is already suspended. I'm just speculating, but worth checking if that's the case.

@marmarek
Copy link
Member

In any case, I would be very happy to get rid of this forced disconnection, if possible...

@RealityAnomaly
Copy link
Author

I received the following message on VMs I had a device passed through, and it didn't go to sleep:
vhci_hcd: we have 1 active connection, do not suspend

After reading https://lwn.net/Articles/1031546, I noticed the following: "The USB/IP Virtual Host Controller (VHCI) platform driver is expected to prevent entering system suspend when at least one remote device is attached to the virtual USB root hub."

So I don't think we can do this. At least not changes to vhci_hcd to make it suspend capable (with active connections).

@marmarek
Copy link
Member

I suspect it might be done this way for the standard case of USB/IP really over IP. If that's the only reason, it's probably okay to change it via a patch. But it's a low priority.

@RealityAnomaly
Copy link
Author

I suspect it might be done this way for the standard case of USB/IP really over IP. If that's the only reason, it's probably okay to change it via a patch. But it's a low priority.

I'll investigate and see how reliable it is with the check removed.

@RealityAnomaly
Copy link
Author

I just tested it with this patch, it doesn't work at all. Suspend fails, and then when it comes back, the USB stack in sys-usb is totally broken and the client domains of the usbip connection get stuck in suspend. Some logs for reference:

[2025-08-24 03:14:09] [  197.468257] xen:manage: Using suspend/resume for sleep/wakeup
[2025-08-24 03:14:09] [  197.470247] usbip-host X-X.X: device removed?
[2025-08-24 03:14:09] [  197.585028] xhci_hcd 0000:00:XX.0: PM: pci_pm_suspend(): hcd_pci_suspend returns -16
[2025-08-24 03:14:09] [  197.585065] xhci_hcd 0000:00:XX.0: PM: dpm_run_callback(): pci_pm_suspend returns -16
[2025-08-24 03:14:09] [  197.585090] xhci_hcd 0000:00:XX.0: PM: failed to suspend async: error -16
[2025-08-24 03:14:09] [  197.756773] xen:manage: do_suspend: dpm_suspend_start -16
[2025-08-24 03:14:09] [  197.757152] OOM killer enabled.
[2025-08-24 03:14:09] [  197.757165] Restarting tasks ... done.
[2025-08-24 03:14:12] [  199.906960] usbip-host X-X.X: submit_urb error, -113
[2025-08-24 03:14:12] [  199.907088] hub X-X:X.0: hub_ext_port_status failed (err = -113)
[2025-08-24 03:14:12] [  199.907118] usb X-X-portX: cannot reset (err = -113)
[2025-08-24 03:14:12] [  199.907139] usb X-X-portX: cannot reset (err = -113)
[2025-08-24 03:14:12] [  199.907159] usb X-X-portX: cannot reset (err = -113)
[2025-08-24 03:14:12] [  199.907178] usb X-X-portX: cannot reset (err = -113)
[2025-08-24 03:14:12] [  199.907198] usb X-X-portX: cannot reset (err = -113)
[2025-08-24 03:14:12] [  199.907216] usb X-X-portX: Cannot enable. Maybe the USB cable is bad?
[2025-08-24 03:14:12] [  199.907247] usb X-X-portX: cannot disable (err = -113)
[2025-08-24 03:14:12] [  199.907269] hub X-X:X.0: hub_ext_port_status failed (err = -113)

BTW, until if and when this is fixed, we'll still need to add an exception in https://github.com/QubesOS/qubes-core-agent-linux/blob/main/qubes-rpc/prepare-suspend for the USB controllers under S0ix mode. Otherwise as I reported in the original S0ix issue USB devices won't get reattached on resume. (A temporary workaround is to just not pass the qubes_exp_pm_use_suspend flag to sys-usb.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants