Skip to content

drm/apple: dcp: stop a T8132 firmware-27.2 external DCP for a deep sleep - #2721

Open
RyanTheTide wants to merge 3 commits into
j713-s2r/dcpext-pr-basefrom
j713-s2r/dcpext-s2r-ext-pr
Open

RyanTheTide wants to merge 3 commits into
j713-s2r/dcpext-pr-basefrom
j713-s2r/dcpext-s2r-ext-pr

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem. On macOS 27.2 firmware the M4 MacBook Air (J713) hands its two DCPEXTs over running. Nothing stopped their firmware for a deep sleep. The sleep powered them off anyway, and on resume the driver talked to a dead firmware until the watchdog reset the machine. This happened on every deep sleep with the external-display handover, with or without a monitor. #2710 refuses that sleep as a stopgap.

Change. The DCPEXTs on 27.2 (apple_dcp_hw_t8132_dcpext_v27) now use the external-DCP sleep stop and start that already exists: A550, RTKit idle, CPU stop and DART streams on the way down; domains, warm restart and route unpark on the way up. Their power words come from the device tree, the same way as the internal DCP's (#2660):

  • the DISPEXTn CPU/FE/SYS states from the power-domains chain;
  • retention from the CPU domain's apple,retention-workaround;
  • the shared pmc-dcp count.

An external DCP with such a layout uses the layout's power sequence instead of the fixed DISPEXT0 one, and needs no lab parameter. On the J713 both DCPEXTs point at the internal DCP's display-power node. There is no new module parameter and no chip or board check. Once this is in, #2710's refusal no longer fires on the J713, because it applies only without hw.s2r_ext.

Testing. On the J713 (macOS 27.2 firmware), with the external-display handover and an MSI monitor on USB-C, deep sleep passed 3 out of 3. Before this change, the same setup hung on every deep sleep. Each cycle was rtcwake -m mem on the PMU RTC for 30 s, with return code 0 and suspend_stats 3/0. In every cycle both DCPEXTs stopped their firmware for the sleep and came back after the wake. The monitor was connected and lit after each one (2560x1440@280 with DSC). There were no DART faults and no warnings. The Air was booted with the stock cmdline. The kernel was the tested lab tree, which carries the same change; the only difference is that it keys the CPU retention on the older dcp->dcpext flag, where this tree uses #2710's hw.external_processor. On this base, dcp.o and t8132-j713.dtb build with W=1 and no new warnings.

Still to run. Lid wake (needs Ryan at the Air); unplug and replug of the monitor during sleep.

Reviewer details

Assisted-by: LLM (Claude:Opus 5.5)

On 27.2 the M4 MacBook Air's DCPEXTs are handed over running, and
nothing stopped their firmware for a deep sleep: the sleep powered them
off with it, and their resume talked to a dead firmware until the
watchdog reset the machine.

Give them the external DCP stop and start that already exists (A550,
RTKit idle, CPU stop, DART streams, then the domains), with the power
words taken from the device tree the way the internal DCP's are: the
DISPEXTn CPU/FE/SYS states from its power-domains chain, the retention
words from the CPU domain's apple,retention-workaround, and the shared
pmc-dcp count. An external DCP with such a layout takes the layout's
power sequence rather than the fixed DISPEXT0 one, and needs no lab
parameter. On the J713 both DCPEXTs point at the internal DCP's
display-power node.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. dcp_s2r_check_dt() (dcp.c:408-416 at aed223c) now derives the layout from the DT for every DCP with hw.s2r_ext and no static s2r_layout, and clears s2r_ext when that fails. The T8140 (MacBook Neo) external DCP is one of them: apple_dcp_hw_t8140_external has .s2r_ext = true and no layout, and its node (t8140-j700-dcpext.dtsi:27) has apple,display-power = <&dcp_power>. But its ps_dispext0_cpu (t8140-pmgr.dtsi:204) has no apple,retention-workaround; in this tree only the J713 nodes carry one. So dcp_s2r_layout_from_dt() returns -EINVAL, s2r_ext is cleared, dcp_s2r_ext_capable() (H17P: hw.s2r_ext) turns false, and the Neo's external DCP no longer gets its firmware stop for a deep sleep. Today it takes the fixed DISPEXT0 (0x328) sequence. drm/apple: dcp: refuse a deep sleep for a firmware-27 external display processor without a stop #2710 doesn't catch that case either, because it only refuses on firmware 27. That makes this a deep-sleep regression with an external display on the Neo.
    Minimal fix: when the DT layout fails, log it but leave s2r_ext alone. A firmware-27 DCPEXT then isn't dcp_s2r_ext_capable() without the layout (no lab parameter), and drm/apple: dcp: refuse a deep sleep for a firmware-27 external display processor without a stop #2710 refuses its deep sleep, so it still fails closed. The Neo keeps its fixed sequence. The other option is to only try the DT layout where no fixed sequence applies (firmware 27), but the first is smaller and keeps the selection off firmware versions.

The rest looks right:

  • The DT derivation checks the chain (CPU -> FE -> SYS under the same pmgr as the ps reg), the retention words' range and alignment inside pwrgate, and that the masks are consistent before it maps anything.
  • dcp_s2r_layout() keeps the T8142 table and static layouts first.
  • The retain-CPU idle minimum (DCP_PS_MIN 4) only applies to an external processor with a DT layout (external_processor && s2r_dt_layout_ok), which matches the J813 sequence it cites.
  • The knob is no longer needed when the layout parses, so the default command line works.
  • Row X (deep 3/3 with the monitor, both DCPEXTs stopped and restarted, DP-2 back) covers the J713.

Rows still needed: a Neo deep sleep with the dock/DP monitor on the fixed head (no regression), plus the J713 deep x3 on the merged candidate.

…e has no power words

Deriving an external DCP's power words from the device tree cleared
hw.s2r_ext whenever that failed. The MacBook Neo's (T8140) external DCP
has s2r_ext and apple,display-power but no apple,retention-workaround
on its DISPEXT0 CPU state, so it lost the fixed DISPEXT0 stop it uses
for a deep sleep and went to sleep with its firmware running.

Keep s2r_ext when the device tree has no layout. A firmware-27 external
DCP without one is still not dcp_s2r_ext_capable() unless the lab
parameter is set, so it refuses the deep sleep as before.

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.

Adversarial review at aed223c40c20964a866a5f34498c7673b05c3363.

Commit/DCO, clean-room compliance, DT layout validation in dcp_s2r_layout_from_dt(), and removing the s2r_untested requirement for validated DT layouts on the default cmdline look good. However, there are three code blockers that must be fixed before merge:

