Linux USB
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Hongyu Xie <xiehongyu1@kylinos.cn>, gregkh@linuxfoundation.org
Cc: guanyulin@google.com, rafael.j.wysocki@intel.com,
	sakari.ailus@linux.intel.com, mathias.nyman@linux.intel.com,
	eadavis@qq.com, kees@kernel.org,
	dominique.martinet@atmark-techno.com, khtsai@google.com,
	stern@rowland.harvard.edu, oneukum@suse.com,
	marco.crivellari@suse.com, thorsten.blum@linux.dev,
	amardeep.rai@intel.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] usb: core: defer leaf-device resume off the S3 critical path
Date: Wed, 5 Aug 2026 15:28:58 +0200	[thread overview]
Message-ID: <aa6f1402-cc78-4600-97c1-e6d4851d9cad@suse.com> (raw)
In-Reply-To: <20260805093641.3543206-1-xiehongyu1@kylinos.cn>



On 05.08.26 11:36, Hongyu Xie wrote:
> Problem:
> System resume (dpm_resume) invokes each device's resume callback
> synchronously on the wake-up critical path.  For a USB leaf device
> this means port resume and, when reset_resume is needed, a port
> reset that, for persistent devices, waits up to 2000 ms for the
> device connection (CCS; on SuperSpeed this includes link training)
> to be re-established (wait_for_connected()).  Slow link training of
> some U-disks and webcams after S3 power-on therefore stalls the
> entire system wake-up: on an
> arm64 test machine with four leaf devices (bluetooth, UVC camera,
> two U-disks) dpm_resume took 2508 ms, about 2.1 s of it caused by a
> single SanDisk U-disk whose link training stayed in Rx.Detect for
> 2000 ms (worst case: -ENODEV fallback to disconnect +
> re-enumeration).  A device compatibility issue should not lengthen
> the system-wide wake-up.
> 
> Fix:
> The patch addresses this on four levels:
> 
> 1. Defer leaf-device recovery off the critical path.  Leaf devices
>     (udev->parent && !udev->maxchild) that are port-suspended on
>     system resume have their real port resume moved to a per-device
>     work item queued from usb_resume_complete(), after all hubs have
>     finished resume.  The work reuses the same udev (in-place reset,
>     devnum preserved); drivers without reset_resume get unbind+rebind.

If you do this, you may have drivers which do not runtime PM
face devices that are effectively runtime suspended. This will
not work.
  
> 2. Safe abandonment.  If a new suspend or a disconnect arrives before
>     the work item runs, the reset is abandoned, not flushed: the
>     device is still port-suspended, which is exactly what the new
>     suspend needs, and the work item then only releases the runtime
>     reference it took.  The abandon decision is serialized with the
>     work item by the device lock, so no cancel_work_sync() (which
>     would deadlock against the work item's device_lock()) is needed
>     on the suspend path.

You cannot do this without checking whether remote_wakeup is correctly
set.

Furthermore you cannot just use the system work queue for this.
You must not have any memory allocations with GFP_KERNEL on that
queue.

	Regards
		Oliver


  parent reply	other threads:[~2026-08-05 13:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  9:36 [RFC PATCH] usb: core: defer leaf-device resume off the S3 critical path Hongyu Xie
2026-08-05  9:59 ` Greg KH
2026-08-05 10:24 ` Marco Crivellari
2026-08-05 13:28 ` Oliver Neukum [this message]
2026-08-05 15:29 ` Alan Stern

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=aa6f1402-cc78-4600-97c1-e6d4851d9cad@suse.com \
    --to=oneukum@suse.com \
    --cc=amardeep.rai@intel.com \
    --cc=dominique.martinet@atmark-techno.com \
    --cc=eadavis@qq.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guanyulin@google.com \
    --cc=kees@kernel.org \
    --cc=khtsai@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=thorsten.blum@linux.dev \
    --cc=xiehongyu1@kylinos.cn \
    /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