[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <adc03a95-baa0-4a2a-9b00-39a644bab426@rowland.harvard.edu>
Date: Wed, 9 Apr 2025 11:17:53 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Guan-Yu Lin <guanyulin@...gle.com>
Cc: gregkh@...uxfoundation.org, mathias.nyman@...el.com,
gargaditya08@...e.com, kekrby@...il.com,
jeff.johnson@....qualcomm.com, elder@...nel.org,
quic_zijuhu@...cinc.com, ben@...adent.org.uk,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 4/4] usb: host: enable USB offload during system sleep
On Tue, Apr 08, 2025 at 03:57:24AM +0000, Guan-Yu Lin wrote:
> Sharing a USB controller with another entity via xhci-sideband driver
> creates power management complexities. To prevent the USB controller
> from being inadvertently deactivated while in use by the other entity, a
> usage-count based mechanism is implemented. This allows the system to
> manage power effectively, ensuring the controller remains available
> whenever needed.
> In order to maintain full functionality of an offloaded USB devices,
> several changes are made within the suspend flow of such devices:
> - skip usb_suspend_device() so that the port/hub are still active for
> USB transfers via offloaded path.
> - not suspending the endpoints which are used by USB interfaces marked
> with needs_remote_wakeup. Namely, skip usb_suspend_interface() and
> usb_hcd_flush_endpoint() on associated USB interfaces. This reserves a
> pending interrupt urb during system suspend for handling the interrupt
> transfer, which is necessary since remote wakeup doesn't apply in the
> offloaded USB devices when controller is still active.
> - not flushing the endpoints of actively offloaded USB devices. Given
> that the USB devices is used by another entity, unilaterally flush the
> endpoint might lead to unexpected behavior on another entity.
> - not suspending the xhci controller. This is done by skipping the
> suspend/resume callbacks in the xhci platform driver.
>
> Signed-off-by: Guan-Yu Lin <guanyulin@...gle.com>
> ---
> drivers/usb/core/driver.c | 43 +++++++++++++++++++++++++++++++-----
> drivers/usb/host/xhci-plat.c | 19 ++++++++++++++++
> drivers/usb/host/xhci-plat.h | 1 +
> include/linux/usb.h | 2 ++
> 4 files changed, 59 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 316526a05250..59b33e5e9a87 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -1420,11 +1420,25 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
> udev->state == USB_STATE_SUSPENDED)
> goto done;
>
> + if (msg.event == PM_EVENT_SUSPEND && usb_offload_check(udev)) {
> + dev_dbg(&udev->dev, "device offload active, skip suspend.\n");
> + udev->offload_at_suspend = 1;
> + }
> +
> /* Suspend all the interfaces and then udev itself */
> if (udev->actconfig) {
> n = udev->actconfig->desc.bNumInterfaces;
> for (i = n - 1; i >= 0; --i) {
> intf = udev->actconfig->interface[i];
> + /*
> + * Don't suspend interfaces with remote wakeup while the controller is
> + * active. This preserves pending interrupt urbs, allowing interrupt
> + * events to be handled during system suspend.
> + */
Here and below, please try to limit the line lengths to below 80
columns, even in comments.
Alan Stern
Powered by blists - more mailing lists