Skip to content

phy: apple: atc: admit suspend-to-idle with DWC3 running in device role - #2700

Merged
DjDeveloperr merged 11 commits into
mainfrom
airs-wifibt2/t8132-s2idle-device-role
Dec 3, 2026
Merged

DjDeveloperr merged 11 commits into
mainfrom
airs-wifibt2/t8132-s2idle-device-role

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

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 7c78f979ad64f68fa9e76b21ff31c24e9882f8fc passed the 13-job ATC host selection and the 65-job display host selection. Earlier J713 M4 Air at da781091715d ran 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

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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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:

  • 3 of 3 suspend-to-idle cycles (rtcwake -m freeze -s 20 on the PMU RTC). suspend_stats went from 0 to 3 successes with 0 failures, and each suspend took about 0.09 s.
  • Wi-Fi reconnected and both displays (eDP and an external DP-2 monitor) were still connected after the cycles.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers. Since every path that asserts the DWC3 reset also clears host_active, the new dwc3_running condition in
atcphy_suspend() only adds the device-role case, and dwc3-apple keeps the core syscore for either role, so the shared
USB domain stays on through suspend-to-idle as the commit says. Only T8132 PHYs read the flag; other generations are
unchanged. Small suggestion: the hibernate/D0 steps write DWC3_RESET_N directly without updating the flag, which is
fine today, but a note in the @dwc3_running kerneldoc that it follows the reset-controller ops only would keep later
users from treating it as the register state. Rows still worth having: the M4 mini with a device-role port (s2idle
x3), and a J713 row with a gadget function passing traffic across s2idle plus the host cable pulled during the sleep.

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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks. The kerneldoc note is in 916d514: dwc3_running follows the reset controller's assert/deassert only, not the DWC3_RESET_N bit that the hibernation/D0 steps toggle within one controller run.

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 rtcwake -m freeze -s 20 x3 with a host computer on the port, plus /sys/power/suspend_stats before and after.

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>

@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.

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

  1. Inconsistent host_active checks in atcphy_resume and atcphy_shutdown (drivers/phy/apple/atc.c:7885, 7915)

    • drivers/phy/apple/atc.c:7885:
      if (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");
      Now that atcphy_suspend() admits s2idle in device role on atcphy->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 inside atcphy_restore_after_pd_off()). Check atcphy->dwc3_running here so host and device roles get the same invariant check.
    • drivers/phy/apple/atc.c:7915: atcphy_shutdown() similarly checks atcphy->host_active when guarding against incomplete USB3 common ownership; checking atcphy->dwc3_running catches a failed dwc3_apple_shutdown reset assert in device role as well.
  2. 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_stats before/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.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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 cdc_ncm):

  • 6 of 6 suspend-to-idle cycles (20 s, PMU RTC) completed with the gadget bound; the UDC stayed configured through each.
  • IPv6 ping over the NCM link passed after the 3rd and 4th sleep. After the 5th and 6th, host-to-device traffic stopped: the host's OUT transfers never complete (cdc_ncm ... NETDEV WATCHDOG: transmit queue 0 timed out on the host), while device-to-host still works.

So the PHY side holds, but a device that stays connected through s2idle can lose its OUT path. dwc3-apple has only a .prepare PM op, so in device role nothing takes the gadget off the bus for the sleep the way dwc3's own system suspend does (dwc3_gadget_suspend() soft-disconnects). Before this PR the same configuration could not enter s2idle at all, and an image with no gadget function bound is unaffected. A follow-up for dwc3-apple (disconnect a device-role gadget for s2idle, connect it again after) is in progress, with its own row.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Both findings from the 11-21 review are fixed in da78109.

  • Resume warning (atcphy_resume(), drivers/phy/apple/atc.c:7886): it now checks dwc3_running instead of host_active, the same condition atcphy_suspend() admits suspend-to-idle on. If a device role loses the power domain across suspend-to-idle, it now gets the warning before the restore asserts the DWC3 reset.
  • atcphy_shutdown() (atc.c:7917): the guard checks dwc3_running instead of host_active. Before this, if dwc3_apple_shutdown() failed to assert the reset with the port in device role, the PHY still powered the common block off under the running controller; now it keeps the epoch and logs the error. Host roles behave as before: every reset-assert path also clears host_active, and host mode is only set while the controller runs.

