Skip to content

usb: dwc3: apple: select idle runtime PM by DT power domains, not a SoC list - #2299

Merged
DjDeveloperr merged 3 commits into
mainfrom
sweep/dwc3-idle-rpm
Nov 25, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
sweep/dwc3-idle-rpm

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An idle Apple DWC3 controller (no cable, core down) could runtime-suspend only on T6040 and T8132
(drivers/usb/dwc3/dwc3-apple.c:1841, from c8372a0 and 4cacc48). A port that never saw a cable
could suspend only on T8132 and on T6041 machines (:1934, from 4cacc48 and dcb1f4f). The T6040
commit left other SoCs out because they were untested. The glue, the DART runtime PM and the way the PHYs use
the controller's power domain are the same on every SoC. On T6000, T8112, T8140 and the others, an idle
controller and its DARTs stayed runtime-active after the first cable. The USB3 PHY was also optional only on
T8132 and T6040 (:1863, from a50abc4).

Change

  1. Idle runtime PM is now selected from the device tree. The controller, every DART in its iommus and every
    PHY provider in its phys must have power-domains. That is what makes a domain drop safe: a DART is resumed
    before its consumer's domain is on, and a PHY in the domain either keeps it on, follows it, or holds it while
    started. The never-plugged path uses the same property. Only a fixed-hub host is left out, because it starts
    at probe.
  2. usb3-phy is looked up as optional on every SoC. A DT that names it behaves as before.
  3. A comment says why the T8140 hibernation setup stays T8140-only: its power-down scale depends on the
    suspend clock rate. No functional change.

All 179 enabled DWC3 nodes in the 135 Apple DTBs have the property. The DWC3 DARTs already name their power
domain on every SoC, so this does not depend on any DT change.

The idle runtime PM mechanism is by Jonathan Goyvaerts (T6040), Erik Bourget (T8132) and AxxzyWasTaken (T6041).
This change only widens where it applies.

Why each SoC is safe
  • A DART is a runtime PM supplier of the controller. It is resumed before the controller, and so before the
    controller's domain is powered. A DART outside any domain would be restored into a block that is still off.
  • ATC PHYs without idle power-off (T8103, T8122, T8140 and T8142 generations: T8103, T6000/1/2, T8112, T6020/1/2,
    T8122, T6030, T6031, T8140, T8142) keep runtime PM disabled. genpd counts them as in use, so atcN_usb stays
    on. On these SoCs an idle controller now suspends the glue and its two DARTs only. No block loses power, the
    PHY is not power-cycled, and the base M1 USB3 handoff path is not reached by this.
  • The T8132 ATC PHY follows the domain and restores its state (restore_after_pd_off, idle_power_off).
    T8132 already ran this.
  • The T6040 PHY sits in its own domain. T6040 idle controllers already suspended. Now a never-plugged T6040
    port suspends too, as T6041 ports already did.
  • The T6050 combo PHY takes the usb domain in its start and drops it in its stop, and its start runs the full
    sequence again. While it is stopped, an idle controller's domain can now drop.
  • J700 has one enabled controller, and it has a fixed hub. It never idles, so J700 does not change.
  • A running controller does not change. The glue holds a runtime PM reference from reset deassert to core
    shutdown, and xHCI keeps the controller active as its child.
Other single-SoC gates in dwc3-apple.c (reviewed, kept)

Each of these follows a PHY IP or board difference:

  • T8132 host-role latch, CIO setup skip, host-before-core-init: T8132 PHY behaviour.
  • T8132/T8142 dis_u3_susphy in host mode: those PHYs do not bring a SuperSpeed link back from U3.
  • T8132/T6050 strict USB3 PHY errors: a failure there leaves the PIPE without a producer.
  • T6040 USB3 PIPE reset: T6040 dummy PHY bring-up.
  • T6040/T6050 host-only: those PHYs implement host mode only.
  • J714s/J716c sleep and tunnel rules: depend on how those boards' port controllers take sleep power states.
  • T8132-only exit at shutdown: tied to the T8132 PHY's common-power epoch.
  • T8140 hibernation and power-down scale: depends on the suspend clock rate (commit 3).

The ATC PHY's own idle_power_off (T8132 only) is unchanged. The PHY documents that its DisplayPort and
tunnel calls take no runtime PM reference.

Testing

  • Build (arm64, LLVM=1, release config, W=1) of drivers/usb/dwc3/dwc3-apple.o: base, each commit and head build with 0 warnings and 0 errors

  • DT review of every enabled apple,*-dwc3 node, with its DARTs and PHY providers: 179/179 have
    power-domains (T8103, T6000/1/2, T8112, T6020/1/2, T8122, T6030, T6031, T6040/1, T8132, T8140, T8142, T6050).

  • Hardware, one-shot boot of a test kernel carrying this series (integration 0abc2f3 + this and other draft PRs), production Stage 2 DT, nothing plugged:

    • T8112 J413: both controllers unsupported on the current kernel, suspended with this series, at boot, after 20 s idle and after 3 s2idle cycles (rtcwake, ~20 s each, rc=0). 0 kernel errors, 0 DART errors, 0 AVC, 0 failed units, 28 DARTs bound as before.
    • T6040 J616s (DT of this test tree via a Stage 2 DTB-only trial): the two never-plugged controllers unsupported before, suspended with this series; the in-use one stays active. 3 s2idle cycles rc=0, 0 AVC, 0 failed units. The genpd_prepare returns -11 line on 392280000.usb at each sleep is also on the current kernel (not from this series).
    • T6000 J316s: all three controllers unsupported before, suspended with this series, same checks, 3 s2idle cycles clean, 34 DARTs bound as before.

Still to run

Hardware rows, one combined test kernel:

  • T6000 J316s and T8112 J413: plug a device after idle suspend, check it enumerates and works after a re-resume: pending (idle suspend itself is proven above).
  • T6040 J616s: plug / re-resume after idle suspend: pending (idle suspend proven above).
  • T8140 J700: the fixed-hub controller stays active. Hub devices work, and one sleep/wake is clean (no
    change expected): pending.

…device tree

An idle controller, whose core is down because no cable is connected,
could runtime-suspend only on T6040 and T8132 ("the PHY driver and the
DARTs follow runtime PM on these SoCs"). A port that never saw a cable
could do so only on T8132 and on T6041 machines. The glue, the DARTs'
runtime PM and the way the PHYs use the controller's power domain are
the same on every SoC, so these lists record where it was tried, not a
hardware difference. On T6000, T8112, T8140 and the others an idle
controller stayed runtime-active for good after its first cable, and
with it its DARTs.

Select it from the device tree instead: the controller, every DART in
its iommus and every PHY provider in its phys must name a power domain.
That is the condition for a domain drop to be safe:
- a DART is resumed before its consumer, and so before the consumer's
  domain is on. A DART outside any domain would be restored into a block
  that is still off;
- a PHY in the domain either keeps it on (an ATC PHY without idle
  power-off has runtime PM disabled, so genpd counts it as in use),
  follows it and restores its state (T8132), or holds it while it is
  started (the T6050 combo PHY).

Every enabled Apple DWC3 node in the tree meets this: 179 nodes in 135
DTBs, on T8103, T6000, T8112, T6020, T8122, T6030, T6031, T6040, T8132,
T8140, T8142 and T6050. Where the ATC PHY has no idle power-off, the PHY
keeps the domain on, so an idle controller now suspends the glue and its
DARTs only. The PHY is not power-cycled by this, and the base M1 USB3
handoff path is not reached by it.

The never-plugged path uses the same property. It stays off only for a
fixed-hub host, which starts at probe and never waits for a cable.

This builds on the idle runtime PM work of Jonathan Goyvaerts (T6040),
Erik Bourget (T8132) and AxxzyWasTaken (T6041), which this only widens.

Fixes: 4cacc48 ("usb: dwc3: apple: Let an idle T8132 controller runtime-suspend")
Fixes: dcb1f4f ("usb: dwc3: apple: Let a never-plugged T6041 port runtime-suspend")
Signed-off-by: Ryan Murray <[email protected]>
The USB3 PHY was optional only for T8132 and T6040 controllers. Whether a
port has a USB3 PHY is what its device tree says in phys/phy-names, and
the glue already handles a NULL PHY everywhere (phy_set_mode() on NULL
is a no-op and the USB3 paths check for it).

Look it up as optional on every SoC. A device tree that names the PHY
behaves as before, including probe deferral. One that does not name it
now gets a USB2-only port instead of a failed probe, which is what the
two listed SoCs already got.

Fixes: a50abc4 ("usb: dwc3-apple: support host-only T6040 ports with a USB2 PHY only")
Signed-off-by: Ryan Murray <[email protected]>
dwc3_apple_setup_hibernation() sets GCTL's hibernation enable and a
power-down scale on T8140 only. Keep that scope and write down the
reason: the power-down scale is the number of suspend clock periods in
one 16 kHz period, so it depends on the SoC's suspend clock rate, and
T8140 is the only SoC whose value is known. Another SoC that keeps its
core through a deep sleep needs its own scale first. No functional
change.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo) row, from one combined test kernel (integration b4cd7b3 plus this PR, #2477, #2474 and #2370), one-shot boot, compared against the production kernel:

  • The Neo binds one dwc3 controller (40a280000.usb, the dock port). It stays active on both kernels, before and after a 30 s s2idle.
  • 31 USB devices before and after on both kernels. s2idle rc 0.
  • The same genpd_prepare returns -11 line at the sleep as the base (usb: dwc3: apple: keep USB teardown out of the PM notifier chain #1947). Nothing new.
  • There's no never-plugged controller on the Neo, so the unsupported → suspended change can't be seen here.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Looks good; approve once the plug-after-idle row below is on the current head.

I checked dwc3_apple_idle_rpm() (drivers/usb/dwc3/dwc3-apple.c:1841). It puts the node on the early return, treats a malformed iommus/phys list (err != -ENOENT) as "no idle PM", and returns false for a missing power-domains. I also checked how it feeds the never-plugged path (:1974) and pm_runtime_allow() in core probe (:707), and the optional usb3-phy lookup (:1905: a named but unbound provider still defers). On T8103 the controller, both DARTs and atcphy0 share ps_atc0_usb (t8103.dtsi). The ATC PHY there has runtime PM disabled, so genpd keeps the domain on and only the glue and the DARTs go to runtime suspend, as the description says. Commits carry a human Signed-off-by, CI is green and the branch merges cleanly. I found no code blockers.

  1. This newly enables two paths on every SoC that has no row yet: an idle controller's DARTs runtime-suspending, and the pre-core runtime PM handoff in dwc3_apple_core_start() (:852-858) on the first cable. The current evidence covers idle suspend only. Resume on a cable plug is the part that can regress, through DART restore and the first core probe after pm_runtime_resume_and_get(). The description lists that row as pending for T6000, T8112 and T6040.

HW row: on the current head, J316s (T6000) and J413 (T8112): leave the ports idle until they reach suspended, plug a USB3 device and a USB2 device into a never-plugged port, check that both enumerate and do I/O, unplug and let the port idle back to suspended, then plug again after one s2idle. Repeat on J615 (T8122), which has the same no-idle-power-off ATC class and no row. Pass: devices work on each plug, 0 DART faults, 0 new kernel errors, 0 AVC, 0 failed units.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent source review at 0d8e6bde9b28. The runtime-PM selector now follows attached power domains and preserves the fixed-hub exception. A cold boot with no cable only covers the never-connected path. Please test a J413 and J473 through USB3 attach, detach, runtime idle and re-enumeration after s2idle while watching the controller and DART state.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR checklist (§1–§6) review at 0d8e6bde9b2825732574b0147500afa1b1726e52 (all 7 CI checks SUCCESS: host-tests, source, rust-build, kunit, and DWC3/ATC build matrix; not superseded on integration/aurora).

Technical verification

Source changes in drivers/usb/dwc3/dwc3-apple.c are clean and apply cleanly onto live integration/aurora:

  • dwc3_apple_idle_rpm() verifies power-domains on the controller, every iommus supplier, and every phys supplier, properly puts it.node on early return, and conservatively returns false on malformed phandle lists (err != -ENOENT).
  • Making usb3-phy optional on all SoCs via devm_phy_optional_get() is safe: all appledwc->usb3_phy callers handle NULL (either via phy_set_mode() no-op or explicit NULL checks), and named-but-unbound providers still defer probe.
  • pre_core_rpm handoff in dwc3_apple_core_start() and cleanup in dwc3_apple_probe()/dwc3_apple_remove() remain balanced; fixed-hub controllers are excluded.
  • Commit 3 documents the hardware reason (PWRDNSCALE / suspend clock rate) why T8140 hibernation remains SoC-scoped.
  • Minor non-blocking nit: the overview comment near the top of live drivers/usb/dwc3/dwc3-apple.c (L116-120) still says Runtime PM (T6040 and T8132...) and On T8132 a port that has not seen a cable yet.

Blockers

  1. §5 Hardware evidence — newly enabled cable-attach / resume handoff from suspended is untested:
    • This PR newly enables both idle runtime PM and pre_core_rpm never-plugged suspend on every non-T6040/T8132 Apple Silicon SoC (and pre_core_rpm on T6040).
    • All posted non-fixed-hub hardware runs (J413, J616s, J316s) were run on a combined multi-PR test kernel with nothing plugged in, and J700 has a fixed hub that never enters idle/pre-core runtime PM.
    • As already noted in ## Still to run and prior review comments, please post a live-head hardware run on newly enabled hardware (at minimum T8112 J413 and T6000 J316s, plus T6040 J616s) exercising: idle until suspended -> plug USB3 and USB2 devices into a never-plugged port (exercising pre_core_rpm handoff, DART restore, and first dwc3_core_probe()) -> enumerate & verify I/O -> unplug -> idle back to suspended -> s2idle -> re-plug/re-enumerate, with 0 DART faults, 0 new kernel errors, 0 SELinux denials, and 0 failed units.

Checklist (§1–§6)

  • §1 No model gating: Pass (replaces SoC allowlists with DT power-domains inspection; justifies remaining T8140 hibernation gate).
  • §2 Production-ready: Pass (default command line, no hacks).
  • §3 Safety: Pass (conservative DT supplier check).
  • §4 Clean-room and attribution: Pass (all 3 commits 4fe837a0bc1d, 93bd6e7e2cdc, 0d8e6bde9b28 carry human author/committer and Signed-off-by: only, zero AI commit trailers; plain Assisted-by: in PR body).
  • §5 Evidence: Incomplete — see Blocker #1.
  • §6 Naming: Pass.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 0d8e6bde: ready to merge

Check Detail
CI at head ok 7 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 0d8e6bde
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: none matched in CODEOWNERS
Merge: gh pr merge 2299 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 0d8e6bde9b28: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: idle runtime PM now runs on SoCs that never had it, and the J413, J616s and J316s boots don't cover a cable attached after the controller has idled. Needed: on one of them at this head, let the port idle into runtime suspend, then plug in a USB device and a host; both should enumerate.

Checked: no Apple material. This removes a SoC list: runtime PM is chosen by the DT power domains. CI green.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 25, 2026 03:25

Superseded by the review at 0d8e6bd

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@RyanTheTide

RyanTheTide commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

0d8e6bde9b28 J316s (T6000), J413 (T8112), J615 (T8122) PASS (guarded one-shot 7.3.0-aurora-pr2299+, default cmdline; all three restored to saved production kernels):

  • J316s (M1 Pro, T6000) — target as USB host (attached USB device: peer J615 on saved fleet85 exposing cdc_acm gadget 1d6b:0104, 480M):
    • Never-plugged pre_core_rpm: booted with Left Front (b02280000.usb) disconnected via partner PD DISC; both b02280000.usb (act_ms=0, susp_ms=12514->18371) and empty f02280000.usb (susp_ms=278746) plus all four DARTs (b02f00000/b02f80000/f02f00000/f02f80000.iommu) entered suspended (vs unsupported/active on saved fleet89).
    • First plug (pre_core_rpm -> dwc3_apple_core_start() + DART restore): b02280000.usb and both b02f* DARTs woke suspended -> active, enumerated attached cdc_acm device (1d6b:0104, 480M) with bidirectional /dev/ttyACM0 <-> /dev/ttyGS0 I/O PASS.
    • Unplug -> idle suspended -> re-plug: confirmed live suspended on b02280000.usb (susp_ms 18371 -> 26108 -> 27806) and both b02f* DARTs -> reconnect -> active, enumerated 1d6b:0104 (480M), bidirectional I/O PASS.
    • s2idle 1/1 (rtc1 8 s) while idle-suspended: stayed suspended across sleep (susp_ms 37531 -> 40381, act_ms unchanged 200638; suspend_stats success=1 fail=0) -> reconnect -> active, enumerated 1d6b:0104 (480M), bidirectional I/O PASS.
    • Health: Enforcing, 0 failed, 0 AVC, 0 DART faults, 0 new USB/DWC3 errors (only existing #1947 genpd_prepare returns -11 on active tether port), GL + Borealis VK smoke PASS.
  • J615 (M3 Air, T8122) — target as USB device (observed and enumerated by external USB host J316s on saved fleet89 across Left Front b02280000.usb):
    • Boot pre_core_rpm: both controllers and all four DARTs suspended 858..877 ms before attach -> first attach bound cdc_acm gadget on J615 b02280000.usb and external host J316s enumerated 1d6b:0104 (480M), bidirectional /dev/ttyACM0 <-> /dev/ttyGS0 I/O PASS.
    • Unplug -> live runtime suspended -> external host re-attach: live suspended on J615 b02280000.usb + both b02f* DARTs (susp_ms 876 -> 2826 -> 10584) -> reconnect -> active, external host J316s enumerated J615 gadget 1d6b:0104 (480M), bidirectional I/O PASS.
    • s2idle 1/1 (rtc0 8 s) while idle-suspended -> external host re-attach: stayed suspended across sleep (susp_ms 35693 -> 38920, act_ms unchanged 64685; success=1 fail=0) -> reconnect -> active, external host J316s enumerated J615 gadget 1d6b:0104 (480M), bidirectional I/O PASS.
    • Health: Enforcing, 0 failed, 0 AVC, 0 DART faults, 0 new USB/DWC3 errors (note: sn201202x 1-0a logged expected -19 during s2idle resume only because 1-0a was held in PD DISC test mode across sleep).
  • J413 (M2 Air, T8112):
    • Both idle controllers (382280000.usb, 502280000.usb) and all four DARTs (382f00000/382f80000/502f00000/502f80000.iommu) transitioned unsupported/active -> suspended (susp_ms=60813..60819) and stayed clean across s2idle 1/1 (rtc1 15.0 s, success=1 fail=0), GL + Borealis VK smoke PASS, Enforcing, 0 failed, 0 AVC, 0 DART faults, 0 new USB/DWC3 errors. (No second USB data peer attached on this lab J413; host-attach and device-attach plug-after-idle I/O are covered on J316s and J615.)

Scope note: the m1pro <-> j615 Left Front cable negotiates USB4/ACIO (thunderbolt 0-1) on its high-speed lanes, so DWC3 operates over USB2 (480M); none of J316s, J413, or J615 currently has a standalone physical 5000M USB3 peripheral attached on the bench, and T6040 (J616s) is outside this bench pass.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr merged commit 70381bd into main Nov 25, 2026
10 checks passed
AxxzyWasTaken pushed a commit to AxxzyWasTaken/linux that referenced this pull request Nov 25, 2026
Commit 0d8e6bd ("usb: dwc3: apple: select idle runtime PM by DT power
domains, not a SoC list", merged in aurora-silicon#2299) replaced the inline SoC check
in dwc3_apple_probe() with a call to dwc3_apple_idle_rpm(dev->of_node).

atc-t8132-usb3.py extracts the early dwc3_apple_probe() prefix into its
usb-native-shutdown host harness and stubs out probe helpers. Add the
matching dwc3_apple_idle_rpm() stub so the host test compiles and passes
again on main.

Signed-off-by: Dj <[email protected]>
@RyanTheTide
RyanTheTide deleted the sweep/dwc3-idle-rpm branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants