Skip to content

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

Open
erikwb wants to merge 1 commit into
mainfrom
ewb/gpu-s2idle-awake-path
Open

erikwb wants to merge 1 commit into
mainfrom
ewb/gpu-s2idle-awake-path

Conversation

@erikwb

@erikwb erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown

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

Change

  • drm/asahi: hold GPU power domain across suspend-to-idle: 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, 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 — 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.
  • Affects Apple Silicon Macs whose GPU power domain is not already apple,always-on or apple,sleep-retained (M1 t8103, M1 Pro/Max/Ultra t600x, M2 t8112 — both ps_gfx and APPLE_USE_PMP pmp_report_gfx -> ps_gfx, M2 Pro/Max/Ultra t602x, M3 t8122, M3 Pro/Max t6030/t6031, and M5 t8142); Macs whose ps_gfx is already apple,always-on or apple,sleep-retained (t8132, t604x, t6050, t8140) are unaffected in deep sleep and retain their GPU domain across s2idle.

Testing

  • Build (e29c9a8d76bd, merges cleanly onto origin/integration/aurora 880a97a3dca2): ARCH=arm64 LLVM=1 W=1 compile of drivers/gpu/drm/asahi/sleep_pd.o (0 errors, 0 warnings); scripts/checkpatch.pl --git origin/integration/aurora..HEAD 0 errors (1 standard MAINTAINERS note for new files).
  • CI (e29c9a8d76bd): Host tests (host-tests workflow) passed (SUCCESS; note: tools/asahi/run-host-tests.py has no dedicated host unit test exercising sleep_pd.c).
  • Root-cause confirmation (prior revision on J313, M1 MacBook Air, T8103): Keeping ps_gfx powered across s2idle eliminated the resume crash (0/1 before vs 6/6 RTC-woken desktop s2idle cycles with Vulkan render-check passing after every wake).

Still to run

  • Live rtcwake -m freeze -s 15 verification on e29c9a8d76bd with GPU work before and after, capturing GPU power-domain state during noirq 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, since userspace is frozen during s2idle and cannot read pm_genpd_summary mid-sleep) alongside pre/post /sys/kernel/debug/pm_genpd/<domain>/idle_states (rejected vs usage_s2idle counters), confirming veto removal on normal resume and on an aborted suspend_noirq unwind, and measuring the s2idle power delta:
    • M1 (t8103) and M2 (t8112, covering both direct ps_gfx and the APPLE_USE_PMP pmp_report_gfx -> ps_gfx parent chain, plus t8112-j413-fw27 for the s2idle retention path in coordination with arm64: dts: apple: t8112-j413-fw27: keep the GFX domain through system sleep #2614; firmware-driven deep-sleep retention on t8112-j413-fw27 is settled separately).
    • M3 (t8122, t6030/t6031) and M5 (t8142).
    • Always-on / sleep-retained ps_gfx Mac (t8132, t604x, t6050, or t8140) confirming no change in s2idle.
    • Firmware-driven deep sleep (pm_suspend_via_firmware() == true) confirming via noirq tracing that the sleep_pd hold is not taken.
  • Fleet regression run confirming 0 SELinux denials (AVC), 0 failed units, and 0 new kernel errors (hold merge until hardware re-verification on e29c9a8d76bd completes).

Assisted-by: LLM (Anthropic:Claude Opus 5.5, Google:Gemini 4 Neon, Google:Gemini 4 Hydrogen)

@RyanTheTide

Copy link
Copy Markdown

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

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

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

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

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 <erik@ebourget.net>
@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
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

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

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

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 <erik@ebourget.net>) 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.

Assisted-by: LLM (Gemini 4 Neon)

@erikwb

erikwb commented Nov 23, 2026

Copy link
Copy Markdown
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.

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.

3 participants