Tests: tools/testing/selftests/drivers/apple/atc-t8132-usb3.py now counts resume warnings and expects one when a device role lost the domain. The shutdown case covers DWC3 left running in device role, and its reset stub clears the flag the way the real assert does. Two new negative controls swap each check back to host_active, and both fail as they should. The same test run against the old atc.c fails on the new resume assertion. Host tests --only atc passed 6/6 (including atc-usb3-tests --mutations and apple/atc-t8132-usb3 at 13/13), --only dwc3 passed 1/1 and apple-dcp passed 1/1. drivers/phy/apple/atc.o builds with W=1 (clang, fleet81 config) with no compiler warnings, and checkpatch --strict is clean.

Hardware rows still to run:

  • J713, device role on port0, with this head and usb: dwc3: apple: take a device role off the bus for suspend-to-idle #2728 on top, stock command line: rtcwake -m freeze -s 20 x3, then 0 AVC (ausearch --input-logs -m avc), 0 failed units, and no new kernel errors against the boot.
  • M4 mini (J773g) with a device-role port: 3 suspend-to-idle cycles plus /sys/power/suspend_stats before and after. We have no M4 mini in the lab, so this one needs an owner who has one, or a waiver.

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>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at da78109: no blockers.

Both findings from the 11-21 review are fixed. atcphy_resume() (drivers/phy/apple/atc.c:7886) now warns on a lost power domain when dwc3_running is set, the same condition atcphy_suspend() (:7864) admits suspend-to-idle on, so a device role that loses the domain is reported before atcphy_restore_after_pd_off() asserts the reset. atcphy_shutdown() (:7917) now keeps the common epoch when DWC3 is still out of reset in either role. Host roles behave as before. Every reader of dwc3_running is behind a T8132 check (hw->gen/t8132_ss/t8132_common_owned), so other Macs are unchanged.

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
  • Commits in integration/aurora..da781091 (8b8e6af, 916d514, da78109): each has only a human Signed-off-by, with no Co-Authored-By, Assisted-by or session trailers. The PR body ends with the Assisted-by: line. git merge-tree onto the current integration/aurora (95a13cf) is clean.
  • Writers of dwc3_running: _atcphy_dwc3_reset_assert() clears it under atcphy->lock, and atcphy_dwc3_reset_deassert() sets it after the RESET_N write, also under the lock. Every reset-assert path goes through the helper: the reset op, atcphy_restore_after_pd_off(), probe finalize and atcphy_sleep_recover(). All three readers (suspend, resume, shutdown) hold the same lock, so the flag cannot change between the check and the decision.
  • If atcphy_park_pipehandler() fails in the assert op, host_active is cleared but dwc3_running stays true. That is correct: the controller has not been reset, and suspend-to-idle with a running controller keeps the shared domain on.
  • The direct RESET_N writes in the sleep-in-place hibernate and come-back steps (atc.c:7071, :7123) leave the flag alone. That matches the kerneldoc ("follows the reset controller's assert/deassert only"). atcphy_sleep_recover() clears the flag, and the glue's dwc3_apple_recover() restarts the controller through sleep_stop/sleep_start and the reset ops, which set it again. That path also only exists on fixed-hub (sleep_power) ports, which none of the T8132 checks reach.
  • Resume warning: system resume runs suppliers before consumers, so the PHY checks pd_was_off before dwc3 can touch the controller. A domain lost at runtime can't produce a false warning, because a started controller holds a runtime PM reference (rpm_held) for as long as reset_pending is set.
  • Shutdown: dwc3_apple_shutdown() (T8132 compatible only) goes through dwc3_apple_exit(), which asserts the reset whenever reset_pending is set. reset_pending is set on every deassert, in either role, so after a normal shutdown dwc3_running is false and the common block is powered off as before. Only a failed assert now keeps the epoch, with the existing dev_err. Without dwc3-apple bound, the reset was never deasserted, so the flag stays false and shutdown is unchanged.
  • No new module or cmdline parameters, no added delays, and no chip or board checks beyond the existing T8132 generation and of-data selection. The struct field is written on every generation but read only on T8132.
  • Tests, run locally at da78109: run-host-tests.py --only atc passed 6/6 (including atc-usb3-tests --mutations with the two new reset-flag mutations, and apple/atc-t8132-usb3 with its new host-only negative controls for suspend, resume warning and shutdown guard). --only dwc3 passed 1/1 and --only apple-dcp passed 1/1. drivers/phy/apple/atc.o builds with W=1 (clang, fleet81 release config) with no compiler warnings. The only W=1 output is the kernel-doc notes for existing t8132_*/cio_sleep members; the new @dwc3_running is documented.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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.

  • Before any sleep: gadget configured at high speed, ping 10/10, iperf3 289 Mbit/s.
  • 3 × rtcwake -m freeze -s 20 on the PMU RTC, then 5 back-to-back s2idle cycles with no idle gap: suspend_stats +9 successes, 0 failures. The UDC was configured afterwards, ping 10/10, iperf3 283 Mbit/s, so device-role traffic survived 8 sleeps. There was no "power domain went off" warning.
  • Counts on that boot: SELinux Enforcing, 0 failed units. The kernel error lines are the existing dwc3 genpd_prepare returns -11 refusals, one per controller per sleep. There was 1 AVC, from the test harness (systemd executing a helper under /var/lib), not from the kernel.

Not valid from this run: the aborted-suspend (pm_test=devices) check and the traffic check after each single cycle. The USB host rebooted at 05:52:51 in the middle of them.

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)

@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.

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 checks atcphy->dwc3_running instead of host_active, matching atcphy_suspend().
  • atcphy_shutdown() guard (drivers/phy/apple/atc.c:7917) — Fixed: Now checks atcphy->dwc3_running instead of host_active, retaining the common epoch if DWC3 reset assert failed in either role.
  • Audited all remaining host_active sites in atc.c (atcphy_configure_t8132:4024, atcphy_rpm_busy:4352, apple_atcphy_cio_off:7710): all intentionally remain host_active (in particular, :4024 must allow device-role lane switches while DWC3 is out of reset). Selftest coverage and negative controls in atc-t8132-usb3.py are 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 + human Signed-off-by: only; PR body includes Assisted-by:.
  • §5 Evidence (Partial): J713 device-role NCM row at da781091 passed 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-tests green (1/1).

Remaining Blockers Before Approval (§5 & Co-Landing Gate)

  1. Second T8132 Mac (J773g M4 mini) device-role s2idle row (rtcwake -m freeze -s 20 ×3 with a host on the port, /sys/power/suspend_stats before/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.
  2. 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). #2728 is still open with CHANGES_REQUESTED and an active J713 warm-reboot hang at its current head 1a91e650, so #2700 should not enter MERGETRAIN-LINUX4 ahead of #2728.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (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 3e590b27: not ready yet

Check Detail
CI at head no failing: host-tests
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 3e590b27
Conflicts ok none
PR text ok Risk: two-way · USB-C PHYs using the T8132 shared link, especially a running device role at suspend or shutdown.

Areas: area:gpu, area:usb

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

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 28, 2026
@aurora-silicon-review
aurora-silicon-review Bot dismissed their stale review December 1, 2026 05:02

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

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 2, 2026

@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.

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.

@aurora-silicon-review
aurora-silicon-review Bot removed the request for review from satchlj December 2, 2026 07:23
@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 2, 2026
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>
@github-actions github-actions Bot added needs-review No approving review from Core or Omarchy Mac yet (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026

@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: 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 main ccb3d8bd. The driver change is line for line the same as at 6515ae4d: atc.c +139/-8, atc-test.c +30/-2, atc-t8132-usb3.py +141/-11. Only the host-test mocks conflicted. Main renamed t8132_device to usb2_device and added fields, and each mock (dwc3/mocks.c, phy.py, quiesce.py, atc-usb3-tests.py) now has main's fields plus dwc3_running.
  • Main's new atc.c code still reads host_active where it means the host role: the T8132 lane-reconfiguration refusal (atc.c:4567) and apple_atcphy_cio_off() (atc.c:9442). The PR moves only suspend admission (:9599), the resume warning (:9627) and shutdown (:9660) to dwc3_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_noirq unless this suspend-to-idle keeps a CIO-mode domain, and reclaimed in resume_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=y and CONFIG_PHY_APPLE_ATC_KUNIT_TEST=y (so atc-test.c is built in), W=1: builds, 0 warnings. I compiled it only: the suite needs an arm64 VM to run.
  • Host tests (the host-tests.yml container, run-host-tests.py, 998 runs): 996 passed. The two failures are centauri-scan-tests and its negative controls. They fail the same way on main ccb3d8bd alone (the extracted Bluetooth harness no longer compiles: cen_rx_consume is undeclared), so they come from main, not from this PR.
  • The hosted DWC3/ATC compile check passed. Hosted host-tests is 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.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Apple M4 Mac mini, T8132, firmware 27.2) receipt at exact head 3e590b27cc9683d77c1b2f4e49d95390abb6fc73, kernel 7.3.0-j773g-comp6a (boot_id=57875cbc-9f1a-4e72-94aa-866d4d596113): PASS (device-role NCM gadget across s2idle + warm reboot; cold boot not exercised).

  • Bound configfs usb_f_ncm gadget to 40a280000.usb (configured high-speed) against host enu1:
    • Pre-s2idle: 5/5 ICMPv6 ping (avg 2.029 ms, 0% loss) + 2 MiB IPv6 TCP SHA-256 5f6ce3e5601135c8 matched.
    • Across rtcwake -d /dev/rtc1 -m freeze -s 5: UDC remained configured high-speed and host 118: enu1 stayed UP without re-enumeration.
    • Post-s2idle: 5/5 ICMPv6 ping (avg 1.678 ms, 0% loss) + 2 MiB IPv6 TCP SHA-256 92e488b9de191ff4 matched.
  • Clean teardown (not attached), 0 DWC3/ATC PHY/WARN errors; subsequent warm reboot clean. Cold boot was not exercised.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
@aurora-silicon-review
aurora-silicon-review Bot requested review from DjDeveloperr and removed request for satchlj December 3, 2026 04:31
@aurora-silicon-review
aurora-silicon-review Bot removed the request for review from DjDeveloperr December 3, 2026 08:43
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J700 (MacBook Neo, T8140, G17P) at 3e590b27cc96: PASS, with the parts the J700 can't reach named below

One-shot trial boot on 2026-12-03 (base arm), built from exact head blobs of this PR and #1688 on main 4c6f0f70 (release 7.3.0-pr2700-4c6f0f70, commit 52cd127df834), not GitHub's merge commit, stock aurora_defconfig with CONFIG_TYPEC_TPS6598X_DEBUG_COMMANDS=y. A second boot carries the same plus #3993, so the sleeps were taken twice.

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.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Merging 3e590b27cc96 into main dc4d6f065001 with an admin merge. The only red check is hosted host-tests.

Checked on the merge (it merges cleanly), arm64, LLVM, on pc:

  • make W=1 drivers/phy/apple/atc.o: builds, 0 warnings.
  • Host tests in the CI container: atc 18/18, dwc3 1/1, typec 1/1, apple-dcp 1/1, centauri 22/22. The two centauri-scan-tests failures in the review came from main at that time, and they pass now.
  • These ran on one tree with ten other open PRs also merged. None of them touches a file this PR changes.

Rows at this head: J773g device role, J700 host role.

Not measured:

  • A J773g cold boot. It was warm rebooted only. The probe does change on T8132: it attaches a second holder of the PHY's own power domain, without powering it on. The next J773g kernel on this tip covers it.
  • Device-role NCM past one s2idle cycle without usb: dwc3: apple: take a device role off the bus for suspend-to-idle #2728. Before this PR that sleep was refused with -EBUSY. This gets its own issue.

@DjDeveloperr
DjDeveloperr merged commit 8ee5629 into main Dec 3, 2026
9 of 10 checks passed
@DjDeveloperr
DjDeveloperr deleted the airs-wifibt2/t8132-s2idle-device-role branch December 3, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants