Skip to content

Commit e40b984

Browse files
cristiccgregkh
authored andcommitted
usb: vhci-hcd: Prevent suspending virtually attached devices
The VHCI platform driver aims to forbid entering system suspend when at least one of the virtual USB ports are bound to an active USB/IP connection. However, in some cases, the detection logic doesn't work reliably, i.e. when all devices attached to the virtual root hub have been already suspended, leading to a broken suspend state, with unrecoverable resume. Ensure the virtually attached devices do not enter suspend by setting the syscore PM flag. Note this is currently limited to the client side only, since the server side doesn't implement system suspend prevention. Fixes: 04679b3 ("Staging: USB/IP: add client driver") Signed-off-by: Cristian Ciocaltea <[email protected]> Acked-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 264a58e commit e40b984

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/usb/usbip/vhci_hcd.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
765765
ctrlreq->wValue, vdev->rhport);
766766

767767
vdev->udev = usb_get_dev(urb->dev);
768+
/*
769+
* NOTE: A similar operation has been done via
770+
* USB_REQ_GET_DESCRIPTOR handler below, which is
771+
* supposed to always precede USB_REQ_SET_ADDRESS.
772+
*
773+
* It's not entirely clear if operating on a different
774+
* usb_device instance here is a real possibility,
775+
* otherwise this call and vdev->udev assignment above
776+
* should be dropped.
777+
*/
778+
dev_pm_syscore_device(&vdev->udev->dev, true);
768779
usb_put_dev(old);
769780

770781
spin_lock(&vdev->ud.lock);
@@ -785,6 +796,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
785796
"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
786797

787798
vdev->udev = usb_get_dev(urb->dev);
799+
/*
800+
* Set syscore PM flag for the virtually attached
801+
* devices to ensure they will not enter suspend on
802+
* the client side.
803+
*
804+
* Note this doesn't have any impact on the physical
805+
* devices attached to the host system on the server
806+
* side, hence there is no need to undo the operation
807+
* on disconnect.
808+
*/
809+
dev_pm_syscore_device(&vdev->udev->dev, true);
788810
usb_put_dev(old);
789811
goto out;
790812

0 commit comments

Comments
 (0)