Skip to content

drm/asahi: hold GPU power domain across suspend_noirq for deferred commit stop - #3865

Merged
satchlj merged 1 commit into
mainfrom
fix/asahi-g14-sleep-pd-hold
Dec 2, 2026
Merged

satchlj merged 1 commit into
mainfrom
fix/asahi-g14-sleep-pd-hold

Conversation

@satchlj

@satchlj satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the T8112 committed deep-sleep hang introduced when #3789 attached gpu@206400000 to pmp_report_gfx (report@6, parent ps_gfx).

Root cause

  • The g14_v27_2 backend keeps GPU ASC firmware alive across dpm_suspend_noirq() during firmware-driven deep sleep and defers halting it to its sleep commit hook (g14_v27_2_commit_stop).
  • asahi_sleep_pd_suspend_noirq() returned early whenever pm_suspend_via_firmware() was true, so genpd_suspend_noirq() powered off pmp_report_gfx, dropped ps_gfx's active subdomain count to 0, and powered down ps_gfx under the live GPU ASC firmware before commit.
  • On T8112 laptops (t8112-j413-fw27.dts, t8112-j415-fw27.dts, t8112-j493-fw27.dts), ps_gfx does not set apple,sleep-retained, causing an immediate hardware hang before commit.

Fix

  • Add asahi_sleep_pd_suspend_noirq_hold(struct device *dev, bool hold_firmware) in drivers/gpu/drm/asahi/sleep_pd.{c,h}, keeping asahi_sleep_pd_suspend_noirq(dev) as a wrapper passing false (matching the hook shape in drm/asahi: m3: support firmware-driven deep sleep on T8122 #3504 so both PRs merge cleanly).
  • Add holds_pd_in_firmware_sleep() on g14_v27_2::Runtime / Backend, returning true when a commit_stop hook is armed under CONFIG_APPLE_SOC_SLEEP.
  • Wire SLEEP_OPS.suspend_noirq in drivers/gpu/drm/asahi/driver.rs through sleep_suspend_noirq_driver() so genpd retains the GENPD_NOTIFY_PRE_OFF veto on pmp_report_gfx (keeping ps_gfx powered) until commit stops the GPU ASC and lowers ps_gfx cleanly.

Required to restore T8112 committed deep sleep on J413/J415/J493 after #3789 and unblock #3786.

Tested: MacBook Air 13" M2 (J413, T8112, 27.2 stub) at exact PR head f14fa751845f (over main 65c41b72ae27) with unmodified post-#3789 t8112-j413-fw27.dtb (gpu -> pmp_report_gfx, no apple,sleep-retained on ps_gfx, apple_pmp active):

  • Default command line (mem_sleep=[s2idle]): boot clean, 0 failed units, 0 new kernel errors, 3/3 s2idle (rtcwake -d rtc1 -m freeze -s 10, pmp-gfx Rejected 0->3, gfx Usage=1 unchanged), 25-frame GLES2/EGL render+readback PASS pre- and post-sleep, MTP 3/3 inputs intact.
  • Committed deep sleep (apple_sleep.deep=1 apple_sleep.untested_commit=1, mem_sleep=s2idle [deep]): 3/3 committed deep sleeps (rtcwake -d rtc1 -m mem -s 10), boot object resumes 0 -> 1 -> 2 -> 3, agx=1 gfx_err=0 on all 3 cycles, GPU firmware 27.2 back in 4316 / 3765 / 5838 us (commit idle=0 230 / 240 / 240 us), pmp-gfx Usage=0 Rejected 0->1->2->3, gfx Usage=1 Rejected=0, 0 GPU/PMP warnings or errors, 0 failed units, 25-frame GLES2/EGL render+readback PASS pre- and post-cycle-3, MTP 3/3 inputs intact. (Pre-existing unrelated BCM4387 D3hot to D0 / Bluetooth 0x0c01 rebind messages observed on deep wake.)
  • Host tests: tools/asahi/run-host-tests.py --only g14 (25/25) and --only pmp PASS; scripts/checkpatch.pl 0 errors / 0 warnings.
  • Untested on hardware: J415, J473, J493, and non-g14_v27_2 GPU backends (g16, g17, SLEEP_REFUSE_OPS keep hold_firmware = false).

Risk: Two-way door affecting T8112 g14_v27_2 Macs during firmware-driven deep sleep. Only activates the GENPD_NOTIFY_PRE_OFF veto during firmware sleep when g14_v27_2 has a deferred commit_stop hook armed; s2idle and all other GPU backends (g16, g17, SLEEP_REFUSE_OPS) are unchanged.

…mmit stop

The g14_v27_2 backend keeps the GPU ASC firmware alive through
dpm_suspend_noirq() during firmware-driven deep sleep and defers halting
it to its sleep commit callback (g14_v27_2_commit_stop).

Previously asahi_sleep_pd_suspend_noirq() returned early whenever
pm_suspend_via_firmware() was true, allowing genpd_suspend_noirq() to
power off the GPU's attached power domain before commit. When the GPU
attaches through pmp_report_gfx to ps_gfx without apple,sleep-retained
on ps_gfx, genpd powered down pmp_report_gfx and ps_gfx under the still-
running GPU ASC firmware, causing an immediate bus hang before commit.

Add asahi_sleep_pd_suspend_noirq_hold(dev, hold_firmware) so backends
that defer stopping GPU firmware to the sleep commit hook can retain the
GENPD_NOTIFY_PRE_OFF veto across suspend_noirq() in firmware-driven
sleep as well as s2idle. Wire SLEEP_OPS.suspend_noirq through
sleep_suspend_noirq_driver() and report holds_pd_in_firmware_sleep()
from g14_v27_2 when a commit-stop hook is armed.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj requested review from a team and DjDeveloperr as code owners December 2, 2026 03:10

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

The firmware-sleep hold is tied to successful registration of the deferred stop, and resume_noirq still removes the notifier. The J413 row exercises the offending domain topology in both s2idle and committed deep sleep and verifies render readback after wake.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at f14fa751: ready to merge

Check Detail
CI at head ok 9 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok in the PR body at f14fa751
Conflicts ok none
PR text ok Risk: two-way · affecting T8112 g14v272 Macs during firmware-driven deep sleep. Only activates the GENPDNOTIFYPREOFF veto during firmware sleep when g14v272 has a deferred commitstop hook armed; s2idle and all other GPU backends (g16, g17, SLEEPREFUSEOPS) are unchanged.

Areas: area:gpu
Merge: gh pr merge 3865 --merge (Owners and Core through the bypass: add --admin).

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

@github-actions github-actions Bot added the ready-to-merge Meets the merge policy: merge it (bot) label Dec 2, 2026
@satchlj
satchlj merged commit 71565fd into main Dec 2, 2026
11 checks passed
@satchlj
satchlj deleted the fix/asahi-g14-sleep-pd-hold branch December 2, 2026 04:36
satchlj added a commit that referenced this pull request Dec 2, 2026
Pulls in merged #3504 (M3 GPU deep sleep), #1490 (J613 USB4), and #3865.

Signed-off-by: Satya Benson <satya@benson.earth>
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) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants