Linux Documentation
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: admin@or1k.net
Cc: Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/2] USB: core: Add USB_QUIRK_DISCONNECT_PARENT_SUSPEND
Date: Thu, 3 Dec 2026 18:31:10 +0100	[thread overview]
Message-ID: <2026120358-dedicator-concise-9d9b@gregkh> (raw)
In-Reply-To: <20261120-quadcast-s-suspend-v1-1-add8ccf12c8f@or1k.net>

On Fri, Nov 20, 2026 at 12:22:25AM +0200, Oleh Kurudz via B4 Relay wrote:
> From: Oleh Kurudz <admin@or1k.net>
> 
> Some USB products are several functions behind a small hub inside the
> same enclosure. On the HyperX QuadCast S microphone one of these
> functions drops off the bus while the system is suspending, and the
> built-in hub then reports the connect change upstream and wakes the
> system, even though remote wakeup is disabled for the hub and for
> everything behind it. On s2idle systems the suspend bounces back within
> about a second.
> 
> USB_QUIRK_DISCONNECT_SUSPEND does not help here. Set on the function
> that drops off, it disables that function's port on the built-in hub,
> but the hub itself still signals the wakeup. Set on the hub, it would
> affect every product that uses the same generic hub chip (a Huasheng
> 214b:7250 in this case), including ones with a keyboard behind it that
> is expected to wake the system.
> 
> Add USB_QUIRK_DISCONNECT_PARENT_SUSPEND. When a hub has a child with
> this quirk, usb_suspend() disables the hub's upstream port after
> suspending it, just as USB_QUIRK_DISCONNECT_SUSPEND would for the hub
> itself. The children are checked at suspend time instead of copying the
> flag to the hub at enumeration, because a reset-resume of the hub re-runs
> usb_detect_quirks() and would drop a copied flag.
> 
> Like USB_QUIRK_DISCONNECT_SUSPEND, this only affects system sleep;
> runtime suspend does not go through usb_suspend(). The quirk can also be
> set with the usbcore.quirks parameter, using the letter 's'.
> 
> This patch and its changelog were written with the help of an AI
> coding assistant (Claude, claude-opus-5-5). I reviewed the result and
> tested it on my hardware, see the next patch.
> 
> Signed-off-by: Oleh Kurudz <admin@or1k.net>
> ---
>  Documentation/admin-guide/kernel-parameters.txt |  5 +++++
>  drivers/usb/core/driver.c                       | 20 +++++++++++++++++++-
>  drivers/usb/core/quirks.c                       |  3 +++
>  include/linux/usb/quirks.h                      |  7 +++++++
>  4 files changed, 34 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 176648941..7751c373a 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -8235,6 +8235,11 @@ Kernel parameters
>  					9-bytes configuration descriptor request.
>  					Ask for 255-bytes request instead to mirror
>  					Windows' behavior);
> +				s = USB_QUIRK_DISCONNECT_PARENT_SUSPEND
> +					(Device sits behind a hub that signals
> +					a spurious wakeup when the device drops
> +					off the bus during suspend; disconnect
> +					the hub before suspend);
>  			Example: quirks=0781:5580:bk,0a5c:5834:gij
>  
>  	usbhid.mousepoll=
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index d3a61ebc6..a40d9595b 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -1620,6 +1620,23 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
>  	udev->do_remote_wakeup = w;
>  }
>  
> +/*
> + * Check whether a child of @hdev wants @hdev disconnected during system
> + * suspend. The caller must hold @hdev's device lock, which keeps the set of
> + * children stable.
> + */
> +static bool usb_child_wants_parent_disconnect(struct usb_device *hdev)

Why "hdev" and not just "udev"?  So you "know" this is a hub?  Are you
sure?

And can you use __must_hold() here?

> +{
> +	struct usb_device *child;
> +	int port1;
> +
> +	usb_hub_for_each_child(hdev, port1, child) {
> +		if (child->quirks & USB_QUIRK_DISCONNECT_PARENT_SUSPEND)
> +			return true;
> +	}
> +	return false;
> +}
> +
>  /* The device lock is held by the PM core */
>  int usb_suspend(struct device *dev, pm_message_t msg)
>  {
> @@ -1637,7 +1654,8 @@ int usb_suspend(struct device *dev, pm_message_t msg)
>  	if (r)
>  		return r;
>  
> -	if (udev->quirks & USB_QUIRK_DISCONNECT_SUSPEND)
> +	if ((udev->quirks & USB_QUIRK_DISCONNECT_SUSPEND) ||
> +	    (udev->parent && usb_child_wants_parent_disconnect(udev)))
>  		usb_port_disable(udev);
>  
>  	return 0;
> diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
> index a4bcbe9c9..3933cf9c0 100644
> --- a/drivers/usb/core/quirks.c
> +++ b/drivers/usb/core/quirks.c
> @@ -146,6 +146,9 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
>  			case 'r':
>  				flags |= USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE;
>  				break;
> +			case 's':
> +				flags |= USB_QUIRK_DISCONNECT_PARENT_SUSPEND;
> +				break;
>  			/* Ignore unrecognized flag characters */
>  			}
>  		}
> diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
> index a4043b33c..101dd1ca4 100644
> --- a/include/linux/usb/quirks.h
> +++ b/include/linux/usb/quirks.h
> @@ -84,4 +84,11 @@
>  /* Use a 255 bytes config descriptor request mirroring windows behavior */
>  #define USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE	BIT(19)
>  
> +/*
> + * Device sits behind a hub that signals a spurious wakeup when the device
> + * drops off the bus during system suspend; the hub needs to be disconnected
> + * before suspend.

So you want to disconnect the parent before the child?  That feels wrong
and really broken.  How does Windows handle this?  Surely it doesn't
have a quirk list like this?  How did this device pass usb.org testing?

thanks,

greg k-h

  reply	other threads:[~2026-12-04  3:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 22:22 [PATCH 0/2] USB: core: Disconnect a parent hub on suspend for HyperX QuadCast S Oleh Kurudz via B4 Relay
2026-11-19 22:22 ` [PATCH 1/2] USB: core: Add USB_QUIRK_DISCONNECT_PARENT_SUSPEND Oleh Kurudz via B4 Relay
2026-12-03 17:31   ` Greg Kroah-Hartman [this message]
2026-11-19 22:22 ` [PATCH 2/2] USB: quirks: Add USB_QUIRK_DISCONNECT_PARENT_SUSPEND for HyperX QuadCast S Oleh Kurudz via B4 Relay

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=2026120358-dedicator-concise-9d9b@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=admin@or1k.net \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=stern@rowland.harvard.edu \
    /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