Repository navigation
phy: apple: atc: admit suspend-to-idle with DWC3 running in device role - #2700
RyanTheTide wants to merge 10 commits into
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 <[email protected]>
|
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 <[email protected]>
|
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 <[email protected]>
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 <[email protected]>
|
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 <[email protected]>
…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 <[email protected]>
|
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. |
Superseded by the review at da78109
Preserve the fixed USB3 and CIO fixture fields from main alongside the DWC3 running state used by this branch. Signed-off-by: Ryan Murray <[email protected]>
Keep the accepted USB and DWC3 fixture fields alongside the CIO power-domain hold fields. The production PHY sources merge without manual changes. Signed-off-by: Ryan Murray <[email protected]>
…on-2700 phy: apple: atc: T8132: keep a CIO-mode port across suspend-to-idle
# Conflicts: # tools/testing/selftests/drivers/gpu/apple-dcp/quiesce.py
|
Forward-merged |
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
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