Skip to content

soc: apple: sleep: release a bound external display's clock protection before lowering it - #2722

Closed
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
j713-s2r/sleep-dispext-prot
Closed

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
j713-s2r/sleep-dispext-prot

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem. On the M4 MacBook Air (J713) with an external monitor on its 27.2 DCPEXT, a deep sleep faulted at the commit. The sleep engine lowers every external display's power domains, but it only released the clock-protection slice that guards the display's CPU power state for an unbound display. The 27.2 DCPEXTs are now bound, and their driver has no stop of its own that releases the slice, so the write to the CPU power state faulted.

Change. sleep_display_off() releases a still-set protection slice before lowering any external display, bound or not. Displays the engine skips (unbound ones on a SoC that doesn't lower them) are still skipped. The slice is only written when it is set. There is no SoC or board check; the slice comes from the SoC's existing disp_prot_slice data.

Testing. J713, macOS 27.2 stub, stock command line, MSI monitor on DP-2, B9 kernel plus this commit:

  • pm_test devices/platform/processors/core all pass. Before this commit the real deep sleep faulted inside the engine's commit with slice 5/30 still set for the bound DCPEXTs.
  • With this commit the machine gets through the commit and wakes: PMU scratch after the watchdog reset shows engine step 0x7e (back in Linux before any device resumes) and display marker 0xc0 (all three displays lowered). The remaining hang was in the DCPEXT's own resume; with the 27.2 DCPEXT stop/start of drm/apple: dcp: stop a T8132 firmware-27.2 external DCP for a deep sleep #2721 on top, deep sleep passed 3/3 with the monitor (both DCPEXTs stopped and restarted each cycle, DP-2 and eDP back, 0 DART faults). drm/apple: dcp: refuse a deep sleep for a firmware-27 external display processor without a stop #2710 refuses the sleep for an external processor that has no stop.
  • W=1 build of drivers/soc/apple/sleep.o is clean.

Still to run. J713 deep x3 with the monitor on the tip-based candidate that also carries #2721 (the 27.2 DCPEXT stop, which does not release the slice itself; its row passed deep 3/3 with this commit in the kernel), and one Mac whose engine lowers unbound displays (no behaviour change expected: the slice release there is the same as before).

Details for reviewers
  • Before: the release sat inside if (i != 0 && !bound), so a bound external display reached the CPU-word write with its slice still on.
  • After: the skip condition is unchanged (!bound && !lower_unbound_displays -> continue); the release runs for every external display that is lowered, and only when PS_PROT_SLICE_ON is set, so a display whose driver already released the slice is untouched.
  • Row S / T3 traces are kept with the lab notes (traces/power/20261121-j713-s2r/).

Assisted-by: LLM (Claude:Opus 5.5)

…n before lowering it

A deep sleep of an M4 MacBook Air with an external display on its 27.2
DCPEXT hung at the commit: the engine lowers every external display's
domains and released the clock-protection slice guarding its CPU power
state only for an unbound one. The 27.2 DCPEXTs are now bound, stopped
by the time the domains are lowered (a running one refuses the sleep),
but their driver has no stop of its own that releases the slice, so the
write to the CPU power state faulted.

Release a still-set slice before lowering any external display, bound
or not.

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 5a229c50056f6226deb3177bd14e99e3ef9a3c06.

Zero code blockers. CI is 7/7 green, commit/DCO and clean-room rules are clean, and there are no chip/board/firmware gates (uses existing soc->disp_prot_slice[i] and s->ps_prot, reading PS_PROT_SLICE_ON before writing). sleep_display_off() (drivers/soc/apple/sleep.c:3415-3428) keeps the skip condition for unbound displays unchanged, and apple_sleep_check_displays() (drivers/soc/apple/sleep.c:3301) already guarantees no running bound display coprocessor can reach sleep_display_off().

Minor non-blocking nits

  • drivers/soc/apple/sleep.c:3426-3427: caching u32 val = readl(slice); avoids reading the MMIO register twice.
  • drivers/soc/apple/sleep.c:7088: s->ps_prot is only mapped when s->soc->lower_unbound_displays is true — fine today since only T8132 sets disp_prot_slice, worth keeping in mind if a future SoC ever sets disp_prot_slice without lower_unbound_displays.
  • drivers/soc/apple/sleep.c:3419-3420: once linux#2721 lands (especially after wiring DART clock-protection release there), keep the comment aligned with whether the driver or sleep engine releases the slice.

Remaining merge gates (ready to approve once posted)

  • Complete the two open "Still to run" hardware rows on the tip-based candidate: J713 deep x3 with monitor + an unbound-display Mac no-regression row, including checklist §5 regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).

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

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers. ps_prot is only mapped for SoCs that lower unbound displays (sleep.c:7088), which today is only T8132, so other
SoCs are untouched. On T8132 the skip condition is unchanged, and the refusal at 3301 makes sure a bound display is stopped
before the release. One suggestion: the slice is cleared but never restored. sleep_dispext_restore() puts the three domain words
back after a refusal or at the wake, but not the protection slice. A bound DCPEXT restarted by its driver therefore runs with the
slice off, at least after a refused sleep. Saving the slice next to dispext_saved and writing it back in sleep_dispext_restore()
would keep the two symmetric. Rows still worth having: deep x3 with the monitor on the tip-based candidate, deep x3 without a
monitor on this head (the release now runs on every deep sleep on 27.2), the M4 mini with an HDMI display, and one refused sleep
with a monitor attached.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Update after #2721 moved to 8d7df23. Two points against this PR, so it is not ready to merge as it stands:

  1. It's probably redundant now. 8d7df23 gives dcpext0/1_dart their GAPF slices (5 and 30). The DCPEXT's own stop releases them and its start restores them (row X2 logs "GAPF slice 0x12 -> 0x2" for both). So by the time sleep_display_off() runs, the slice of a bound, stopped DCPEXT is already off, and the new readl(slice) & PS_PROT_SLICE_ON branch does nothing. A DCPEXT that has no stop never gets this far either: drm/apple: dcp: refuse a deep sleep for a firmware-27 external display processor without a stop #2710 refuses its deep sleep at device suspend.
  2. A refused commit doesn't undo it. If the release does clear a slice for a bound display, and the commit is then refused (apple_sleep_coprocs_check(), pm_wakeup_pending() or apple_sleep_enclave_stop() failing), sleep_dispext_restore() restores the power domains but not the slice. A running display would be left without its clock protection. The old unbound-only release had the same gap, but there it didn't matter.

Plan: an A/B on the J713 of deep x3 with the monitor, with and without this commit, on top of #27218d7df23.

@RyanTheTide
RyanTheTide marked this pull request as draft November 21, 2026 20:26
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

I ran the A/B planned in the review. The result is that this PR is not needed on top of #2721 at 8d7df23.

So once #2721's GAPF slices are in, a bound, stopped DCPEXT has already released its slice before sleep_display_off() runs, and nothing in these rows depends on this change. I propose closing this PR as superseded by #2721. I'll wait for Dj's side to agree before closing it. One caveat: the USB4 tether peer was not up during the "without" run, but that path doesn't involve this change.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #2721: the external DCP stop there releases the clock-protection slice itself, and deep sleep with a monitor passes without this change.

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