Skip to content

drm/asahi: hold GPU power domain across suspend-to-idle - #2715

Merged
DjDeveloperr merged 3 commits into
mainfrom
ewb/gpu-s2idle-awake-path
Nov 26, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
ewb/gpu-s2idle-awake-path

Conversation

@erikwb

@erikwb erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What: Hold the GPU's attached power domain (ps_gfx) across suspend-to-idle (!pm_suspend_via_firmware()) from drm/asahi via a temporary GENPD_NOTIFY_PRE_OFF veto notifier during the noirq sleep window, preventing genpd_suspend_noirq() from powering down the GPU under live GFX firmware and crashing on resume (PC = 0x0, FAR = 0x0, ESR = 0x86000004).
Tested:

  • J316s (M1 Pro, T6000, G13S C0) at 69ee6f661a63 (guarded one-shot combined batch over main 8f99a858b456, 0 merge-tree diffs on the 5 changed files, default cmdline, run by @RyanTheTide): 3/3 real rtcwake -d rtc1 -m freeze -s 4 cycles; kprobes 18/18 (asahi_sleep_pd_suspend_noirq -> 0, asahi_sleep_pd_notify GENPD_NOTIFY_PRE_OFF -> 0x8011 -EBUSY veto keeping ps_gfx on, asahi_sleep_pd_resume_noirq -> 0 with 0 -EEXIST on cycles 2–3); Borealis api.smoke 8/8 & Asahi gl-smoke 32/32 pre/post, 0 GPU/DART faults, 0 failed units, SELinux Enforcing, 0 new AVC.
  • J713 (M4 Air, T8132, g16, apple,sleep-retained) at 69ee6f661a63 (one-shot Linux 7.3.0 trial, default cmdline): 0 failed units, 0 AppArmor denials/AVC (SELinux not built), 0 new kernel errors; s2idle (rtcwake -d rtc1 -m freeze -s 30) kprobes 1/1 add/remove, clean resume (AC readings 4.725 W before / 4.701 W 20 s after vs 4.742 W / 4.726 W no-hold control — AC before/after readings do not establish in-sleep power delta); firmware-driven deep sleep (rtcwake -d rtc1 -m mem -s 30) 0/0 notifier calls (GPU firmware back in 729 us); dEQP-VK.api.smoke.* 6/6 pass after both sleeps, 0 GPU errors.
  • J313 (M1 MacBook Air, T8103, G13G B1):
    • Exact head 69ee6f661a63 (one-shot Linux 7.3.0 trial, default cmdline): boots cleanly, 2/2 s2idle cycles clean, 0 AppArmor denials/AVC/Oops; GPU does not bind on firmware 27.2 (Unsupported GPU/firmware combination (G13, G, [27, 2, 0])), so the legacy -EBUSY deep-sleep refusal (driver.rs:287) could not be exercised live on this 27.2 machine.
    • Patched J313 27.2 GPU stack (NOT exact head — same 5-file diff 6c7d489e0fbc..69ee6f661a63 on dbb7b44b3d99 + 3577ce0e4885, default cmdline): 10 s2idle cycles (pm_test=platform, 3 × 15 s, 6 × 1 s) + 1 deep-sleep cycle (rtcwake -d rtc1 -m mem -s 30, GPU firmware back in 5954 us) clean; PR notifier add/remove 1/1 per s2idle cycle (GENPD_NOTIFY_PRE_OFF returning 0x8011 -EBUSY) and 0/0 in deep sleep; GPU compute checksum + dEQP-VK.api.smoke.* 6/6 pass after every wake; idle AC power 20 s after resume unchanged (3.69-3.77 W / 2.53-2.64 W vs 3.89 / 3.85 / 2.69 W control). Caveats: J313's DT already marks gfx apple,sleep-retained (control also keeps gfx on and logs 1 rejected power-off/cycle), short 1 s RTC alarms did not abort suspend_noirq (only pm_test=platform exercised noirq enter/resume), and aurora-sep.service has a pre-existing failure on every boot of this machine.
  • J716c (M5 Max, T6050, G17C B1, fw 27.2) at 69ee6f661a63 (one-shot Linux 7.3.0 trial, Stage 2 1.0.0b17-gae94218e, default cmdline): s2idle dEQP-VK.api.smoke.* 6/6 + gpubench-vk compute.light 2/2 ok before/after, notifier add/remove kprobes 1/1 on head vs 0/0 on pre-#2715 main baseline 15b1e2e0aaca, 0 kernel err+ lines during/after s2idle (1 pre-existing failed unit aurora-peripherals.service). Caveats: 15 s rtc0 rtcwake alarm failed to wake on both #2715 head and pre-#2715 main baseline 15b1e2e0aaca (pre-existing RTC wake regression on main, woken by key press); deep-sleep rtc0 wake also failed on head so J716c deep-sleep notifier count and in-sleep power delta were not measured.
  • Build & CI at 69ee6f661a63: ARCH=arm64 LLVM=1 W=1 build of sleep_pd.o and aurora.o (0 errors), checkpatch.pl (0 errors), CI host-tests / pr-text / readiness PASS.
    Risk: two-way door · M1 (t8103), M1 Pro/Max/Ultra (t600x), M2 (t8112), M2 Pro/Max/Ultra (t602x), M3 (t8122, t6030/t6031), M5 (t8142); no-op during firmware-driven deep sleep, and unchanged power behavior on Macs where ps_gfx is already always-on or sleep-retained (t8132, t604x, t6050, t8140)
    Not yet:
  • Real aborted suspend_noirq unwind on hardware (short 1 s RTC alarms on J313 slept normally with 0 aborts; only pm_test=platform noirq enter/resume was exercised).
  • In-sleep power delta measurement (AC before/after readings on J713 and J313 do not establish in-sleep power delta; J716c was on AC charging).
  • J716c (T6050) firmware-driven deep-sleep 0/0 notifier count (blocked by pre-existing rtc0 wake failure on main 15b1e2e0aaca / 69ee6f661a63).
  • Legacy -EBUSY deep-sleep refusal (driver.rs:287) on a t8103 stack where the GPU binds without apple,sleep-retained.
  • Hardware rows on external Macs not in lab: M1 Max/Ultra (t600x), M2 (t8112 direct ps_gfx, APPLE_USE_PMP pmp_report_gfx -> ps_gfx, and t8112-j413-fw27 in coordination with #2614), M2 Pro/Max/Ultra (t602x), M3 (t8122, t6030/t6031), and M5 (t8142).
Details

Problem

During suspend-to-idle (s2idle), pm_suspend_via_firmware() is false so drm/asahi leaves the GPU firmware running. However, genpd_suspend_noirq() still powered off the GPU's attached power domain (ps_gfx on Macs where it is neither apple,always-on nor apple,sleep-retained), cutting power to the running GFX ASC and crashing the GPU firmware immediately on resume (PC = 0x0, FAR = 0x0, ESR = 0x86000004, followed by EIO lost-device errors for desktop clients).

Design

  • Add drivers/gpu/drm/asahi/sleep_pd.{c,h} with asahi_sleep_pd_init(), asahi_sleep_pd_suspend_noirq(), and asahi_sleep_pd_resume_noirq().
  • Allocate the per-device struct asahi_sleep_pd state via devres_alloc()/devres_add() at probe time across AsahiPlatformDriver::probe (covering legacy, probe_g14_v27_2, probe_g17, probe_g17_m5, probe_t8122, and probe_m5), probe_g15, and probe_g16 (before firmware start, so probe failures clean up automatically and retained-firmware bound states on G15/G16 keep the hold), and look it up via devres_find() in suspend_noirq/resume_noirq with no allocation in suspend_noirq and no global list or lock.
  • Wire suspend_noirq and resume_noirq into SLEEP_OPS (AsahiPlatformDriver), SLEEP_REFUSE_OPS (g15::Driver), and g16::sleep::SLEEP_OPS.
  • During s2idle (!pm_suspend_via_firmware()), when the GPU's attached genpd is on, suspend_noirq registers a temporary GENPD_NOTIFY_PRE_OFF veto notifier (returning notifier_from_errno(-EBUSY)) on the GPU device's own genpd and resume_noirq removes it, matching pcie-apple's consumer-side hold pattern.
  • Fail safe on hold failures: if dev_pm_genpd_add_notifier() returns -EEXIST, if the probe-allocated devres hold is unexpectedly missing, or if a future multi-domain GPU DT node leaves dev->pm_domain unset with of_count_phandle_with_args(..., "power-domains", "#power-domain-cells") > 1, log a warning and return -EBUSY to refuse s2idle rather than letting GPU power domains power off under live firmware.
  • g18 (t8152, drivers/gpu/drm/asahi/g18/probe.rs) has no pm_ops and attaches no genpd (t8152-j873-gpu.dtsi uses PMGR2 PSD services rather than an attached genpd), so genpd_suspend_noirq() cannot power off a GPU domain there.
  • drivers/pmdomain/apple/pmgr-pwrstate.c is untouched, so no other PMGR power domain changes behavior in s2idle or deep sleep. Firmware-driven deep sleep (pm_suspend_via_firmware() == true) is a no-op.
  • Coordination with #2614: #2715 covers t8112-j413-fw27 on the s2idle path from the GPU driver side while leaving firmware-driven deep sleep untouched.
Evidence

Credits

Tested-by: RyanTheTide (J316s M1 Pro T6000 at 69ee6f661a63)

Build, style, and CI (69ee6f661a63)

  • Merge (82f12be07bc5, main 6c7d489e0fbc into the PR branch): resolved drivers/gpu/drm/asahi/Makefile (sleep_pd.o + rtkit_dump.o) and drivers/gpu/drm/asahi/driver.rs (sleep_pd_init(pdev.as_ref())? kept before ProbeConfig match so LegacyWithG14Handoff / probe_g14_v27_2 also receives probe-time devres allocation).
  • License (69ee6f661a63): updated drivers/gpu/drm/asahi/sleep_pd.c and drivers/gpu/drm/asahi/sleep_pd.h SPDX headers to GPL-2.0-only.
  • Build (69ee6f661a63): make O=_build ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/sleep_pd.o drivers/gpu/drm/asahi/aurora.o (CONFIG_DRM_ASAHI=m, G15=y, G16=y, G14_V27_2=y, M3_T8122=y, M5=y, G18=y): 0 errors, 0 warnings in sleep_pd.c, driver.rs, and g16/sleep.rs; llvm-nm confirmed asahi_sleep_pd_init, asahi_sleep_pd_suspend_noirq, asahi_sleep_pd_resume_noirq, asahi_sleep_pd_notify, and asahi_sleep_pd_release linked in aurora.o.
  • Style (69ee6f661a63): ./scripts/checkpatch.pl --git origin/main..HEAD 0 errors (1 standard MAINTAINERS warning on e29c9a8d76bd for new files).
  • GitHub CI (69ee6f661a63): Host tests/host-tests, pr-text/pr-text, and pr-readiness/readiness PASS.

J316s (M1 Pro, T6000, G13S C0) at 69ee6f661a63 (by @RyanTheTide)

  • Guarded one-shot combined batch (427b2c2dc67c over main 8f99a858b456, 0 merge-tree diffs on the 5 changed files, default cmdline): 3/3 real rtcwake -d rtc1 -m freeze -s 4 cycles.
  • Kprobes recorded 18/18 hits across all 3 cycles (asahi_sleep_pd_suspend_noirq -> 0x0, asahi_sleep_pd_notify action=0x0 GENPD_NOTIFY_PRE_OFF -> 0x8011 -EBUSY veto keeping ps_gfx on, asahi_sleep_pd_resume_noirq -> 0x0 cleanly removing notifier with 0 -EEXIST on cycles 2–3).
  • Borealis dEQP-VK.api.smoke.* 8/8 pre & 8/8 post, Asahi GL gl-smoke 32/32 pre & post, 0 GPU faults, 0 DART faults, 0 failed units, SELinux Enforcing, 0 new AVC.

J713 (M4 Air, T8132, g16, apple,sleep-retained) at exact head 69ee6f661a63

  • One-shot Linux 7.3.0 trial, default cmdline, asahi_sleep_pd symbols present in /proc/kallsyms:
    • Boot regression check: 0 failed units (systemctl --failed); SELinux not built (AppArmor active, 0 DENIED/AVC kernel audit lines); 0 new kernel errors or warnings vs prior boot (macaudio, apple-pmc, apple-cpufreq bound).
    • s2idle (rtcwake -d rtc1 -m freeze -s 30, kprobes on dev_pm_genpd_add_notifier and dev_pm_genpd_remove_notifier, AC power / battery full):
      • PR kernel (69ee6f661a63): rc 0, 31.14 s elapsed, suspend_stats 1/0, 1/1 notifier add/remove (stack pm_suspend -> dpm_suspend_noirq -> genpd_suspend_noirq -> pm_generic_suspend_noirq -> dev_pm_genpd_add_notifier; removed ~15 ms later in resume_noirq), clean resume (0 dmesg err/warn, GPU firmware recovered, ANE reboot-from-preload OK), macsmc Total System Power 4.725 W before / 4.701 W 20 s after.
      • No-hold control kernel (Linux 7.3.0 without sleep_pd, different base, same rtcwake command): rc 0, 31.59 s elapsed, suspend_stats 1/0, 0/0 notifier calls, 4.742 W before / 4.726 W 20 s after. (Caveat: AC before/after readings at full battery do not establish an in-sleep power delta, and the control was a different-base kernel rather than a same-base A/B.)
    • Firmware-driven deep sleep (rtcwake -d rtc1 -m mem -s 30, mem_sleep = s2idle [deep], same kprobe setup): rc 0, 32.08 s elapsed, suspend_stats 1 -> 2 (0 fail), 0/0 dev_pm_genpd_{add,remove}_notifier calls, aurora-g16 302600000.gpu: GPU firmware back in 729 us. (Two unrelated pre-existing deep-sleep warnings seen in dmesg: apple-sleep dma-controller isn't bound and brcmf_cfg80211_suspend: WoWLAN wakes only from suspend-to-idle here.)
    • Post-sleep Vulkan check: dEQP-VK.api.smoke.* 6/6 pass after both sleeps with 0 GPU errors in dmesg.

J313 (M1 MacBook Air, T8103, G13G B1, GPU fw 27.2)

  • Exact head 69ee6f661a63 (one-shot Linux 7.3.0 trial, default cmdline, asahi_sleep_pd_* symbols present):
    • GPU does not bind on firmware 27.2 (aurora 206400000.gpu: Unsupported GPU/firmware combination (G13, G, [27, 2, 0]); main uses the legacy t8103 path), /dev/dri has card1 only, mem_sleep=[s2idle] (no deep). Consequently, GPU work before/after and the legacy -EBUSY deep-sleep refusal (driver.rs:287) could not be exercised live on this 27.2 machine.
    • s2idle × 2 (rtcwake -d rtc1 -m freeze -s 15 and -m mem -s 15 falling back to s2idle): both clean (~18 s); kprobes show only apple_pcie_hold_domains (1/1) and 0/0 PR notifier calls (no bound GPU driver).
    • Boot regression health: 0 failed units at initial snapshot (aurora-sep.service fails after 120 s with trusted_key: key_seal failed (-5) on every boot of this machine, default kernel included), 0 AppArmor denials (SELinux not built), 0 Oops, 9 pre-existing boot err lines (DCP and PCI IRQ parsing, same families as other boots).
  • Patched J313 27.2 GPU stack (NOT exact head — dbb7b44b3d99 / #3178 + 3577ce0e4885 / #3171 + the 5-file #2715 diff 6c7d489e0fbc..69ee6f661a63 applied cleanly, default cmdline; compared against shipped J313 27.2 control kernel without #2715):
Kernel / cycles Mode Notifier kprobes (add / remove / asahi_sleep_pd_notify) gfx genpd Rejected GPU post-wake check
Control (no #2715, 1 cycle) rtcwake -d rtc1 -m freeze -s 15 (17 s) 0 / 0 / n/a (apple_pcie_hold_domains 1/1) 0 -> 1 Compute checksum identical, dEQP-VK.api.smoke.* 6/6 Pass
Patched stack, c1 pm_test=platform, -m freeze -s 15 1 / 1 / 0 (ret=0) 0 -> 1 noirq enter + resume_noirq unwind clean
Patched stack, c2–c4 Real s2idle, rtcwake -d rtc1 -m freeze -s 15 (18–19 s) 1 / 1 / 1 per cycle (action=0 GENPD_NOTIFY_PRE_OFF -> 32785 / 0x8011) 1 -> 4 Compute checksum b336c570f7a9e87c (3/3 runs), api.smoke 6/6 Pass
Patched stack, c5–c10 Real s2idle, rtcwake -d rtc1 -m freeze -s 1 (2–3 s, 0 aborts) 1 / 1 / 1 per cycle (action=0 -> 0x8011) 4 -> 10 Compute checksum b336c570f7a9e87c (3/3 runs), api.smoke 6/6 Pass
Patched stack, c11 Deep sleep, rtcwake -d rtc1 -m mem -s 30 (32 s, NUB.SPMI0Sw3IRQ) 0 / 0 / 0 (pm_suspend_via_firmware() gate) 10 -> 11 GPU firmware 27.2 back in 5954 us, checksum b336c570f7a9e87c, api.smoke 6/6 Pass
  • gfx genpd remained current_state: on with total_idle_time: 0 ms; kernel logs recorded GPU held for sleep / GPU released after sleep around every cycle and 0 GPU fault/timeout/recovery/EIO lines.
  • Idle AC power (macsmc_hwmon power1_input / power2_input / power3_input, mean of 5 samples 1 s apart, 20 s after resume, AC connected at 100% battery): 3.69-3.74 / 3.70-3.77 / 2.53-2.64 W (c5–c10) vs 3.89 / 3.85 / 2.69 W (control) — AC idle no-regression check only; does not establish in-sleep power delta.
  • Regression health on patched stack (~18 min boot): 0 AppArmor DENIED (SELinux not built), 0 AVC, 0 OOM, 0 Oops/BUG/WARNING/call trace, 0 GPU errors, 0 failed units at end snapshot (pre-existing aurora-sep.service failures also seen before testing and on default); 18,365 Vulkan CTS cases (api.smoke.*, glsl.builtin.*, compute.pipeline.cooperative_matrix.*, compute.basic.*) 2,254 Pass / 16,111 NotSupported / 0 Fail / 0 DeviceLost (2,682 glsl.builtin.* cases identical to default kernel).
  • Caveats: (1) /proc/device-tree/soc/power-management@23b700000/power-controller@3f8 already marks gfx apple,sleep-retained and apple,no-auto-pm, so the control kernel also kept gfx on across s2idle (Rejected 0 -> 1) and the PC = 0x0 crash is not reproducible under this DT; (2) none of the six 1 s alarms hit an aborted suspend_noirq window; (3) deep sleep c11 logged unattributed apple-pmgr-pwrstate ...@1e0: PS fpwm1: Failed to reach power state 0xf, pci ... bridge window [io] failed to assign, and AFK service DCPDP2XService admission failed: -19 (no control deep-sleep run for comparison).

J716c (M5 Max, T6050, G17C B1, GPU fw 27.2 (26B123)) at exact head 69ee6f661a63

  • One-shot Linux 7.3.0 trial, Stage 2 1.0.0b17-gae94218e, default cmdline, mem_sleep = [s2idle] deep, wake-capable RTC rtc0 (apple-pmu-rtc):
    • Boot regression health: GPU and Hyprland desktop up, 0 new boot err+ lines (only 2 pre-existing systemd-gpt-auto-generator lines), 1 pre-existing failed unit (aurora-peripherals.service).
    • s2idle (rtcwake -d rtc0 -m freeze -s 15):
Kernel s2idle wake behavior Notifier kprobes (add / remove) GPU pre & post s2idle Window dmesg err+
Exact head 69ee6f661a63 15 s rtc0 alarm did not wake; woken by key press after ~20 min 1 (suspend entry) / 1 (resume) dEQP-VK.api.smoke.* 6/6 Pass, gpubench-vk compute.light 2/2 ok (before & after) 0 (38 non-audit lines)
Pre-#2715 main baseline 15b1e2e0aaca 15 s rtc0 alarm did not wake; woken by key press after ~20 min 0 / 0 dEQP-VK.api.smoke.* 6/6 Pass, gpubench-vk compute.light 2/2 ok (before & after) 4 (non-GPU)
  • Deep sleep (mem_sleep=deep, rtcwake -d rtc0 -m mem -s 30): run once on #2715 head 69ee6f661a63 and did not RTC-wake (required hard power cycle; not repeated on baseline because the s2idle baseline already showed rtc0 alarms are not waking on main).
  • Power on J716c 20 s after s2idle resume (90.2 W) was sampled while AC was connected and charging, so in-sleep / s2idle power delta and J716c deep-sleep 0/0 notifier count remain unmeasured.

@RyanTheTide

Copy link
Copy Markdown
Contributor

The crash diagnosis is convincing, and keeping the GFX domain up for s2idle while the firmware runs is the right goal. One problem with the pmgr-pwrstate half:

GENPD_FLAG_ACTIVE_WAKEUP reaches more than device_set_awake_path() callers. The commit message says the flag "only has an effect when a device in the domain explicitly marks device_set_awake_path(dev)". But device_suspend() also sets power.wakeup_path for every device with device_may_wakeup() (drivers/base/power/main.c, right after the suspend callback succeeds). dpm_propagate_wakeup_to_parent() then passes it up to the parents, and genpd_finish_suspend() checks only device_awake_path(). So with the flag on every PMGR domain, any domain that has an enabled wakeup source under it now stays powered for every system sleep, deep sleep included. Today that only happens for domains that were on at boot (the 2023 "Mark on-at-boot PDs as wakeup" behaviour). That may be harmless, or it may hold domains up that the deep-sleep entry or the s2idle floor expects off.

Could you show which domains change? A pm_genpd_summary (or the genpd power_off tracepoints) taken during an s2idle sleep before and after the change on the J313 would show it. Then, on deep-sleep Macs (M4/M5), a sleep that still enters and wakes with no new domain held up. If other domains do change, an option is to leave the boot-time rule as it is and keep the GFX domain up from the GPU driver's side only.

Smaller:

  • .suspend in SLEEP_REFUSE_OPS never runs, because .prepare already refused. It's harmless, but it can go.
  • Do other PMGR-GPU Macs (M1 Pro/Max, M2, M3) crash in s2idle without this today? If not, it would help to say why M1 differs, for example whether their GPU domain is always-on or firmware-owned there. That also tells us where the rows matter.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the ewb/gpu-s2idle-awake-path branch from c228da2 to 723bcb7 Compare November 22, 2026 01:00
@erikwb
erikwb marked this pull request as draft November 22, 2026 01:00
@erikwb erikwb changed the title drm/asahi: keep PMGR GPU power domains powered across suspend-to-idle drm/asahi: hold GPU power domain across suspend-to-idle Nov 22, 2026
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Dropped the apple-pmgr-pwrstate GENPD_FLAG_ACTIVE_WAKEUP change and reworked this to keep the GPU's attached power domain powered from drm/asahi only, rebased onto integration/aurora (606d37ec77a5).

  • Scoped to the GPU domain only: Instead of touching pmgr-pwrstate.c, drivers/gpu/drm/asahi/sleep_pd.c registers a temporary GENPD_NOTIFY_PRE_OFF veto notifier (notifier_from_errno(-EBUSY)) on the GPU device's own attached genpd during suspend_noirq when !pm_suspend_via_firmware() and releases it in resume_noirq (matching pcie-apple's apple_pcie_pd_notify hold). No other PMGR domain changes in s2idle or deep sleep, and firmware-driven deep sleep (pm_suspend_via_firmware() == true) is untouched.
  • SLEEP_REFUSE_OPS: Kept suspend_noirq/resume_noirq wired there because sleep_refuse() (drivers/gpu/drm/asahi/driver.rs) only returns -EBUSY when pm_suspend_via_firmware() is true; during s2idle it returns 0, so g15::Driver (M3 Pro/Max T6030/T6031) enters suspend_noirq and needs the same hold. Also wired g16::sleep::SLEEP_OPS for consistency.
  • Which Macs have unprotected ps_gfx in DT: Inspecting arch/arm64/boot/dts/apple/, ps_gfx has neither apple,always-on nor apple,sleep-retained on M1 (t8103), M1 Pro/Max/Ultra (t600x), M2 (t8112, both ps_gfx and pmp_report_gfx), M2 Pro/Max/Ultra (t602x), M3 (t8122), M3 Pro/Max (t6030/t6031), and M5 (t8142). By contrast, M4 (t8132) sets apple,sleep-retained, M4 Pro/Max (t604x) and A18 Pro (t8140) set apple,always-on, and M5 Pro/Max (t6050) sets apple,always-on (J714s/J716c) or apple,sleep-retained (K114c).

Moved back to Draft until the reworked consumer-side hold is re-verified live on J313 (and fleet Macs).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-reviewed at 723bcb7. The rework answers the earlier point: no PMGR domain changes any more, the hold is on the GPU device's own genpd and only for the noirq window of a sleep that does not go through firmware.

Checked against the genpd core:

  • The driver's suspend_noirq runs from genpd_suspend_noirq() before genpd_finish_suspend() powers the domain off, so the notifier is registered in time, and _genpd_power_off() honours a GENPD_NOTIFY_PRE_OFF veto. On an aborted suspend the PM core calls resume_noirq for every device whose suspend_noirq completed, so the hold is always dropped.
  • Every GPU node attaches exactly one domain (M2 attaches pmp_report_gfx with APPLE_USE_PMP, which keeps ps_gfx up as its parent), so dev_pm_genpd_add_notifier() won't hit the multi-domain -ENODEV case and silently skip the hold. Worth a comment, because a future GPU node with two domains would lose the hold without a word.

Small:

  • kzalloc(..., GFP_ATOMIC) in suspend_noirq can fail under memory pressure and then fails the whole suspend with -ENOMEM. noirq callbacks may sleep, and the hold can live in the driver's per-device data (allocated at probe), which also removes the list and lock.
  • dev_pm_genpd_add_notifier() returns -EEXIST if the device already has a notifier; nothing in drm/asahi registers one today, so fine, but that error would currently fail suspend rather than skip.

Rows owed for the draft: short rtcwake -m freeze -s 15 with a GPU job before and after (vkcube/compute dispatch, no GPU fault, ps_gfx on in pm_genpd_summary during the sleep) on an M1/M2 (single ps_gfx), an M3 (T8122) and one Mac where ps_gfx is always-on (no change expected), plus one deep-sleep row showing the hold is not taken there.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the ewb/gpu-s2idle-awake-path branch from 723bcb7 to 4c635ff Compare November 22, 2026 02:16
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Addressed all three follow-up items in 4c635ff7427e:

  • Probe-allocated per-device hold: Added asahi_sleep_pd_init() using devres_alloc(asahi_sleep_pd_release, ..., GFP_KERNEL) and wired it into AsahiPlatformDriver::probe, probe_g15, and probe_g16 (before firmware start, so probe failures clean up via devres and retained-firmware bound states on G15/G16 keep the hold). suspend_noirq and resume_noirq look up the hold via devres_find() with no allocation, global list, or spinlock.
  • Single-domain assumption: Documented in sleep_pd.c that current GPU nodes attach a single power domain (including M2 attaching pmp_report_gfx with APPLE_USE_PMP, keeping ps_gfx up as its parent), so dev_pm_genpd_add_notifier() won't hit the multi-domain -ENODEV path and a future multi-domain GPU node would need a different hook.
  • -EEXIST handling: When dev_pm_genpd_add_notifier() returns -EEXIST, log via dev_warn() and return 0 without marking hold->active, so suspend proceeds and resume_noirq does not remove a pre-existing notifier.

Verified ARCH=arm64 LLVM=1 compile and link of drivers/gpu/drm/asahi/aurora.o (CONFIG_DRM_ASAHI=m, G15=y, G16=y, M3_T8122=y, M5=y), checkpatch.pl (0 errors, 0 warnings), and tools/asahi/run-host-tests.py (asahi, sleep, pmgr, binding, g15, retain, m3). Keeping the PR in Draft for the hardware rtcwake and deep-sleep verification rows.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 4c635ff. The probe-time devres hold is right: one allocation per binding (the g15/g16 drivers call probe_g15()/probe_g16() directly, so there's no double init through AsahiPlatformDriver::probe), no list or lock left, and suspend_noirq can no longer fail on memory.

One correction to my own earlier note, sorry for the round trip: on -EEXIST it should not skip. Skipping means the domain powers off under live GPU firmware, the exact failure this PR exists to prevent, with only a warning. Refusing that suspend (-EBUSY with the warning) is the safe side. Nothing registers a notifier on the GPU device today, so it's theoretical, but if it ever happens a refused sleep is much easier to diagnose than a dead GPU after resume.

Otherwise ready for the rows.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 4c635ff: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2715 drm/asahi: hold GPU power domain across suspend-to-idle @4c635ff7

VERDICT: BLOCKERS

Checked against the genpd core in this tree. genpd_finish_suspend() (drivers/pmdomain/core.c:1588) runs the driver's suspend_noirq before genpd_sync_power_off() (core.c:1607), and _genpd_power_off() honours a GENPD_NOTIFY_PRE_OFF veto (core.c:1467 path), so the mechanism works. Parents stay up because the child never powers off. Coverage: AsahiPlatformDriver (M1/M2/M3 t8122/M5 t8142/G17), g15 (T6030/T6031) and g16 all get the ops, with one devres allocation per binding. The g15/g16 drivers call probe_g15()/probe_g16() directly, so there is no double init.

Blockers:

  1. drivers/gpu/drm/asahi/sleep_pd.c:92-95: on -EEXIST the code warns and returns 0, so the suspend continues without the hold. ps_gfx then powers off under the live GFX firmware, which is the exact crash this PR fixes (PC=0 on resume, EIO for every client). Only a dev_warn is left behind. The reviewer's last comment on this head (RyanTheTide 11-22 02:17) asks for -EBUSY here, and the head has not been updated. Today it is theoretical (nothing else registers a notifier on the GPU device), but this is the fail-unsafe branch of a hardware-safety hold.
  2. No hardware row on this revision. The only hardware evidence is J313 on a prior revision (which also changed pmgr-pwrstate flags). The PR is still a Draft and owes these rows itself: rtcwake -m freeze with GPU work before and after, plus pm_genpd_summary during sleep showing the hold on M1/M2/M3, and a deep-sleep row (M4/Neo) showing the hold is not taken. Keeping ps_gfx and its parent chain powered across s2idle also costs s2idle power on every M1/M2/M3/M5 Mac, and that cost is unmeasured.

Nits:

  • sleep_pd.c:70-79: the comment says a future multi-domain GPU node would hit the "-ENODEV path". It never gets there. For a multi-PD device dev->pm_domain is not a genpd, so dev_pm_genpd_is_on() (core.c:791-793) returns false and the hold is skipped silently at line 79, with no warning. Add a dev_warn_once or a dev_pm_domain_attach_list lookup if this is meant to be caught.
  • sleep_pd.c:90: -ENODEV is also skipped silently. Same remark.
  • g18 (T8152, drivers/gpu/drm/asahi/g18/probe.rs:52) has no pm_ops, so it gets no s2idle hold. That's fine if its GFX domain is retained, but the PR body does not mention it.
  • The PR body's Assisted-by lists three models. That is a style point only.

Missing rows: every Mac in scope on this head. That's M1 (J313/J413-class t8103), M1 Pro/Max (t600x), M2 (t8112, pmp_report_gfx), M2 Pro/Max (t602x), M3 J615/J613 (t8122), M3 Pro/Max (t6030/1, g15 path) and M5 t8142, each with an s2idle+GPU row. M4/Neo/J616s need a no-change row in s2idle and deep sleep, plus an s2idle power delta on at least one M1/M2 Mac.

@erikwb
erikwb force-pushed the ewb/gpu-s2idle-awake-path branch from 4c635ff to 3f6071e Compare November 22, 2026 07:24
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Fixed the fail-unsafe -EEXIST blocker and the sleep_pd.c nits in 3f6071e1fc05:

  • -EEXIST (and missing devres hold) now fail safe with -EBUSY: asahi_sleep_pd_suspend_noirq() logs a warning and returns -EBUSY instead of 0, refusing s2idle rather than letting ps_gfx power off under live GPU firmware.
  • Multi-domain GPU DT warning and comment (sleep_pd.c): Fixed the comment to reflect that genpd_dev_pm_attach() leaves dev->pm_domain unset on a multi-domain DT node (so dev_pm_genpd_is_on() would otherwise return false silently), added a !dev->pm_domain check that calls dev_warn_once() if power-domains has > 1 entry, and added a dev_warn_once() on the -ENODEV return from dev_pm_genpd_add_notifier().
  • g18 (t8152) note in PR body: Added a note that g18 has no pm_ops and attaches no genpd (t8152-j873-gpu.dtsi uses PMGR2 PSD services), so genpd_suspend_noirq() does not manage a GPU domain there.

Keeping the PR in Draft until the live rtcwake -m freeze + pm_genpd_summary + deep-sleep hardware rows and s2idle power delta are collected on this revision.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 3f6071e (same base, only sleep_pd.c changed since 4c635ff).

  • -EEXIST now refuses the sleep with -EBUSY and a warning (sleep_pd.c:106-109), and a missing devres hold does the same (sleep_pd.c:93-95). That was the blocker; fixed.
  • Multi-domain GPU node (sleep_pd.c:82-88): it warns now, but it still returns 0, so the suspend goes on and genpd powers those domains off under the running firmware. It's the same case as -EEXIST, so I'd return -EBUSY there too. Nothing in the tree hits it today.
  • sleep_pd.c:101-104: the -ENODEV branch can't be reached. dev_pm_genpd_is_on() (drivers/pmdomain/core.c:791) and dev_pm_genpd_add_notifier() (core.c:2107) both resolve the domain through dev_to_genpd_safe(), so once is_on has returned true the add can't fail with -ENODEV. It does no harm, and dropping it is fine.
  • The g18 note in the body covers the last nit.

The hardware rows on this head are still open: rtcwake -m freeze with GPU work before and after, and pm_genpd_summary during the sleep, on an M1/M2 (including the M2 pmp_report_gfx path) and an M3 (t8122); a no-change s2idle and deep-sleep row on an always-on/sleep-retained Mac; and the s2idle power delta. Apart from those and the multi-domain return value, this looks ready.

Assisted-by: LLM (Claude:Opus 5.5)

During suspend-to-idle (!pm_suspend_via_firmware()), the GPU driver leaves
its firmware running, but genpd_suspend_noirq() still powered off attached
GPU power domains that are neither always-on nor sleep-retained (such as
ps_gfx on M1/M2/M3 and M5 J813). Cutting power under the live GFX ASC
crashed the firmware immediately on resume (PC=0, FAR=0).

Instead of changing PMGR domain flags globally, hold the GPU device's own
attached genpd from the drm/asahi driver side during the noirq sleep window
using a temporary GENPD_NOTIFY_PRE_OFF veto notifier, matching pcie-apple.
Allocate per-device hold state via devres at probe time across
AsahiPlatformDriver, g15::Driver, and g16::Driver (so suspend_noirq never
allocates and needs no global list or lock), and wire suspend_noirq and
resume_noirq into SLEEP_OPS, SLEEP_REFUSE_OPS (g15::Driver, whose prepare
only refuses firmware-driven sleep and allows s2idle), and
g16::sleep::SLEEP_OPS. If dev_pm_genpd_add_notifier() reports -EEXIST, if
the probe-time devres hold is unexpectedly absent, or if a future
multi-domain GPU DT node leaves dev->pm_domain unset with more than one
power-domains entry, warn and refuse suspend with -EBUSY rather than
letting GPU power domains power off under live firmware.

Firmware-driven deep sleep (pm_suspend_via_firmware() == true) and all
other power domains are unaffected.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb force-pushed the ewb/gpu-s2idle-awake-path branch from 3f6071e to e29c9a8 Compare November 22, 2026 17:05
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Rebased onto integration/aurora (a9626a1487ad) and addressed both sleep_pd.c review points in e29c9a8d76bd:

  • Multi-domain GPU DT node now fails safe with -EBUSY: When !dev->pm_domain and of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells") > 1, asahi_sleep_pd_suspend_noirq() now warns once and returns -EBUSY instead of 0, refusing s2idle rather than letting genpd power domains off under live firmware.
  • Dropped unreachable -ENODEV branch: Removed the ret == -ENODEV check after dev_pm_genpd_add_notifier(), since dev_pm_genpd_is_on() already resolves the domain via dev_to_genpd_safe().
  • Rebase & verification: Resolved the drivers/gpu/drm/asahi/Makefile context conflict against integration/aurora, verified ARCH=arm64 LLVM=1 W=1 compile of drivers/gpu/drm/asahi/sleep_pd.o (0 errors, 0 warnings) and scripts/checkpatch.pl (0 errors, 1 standard MAINTAINERS note for new files).

Keeping Draft until the live rtcwake -m freeze / pm_genpd_summary / deep-sleep / s2idle power-delta rows are collected on this head.

@erikwb
erikwb marked this pull request as ready for review November 22, 2026 21:26
@RyanTheTide

Copy link
Copy Markdown
Contributor

Still needed: integration/aurora at daa9e2d has no hold on the GPU's power domain for a suspend-to-idle, and e29c9a8 merges onto that tip without conflicts. The review points are all answered at this head. @erikwb what is left is the hardware rows on this head from the description: rtcwake -m freeze with GPU work before and after and the domain shown on in pm_genpd_summary, on an M1 or M2 and on an M3; a no-change row on a Mac whose GFX domain is always-on or sleep-retained; and one deep sleep showing the hold is not taken. The description says the PR is kept as a draft, but it is open for review. #2614 keeps the same domain up on one board from its device tree, so it is worth agreeing with its author which of the two should carry that board.

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

Independent source review at e29c9a8d76bd. The notifier is registered before genpd's final power-off and the core propagates its PRE_OFF veto. Please test the T8112 parent chain with both ps_gfx and the PMP-report child arrangement, verify the domain stays on through suspend and the veto is removed on unwind, and compare against #2614. Prefer one retention owner where the same shared callback covers both.

@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 pre-PR checklist (§1–§6) review at verified live head e29c9a8d76bd30582943b39e45874a4a157ee2af (MERGEABLE CLEAN; live CI: host-tests pass).

Code Audit (0 code/policy blockers)

  • Verified sleep_pd_init() placement in AsahiPlatformDriver::probe, AsahiPlatformDriver::probe_g15, and AsahiPlatformDriver::probe_g16 (g15::Driver and g16::Driver invoke probe_g15/probe_g16 directly, so devres is registered exactly once per binding and automatically cleaned up on probe failure or unbind).
  • Verified SLEEP_OPS, SLEEP_REFUSE_OPS (g15::Driver), and g16::sleep::SLEEP_OPS all wire suspend_noirq/resume_noirq, while g18 (t8152) attaches no genpd.
  • drivers/gpu/drm/asahi/sleep_pd.c is clean and fail-safe: deep sleep (pm_suspend_via_firmware()) is untouched, multi-domain GPU DT nodes (!dev->pm_domain with power-domains > 1), missing devres holds, and -EEXIST from dev_pm_genpd_add_notifier() all warn and refuse s2idle with -EBUSY rather than letting ps_gfx power off under live firmware; notifier callback is IRQ-safe and unwind removes the notifier cleanly in resume_noirq.

Checklist Summary (§1–§6)

  • §1 No model gating: Pass — uses attached genpd state and DT power-domains uniformly across all affected drivers with zero chip, SoC, board, or firmware gates.
  • §2 Production-ready, no hacks: Pass — default kernel command line, no new parameters, no global PMGR flag side effects.
  • §3 Safety: Pass — consumer-side hold scoped to the GPU's attached genpd during s2idle noirq window only; fails safe with -EBUSY.
  • §4 Clean-room & attribution: Pass — commit e29c9a8d76bd carries human author/committer (Erik Bourget <[email protected]>) and human Signed-off-by: only; PR body includes Assisted-by:.
  • §6 Naming: Pass.
  • §5 Evidence: Blocker (see below).

Concrete Actionable Blockers (§5)

  1. Zero live hardware or regression runs on e29c9a8d76bd (or any sleep_pd.c notifier revision):
    • The only hardware result in the PR body (6/6 on J313) is from the superseded PMGR-flag revision, not this sleep_pd.c implementation.
    • Note that the PR body and latest comment state the PR is kept Draft until hardware re-verification completes, yet the PR is currently marked ready for review (isDraft: false). Please either return the PR to Draft until testing completes or post the full §5 hardware rows on e29c9a8d76bd (default command line):
      • Live rtcwake -m freeze with GPU work before and after, confirming ps_gfx stays powered in pm_genpd_summary during sleep and the veto notifier is removed cleanly on wake/unwind, on M1/M2 (specifically including T8112 with the pmp_report_gfx -> ps_gfx parent chain), M3 (t8122 and/or t6030/t6031 g15 path), and M5 (t8142).
      • A no-change s2idle + deep-sleep row on an always-on/sleep-retained ps_gfx Mac confirming the hold is not taken in firmware-driven sleep.
      • An s2idle power-delta measurement on at least one affected M1/M2 Mac.
      • Regression run: 0 SELinux denials, 0 failed units, 0 new kernel errors.
  2. Retention-owner coordination with #2614:
    • #2614 (t8112-j413-fw27: marks &ps_gfx apple,sleep-retained) addresses the same s2idle failure on J413 from DT; confirm whether #2715 supersedes #2614 so J413 has a single retention owner.

@erikwb

erikwb commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Updated the PR description (Still to run and Testing); holding merge until the live noirq hold, abort-unwind, deep-sleep, and s2idle power-delta checks on e29c9a8d76bd are recorded.

Because userspace is frozen during s2idle and cannot read /sys/kernel/debug/pm_genpd/pm_genpd_summary mid-sleep, the live rtcwake -m freeze checks will capture noirq domain state via kernel tracing (ftrace / function_graph on genpd_sync_power_off, _genpd_power_off, apple_pmgr_ps_power_off, and asahi_sleep_pd_*, plus power:suspend_resume and pmgr-pwrstate dev_dbg) alongside pre/post /sys/kernel/debug/pm_genpd/<domain>/idle_states (rejected vs usage_s2idle counters) across both normal resume and an aborted suspend_noirq unwind.

On the T8112 parent chain and abort unwind (verified in source; live T8112 hardware rows remain in Still to run):

  • In arch/arm64/boot/dts/apple/t8112.dtsi:563-567, gpu@206400000 attaches &ps_gfx by default (none of the current t8112-j*.dts board trees define APPLE_USE_PMP) or &pmp_report_gfx when APPLE_USE_PMP is defined (t8112.dtsi:1175-1182, with power-domains = <&ps_gfx>, linked as a subdomain via of_genpd_add_subdomain() in drivers/pmdomain/apple/pmp-report.c:3542-3554).
  • In drivers/pmdomain/core.c:1467-1489, genpd_sync_power_off() calls _genpd_power_off(genpd, false) (GENPD_NOTIFY_PRE_OFF at core.c:887-892) before marking GENPD_STATE_OFF or iterating child_links to decrement parent sd_count and recurse into ps_gfx. A -EBUSY veto on pmp_report_gfx therefore keeps both pmp_report_gfx and its parent ps_gfx powered.
  • On normal resume or dpm_noirq_suspend_devices() error unwind (dpm_suspend_noirq() -> dpm_resume_noirq() in drivers/base/power/main.c:1669-1671), genpd_resume_noirq() invokes asahi_sleep_pd_resume_noirq() (drivers/gpu/drm/asahi/sleep_pd.c:114-125), which removes the notifier with dev_pm_genpd_remove_notifier() and clears hold->active. asahi_sleep_pd_release() also removes any active notifier on unbind.

Comparing #2715 against #2614:

  • #2614 sets apple,sleep-retained; on &ps_gfx in arch/arm64/boot/dts/apple/t8112-j413-fw27.dts only, which makes apple_pmgr_ps_power_off() (drivers/pmdomain/apple/pmgr-pwrstate.c:443) return -EBUSY whenever ps->system_sleep is set (suspend_late..resume_early, covering both s2idle and firmware-driven deep sleep) if ps_gfx is on at sleep entry.
  • #2715 takes the consumer-side GENPD_NOTIFY_PRE_OFF veto in drm/asahi (sleep_pd.c) only when !pm_suspend_via_firmware() and only while the GPU driver is bound with its genpd on (suspend_noirq..resume_noirq). Since GENPD_NOTIFY_PRE_OFF runs before genpd->power_off() (core.c:887-899), #2715 covers t8112-j413-fw27 on the s2idle path alongside the other M1/M2/M3/M5 boards without per-board apple,sleep-retained overrides.
  • Agree that one retention owner is preferable on the tested s2idle path: once #2715 is verified on J413 27.2 (#2544 + e29c9a8d), #2614 is not needed for s2idle (pending agreement with @satchlj). However, because #2715 is a no-op when pm_suspend_via_firmware() is true while #2614 also keeps ps_gfx up across firmware-driven deep sleep whenever the domain is on at sleep entry, deep-sleep coverage on t8112-j413-fw27 is not covered by an s2idle pass and must be verified and settled separately with @satchlj.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
Use GPL-2.0-only for the new sleep_pd.c and sleep_pd.h files to match

the repository's licensing policy for new Aurora code.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team as code owners November 24, 2026 21:28
@erikwb
erikwb requested a review from Acelogic November 24, 2026 21:28
@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Resolved the merge conflicts with main (6c7d489e0fbc) in 82f12be07bc5 and updated the new files' SPDX headers to GPL-2.0-only in 69ee6f661a63; the live J313 (t8103) and deep-sleep hardware rows on this head are still pending before merge.

  • Conflict resolution (82f12be07bc5): Merged origin/main (6c7d489e0fbc) into the PR branch, keeping both sleep_pd.o and rtkit_dump.o in drivers/gpu/drm/asahi/Makefile and keeping sleep_pd_init(pdev.as_ref())? ahead of the ProbeConfig match in AsahiPlatformDriver::probe (drivers/gpu/drm/asahi/driver.rs) so the LegacyWithG14Handoff / probe_g14_v27_2 path also initializes its devres hold.
  • License fix (69ee6f661a63): Updated drivers/gpu/drm/asahi/sleep_pd.c and drivers/gpu/drm/asahi/sleep_pd.h SPDX headers from GPL-2.0-only OR MIT to GPL-2.0-only.
  • Checks: At 69ee6f661a63, the ARCH=arm64 LLVM=1 W=1 build of drivers/gpu/drm/asahi/sleep_pd.o and drivers/gpu/drm/asahi/aurora.o (CONFIG_DRM_ASAHI=m with G15=y, G16=y, G14_V27_2=y, M3_T8122=y, M5=y, G18=y) succeeded with 0 errors and 0 warnings in the touched files, and scripts/checkpatch.pl --git origin/main..HEAD reported 0 errors; at 82f12be07bc5, tools/asahi/run-host-tests.py passed 531/532 (asahi-g15 and asahi-m4 passed; apple-dcp failed under host gcc 16.2.1 / clang 23.1.4, unrelated to drm/asahi).
  • Remaining hardware blocker: rtcwake -m freeze -s 15 with GPU work before and after, noirq domain-state confirmation (ps_gfx kept powered, clean veto removal on normal resume and aborted suspend_noirq unwind), s2idle power delta, and deep-sleep check on J313 (t8103), plus unchanged s2idle power behavior and no notifier registration during firmware-driven deep sleep (pm_suspend_via_firmware() == true) on J713 (t8132) and J716c (t6050) at 69ee6f661a63. Agreed that #2614 is not needed for the s2idle path on t8112-j413-fw27 once #2715 is verified and landed.

@erikwb
erikwb requested a review from maralcbr November 24, 2026 21:28
@github-actions github-actions Bot added blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo 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) and removed merge-conflict Conflicts with the base branch (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Completed the J713 (M4 Air, T8132, g16, apple,sleep-retained) trial kernel row at exact head 69ee6f661a63 (one-shot Linux 7.3.0 trial build, default command line):

  • Boot regression: 0 failed units, SELinux not built (AppArmor active, 0 DENIED/AVC lines), 0 new kernel errors or warnings vs prior boot.
  • s2idle (rtcwake -d rtc1 -m freeze -s 30, kprobes on dev_pm_genpd_{add,remove}_notifier): rc 0 (31.14 s), 1/1 notifier add/remove (suspend_noirq -> resume_noirq, removed ~15 ms later), clean resume with 0 dmesg err/warn (4.725 W before / 4.701 W 20 s after on AC vs 4.742 W / 4.726 W on a no-hold control kernel; battery was full on AC so in-sleep battery drain could not be sampled).
  • Firmware-driven deep sleep (rtcwake -d rtc1 -m mem -s 30, same kprobes): rc 0 (32.08 s), 0/0 notifier calls (confirming pm_suspend_via_firmware() gates the hold), GPU firmware back in 729 us.
  • Post-sleep Vulkan check: dEQP-VK.api.smoke.* 6/6 pass after both sleeps, 0 GPU errors in dmesg.

Updated the PR body's Tested, Not yet, and Evidence sections (J313 t8103 and J716c t6050 rows remain listed under Not yet). Head 69ee6f661a63 is unchanged.

@RyanTheTide

Copy link
Copy Markdown
Contributor

69ee6f6 J316s (M1 Pro, T6000, G13S C0) PASS: guarded one-shot combined batch (427b2c2dc67c over main 8f99a85, 0 merge-tree diffs on 5 changed files, default cmdline, boot 01758010-6fb9-4be3-b307-d1ab867a1a28): 3/3 real rtcwake -d rtc1 -m freeze -s 4 cycles; kprobes recorded 18/18 hits across all 3 cycles (asahi_sleep_pd_suspend_noirq -> 0x0, asahi_sleep_pd_notify action=0x0 GENPD_NOTIFY_PRE_OFF -> 0x8011 -EBUSY veto keeping ps_gfx on, asahi_sleep_pd_resume_noirq -> 0x0 cleanly removing notifier with 0 -EEXIST on cycles 2-3); Borealis VK api.smoke 8/8 pre & 8/8 post, Asahi GL gl-smoke 32/32 pre & post, 0 GPU faults, 0 DART faults, 0 failed units, Enforcing, 0 new AVC; stock 7.3.0-aurora-fleet89 restored.

DjDeveloperr added a commit that referenced this pull request Nov 26, 2026
DjDeveloperr added a commit that referenced this pull request Nov 26, 2026
@DjDeveloperr
DjDeveloperr dismissed their stale review November 26, 2026 03:35

The branch merges cleanly and the J713 and J316s results at 69ee6f6 address this hold.

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

Approved at 69ee6f661a63. J316s exercised the real power-off veto in three suspend-to-idle cycles. All three resumed with the notifier removed and GPU work passing. J713 confirmed that firmware-driven deep sleep skips the notifier. I checked the error path and the shared resume_noirq cleanup. Erik will follow up on J313 with an aborted suspend and an in-sleep power measurement. J316s test results

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@erikwb

erikwb commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Updated the PR body (**Tested:**, **Not yet:**, and Details/Evidence) at 69ee6f661a63 (no code changes) to fold in the J313 (T8103, G13G B1) and J716c (T6050, G17C B1) hardware runs, the J316s (T6000) row from @RyanTheTide, and the exact caveats on the two follow-up items you noted (aborted suspend and in-sleep power measurement):

  • J313 (M1 MacBook Air, T8103, G13G B1, fw 27.2) — exact head 69ee6f661a63 + patched J313 27.2 GPU stack:

    • At exact head 69ee6f661a63 (default cmdline), the kernel boots cleanly with 2/2 s2idle cycles clean and 0 AppArmor denials/AVC/Oops (aurora-sep.service has a pre-existing 120 s failure on every boot of this machine, default kernel included). However, the GPU does not bind on firmware 27.2 because main uses the legacy t8103 path (Unsupported GPU/firmware combination (G13, G, [27, 2, 0])), so the legacy -EBUSY deep-sleep refusal (driver.rs:287) could not be exercised live on this 27.2 machine.
    • With the identical 5-file #2715 diff (6c7d489e0fbc..69ee6f661a63) applied onto the J313 27.2 GPU stack (dbb7b44b3d99 + 3577ce0e4885, default cmdline, NOT exact head), 10 s2idle cycles (pm_test=platform, 3 × 15 s, 6 × 1 s) and 1 deep-sleep cycle (rtcwake -d rtc1 -m mem -s 30, GPU firmware back in 5954 us) completed cleanly: PR notifier add/remove hit 1/1 per s2idle cycle (asahi_sleep_pd_notify GENPD_NOTIFY_PRE_OFF returning 0x8011 -EBUSY) and 0/0 in deep sleep, with the GPU compute checksum (b336c570f7a9e87c, 3/3 runs) and dEQP-VK.api.smoke.* 6/6 passing after every wake.
    • J313 caveats (kept explicit in **Tested:** / **Not yet:**): (1) this J313 DT already marks gfx apple,sleep-retained and apple,no-auto-pm (/proc/device-tree/soc/power-management@23b700000/power-controller@3f8), so the control kernel without #2715 also kept gfx on (Rejected 0 -> 1) and passed GPU checks; (2) the six 1 s RTC alarms did not trigger a real aborted suspend_noirq unwind (all slept cleanly with 0 aborts; only pm_test=platform exercised noirq enter and resume_noirq without entering idle, 1/1 add/remove), so a real aborted suspend_noirq unwind remains in **Not yet:**; (3) idle AC power 20 s after resume (3.69-3.77 W / 2.53-2.64 W vs 3.89 / 3.85 / 2.69 W control) was measured on AC at 100% battery, which is a no-regression idle check and does not establish an in-sleep power delta.
  • J716c (M5 Max, T6050, G17C B1, fw 27.2) — exact head 69ee6f661a63 (Stage 2 1.0.0b17-gae94218e, default cmdline):

    • s2idle (rtcwake -d rtc0 -m freeze -s 15) passed dEQP-VK.api.smoke.* 6/6 and gpubench-vk compute.light 2/2 before and after sleep with 0 err+ kernel lines (38 non-audit lines) and notifier add/remove kprobes 1/1 on 69ee6f661a63 vs 0/0 on the pre-#2715 main baseline 15b1e2e0aaca (1 pre-existing failed unit aurora-peripherals.service).
    • J716c caveats: the 15 s rtc0 alarm failed to wake the Mac on both 69ee6f661a63 and the pre-#2715 main baseline 15b1e2e0aaca (each stayed in s2idle ~20 min until woken by a key press — pre-existing RTC wake regression on main, not #2715). Deep sleep (rtcwake -d rtc0 -m mem -s 30) also failed to RTC-wake on 69ee6f661a63 (and was not repeated on baseline), and resume power was sampled while AC-charging (90.2 W), so J716c deep-sleep 0/0 notifier count and in-sleep power delta remain in **Not yet:**.
  • J713 (M4 Air, T8132) AC power caveat:

    • Updated the existing 69ee6f661a63 J713 row and **Not yet:** to note explicitly that AC before/after power readings (4.725 W / 4.701 W vs 4.742 W / 4.726 W control) do not establish an in-sleep power delta.

@DjDeveloperr
DjDeveloperr merged commit 22ae94c into main Nov 26, 2026
8 of 12 checks passed
@RyanTheTide
RyanTheTide deleted the ewb/gpu-s2idle-awake-path branch November 27, 2026 13:21
@pomeranceu

Copy link
Copy Markdown

In-sleep power data point for the "Not yet: in-sleep power measurement" item, from an M1 Pro (t6000) laptop.

Machine: MacBook Pro 14" M1 Pro 2021 (apple,j314s, apple,t6000)
Kernel: Fedora Asahi Remix 7.3.4-401.asahi.fc45.aarch64+16k (stock distro kernel – I don't know whether it already carries this PR, so treat this as a baseline)
mem_sleep: [s2idle]

Duration 64.3 min (suspend → manual wake, incl. ~20 s after resume)
Battery energy (macsmc-battery/energy_now) 52.508 Wh → 50.263 Wh (full 57.51 Wh)
Energy used 2.246 Wh
Average power in s2idle 2.10 W
Drain 3.65 %/h

Method: on battery, display/lid path via systemctl suspend, one successful suspend (suspend_stats/success +1, no failures), energy read before suspend and ~20 s after resume. DCP powered off/on cleanly in the kernel log (dcp_poweroff() done … dcp_poweron()), resume devices took 0.289 s. apple-pmgr-misc is bound on this kernel.

One note for the requested rtcwake -m freeze -s 15 rows: on J314s, macsmc-rtc exposes no wakealarm (/sys/class/rtc/rtc0/wakealarm is missing) and rtcwake fails with Invalid argument, so timed self-wake tests can't run on this machine; I woke it manually instead.

Happy to re-run the same measurement on a kernel that includes this change for a before/after comparison.

@pomeranceu

Copy link
Copy Markdown

Follow-up on the J314s (M1 Pro, t6000) s2idle numbers above: the radios are not where the power goes.

Same machine and kernel (7.3.4-401.asahi.fc45.aarch64+16k), second run with a /etc/systemd/system-sleep/ hook that rfkill blocks Wi-Fi and Bluetooth before suspend (confirmed in the journal: block set for type bluetooth / wlan, NetworkManager Wi-Fi now disabled by radio killswitch) and unblocks them on resume:

run duration avg power in s2idle drain
radios on (above) 64 min 2.10 W 3.65 %/h
Wi-Fi + BT rfkill-blocked 177 min 2.23 W 3.86 %/h

No improvement within measurement noise (energy from macsmc-battery/energy_now, same method as before, manual wake since macsmc-rtc has no wakealarm). So on this SoC the ~2.1–2.2 W in s2idle appears to come from the SoC/fabric side rather than the Wi-Fi/BT radios.

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:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants