Repository navigation
phy: apple: atc: admit suspend-to-idle with DWC3 running in device role - #2700
RyanTheTide wants to merge 3 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 <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) |
DjDeveloperr
left a comment
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 (
Assisted-by: LLM (Google:Gemini 4 Neon)
|
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) |
|
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) |
Problem
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. A port in device role (the Mac connected to another computer as its USB device) therefore refuses every suspend-to-idle:
atcphy_suspendreturns -EBUSY and the sleep aborts. On the M4 MacBook Air (J713) with a computer on its USB-C port, s2idle never starts.Change
The host-only rule rests on the DWC3 glue keeping the controller, and with it the
atcN_usbpower domain the PHY shares, on across system sleep. dwc3-apple does that for either role: it 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. The PHY now tracks whether DWC3 is out of the reset it provides (set on deassert, cleared on assert) and admits suspend-to-idle on that. A controller held in reset, or any deeper sleep, is still refused. No new parameters; nothing keyed on a board or SoC beyond the existing T8132 common-block path.Testing
run-host-tests.py --only atc6/6, including the mutation run. Both atc harnesses carry the new field. The T8132 sleep test admits s2idle with a running device and refuses it with the controller in reset. New negative controls and mutations (host-only rule, release not marking the controller running, assert not clearing it) are rejected.drivers/phy/apple/.atcphy_suspend()returns 0 before this check unless the PHY is a T8132 one with its SuperSpeed side (hw->gen != ATCPHY_GENERATION_T8132 || !t8132_ss), and nothing else reads the new flag, so T8103/T600x/T8112/T6020/T8122/T6040/T6050 behave as before (the host tests keep their T8103-generation sleep cases).atcphy_suspend returns -16.brcmf_pcie_intr(RTC fallback at +120 s): the J713 row for Airs: Wi-Fi wake on the M4 Airs, and deep sleep with WoWLAN on #2662.suspend_stats9 / 0, no Oops/WARN.Still to run
Details for reviewers
atcphy0anddwc3_0both sit inps_atc0_usb(parentsps_atc0_common,ps_atc0_usb_aon). ACIO holds theatc0_cio*domains itself for a connected cable (syscore pd devices), so a USB4 link on the same port is unaffected by this check.dwc3_apple_init()callsdwc3_apple_syscore(appledwc, true)for HOST and DEVICE. At PM_SUSPEND_PREPARE the notifier clears syscore so prepare runs, anddwc3_apple_pm_prepare()sets it again and returns -EAGAIN (thegenpd_prepare returns -11line).dwc3_apple_sleep_prepare_work()returns right afterdwc3_apple_sleep_start()when!sleep_deep.phy-apple-atc 402a90000.phy: PM: dpm_run_callback(): atcphy_suspend [phy_apple_atc] returns -16,PM: failed to suspend: error -16.DWC3_RESET_Ninside one controller session (atcphy_controller_hibernate/_d0) do not change the flag: it follows only the reset controller ops.Assisted-by: LLM (Claude:Opus 5.5)