Repository navigation
drm/apple: dcp: fix firmware-27 external and primary-HDMI s2r_ext deep sleep - #3822
Conversation
dcp_s2r_ext_suspend() was the only caller of dcp_external_disconnect() not guarded by dcp_is_retained_external(). On non-retained firmware-27 external DCPs (such as T8112/T8103/T8132-v27 dcpext), routing link teardown through dcp_external_stop_locked() caused two failures during deep sleep with a USB-C display attached: 1. dptxport_set_hpd(false) ran with v27_hpd_low_ms == 0 (1000 ms timeout) instead of the 15 s firmware-27 withdrawal bound used by dcp-v27-sleep.inc (V27_EXT_WITHDRAW_MS), and gave up without calling dptxport_release_display() when HPD-low failed or timed out. 2. Any error in release_link permanently latched dcp->external_error for the rest of the boot even though non-retained s2r_ext pipes have no retained epoch and stop the firmware cold on sleep, turning a single timeout into an immediate -110 refusal on every subsequent suspend. Split the suspend link-withdrawal step into dcp_s2r_ext_disconnect(): - Keep dcp_external_disconnect(dcp, false) unchanged when dcp_is_retained_external(dcp) is true. - For non-retained s2r_ext pipes, disconnect audio, mark attached Type-C outputs typec_crtc_off before dropping HPD (restoring it on failure), withdraw split port 1 (when active) then port 0 with DCP_V27_EXT_WITHDRAW_MS (15000 ms, shared with V27_EXT_WITHDRAW_MS) for DCP_FIRMWARE_V_27_0, still call dcp_dptx_disconnect() if HPD-low fails (matching dcp_poweroff() and dcp_t6040_ext_link_down()), and return any release error cleanly without latching dcp->external_error or mutating dcp->external_stopped. Add host test tools/asahi/dcp-s2r-ext-disconnect-tests.py (registered in tools/asahi/run-host-tests.py) exercising the extracted production code against mocks and six negative-control mutations. Signed-off-by: Satya Benson <satya@benson.earth>
|
Row: 5e7dcf8 (+ #3786 8c8cce3, on main fe7d114) + J473 (Mac mini M2, 27.2 stub, USB-C + HDMI monitors both DPMS-off, default options, mem_sleep booted
For comparison, #3786 alone on the same Mac in the same night state: 7/7 suspends aborted cleanly with -110 (#3790) and the Mac stayed healthy (#3786 issuecomment-7318187459). One difference: this time a USB4 peer link (thunderbolt0) was up, and the ACIO port power-off took 11 s of cycle 1. The resets are probably not the peer's doing, but I can rerun without it if that helps. Kit and logs are kept locally (not public); I can share specific lines. |
|
Thanks for the J473 row — confirming
If you can share those specific
|
|
Follow-up from code inspection while waiting on the Cycle 1
Still holding code edits until we see the Cycle 1 |
|
Lines from the J473 row at Cycle 1, all The suspend took 11.3 s wall, most of it before freeze (ACIO port power-off / xhci-hcd.1 removal, 242.75 -> 253.99). Cycle 2 lead-in ( The RTKit crash dump of 271c00000 follows after 231c00000 DPMS-off earlier in that boot: yes. Before the first sleep it went off -> on at boot, then Cycle 3 reset the Mac during the suspend; no log survived it. |
A primary DCP driving an external output (fixed DP/HDMI PHY, Type-C display routes, or an explicit HDMI/DP/USB connector type) has no internal panel: dcp_poweroff() already turns the display pipe off on DPMS off and DRM suspend. Routing it through internal-panel dcp_s2r_capable() sends a redundant set_power_state(0) and times out waiting for D572 (-16), skips HDMI HPD IRQ disable and DPTX link withdrawal before sleep, and bypasses fixed-HDMI reconnect on wake. Add dcp_s2r_primary_external() so primary external-output DCPs leave dcp_s2r_capable() and (when s2r_no_secure_port is set) enter dcp_s2r_ext_capable(). Move dcp_s2r_pm_register() after fixed_phy and Type-C route setup in dcp_platform_probe_pipe() so the S2R PM notifier sees the populated external-output state. Internal eDP panels stay on dcp_s2r_capable() unchanged. Add host tests and mutation checks in tools/asahi/dcp-s2r-primary-ext-tests.py. Signed-off-by: Satya Benson <satya@benson.earth>
… refusal When dcp_s2r_ext_suspend() withdraws an attached external display link immediately before system sleep, the firmware emits hotplug, AFK teardown, IOMFB callback, and OSLOG counter traffic right before A500 and RTKit idle. Unlike dcp_s2r_quiesce(), dcp_s2r_ext_suspend() did not flush hotplug work, AFK endpoint workqueues, or RTKit RX, did not wait for IOMFB channels to go idle before or after A500, and did not poll and retry RTKit idle once. In addition, when apple_rtkit_sleep_stop() failed with the CPU still running (control RUN set, not crashed), dcp_s2r_ext_suspend() unconditionally latched dcp->crashed = true without undoing AP idle or re-enabling presentation and link work. The next sleep then entered dcp_s2r_stop_crashed(), clearing RUN under live firmware and crashing warm restart. Drain hotplug work, RTKit RX, AFK endpoint workqueues, and in-flight IOMFB channels before A500, wait for IOMFB channels and RTKit RX after A500, poll and retry RTKit idle once when the firmware is still live, and on final idle refusal with a running non-crashed CPU restore AP power, unpark the route, unpause presentation, re-enable Type-C work and HDMI HPD (reconnecting fixed HDMI when applicable), and leave dcp->crashed clear (matching dcp_s2r_quiesce()). Add host test tools/asahi/dcp-s2r-ext-idle-tests.py (registered in tools/asahi/run-host-tests.py) exercising the extracted production functions against mocks and six negative-control mutations. Signed-off-by: Satya Benson <satya@benson.earth>
|
@RyanTheTide Thanks for the Cycle 1/2 log lines — they pinpoint all three failures cleanly. Pushed two follow-on commits on top of
All three fixes are verified with host tests and 18/18 negative-control mutations ( |
RyanTheTide
left a comment
There was a problem hiding this comment.
Ran the three exact-head host fixtures for external disconnect, primary external routing, and idle refusal. All passed. The running-firmware refusal path undoes AP idle, restores presentation and link work, and leaves crashed clear. The primary HDMI route now goes through the external path while internal eDP keeps its original path. B7 still has the exact J473 dual-output committed sleep row.
|
Exact-head J413 (MacBook Air 13" M2, T8112, macOS 27.2 stub, internal eDP +
(Note: J413 has internal eDP and no external HDMI/USB-C monitor attached; keeping PR in draft pending the J473 dual-output committed deep-sleep row at |
|
Row: 875c1ce + #3786 Setup: kernel-only one-shot, fleet94 config, production b18 Stage 2 (no T8112 DT change since). HDMI monitor on the primary DCP
So on the J473 this head makes deep worse: an immediate reset instead of an abort. My guess is the new quiesce in the prepare/early suspend path on the HDMI-primary DCP (nothing is printed without dyndbg). The s2idle path is unaffected. If you want a dyndbg run ( |
|
Thanks for testing this on J473 — two findings from auditing the trace against 1. Why netconsole stopped at
|
|
Control row: main
That is the same as Retraction: ignore the "last line out = What stands: J473 + this PR + #3786 resets on the first deep sleep (2/2 runs), and s2idle passes 3/3 on the same kernel. Next I trace how macOS 27.2 takes both DCPs into sleep on this J473 under our hypervisor and post the sequence. |
Under run-host-tests.py, killed mutation runs must fail via a runtime assertion without emitting a Python traceback (BROKEN_SIGN). 1. Pass -Wno-unused-function to cc only when --mutation is set so call-deleting mutations (skip-quiesce, skip-idle-undo, skip-fixed-hdmi-reconnect) compile and fail at their C assertions instead of failing compile with -Werror=unused-function. 2. Check the C test binary return code explicitly instead of passing check=True to subprocess.run(), so assertion aborts exit non-zero without printing a Python CalledProcessError traceback. No kernel code changes. Signed-off-by: Satya Benson <satya@benson.earth>
|
Ran the Result: Summary by stage
|
|
Follow-up bisection inside Result: cleanly reached That clears |
|
Thank you for running the
|
|
Pushed three commits on top of What was wrong. #4013 landed after your last push. It clears What changed.
#4013's KUnit case still passes either way. It calls Ran locally (hosted runs fail at startup right now), on the pushed tree:
Rows owed at
T8112. The J413 and J473 rows ran at |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Exact-head review at b3b1fc5c06af (including dual-order compatibility check with #4037 at 73eddd32ebd7):
Merge, build, and host tests
- Trial-merged on
main(5f32aa72fa7e) in both land orders (#3822then#4037, and#4037then#3822): both merge cleanly with zero conflicts and zero diff between the two merge results acrossdrivers/gpu/drm/apple/. make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/dcp.o: 0 warnings on the merged tree.scripts/checkpatch.pl --stricton#3822'sdrivers/diff: 0 errors, 0 warnings, 0 checks.- Host tests on both merge orders:
run-host-tests.py --only dcp-s2r22/22 PASS (dcp-s2r-ext-disconnect-tests,dcp-s2r-primary-ext-tests,dcp-s2r-ext-idle-tests, plus mutations) and--only dcpext24/24 PASS.
Semantic check with #4037's firmware-27 gate
- T8122 27.2 (
J613/J615): Internalapple,t8122-dcp(v27_early_stop = true,s2r = s2r_ext = false) keepsdcp_s2r_t8122onV_27_0and stays ondcp_v27_early_suspend()/resume(), unaffected bydcp_s2r_primary_external(). Externalapple,t8122-dcpextenableshw.s2r_ext = trueunderV_27_0withdcp_s2r_t8122_extandapple,display-power, sodcp_s2r_ext_capable()is true at bothdcp_s2r_pm_register()and suspend/resume;dcp_is_retained_external()is false, so deep sleep runs#3822's non-retained 15 sDCP_V27_EXT_WITHDRAW_MSwithdrawal, unconditionaldcp_dptx_disconnect(), endpoint quiesce, and idle retry/leave-running fallback. - T8122 14.7 / 26.6: Internal
apple,t8122-dcpclearshw.s2r_layout = NULLwhenfw_compat != V_27_0(preservingdcp_v26_find_darts()'s owns2r_dt_layoutdiscovery). Externalapple,t8122-dcpextkeepss2r = falseands2r_ext = falseon both 14.7 and 26.6 (H17P/ext26), sodcp_s2r_ext_capable()stays false and neither path touchesdcp_s2r_layout(). - T8112 27 (J473 HDMI): Primary
&dcp(HDMI-A,phys = <&dptxphy>,hw.s2r = true,hw.s2r_no_secure_port = true,dcp_s2r_t8112,apple,display-power) matchesdcp_s2r_primary_external()oncedcp_s2r_pm_register()runs after fixed-PHY/connector/Type-C route setup, suppressing internalset_power_state(0)/D572,dcp_s2r_display_on(), and internal DPMS cycling, and routing suspend/resume throughdcp_s2r_ext_capable()(dcp_s2r_ext_by_layout() == true,dcp_s2r_domains_off/on()withdcp_s2r_t8112, fixed-HDMI reinit/reconnect, and HDMI HPD IRQ re-enable). Secondary&dcpext(apple,t8112-dcpext) enters#3822's non-retained disconnect/quiesce/idle-retry path cleanly. - T8132: M4 firmware (
DCP_FIRMWARE_M4) keepss2r = s2r_ext = falseand is untouched. On firmware 27,J713internaldcp(apple_dcp_hw_t8132_v27) has no external output/connector and stays on internaldcp_s2r_capable();J713dcpext0/dcpext1(apple_dcp_hw_t8132_dcpext_v27+apple,display-power) enter#3822's non-retained disconnect/quiesce/idle-retry path;J773glacksapple,display-powerondcpext0/dcpext1sodcp_s2r_ext_capable()remains false. - T6030: Internal
apple,t6030-dcp(v27_early_stop = true,s2r = s2r_ext = false) keepsdcp_s2r_t6030on 27.2 and clears it toNULLon 14.7/26.6;apple,t6030-dcpexthass2r = s2r_ext = false. Both are unaffected.
One minor pre-existing observation (not introduced by #3822 or #4037): for DT-layout-only V_27_0 external DCPs (such as J713 dcpext0/dcpext1), dcp_s2r_check_dt() sets s2r_dt_layout_ok during bind after dcp_s2r_pm_register() runs in probe, so s2r_pm_nb is not registered for those nodes; all static-layout targets (T8112, T8122, T8103, T8140) have hw.s2r_layout populated at probe and register normally.
No fix-up is needed in either #3822 or #4037; both land orders are clean and semantically consistent.
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed b3b1fc5. The non-retained Type-C path now rearms the HPD completion before withdrawing either port, retaining the fix already on main. The retained path still uses its existing helper. The reported exact host run passes 125/125 and the new case fails on the plain merge. Attached-display hardware coverage at this head is pending.
|
J516s (Apple MacBook Pro 16-inch, M3 Pro,
|
|
J516s (Apple MacBook Pro 16-inch, M3 Pro,
|
|
J700 (MacBook Neo, A18 Pro, T8140) row, 12-03 12:55-13:03Z: PASS, with this PR as part of the dsrows merge tree Three committed deep sleeps (
Not covered here: external displays and HDMI (no Type-C display on this Mac), and the PR head alone. Evidence |
|
Local checks for
Rows at this head: J516s s2idle and GPU control, J700 three committed deep sleeps (the retained path, so no regression only). J413 and J473 ran Still owed, by us: J773g, USB-C display attached, committed deep sleep, with and without this PR. Since #4164, J773g's two external DCPs have |
|
HW: J773g (Mac mini M4, T8132, os-fw 27.2, attached USB-C DP-3 Samsung Odyssey G81SF 3840x2160@60,
All deep-sleep and s2idle wakes restored |
|
Local checks on
Hardware rows at this head: J773g A/B PASS (base deep=2, head deep=3, DP-3 back after every wake), J700 three deep sleeps PASS in merge tree |
Fixes #3790. Required for daily-use deep-sleep stability on Mac mini M2 (J473) with external USB-C and HDMI displays attached, and unblocks #3786 (T8112 deep sleep by default).
Problems
s2r_extlink withdrawal (-110latch):dcp_s2r_ext_suspend()was the only caller ofdcp_external_disconnect(dcp, false)not guarded bydcp_is_retained_external(dcp). On non-retained firmware-27 external DCPs,dptxport_set_hpd(false)used a 1000 ms timeout instead of the 15 s firmware-27 withdrawal bound, aborted without releasing the display on HPD-low error, and latcheddcp->external_errorfor the rest of the boot.dcp_s2r_capable()(-16/no D572): On desktops whose primary DCP (231c00000.dcp) drives a fixed HDMI-A/DP PHY or external output rather than an internal eDP panel,dcp_poweroff()already turns the display pipe off on DPMS off and DRM suspend. Routing it throughdcp_s2r_capable()sent a redundantset_power_state(0)waiting for D572 (timing out with-16), skipped HDMI HPD IRQ disable and link withdrawal before sleep, and bypassed fixed-HDMI reconnect on wake.s2r_extteardown traffic beforeA500/idle (-62) and live-firmware crash cascade: Whendcp_s2r_ext_suspend()withdraws an attached external display link immediately before sleep, hotplug work, AFK teardown replies, IOMFB callbacks, and RTKit RX/OSLOG traffic are still in flight beforeA500andapple_rtkit_sleep_stop(). In addition, whenapple_rtkit_sleep_stop()failed with the CPU still running (RUNset, not crashed),dcp_s2r_ext_suspend()unconditionally setdcp->crashed = truewithout undoing AP idle or restoring presentation/link work, so the next suspend entereddcp_s2r_stop_crashed()under live firmware and crashed warm restart.Changes
5e7dcf85729e(dcp_s2r_ext_disconnect): Keep retained-external (H17P/ext26) pipes ondcp_external_disconnect(). For non-retaineds2r_extpipes, disconnect audio, marktypec_crtc_off(restored on error), withdraw split port 1 then port 0 with the 15 s firmware-27 HPD-low timeout, still attemptdcp_dptx_disconnect()if HPD-low fails, and never latchdcp->external_error.cb39f7a8f1eb(dcp_s2r_primary_external): Movedcp_s2r_pm_register()afterfixed_phyand Type-C route setup indcp_platform_probe_pipe(), exclude primary external-output DCPs fromdcp_s2r_capable(), and route them (whens2r_no_secure_portis set) throughdcp_s2r_ext_capable(). Internal eDP panels stay ondcp_s2r_capable()unchanged.875c1cec941a(dcp_s2r_ext_quiesce_endpoints,dcp_s2r_ext_idle_stop): Flush hotplug work, RTKit RX, AFK endpoint workqueues, and in-flight IOMFB channels beforeA500; wait for IOMFB channels and RTKit RX afterA500; poll and retry RTKit idle once when the firmware is still live; and on final refusal with a running non-crashed CPU restore AP power (dcp_s2r_idle_undo()), unpark the route, unpause presentation, re-enable Type-C work and HDMI HPD (reconnecting fixed HDMI when applicable), and leavedcp->crashedclear (matchingdcp_s2r_quiesce()).Tested
Hardware rows at head
b3b1fc5c06af:appledrm.koA/B: basedeep=2, headdeep=3, every wake brought DP-3 back, 0 DCP/IOMFB errors, 0 warnings, 0 retries. PASS (comment).11a037b7481d(comment).Local checks on this head merged with main
f0b6f4bec87c(clean merge):tools/asahi/run-host-tests.py --only dcp: alldcp-s2r-*tests and their mutations pass; the only failure,apple-dcp, fails the same way on main alone with clang 23 (-Wunused-but-set-global) and passes on both trees with that warning off.tools/asahi/run-host-tests.py --only pmgr-inherited: passes on main and on the merge. The red hostedhost-testsrun failed there, and main has fixed that test since.W=1clang 23 build ofdrivers/gpu/drm/apple/(44 objects,CONFIG_DRM_APPLE=m): 0 warnings.scripts/checkpatch.pl --stricton all three commits: 0 errors, 0 warnings, 0 checks.Risk
Two-way door. Scoped to non-retained
s2r_extexternal DCPs and primary external-output DCPs (withs2r_no_secure_port) during deep sleep (mem_sleep=deep); internal eDP panels, retained-external (H17P/ext26), ands2idlepaths are unchanged.Not yet