Repository navigation
phy: apple: atc: T8132: keep a CIO-mode port across suspend-to-idle - #2705
RyanTheTide wants to merge 3 commits into
Conversation
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>
|
Blockers: 1. The comment at atc.c:7856-7863 says the port survives suspend-to-idle because the router's power states stay on. |
|
J713 row, run on the J713 default kernel (7.3.0-bj713t6+ = the integration tip plus open J713 PR heads, including this one at 766641b; default cmdline; 27.2). Test: s2idle three times, 15 s each, with the USB4 host-to-host link to the J616s up and carrying traffic (5 Hz ping over thunderbolt-net).
This is the row alternative to holding the domain in code. It covers a host-to-host link only; a dock with a DP tunnel is not covered. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review at 766641b3586c against pre-pr-checklist.md.
Blockers
-
§3 (Correctness —
ps_atcN_usbis not kept on across s2idle in CIO mode, andatcphy_restore_after_pd_off()silently tears down/re-initializes the live CIO PHY on resume):drivers/phy/apple/atc.c:7860-7862assumes a CIO-mode PHY stays powered because the USB4 router's power states stay on. In DT,usb4_0_acioonly ownsps_atc0_cio,ps_atc0_cio_pcie,ps_atc0_cio_usb, andps_atc0_pcie(arch/arm64/boot/dts/apple/t8132-usb4.dtsi:468-471, marked syscore indrivers/thunderbolt/apple.c:3448). Those keep parentps_atc0_commonon, notps_atc0_usb.atcphy0sits inps_atc0_usb(t8132.dtsi:1176), a sibling underps_atc0_common(t8132-pmgr.dtsi:1237-1244;t8132-j713-pmgr.dtsi:594-596does not mark it always-on or sleep-retained). With DWC3 in reset (dwc3_running == false),dwc3-appledrops syscore, so nothing inps_atc0_usbpreventsgenpd_finish_suspend()(drivers/pmdomain/core.c:1605-1608) from powering offps_atc0_usband firingGENPD_NOTIFY_OFF→atcphy->pd_was_off = true(atc.c:6845-6846).- On resume (
atc.c:7879-7903), thepd_was_offwarning at line 7887 only checksatcphy->host_active(false in CIO mode), so nothing warns. Thenatcphy_restore_after_pd_off()(atc.c:4439-4508, enabled byatcphy_hw_t8132.restore_after_pd_off = truesincecio_sleep.preparedis false) runs: it callsatcphy_forget_common_state()(wiping tracked DP/tunnel clock state), setsatcphy->mode = APPLE_ATCPHY_MODE_OFFat line 4467 whileatcphy->t8132_common_ownedis stilltrue, and then callsatcphy_configure(atcphy, APPLE_ATCPHY_MODE_USB4)→atcphy_configure_t8132(). Becauseatcphy->modewas already overwritten toOFF, line 4033–4040 skipsatcphy_t8132_phy_stop()and executesatcphy_power_off(atcphy)followed by a full CIO re-init underneath the live USB4 router. - Checking that
atc0_usbreadsonbefore and after s2idle (issuecomment-7074095251) does not prove it stayed on during s2idle, becausegenpd_finish_resume()powers it back on before userspace reads it. - Required fix: Explicitly hold
ps_atcN_usbacross s2idle while the PHY is kept in CIO mode (releasing it when leaving CIO or for deep sleep), and extend thepd_was_offresume warning atatc.c:7887to CIO mode (and device-roledwc3_running).
-
§3 (Cross-board regression — mode-only check admits CIO s2idle without an active ACIO router):
atcphy_suspend()checks onlyatcphy_mode_is_cio(atcphy->mode). Boards such ast8132-j604(M4 Mac mini) includet8132-j604-atcphy-tunables.dtsi(apple,tunable-cio-*, soatcphy->cio_tunablesis true) without anyusb4_*_acionode int8132-j604.dts. Without a running ACIO router holdingps_atcN_common, evenps_atcN_commonis not kept on across s2idle. Gate admission on the PHY/router actually keeping the required power domain(s) on (or holdingps_atcN_usb, which itself keeps parentps_atcN_commonon).
-
CI / Stack:
What checks out & remaining §5 rows
- §4 & §6: Clean (human author/committer + human
Signed-off-by:only,Assisted-by:in PR body). - §5 (for re-review after fixes): Include
genpd_summaryoff-count/off-time delta (orpd_was_offverification) provingps_atcN_usbhad 0 off transitions during s2idle, plus explicit regression counts (0 SELinux AVCs, 0 failed units, 0 new kernel errors). A dock with a DP tunnel across s2idle is also worth covering.
Assisted-by: LLM (Gemini 4 Neon)
…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>
|
Updated to 0ed3520. The branch first takes the current #2700 head (da78109) with a normal merge, 1866ac2. That merge is needed because both PRs change the resume warning and the T8132 host test. The fix is a single commit on top. 1.
2. Admission without a router or hold (J604). Admission now keys on 3. Stack / CI. Still stacked on #2700. Retarget to Also fixed: the KUnit Testing (no hardware in this round):
Still to run on hardware:
Assisted-by: LLM (Claude:Opus 5.5) |
|
Review at 0ed3520: no blockers. Both code findings from the review at 766641b are fixed. The PHY now holds ATCn_USB itself: a syscore genpd virtual consumer that is given up in noirq unless this suspend-to-idle keeps a CIO port. CIO admission requires that hold, so a CIO-tunables board with no hold is refused. The resume warning now covers CIO mode and DWC3 running in either role. I found no get/put imbalance and no lifetime bug. Two non-blocking points are below. The J713 genpd off-count row asked for in the earlier review has not been posted for this head, and the PR still needs a retarget once #2700 lands. Non-blocking:
Full reviewEarlier findings:
Refcount walk for the hold:
Locking:
Other checks:
Still to run (from the earlier review's section 5): J713 at this head, USB4 link with traffic, s2idle x3, with the Assisted-by: LLM (Claude:Opus 5.5) |
Problem
With a USB4 cable in (a dock, or a host-to-host link to another Mac), a T8132 port runs in CIO mode under its USB4 router, and DWC3 does not run on it. #2700 admits suspend-to-idle while DWC3 runs, in either role, so on such a port the M4 MacBook Air still refused every suspend-to-idle:
atcphy_suspend()-EBUSY.Change
Also admit suspend-to-idle for a port in CIO mode. The router's power states stay on across suspend-to-idle, because the ACIO's links to them are syscore devices, as the glue keeps the controller's on for DWC3. So the link stays as it is. A deeper sleep still needs the native CIO sleep's handoff. The T8132 selftest gets the CIO case and a negative control for it.
Stacked on #2700.
Testing
tools/testing/selftests/drivers/apple/atc-t8132-usb3.py: 13/13. The new CIO case admits s2idle and refuses deep; the no-CIO mutation fails as it should.tools/asahi/atc-usb3-tests.py --mutations: 38/38 cases, all mutations killed.phy-apple-atc 402a90000.phy: atcphy_suspend returns -16.Assisted-by: LLM (Claude:Opus 5.5)