mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Alan Stern <stern@rowland.harvard.edu>,
	Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Cc: Valentina Manea <valentina.manea.m@gmail.com>,
	Shuah Khan <shuah@kernel.org>, Hongren Zheng <i@zenithal.me>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Brian G. Merrell" <bgmerrell@novell.com>,
	kernel@collabora.com, Greg Kroah-Hartman <gregkh@suse.de>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 1/9] usb: vhci-hcd: Prevent suspending virtually attached devices
Date: Thu, 17 Jul 2025 13:55:14 -0600	[thread overview]
Message-ID: <2a87101f-6bee-4bd1-816a-1dfbe7b4a578@linuxfoundation.org> (raw)
In-Reply-To: <42bcf1e1-1bb2-4b63-9790-61393f780202@rowland.harvard.edu>

On 7/17/25 12:26, Alan Stern wrote:
> On Thu, Jul 17, 2025 at 06:54:50PM +0300, Cristian Ciocaltea wrote:
>> 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 attached devices do not enter suspend by setting the syscore
>> PM flag.
>>
>> Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver")
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
>> ---
>>   drivers/usb/usbip/vhci_hcd.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
>> index e70fba9f55d6a0edf3c5fde56a614dd3799406a1..762b60e10a9415e58147cde2f615045da5804a0e 100644
>> --- a/drivers/usb/usbip/vhci_hcd.c
>> +++ b/drivers/usb/usbip/vhci_hcd.c
>> @@ -765,6 +765,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
>>   				 ctrlreq->wValue, vdev->rhport);
>>   
>>   			vdev->udev = usb_get_dev(urb->dev);
>> +			dev_pm_syscore_device(&vdev->udev->dev, true);
>>   			usb_put_dev(old);
>>   
>>   			spin_lock(&vdev->ud.lock);
>> @@ -785,6 +786,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
>>   					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
>>   
>>   			vdev->udev = usb_get_dev(urb->dev);
>> +			dev_pm_syscore_device(&vdev->udev->dev, true);
>>   			usb_put_dev(old);
>>   			goto out;
> 
> This looks very strange indeed.
> 
> First, why is vhci_urb_enqueue() the right place to do this?  I should
> think you would want to do this just once per device, at the time it is
> attached.  Not every time a new URB is enqueued.

Correct. This isn't the right place to do this even if we want to go with
the option to prevent suspend. The possible place to do this would be
from rh_port_connect() in which case you will have access to usb_hcd device.

This has to be undone from rh_port_disconnect(). Also how does this impact
the usbip_host - we still need to handle usbip_host suspend.

> 
> Second, how do these devices ever go back to being regular non-syscore
> things?
> 
> Third, if this change isn't merely a temporary placeholder, it certainly
> needs to have a comment in the code to explain what it does and why.
> 
> Fourth, does calling dev_pm_syscore_device() really prevent the device
> from going into suspend?  What about runtime suspend?  And what good
> does it to do prevent the device from being suspended if the entire
> server gets suspended?
> 
> Fifth, the patch description says the purpose is to prevent the server
> from going into system suspend.  How does marking some devices with
> dev_pm_syscore_device() accomplish this?
> 

We have been discussing suspend/resume and reboot behavior in another thread
that proposed converting vhci_hcd to use faux bus.

In addition to what Alan is asking, To handle suspend/resume cleanly, the
following has to happen at a higher level:

- Let the usbip hots host know client is suspending the connection.
   The physical device isn't suspended on the host.
- suspend the virtual devices and vhci_hcd

Do the reverse to resume.

I would say:

- We don't want vhci_hcd and usbip_host preventing suspend
- It might be cleaner and safer to detach the devices during
   suspend on both ends. This is similar to what happens now when
   usbip host and vhci_hcd are removed.
- Note that usbip_host and vhci_hcd don't fully support suspend and
   resume at the moment.

thanks,
-- Shuah


  reply	other threads:[~2025-07-17 19:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 15:54 [PATCH 0/9] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 1/9] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
2025-07-17 18:26   ` Alan Stern
2025-07-17 19:55     ` Shuah Khan [this message]
2025-07-18  6:41       ` Cristian Ciocaltea
2025-07-25 10:20         ` Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 2/9] usb: vhci-hcd: Fix space, brace, alignment and line length issues Cristian Ciocaltea
2025-07-17 16:18   ` Greg Kroah-Hartman
2025-07-17 17:26     ` Cristian Ciocaltea
2025-07-18  6:26       ` Greg Kroah-Hartman
2025-07-18  6:48         ` Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 3/9] usb: vhci-hcd: Simplify NULL comparison Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 4/9] usb: vhci-hcd: Simplify kzalloc usage Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 5/9] usb: vhci-hcd: Do not split quoted strings Cristian Ciocaltea
2025-07-17 16:19   ` Greg Kroah-Hartman
2025-07-17 17:35     ` Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 6/9] usb: vhci-hcd: Fix block comments Cristian Ciocaltea
2025-07-17 16:19   ` Greg Kroah-Hartman
2025-07-17 15:54 ` [PATCH 7/9] usb: vhci-hcd: Use the paranthesized form of sizeof Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 8/9] usb: vhci-hcd: Consistently use __func__ Cristian Ciocaltea
2025-07-17 16:18   ` Greg Kroah-Hartman
2025-07-17 17:43     ` Cristian Ciocaltea
2025-07-17 15:54 ` [PATCH 9/9] usb: vhci-hcd: Remove ftrace-like logging Cristian Ciocaltea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a87101f-6bee-4bd1-816a-1dfbe7b4a578@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=bgmerrell@novell.com \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregkh@suse.de \
    --cc=i@zenithal.me \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=valentina.manea.m@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®