Blockers

  1. Regresses T8140 (MacBook Neo) external-display deep sleep (drivers/gpu/drm/apple/dcp.c:410-418, 8685-8692, 9874-9886):
    dcp_s2r_check_dt() derives a DT layout for every DCP with hw.s2r_ext && !hw.s2r_layout and sets dcp->hw.s2r_ext = false if derivation fails (dcp.c:416). apple_dcp_hw_t8140_external (dcp.c:9874-9886) has .s2r_ext = true and .s2r_layout = NULL, with apple,display-power = <&dcp_power> (arch/arm64/boot/dts/apple/t8140-j700-dcpext.dtsi:27), but its ps_dispext0_cpu (arch/arm64/boot/dts/apple/t8140-pmgr.dtsi:204-212) has no apple,retention-workaround. dcp_s2r_layout_from_dt() returns -EINVAL (dcp.c:342-344), clearing hw.s2r_ext and disabling Neo's working fixed DISPEXT0 (0x328) stop (dcp.c:8691). #2710 only refuses DCP_FIRMWARE_V_27_0, so Neo silently loses its H17P external-display stop.

    • Important when fixing: If you leave hw.s2r_ext set when dcp_s2r_layout_from_dt() fails, also tighten dcp_s2r_ext_capable() (dcp.c:8687-8690) for DCP_FIRMWARE_V_27_0 to require dcp->s2r_dt_layout_ok || (dcp->hw.s2r_layout && s2r_untested). Otherwise, booting a V_27_0 DCPEXT without a valid DT layout under appledrm.s2r_untested=1 would make dcp_s2r_ext_capable() return true while dcp_s2r_ext_by_layout() is false, sending it down T8140's hardcoded 0x328/0x320/0x288 sequence!
  2. Refused deep sleep on J713 faults in dcp_s2r_ext_cycle() because dcpext0_dart/dcpext1_dart never release their clock-protection slices (drivers/gpu/drm/apple/dcp.c:9229-9255, 8975, drivers/iommu/apple-dart.c:5661,7722,7754, arch/arm64/boot/dts/apple/t8132-j713.dts:289-303):
    On a real deep sleep, linux#2722 (sleep_display_off()) clears PS_PROT_SLICE_ON on slices 5 and 30 before lowering DISPEXT0_CPU/DISPEXT1_CPU. However, when a deep sleep is refused after dcp_s2r_ext_suspend() has already stopped dcpext0/dcpext1 (e.g., a later device refuses .suspend(), pm_test, or dcp_s2r_restart_failed_stop()), dcp_s2r_resume() -> dcp_s2r_restart(dcp, false) -> dcp_s2r_ext_cycle() calls apple_dart_gapf_ready(dcp->s2r_dcp_dart) (dcp.c:9236) and then dcp_s2r_ext_domains_off() -> dcp_s2r_domains_off() (dcp.c:8975), writing DISPEXTn_CPU (0x1e8/0x4f0).

    • In arch/arm64/boot/dts/apple/t8132-j713.dts:289-303, dcpext0_dart and dcpext1_dart only carry apple,clock-protection = <&ps_prot 5/30> (no gapf reg, unlike &dcp_dart at lines 212-216), and drivers/iommu/apple-dart.c:5661 only parses apple,clock-protection when j713_display is true (not j713_dcpext).
    • Thus dart->gapf is NULL on dcpext0_dart/dcpext1_dart, making apple_dart_gapf_release() (apple-dart.c:7722) and apple_dart_gapf_ready() (apple-dart.c:7754) silent no-ops. Writing DISPEXTn_CPU in dcp_s2r_domains_off() while slice 5/30 still has PS_PROT_SLICE_ON set will fault (the same fault #2722 fixes in sleep.c), and apple_dart_gapf_protect() also never re-protects slices 5/30 after wake.
    • Fix: wire dcpext0_dart/dcpext1_dart to release and re-protect their clock-protection slice (via gapf reg or apple,clock-protection support in apple_dart_gapf_*), and verify a refused deep sleep (pm_test = devices/platform) on J713.
  3. dcp_s2r_ext_domains_off() skips apple_dart_power_dark(dcp->s2r_disp_dart, true) on the layout path (drivers/gpu/drm/apple/dcp.c:9157-9174 vs 9137-9138):
    Returning dcp_s2r_domains_off(dcp) immediately at dcp.c:9157-9158 bypasses apple_dart_power_dark(dcp->s2r_disp_dart, true) (dcp.c:9173-9174), while dcp_s2r_ext_start(dcp, true) (dcp.c:9137-9138) still unconditionally calls apple_dart_power_dark(dcp->s2r_disp_dart, false). During dcp_s2r_ext_cycle()'s 1000 ms power-off hold (dcp.c:9248-9251), dispextN_dart is powered down without display_dark set, exposing concurrent IOMMU maps/unmaps to powered-off DART registers. Mark s2r_disp_dart dark before calling dcp_s2r_domains_off(dcp) on the layout path as well.

Minor notes & merge gates

  • drivers/gpu/drm/apple/dcp.c:7218-7219: update the stale "No sleep support" comment above apple_dcp_hw_t8132_dcpext_v27.
  • No CI has run on this head (stacked base j713-s2r/dcpext-pr-base). Retarget to integration/aurora once dependencies land, and post: (a) Neo deep-sleep regression row with external display, (b) J713 refused-sleep row (pm_test), and (c) J713 deep x3 on the tip-merged head with 0 AVC, 0 failed units, and 0 new kernel errors.

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed 597f023 for the blocker above, as one commit with no force push. When the device tree has no power words, the driver now logs that at debug level and keeps hw.s2r_ext:

W=1 dcp.o is clean (only the existing kernel-doc warning at dcp.c:896), and checkpatch is clean. Still owed: a Neo deep sleep with the dock/DP monitor on this head.

…p stop

Three gaps in the DCPEXT deep-sleep stop, found in review:

- A firmware-27 DCPEXT is capable of the stop only with a power layout,
  the device tree's or a static one under the lab parameter. Without
  one, the lab parameter alone would send it down the fixed DISPEXT0
  sequence, which is not its own.
- A refused sleep powers a stopped DCPEXT off and on again
  (dcp_s2r_ext_cycle()). On the layout path its display DART was left
  powered on in the driver's view while its domains were off; mark it
  dark first, as the fixed sequence does.
- On the J713 the DCPEXT DARTs had no GAPF slice to release, so the
  power-off on a refused sleep wrote DISPEXTn_CPU with its clock
  protection still on. Give dcpext0/1_dart their slices (5 and 30, at
  PS_PROT + 0x100 + 0x40 * n), as the internal DCP's DART has slice 42.

Also describe the J713 DCPEXT's sleep in its hw data.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks. All three blockers are fixed at 8d7df23, which sits on 597f023; it is one new commit, with no force push.

  1. Neo regression (597f023): if the device tree has no power words, s2r_ext is kept, so the Neo's external DCP keeps its fixed DISPEXT0 stop. On firmware 27, dcp_s2r_ext_capable() now requires s2r_dt_layout_ok || (hw.s2r_layout && s2r_untested). A V_27_0 DCPEXT without a layout can therefore no longer reach the fixed 0x328/0x320/0x288 sequence, even with the lab parameter set, and its deep sleep is refused by drm/apple: dcp: refuse a deep sleep for a firmware-27 external display processor without a stop #2710 instead.
  2. Clock protection on a refused sleep: dcpext0_dart and dcpext1_dart now carry gapf regs for slices 5 and 30, at PS_PROT + 0x100 + 0x40·n (0x38079c240 and 0x38079c880), the same pattern as the internal DCP's slice 42 at 0x38079cb80. The DCPEXTs' stop and start now release and restore the slices through the existing apple_dart_gapf_* path.
  3. DART dark on the layout path: dcp_s2r_ext_domains_off() marks s2r_disp_dart dark before dcp_s2r_domains_off(), matching the fixed sequence and the un-dark in dcp_s2r_ext_start(dcp, true).

I also replaced the stale "No sleep support" comment.

J713 hardware row (X2): the lab kernel carries exactly this content, on the stock fleet cmdline, with the MSI monitor on DP-2.

  • Deep sleep with the monitor: 3/3. rtcwake rc=0 each time, suspend_stats 3/0, and DP-2 was back after every wake.

  • Refused sleep (pm_test=devices and pm_test=platform, rc=0 for both). On both DCPEXTs:

    • "firmware stopped for sleep";
    • their DARTs log GAPF slice 0x12 -> 0x2;
    • display domains off: CPU 0xf040300 FE 0x2300 SYS 0x2100;
    • sleep refused: firmware back after a power cycle: 0;
    • then GAPF slice 0x2 -> 0x12.

    DP-2 retrains once and comes back connected, and the internal DCP restarts as it does for DPMS.

  • 0 DART faults, 0 WARN, 0 oops.

dcp.o and t8132-j713.dtb build with W=1 and no new warnings.

Still owed: a Neo deep sleep with the dock or DP monitor on this head. It needs the Neo, and I'll request it through its queue.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Relation to #2200 (keep an external display across a deep sleep on T8132): the two don't overlap at runtime, and they merge without conflicts on integration/aurora cacf355 (#2200 first, then this).

  • drm: apple: t8132: keep an external display across a deep sleep #2200 acts in the iomfb_is_m4() branch of dcp_platform_suspend(), i.e. fw_compat == DCP_FIRMWARE_M4 (apple_dcp_hw_t8132_dcpext). Its cold stop (iomfb_m4_ext_stop()) restarts the firmware from reset, so it has to release the display first.
  • This PR acts on apple_dcp_hw_t8132_dcpext_v27 (fw_compat == DCP_FIRMWARE_V_27_0). Probe selects it only when apple_t8132_dcpext_v27_2() matches, and dcp_s2r_ext_capable() returns from suspend before the iomfb_is_m4() branch. Its restart is warm, with retention from the DT.
  • A given dcpext is one or the other on a given boot, so drm: apple: t8132: keep an external display across a deep sleep #2200's release/reconnect never runs on a 27.2 DCPEXT, and this PR never runs on the M4 firmware.
  • One piece of drm: apple: t8132: keep an external display across a deep sleep #2200 does apply to both: the dptxep "rate 0 refused with -EOPNOTSUPP is answered as done" change, which covers any DCP. On 27.2 it only matters if the ATC PHY refuses a rate 0 during set_hpd(0). The t5 rows below (3/3 deep with the MSI monitor attached, display back after each wake) ran without it.

J713 rows on 27.2 with this head: t5 = integration + #2692 + this @ 8d7df23, deep 3/3 (rtc 20 s) with the MSI monitor on USB-C plus a USB4 peer. Both DCPEXTs stopped and restarted warm, and DP-2 came back at 2560x1440 each time. No crash on restart with the display attached.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The three review blockers are answered at 8d7df23, which now needs a fresh review. Still needed: a Neo deep sleep with the dock or a DP monitor on this head, and since it sits on #2660 and #2710, those land first and then this is retargeted onto integration/aurora so CI runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants