Repository navigation
phy: apple: atc: admit suspend-to-idle with DWC3 running in device role - #2700
Conversation
A T8132 Type-C PHY that owns its common block refuses system sleep unless DWC3 runs on it as a host and the target is suspend-to-idle. The reasoning behind the host condition is that the DWC3 glue keeps the controller, and with it the power domain the PHY shares (atcN_usb), on across system sleep. The glue does that for either role: dwc3-apple makes the core a syscore device whenever it is started, host or device, and for suspend-to-idle its prepare work only makes sure the controller is started. So a port in device role (connected to another computer, the Mac being the USB device, with or without a gadget bound) refused every suspend-to-idle with -EBUSY from atcphy_suspend(), although nothing the PHY holds is lost. On a J713 tethered to a host that blocked s2idle outright. Track whether DWC3 is out of the reset this PHY provides, in either role, and admit suspend-to-idle on that instead of host mode. A controller held in reset, or any deeper sleep, is still refused. The host tests follow: every harness that stubs the PHY (the two atc harnesses and the apple-dcp USB mocks) carries the new field, the T8132 sleep test admits suspend-to-idle with a running device and refuses it with the controller in reset, and new negative controls and mutations reject the host-only rule, a release that doesn't mark the controller running and an assert that doesn't clear it. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
J713 row on a candidate default kernel (this PR merged with #2675, #2670, #2662 and #2694 on the J713 deep-sleep/display/GPU series), stock command line, with a host computer on port0, so DWC3 runs in device role:
|
|
No blockers. Since every path that asserts the DWC3 reset also clears host_active, the new dwc3_running condition in |
The flag tracks the reset controller ops DWC3 uses, not the DWC3_RESET_N bit: the sleep hibernation and D0 steps toggle that bit within one controller run without changing it. Say so, so a later user doesn't read it as the register state. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Thanks. The kerneldoc note is in 916d514: On the rows: a J713 gadget row (NCM bound and passing traffic across s2idle) is queued on the J713. Pulling the host cable during the sleep needs a hand at the lab, so it waits for that. The M4 mini with a device-role port needs an owner with one; the row is just Assisted-by: LLM (Claude:Opus 5.5) |
With a USB4 cable in (to a dock, or a host-to-host link to another Mac), the port runs in CIO mode under its USB4 router and DWC3 is not running on it, so suspend-to-idle was still refused there. The router's power states stay on across suspend-to-idle (the ACIO's links to them are syscore devices), as the glue keeps the controller's on for DWC3: the link stays as it is. Admit that case too; a deeper sleep still needs the native CIO sleep's handoff. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
There was a problem hiding this comment.
Reviewed at 916d5142abe7 (host-tests CI green, clean commits/DCO and PR attribution, no new cmdline params or chip/board gates beyond the existing T8132 common-block path).
The dwc3_running invariant against dwc3-apple's syscore ownership (dwc3-apple.c:886-908, 1784-1788, 1907-1979) holds for both host and device roles, atcphy_dwc3_reset_assert() properly keeps dwc3_running = true if atcphy_park_pipehandler() fails, and commit 916d5142 cleanly documents that dwc3_running follows reset-controller ops rather than the DWC3_RESET_N register bit.
Findings before approval
-
Inconsistent
host_activechecks inatcphy_resumeandatcphy_shutdown(drivers/phy/apple/atc.c:7885,7915)drivers/phy/apple/atc.c:7885:Now thatif (atcphy->t8132_common_owned && atcphy->host_active && READ_ONCE(atcphy->pd_was_off)) dev_warn(dev, "power domain went off under an active USB3 link\n");
atcphy_suspend()admits s2idle in device role onatcphy->dwc3_running(atc.c:7863-7865), an unexpected power-domain loss during device-role s2idle will silently skip this warning (and then assert DWC3 reset insideatcphy_restore_after_pd_off()). Checkatcphy->dwc3_runninghere so host and device roles get the same invariant check.drivers/phy/apple/atc.c:7915:atcphy_shutdown()similarly checksatcphy->host_activewhen guarding against incomplete USB3 common ownership; checkingatcphy->dwc3_runningcatches a faileddwc3_apple_shutdownreset assert in device role as well.
-
Hardware rows still needed
- Second T8132 Mac with a device-role port: M4 mini (
J773g)rtcwake -m freeze -s 20×3 with a host on the port and/sys/power/suspend_statsbefore/after. - Queued J713 gadget row (NCM bound and passing traffic across s2idle).
- Explicit regression check (
0 AVC,0 failed units,0 new kernel errors) on the J713 row.
- Second T8132 Mac with a device-role port: M4 mini (
|
Gadget row on the J713 (lab kernel = J713 batch 7 + this PR, stock command line, NCM gadget on port0, the other computer enumerating it as
So the PHY side holds, but a device that stays connected through s2idle can lose its OUT path. dwc3-apple has only a Assisted-by: LLM (Claude:Opus 5.5) |
|
The gadget stall is fixed in #2728 (dwc3-apple takes a device role off the bus for suspend-to-idle and connects it again after). With it on top of this PR, the J713 gadget row passes: 6/6 suspend-to-idle with ping 10/10 and iperf3 host-to-device 280 Mbit/s after each, a clean disconnect and re-enumeration on the host every time, and no watchdog timeouts. Assisted-by: LLM (Claude:Opus 5.5) |
|
Still needed: check dwc3_running instead of host_active in the resume power-domain warning (atc.c:7885) and in atcphy_shutdown() (:7915), an M4 mini (J773g) row with a device-role port (3 suspend-to-idle cycles), and the 0 AVC / 0 failed units / 0 new kernel errors counts on the J713 row. It should land together with #2728, which keeps the device-role OUT path working across suspend-to-idle, and #2705 after it. |
atcphy_suspend() now admits suspend-to-idle for a T8132 common epoch whenever DWC3 runs on the PHY, as a host or as a device. Two checks of the same invariant still looked at host mode only: - atcphy_resume() warns when the power domain went off under an active USB3 link. A device role that lost the domain across suspend-to-idle went unreported, although it was admitted on the same promise that the domain stays on. - atcphy_shutdown() refuses to take down a common epoch that is still in use. A device role whose reset assert failed in dwc3_apple_shutdown() left DWC3 running with host_active clear, so the PHY went on to power the common block off under it. Check dwc3_running in both. Every path that asserts the DWC3 reset also clears host_active, and host mode is only set on a running controller, so host roles are covered as before. The T8132 host test now counts the resume warning and expects it for a device role that lost the domain, the shutdown test blocks on a DWC3 left running in device role and its reset stub clears the flag, and two negative controls reject the host-only checks. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Both findings from the 11-21 review are fixed in da78109.
Tests: Hardware rows still to run:
This should land together with #2728. Assisted-by: LLM (Claude:Opus 5.5) |
…c-s2idle-cio-on-2700 Bring in the resume and shutdown checks of a running DWC3 in either role, which the CIO-mode suspend-to-idle change builds on. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…in CIO mode A T8132 port in CIO mode was admitted to suspend-to-idle on the assumption that its USB4 router keeps the PHY powered. It does not: the ACIO holds the CIO and PCIe power states, and through them ATCn_COMMON, but the PHY sits in ATCn_USB, a sibling of those. With DWC3 held in reset nothing else holds ATCn_USB, so genpd may switch it off in the noirq phase. atcphy_resume() then runs atcphy_restore_after_pd_off(), which power-cycles and sets up CIO again under the live router, and the resume warning only looked at USB3, so nothing reported it. A board with CIO tunables and no ACIO at all, such as the J604, was admitted the same way. Hold the domain from the PHY itself. At probe, a T8132 PHY with CIO tunables attaches a second consumer to its own domain: a syscore virtual device, as the ACIO uses for its own states, which the system sleep leaves alone and which stays runtime suspended, so runtime PM of the domain is unchanged. In its noirq suspend the PHY gives up that consumer's share with dev_pm_genpd_suspend(), and takes it back on resume, unless this suspend-to-idle keeps a CIO-mode port: then the domain, and its parent ATCn_COMMON, have no off transition. Leaving CIO mode, a deeper sleep (refused, or taken over by the router's CIO sleep handoff) and hibernation release it as before. Admit CIO mode only with the hold in place, and extend the resume warning to a port in CIO mode, next to DWC3 running in either role. The T8132 host test models genpd's system-sleep count of the domain and checks: no off transition and no warning for a held CIO port, the warning when it was lost anyway, refusal without a hold and in a deeper sleep, and the release once the port left CIO mode or the router took the sleep. Negative controls reject admission without a hold, a hold never kept, a hold never released and a resume warning blind to CIO. The KUnit suspend case covers the CIO admission and now sets dwc3_running for its host case, which admission checks since DWC3 in device role was admitted. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Review at da78109: no blockers. Both findings from the 11-21 review are fixed. Still open, as listed earlier: the J773g device-role suspend-to-idle row (x3, suspend_stats before and after), and the 0 AVC / 0 failed units / 0 new kernel errors counts on the J713 row. This should land together with #2728. Full review
Assisted-by: LLM (Claude:Opus 5.5) |
|
J713 device-role row at da78109 (13-inch M4 Air, 27.2), for the "J713 row with counts" item. The kernel is integration/aurora f5fae3c plus open heads, including this PR at da78109 and #2728 at 1a91e65, booted as a one-shot on the default command line. An NCM gadget ran on the device-role port, and the host on the other end was an M4 Pro MacBook Pro running Linux.
Not valid from this run: the aborted-suspend ( Separate finding on the same tree: a warm reboot of the J713 hangs, and it bisects to #2728's 1a91e65, not to this PR. A tree with this PR at da78109 and #2728 at its previous head rebooted cleanly 2/2. Details are on #2728. Still to run: the J773g device-role row. Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist re-review at da781091715d7032da3ddfe9597052d89143cda4 (REQUEST_CHANGES — 0 code/policy/attribution/CI blockers in this PR; holding formally on remaining §5 hardware evidence and co-landing dependency #2728).
Prior Code Findings — Resolved in da781091715d
atcphy_resume()lost-PD warning (drivers/phy/apple/atc.c:7886) — Fixed: Now checksatcphy->dwc3_runninginstead ofhost_active, matchingatcphy_suspend().atcphy_shutdown()guard (drivers/phy/apple/atc.c:7917) — Fixed: Now checksatcphy->dwc3_runninginstead ofhost_active, retaining the common epoch if DWC3 reset assert failed in either role.- Audited all remaining
host_activesites inatc.c(atcphy_configure_t8132:4024,atcphy_rpm_busy:4352,apple_atcphy_cio_off:7710): all intentionally remainhost_active(in particular,:4024must allow device-role lane switches while DWC3 is out of reset). Selftest coverage and negative controls inatc-t8132-usb3.pyare clean.
Checklist Summary
- §1 No model gating: Pass — uses existing T8132 common-block gating only; not superseded on live
integration/aurora(70a00e583b03). - §2 Production-ready & §3 Safety: Pass.
- §4 Clean-room & attribution: Pass — all 3 commits (
8b8e6af4,916d5142,da781091) carry human author/committer + humanSigned-off-by:only; PR body includesAssisted-by:. - §5 Evidence (Partial): J713 device-role NCM row at
da781091passed 8 s2idle cycles (suspend_stats+9/0, ping 10/10, iperf3 283 Mbit/s, no PD-off warning, SELinux Enforcing, 0 failed units, 0 kernel AVCs), but two items remain below. - §6 Naming & CI: Pass —
host-testsgreen (1/1).
Remaining Blockers Before Approval (§5 & Co-Landing Gate)
- Second T8132 Mac (
J773gM4 mini) device-role s2idle row (rtcwake -m freeze -s 20×3 with a host on the port,/sys/power/suspend_statsbefore/after, and 0 AVC / 0 failed units / 0 new kernel errors — or an explicit owner waiver if no J773g run is available), plus a clean rerun of the aborted-suspend (pm_test=devices) check invalidated when the USB host rebooted. - Co-landing dependency on
#2728: As noted in the PR body and comments, this PR must land together with#2728(without#2728, device-role NCM OUT transfers stall after 5–6 s2idle cycles).#2728is still open withCHANGES_REQUESTEDand an active J713 warm-reboot hang at its current head1a91e650, so#2700should not enterMERGETRAIN-LINUX4ahead of#2728.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: Changes requested at 6515ae4df331.
The current patch also attaches a second genpd consumer and admits CIO/USB4 suspend-to-idle with it. The body and earlier gadget row cover DWC3 device role, but leave this separate power-domain lifecycle unqualified. Document the new path and provide current-head USB4 dock wake and power-domain balance coverage, including an aborted suspend and a no-router peer if it can take the new branch. Retain the planned J713 warm reboot and device/host traffic checks.
Dismissed under the 12-01 merge bar: this review's blockers were not shown failures (CI/rows/rebase/design or re-run asks). Follow-ups, not blocking: No code affirmation; follow-ups: document second genpd consumer/CIO s2idle path, USB4 dock wake + aborted-suspend coverage, J713 rows
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approving at 6515ae4d. dwc3_running is set and cleared only in the reset controller's assert/deassert, so the suspend admission adds the device role and nothing else. The CIO hold attaches only on T8132 PHYs with CIO tunables, is a syscore consumer, and gives its share back in noirq unless this sleep keeps the domain. The shutdown check now also refuses a device role whose DWC3 is still out of reset, which is right.
One small thing, not a blocker. atcphy_resume() now warns for any PHY in CIO mode whose domain went off (|| atcphy_mode_is_cio(atcphy->mode) isn't gated on T8132 or on pd_hold_sleep). On a T8140/T8142 deep sleep without cio_sleep.prepared, atcphy_sleep_lost_common() sets pd_was_off, so that would print a warning for an expected loss. Testing the hold you took (save pd_hold_sleep before clearing it) would keep the warning to the case it's meant for.
Still needed before merge, as you listed: the forward merge (the branch conflicts again), the J773g device-role row (3 suspend-to-idle cycles; I've requested it from our lab), and landing together with #2728.
The conflicts are all in host-test mocks of struct apple_atcphy: main renamed t8132_device to usb2_device and added usb3_tunables, usb2_need_reset and pipehandler, and this branch adds dwc3_running. Keep main's fields and add dwc3_running to each. atc.c merges cleanly, and the branch's code adds no use of the renamed field. Signed-off-by: DjDeveloperr <hey@djdev.me>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 3e590b27cc96 once the J773g device-role row and a second-generation host-role row pass at this head. No blocking findings in the code.
Checked
- The forward merge of
mainccb3d8bd. The driver change is line for line the same as at6515ae4d:atc.c+139/-8,atc-test.c+30/-2,atc-t8132-usb3.py+141/-11. Only the host-test mocks conflicted. Main renamedt8132_devicetousb2_deviceand added fields, and each mock (dwc3/mocks.c,phy.py,quiesce.py,atc-usb3-tests.py) now has main's fields plusdwc3_running. - Main's new
atc.ccode still readshost_activewhere it means the host role: the T8132 lane-reconfiguration refusal (atc.c:4567) andapple_atcphy_cio_off()(atc.c:9442). The PR moves only suspend admission (:9599), the resume warning (:9627) and shutdown (:9660) todwc3_running. Only the reset controller's assert and deassert set or clear that field (:6240,:6291). - The domain hold attaches only on T8132 with CIO tunables, as a syscore device. It is released in
suspend_noirqunless this suspend-to-idle keeps a CIO-mode domain, and reclaimed inresume_noirq. The hibernation phases keep the plain noirq callbacks. - Commits: every non-merge commit is signed off by its human author, and there is no AI attribution in the commits or the body.
Local checks (pc, arm64, LLVM, asahi config, this head)
make W=1 drivers/phy/apple/atc.o: builds, 0 warnings.- The same object with
CONFIG_KUNIT=yandCONFIG_PHY_APPLE_ATC_KUNIT_TEST=y(soatc-test.cis built in), W=1: builds, 0 warnings. I compiled it only: the suite needs an arm64 VM to run. - Host tests (the
host-tests.ymlcontainer,run-host-tests.py, 998 runs): 996 passed. The two failures arecentauri-scan-testsand its negative controls. They fail the same way onmainccb3d8bdalone (the extracted Bluetooth harness no longer compiles:cen_rx_consumeis undeclared), so they come frommain, not from this PR. - The hosted
DWC3/ATCcompile check passed. Hostedhost-testsis still queued.
Still owed at this head
- J773g: a device-role gadget with traffic before and after a short suspend-to-idle, plus a cold boot and a warm reboot.
- J700 or J714s: a host-role suspend-to-idle with no regression. The earlier J713 rows ran together with #2728, which is closed, so this row also shows that the link recovers without it.
|
J773g (Apple M4 Mac mini, T8132, firmware 27.2) receipt at exact head
|
J700 (MacBook Neo, T8140, G17P) at
|
| Check | Result |
|---|---|
| s2idle × 3 (30 s each), twice | PASS. suspend_stats success 0 → 3, fail 0, Wi-Fi and the partner back after each, recovery gate good in 3 to 5 s |
mem sleep × 1 |
PASS. success 3 → 4, fail 0, same recovery |
| USB controller roles | PASS. The DWC3 controllers stay xHCI hosts before and after every sleep, the on-board hub (2109:2122) re-enumerates, 0 new USB warnings |
| Type-C PD roles | PASS. No PD role change across the sleeps on either port |
| Display (eDP), kernel log, watchdog | PASS. eDP-1 present, 0 WARN, BUG, Oops or fault lines, trial watchdog armed and fed throughout |
What the J700 can't show: the PR's suspend admission and domain hold are T8132-only and don't run on T8140; the DEVICE role isn't covered (the fixed on-board hub keeps the controller a host, and nothing external was plugged in, so host mode is covered with that hub only).
Stock restored after both boots (boot-ctxr.bin byte-identical, no trial marker, PMU boot-error count 00, stock 7.3.0-41). Reset route checked before each slot, no reset used.
|
Merging Checked on the merge (it merges cleanly), arm64, LLVM, on pc:
Rows at this head: J773g device role, J700 host role. Not measured:
|
What: Let the Apple ATC PHY retain a running DWC3 link through suspend-to-idle in device role. The reset controller supplies the running state, and deeper firmware sleep keeps its existing refusal.
Tested: Forward head
7c78f979ad64f68fa9e76b21ff31c24e9882f8fcpassed the 13-job ATC host selection and the 65-job display host selection. Earlier J713 M4 Air atda781091715dran eight short suspend-to-idle and gadget traffic checks on the default command line with the paired controller code.Risk: two-way door · USB-C PHYs using the T8132 shared link, especially a running device role at suspend or shutdown.
Not yet: Exact forward-head J713 cold boot, warm reboot, gadget and host traffic before and after a short wake, and shared peer. Retest with the earlier controller stage that boots reliably on the J713.
Details
The existing reset controller's assert and deassert update the running state in both roles. The PHY uses that state when deciding whether to retain the common link on suspend and release it on shutdown. The forward merge preserves main's fixed USB3 and CIO mock fields as well as the new running state.
Evidence