Repository navigation
usb: dwc3: apple: keep USB teardown out of the PM notifier chain - #1947
Merged
Merged
Conversation
m0d16l14n1
added a commit
to m0d16l14n1/linux
that referenced
this pull request
Nov 15, 2026
DjDeveloperr: usb: dwc3: apple: stop a host for deep sleep outside the PM notifier chain # Conflicts: # drivers/usb/dwc3/dwc3-apple.c
m0d16l14n1
added a commit
to m0d16l14n1/linux
that referenced
this pull request
Nov 15, 2026
…n#1947 merge aurora-silicon#1947 added the prepare callback in its own dwc3_apple_pm_ops; this tree already had one with the out-of-band wake suspend. Both callbacks now sit in the one table. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <[email protected]>
When "mem" means deep sleep, the glue prepares its controller at PM_SUSPEND_PREPARE. A host behind a fixed hub sleeps in place; any other controller, or one whose PHY can't keep it, is stopped the way a cable disconnect does. Stopping a running host disconnects its devices, and so does restarting a host that lost its state in the sleep, at PM_POST_SUSPEND. Outside the J714s both ran inside the PM notifier chain. A driver that unregisters a PM notifier of its own as its device goes away then waits for the chain it is being called from: r8152 does so when its interface is closed (rtl8152_close() -> unregister_pm_notifier()). With such an adapter attached the suspend never gets past PM_SUSPEND_PREPARE. The hang was seen on one machine (J714s, T6050) with an r8152 adapter. Let the notifier only open a sleep epoch or queue its finish, on every board: - PM_SUSPEND_PREPARE takes the glue lock with a trylock, checks that the PHY's finish after the last wake is over, opens the epoch, lifts the syscore mark so that the controller's prepare callback runs, and queues the preparation work. It never waits. A busy lock, an unfinished PHY finish or an epoch still open refuse the sleep with -EBUSY. - The preparation work does what the notifier did: it keeps the host in place, or stops the controller. - The controller's prepare callback, after the freezer and before any device suspends, waits for that work with the existing 5 s bound. A preparation that failed or hasn't ended refuses the sleep. A host that keeps running gets its syscore mark back through -EAGAIN, so that genpd unwinds its prepare count before the PM core retries and skips it. - PM_POST_SUSPEND queues the finish work. It waits for the preparation, then checks, recovers or restarts the host, applies a role change that came during the epoch, restores the syscore mark as the remaining power ownership requires, and queues the PHY's finish under the glue lock. A failed exit keeps its restart and cleanup obligations. - The fixed hub's check runs only while no epoch is open and the host is healthy; the finish drains an older check before it closes the epoch. - Shutdown and remove quiesce this work on every board. Only T8132 still takes the controller down at shutdown. The PHY's finish work gets a completion and a non-blocking query, apple_atcphy_sleep_finish_done(), for the admission check. Its work items are set up after the resources they use, so that devres drains them first. Waiting for a Type-C PHY that has not started after a sleep stays specific to the J714s. Signed-off-by: Diljit Singh <[email protected]>
DjDeveloperr
force-pushed
the
dwc3-pm-notifier-host-stop
branch
from
November 15, 2026 22:42
67e2596 to
a667121
Compare
The host tests that extract dwc3-apple code no longer compiled: the glue now sets its syscore mark through dwc3_apple_syscore(), its role switch reads the sleep epoch, and its remove quiesces the PM work through dwc3_apple_pm_quiesce(). neo-stability: extract the syscore helper too, with the driver's sleep epoch enum and the fields it uses in the model struct; the old-USB control keeps the current core stop and helper. The helper's only new rule is that an open epoch records the wanted mark without setting it, so that device prepare still runs: check it, and add the matching mutation. apple-dcp dwc3-teardown: extract the syscore helper as well, take the epoch enum from the driver, add the epoch fields to the model struct, and model the epoch spinlock (taken only when free, released only when held). apple-dcp controller-lifecycle: model the PM quiesce. It must run once, before the host is removed, for a controller removal, and it stops new starts as the driver's does. Signed-off-by: Diljit Singh <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One commit, three files:
drivers/usb/dwc3/dwc3-apple.c,drivers/phy/apple/atc.c,include/linux/phy/apple-atc.h. Based on integration/aurora 580e911; it applies unchanged on the current tip (nothing since touches these files).The glue's PM notifier no longer tears USB down or waits for anything, on every board:
PM_SUSPEND_PREPAREopens a sleep epoch with a trylock and queues the preparation work. A busy glue lock, an epoch still open, or the PHY's finish from the last wake not over yet refuse the sleep with-EBUSYinstead of waiting inside the chain.-EAGAIN, so that genpd unwinds its prepare count before the PM core retries.PM_POST_SUSPENDqueues the finish work: it waits for the preparation, then checks, recovers or restarts the host (the restart of a host that lost its state in the sleep now runs here, not in the notifier), applies a role change that came during the epoch, restores the syscore mark as the remaining power ownership requires, and queues the PHY's finish under the glue lock.apple_atcphy_sleep_finish_done(); its work items are set up after the resources they use.Second commit, tests only: the host-test harnesses (neo-stability; apple-dcp dwc3-teardown and controller-lifecycle) learn
dwc3_apple_syscore()and the PM quiesce, plus a newusb-epoch-syscoremutation for the epoch rule; no kernel code changes.Why
Stopping a running host disconnects its devices, and so does restarting a host that lost its state in the sleep. A driver that unregisters a PM notifier of its own as its device goes away then waits for the chain it is being called from: r8152 does so when its interface is closed (
rtl8152_close()→unregister_pm_notifier()). With such an adapter attached the suspend never gets pastPM_SUSPEND_PREPARE(seen on J714s / T6050). On boards with a fixed hub the same applies to the in-place host's restart atPM_POST_SUSPEND.Tested
On a J700 (T8140) with an r8152 adapter (RTL8153, interface open) on the front port behind the on-board hub; two one-shot boots of a full arm64 build (Image, modules, dtbs) of this exact tree with the distribution kernel's config, then a third boot of it as the default kernel:
pm_test=platform: no real sleep, USB and the adapter fine afterwards, the next sleep normal.Not covered yet
PM: device_prepare(): genpd_prepare returns -11for the controller: the PM core reports the deliberate-EAGAINsyscore handoff withdev_err. Harmless; a follow-up should avoid the noise.🤖 Generated with Claude Code