Skip to content

soc: apple: sleep: keep s2idle default on legacy GPU/DCP firmware - #4207

Merged
RyanTheTide merged 3 commits into
aurora-silicon:mainfrom
Sedmio:fix/sleep-legacy-firmware-default
Dec 5, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:mainfrom
Sedmio:fix/sleep-legacy-firmware-default

Conversation

@Sedmio

@Sedmio Sedmio commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

What: Keep s2idle as the default sleep mode when the DT advertises legacy GPU (< 27.x on T8103/T8112) or legacy internal display (< 14.x) apple,firmware-compat, instead of promoting deep to default where every suspend fails at GPU prepare (-16) and cascades into a failed s2idle fallback (addresses omacom/linux-aurora#567). Also log an explicit warning in aurora's sleep_prepare() when the legacy GPU backend refuses an explicit deep request, and add a host test covering legacy and 27.2 combinations.
Tested: J313 M1 Air (13.5 OS stub / 27.2 system firmware) at b5484a7d9dae: boots with s2idle default ([s2idle] deep), 1/1 s2idle suspend/resume pass (fail=0), explicit deep request refused cleanly with the new legacy-backend warning; tools/asahi/run-host-tests.py --only sleep: 52/52 passed.
Risk: two-way door · M1 (T8103) and M2 (T8112) Macs; affects default mem_sleep selection only when DT apple,firmware-compat is legacy (< 14 on internal DCP or < 27 on GPU).
Not yet: T8103/T8112 on a 27.2 OS firmware stub (covered by host tests verifying 27.2.0 leaves deep as default).

Details
  • drivers/soc/apple/sleep.c, sleep-t8103.h, sleep-t8112.h: store the T8103/T8112 GPU DT node in s->gpu_np (managed with devm_add_action_or_reset(..., apple_sleep_put_node, np)) and check apple,firmware-compat in apple_sleep_undescribed():
    • Available internal display (disp) with fw[0] < 14 (legacy 12.x/13.x DCP has no deep-sleep wake restart path, leaving the panel dark until reboot).
    • Available GPU (s->gpu_np) with fw[0] < 27 (routes to the legacy GpuManagerG13/GpuManagerG14 backend, which unconditionally returns -EBUSY from sleep_prepare()).
    • When either is present, apple_sleep_probe() keeps s2idle as the default while still offering deep if requested via mem_sleep_default=deep or /sys/power/mem_sleep.
  • drivers/gpu/drm/asahi/driver.rs: log dev_warn! before returning -EBUSY on the legacy fallback arm of sleep_prepare(), replacing a silent genpd_prepare returns -16.
  • tools/asahi/sleep-legacy-fw-tests.{c,py} (registered in tools/asahi/run-host-tests.py): exercises apple_sleep_undescribed() across laptop/desktop 13.5, 27.2, disabled-node, and non-legacy SoC combinations.
Evidence

J313 M1 Air (apple,j313 / apple,t8103, asahi,os-fw-version=13.5, asahi,system-fw-version=27.2) at b5484a7d9dae (7.3.0-legacyfw-test+):

Boot logs:

apple-sleep 23b700000.sleep-controller: T8103: wake sources 00000000 00400000 00000000 00000000 00000000
apple-sleep 23b700000.sleep-controller: deep sleep: /soc/dcp@231c00000 firmware-compat 13.5.0 has no deep-sleep wake path
apple-sleep 23b700000.sleep-controller: deep sleep: /soc/gpu@206400000 firmware-compat 13.5.0 has no deep-sleep GPU backend
apple-sleep 23b700000.sleep-controller: deep sleep needs the parts named above: s2idle stays the default
apple-sleep 23b700000.sleep-controller: deep sleep available, not the default: boot object resumes 0

/sys/power/mem_sleep and suspend_stats after systemctl suspend:

[s2idle] deep
/sys/power/suspend_stats/success:1
/sys/power/suspend_stats/fail:0

Suspend log:

kernel: PM: suspend entry (s2idle)
kernel: PM: suspend exit

Explicit deep check (echo deep > /sys/power/mem_sleep && echo mem > /sys/power/state):

kernel: PM: suspend entry (deep)
kernel: aurora 206400000.gpu: GPU: deep sleep refused, legacy firmware backend has no deep-sleep support
kernel: aurora 206400000.gpu: PM: device_prepare(): genpd_prepare returns -16
kernel: PM: Some devices failed to suspend, or early wake event detected
kernel: PM: suspend exit

Host tests (python3 -I tools/asahi/run-host-tests.py --only sleep):

ok sleep-legacy-fw-tests (0.1s)
ok t8132-sleep-refuse-tests (0.3s)
52/52 passed in 13s

Build & checkpatch:

  • Full arm64 LLVM=1 build (Image + modules, including drivers/soc/apple/sleep.o and drivers/gpu/drm/asahi/aurora.ko): 0 errors.
  • scripts/checkpatch.pl -g HEAD: 0 errors.

Note on unrelated pre-existing system state on this Omarchy 0.2.13-1 userspace against aurora-silicon/linux main: speakersafetyd.service (needs omacom/omarchy-mac-pkgs#210), systemd-growfs-root.service (omacom/omarchy-mac-pkgs#247), and one fpwm1 power-state error on resume were unrelated to this change.

On T8103 (M1) and T8112 (M2) systems still running a legacy 12.x/13.x OS
firmware stub, the device tree advertises apple,firmware-compat <13 5 0>
on both the GPU and internal display coprocessor. In that configuration
the GPU binds the legacy backend (which has no deep-sleep path and
unconditionally returns -EBUSY from sleep_prepare()) and the internal
DCP has no deep-sleep wake restart path (leaving the panel off until
reboot).

apple_sleep_undescribed() did not check these firmware-compat properties,
so T8103 promoted deep sleep to the default on 13.5 stubs. Every suspend
attempt then failed at GPU prepare (-16), and systemd-sleep's immediate
fallback to freeze (s2idle) also failed with -EBUSY while dwc3-apple was
still running its post-suspend recovery work.

Record the GPU DT node in T8103/T8112 map_regs and check both the
internal display (< 14.x) and GPU (< 27.x) firmware-compat in
apple_sleep_undescribed() so s2idle remains the default unless the user
explicitly asks for deep sleep. Also log a warning in aurora's
sleep_prepare() when the legacy GPU backend refuses an explicit deep
sleep, and add a host test covering the legacy/27.2 combinations.

Signed-off-by: Dmitrii Semenenko <116227467+Sedmio@users.noreply.github.com>
@Sedmio
Sedmio requested review from a team and DjDeveloperr as code owners December 3, 2026 15:27
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at f81e62ad: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at f81e62ad
Conflicts ok none
PR text ok Risk: two-way · M1 (T8103) and M2 (T8112) Macs; affects default memsleep selection only when DT apple,firmware-compat is legacy (< 14 on internal DCP or < 27 on GPU).

Areas: area:gpu, area:platform

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

Signed-off-by: Dmitrii Semenenko <116227467+Sedmio@users.noreply.github.com>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

The J313 receipt names b5484a7d9dae. At d11e3303fa3b, the missing rows are J313 or J413 on a legacy OS stub (s2idle default and clean refusal of explicit deep sleep) and a 27.2 stub control that keeps its existing deep-sleep default.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 3, 2026
@Sedmio

Sedmio commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Re-tested on hardware at head d11e3303fa3b (clean tree, no sleep.conf.d override):

  • J313 (MacBook Air M1, apple,t8103, legacy OS stub asahi,os-fw-version=13.5, asahi,system-fw-version=27.2) at d11e3303fa3b — PASS:
    • Boot default /sys/power/mem_sleep is [s2idle] deep with apple-sleep logging both legacy 13.5.0 checks (/soc/dcp@231c00000 and /soc/gpu@206400000) and keeping s2idle as the default.
    • Default mem suspend (rtcwake -d /dev/rtc1 -m mem -s 5) enters PM: suspend entry (s2idle) and resumes cleanly (rc=0).
    • Explicit deep sleep (echo deep > /sys/power/mem_sleep && echo mem > /sys/power/state) is cleanly refused with -EBUSY (aurora 206400000.gpu: GPU: deep sleep refused, legacy firmware backend has no deep-sleep support → PM: suspend exit), leaving the system responsive.

I don't have a 27.2 OS stub Mac available locally to run the 27.2 deep-sleep control row, so that check would need to be run on a 27.2 stub machine.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Interaction with #3534 (T6000 deep sleep), raised by the J316s lane: the display check here is in the generic apple_sleep_undescribed(), so any internal DCP with apple,firmware-compat major < 14 makes deep undescribed on every SoC. Every M1 Pro/Max we know of runs a 13.5 stub, so with both PRs in, T6000 drops back to s2idle by default. Before either merges we need to know whether the internal panel comes back after a deep wake on a 13.5 stub on T6000 (panel lit, DCP up). If it does, the display half needs a different test than the firmware major. The GPU half (< 27, only where gpu_np is set) is unaffected.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Note on how this interacts with #3534 (T6000 deep sleep). Not a hardware row, just a read of the code at d11e3303.

The display check in apple_sleep_undescribed() applies on every SoC with a display coprocessor in its sleep profile, not just T8103/T8112:

if (disp && of_device_is_available(disp) &&
    !of_property_read_u32_array(disp, "apple,firmware-compat", fw, 3) &&
    fw[0] < 14)
        missing++;

#3534 adds a T6000 profile with apple,display-coprocessors = <&dcp>, and every M1 Pro/Max we know of runs a 13.5 OS stub (our J316s, and the J314s rows on #3534 from olivergreg and CoreyH). On those Macs #3534 brings the 13.x panel back after a deep sleep (J314s 25/25 with the panel back, through iomfb_v13_3.c). Once both PRs are in, this check would push the T6000 default back to s2idle even though the deep-sleep wake path works there.

Two ways to fix it:

  • Narrow the DCP check to the profiles that have no 13.x restart path (a flag in the T8103/T8112 profile data, as you already do for gpu_np).
  • Or better, let the DCP driver say whether it can restart, and have the sleep driver ask it, instead of comparing version numbers.

Either way works for #3534's J314s/J316s. I'll post our J316s deep row on #3534 shortly. The J473 27.2-stub control row for this PR is queued in the same batch.

Gate the < 14 internal DCP apple,firmware-compat check in
apple_sleep_undescribed() behind a per-SoC display_legacy_no_wake flag
enabled only on T8103 and T8112.

SoCs with a working 13.x DCP deep-sleep wake path (such as T6000 in aurora-silicon#3534)
now keep their deep-sleep default unaffected. Extend the host test suite
with a T6000 13.5 case verifying display_legacy_no_wake = false leaves
apple_sleep_undescribed() at 0.

Signed-off-by: Dmitrii Semenenko <116227467+Sedmio@users.noreply.github.com>
@Sedmio

Sedmio commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Good catch on #3534 — updated at f81e62ad1cb5 to gate the < 14 internal DCP check behind a per-SoC display_legacy_no_wake flag on struct apple_sleep_soc, enabled only on t8103_sleep_soc and t8112_sleep_soc (matching the existing per-SoC flags in apple_sleep_undescribed()).

SoCs without display_legacy_no_wake (including T6000 on 13.5 in #3534) are unaffected, and tools/asahi/sleep-legacy-fw-tests.c covers that T6000 13.5 case alongside T8103/T8112 (python3 tools/asahi/sleep-legacy-fw-tests.py passes).

Hardware receipt at head f81e62ad1cb5 (clean tree, no sleep.conf.d override):

  • J313 (MacBook Air M1, apple,t8103, legacy OS stub asahi,os-fw-version=13.5, asahi,system-fw-version=27.2) at f81e62ad1cb5 — PASS:
    • Boot default /sys/power/mem_sleep is [s2idle] deep with apple-sleep logging both 13.5.0 legacy checks (/soc/dcp@231c00000 and /soc/gpu@206400000) and keeping s2idle as default.
    • Default mem suspend (rtcwake -d /dev/rtc1 -m mem -s 5) enters PM: suspend entry (s2idle) and resumes cleanly (rc=0).
    • Explicit deep sleep (echo deep > /sys/power/mem_sleep && echo mem > /sys/power/state) is cleanly refused with -EBUSY (-16, aurora 206400000.gpu: GPU: deep sleep refused, legacy firmware backend has no deep-sleep support → PM: suspend exit), leaving the system responsive.

@RyanTheTide

Copy link
Copy Markdown
Contributor

J473 control half at exact head d11e3303fa3b (Mac mini M2, T8112, 27.2 stub; GPU and DCP apple,firmware-compat = 27.2.0 in the booted DT). The J413 (13.5 stub) half is still to come; that Mac is busy with another row.

  • Kernel 7.3.0-mrp4207 from the head (merge base 49d5220916b8), no other patches. One-shot via aura-try (aura main 70d844e3, U-Boot 5c0d5fe1) with the PR's t8112-j473-fw27.dtb (the 27.2-stub board file). The saved default was not changed.
  • Default cmdline (boot 6d882a91): /sys/power/mem_sleep = [s2idle]. Deep is not offered, but that is not this PR. T8112 is untested in the sleep driver ("sleep data derived for this SoC, untested: deep sleep is off (apple_sleep.deep=1 offers it), and a sleep stops before the commit (dry run)"), and an untested node always resets the default to s2idle. So on T8112, deep is not the default on a 27.2 stub either, with or without soc: apple: sleep: keep s2idle default on legacy GPU/DCP firmware #4207. The "deep is the default" control only exists on a node with apple,sleep-tested, and no T8112 DT has that. s2idle (rtcwake on the PMU RTC): success +1, fail 0. vkcube 300 frames PASS. Display up (2/2 DCP, HDMI).
  • apple_sleep.deep=1 (one-shot entry only; boot 7ebbb7e9): mem_sleep = [s2idle] deep. The new legacy checks in apple_sleep_undescribed() do not fire on 27.2 (no "firmware-compat … has no deep-sleep GPU backend" / "no deep-sleep wake path" lines). An explicit deep request (echo deep > mem_sleep; rtcwake -m mem) goes:
    • aurora 206400000.gpu: GPU prepared for deep sleep: submitted=2128 completed=2128 pending=0 (27.2 backend, no legacy refusal warning)
    • apple-sleep: dry run: every check passed; refusing before the first stop and the commit (untested SoC …)
    • DCPs, ANS, SART, PMP and GPU came back (GPU: deep sleep refused before commit). rtcwake got -EAGAIN (fail +1), as a dry run should.
    • s2idle afterwards PASS.
  • One thing seen on that dry run, not from this PR: "PM: suspend devices took 10.467 seconds" tripped the suspend_test_finish WARN. The 10 s are in the J473's HDMI DCP suspend (dcp_dptx_disconnect(port=0) arrives 10 s after the previous device, then "RTKit: idle, but not stopped: status 0x2d"). It is reproducible only with the opt-in deep request on this untested SoC.

Afterwards the Mac went back to its production default (fleet94, Enforcing, 0 failed units, no extra cmdline left).

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: MERGE at f81e62a

Blockers: None.

Checked: The display check uses the sleep profile's wake capability and the DCP firmware compatibility reported in the DT. T6000 keeps its 13.5 panel wake path. The GPU node reference is released through devres on removal and probe failure. The prepare callback leaves s2idle and the existing deep-capable backends alone. No DT node or binding changes are needed for the existing properties.

Evidence

The exact host fixture passed all eight assertions on legacy, 27.2, disabled and unaffected profiles. Removing the display capability check made its T6000 13.5 assertion fail. The author’s exact J313 row reports s2idle as the default, a successful PMU RTC suspend/resume, and a clean -EBUSY on an explicit deep request. The earlier J473 27.2 control confirms that the existing untested-profile policy keeps s2idle as default there.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Legacy-stub half at exact head d11e3303fa3b, and why J413 can't be it:

  • J413 (M2 Air, T8112) is on the 27.2 stub now, not 13.5: asahi,os-fw-version 27.2 and GPU apple,firmware-compat 27.2.0 on its production boot. So it is the same case as the J473 control above. None of our T8103/T8112 Macs is on a pre-27 GPU stub, so the GPU half (< 27 with gpu_np) has no legacy board in our fleet.
  • M1 Pro (J316s, T6000) on the 13.5 stub (GPU and all three DCPs apple,firmware-compat 13.5.0). It got a one-shot boot of 7.3.0-mrp4207 from the head through a copied custom.cfg entry (DT from its bootloader; saved default not changed), boot 42a16eaf. Result: /sys/power/mem_sleep = [s2idle] and no apple-sleep lines at all. T6000 has no apple,t6000-sleep node and no match in apple_sleep_of_match, so the sleep driver doesn't bind and the new display check (fw[0] < 14) never runs. On this tree, then, the T6000 interaction Dj raised for soc: apple: sleep: add T6000 (M1 Pro / J314s) suspend-to-RAM support (on #3381) #3534 cannot happen: it appears only once soc: apple: sleep: add T6000 (M1 Pro / J314s) suspend-to-RAM support (on #3381) #3534 adds T6000 sleep. Whether the internal panel comes back after a deep wake on a 13.5 T6000 needs soc: apple: sleep: add T6000 (M1 Pro / J314s) suspend-to-RAM support (on #3381) #3534 plus a Mac someone can recover (I did no sleep cycles on the M1 Pro: it has no proven unattended reset path). Boot otherwise clean (0 kernel err lines; the usual speakerguardd-v2-switchtest failed unit).

Afterwards the Mac went back to its production default (7.3.0-aurora-edge, custom.cfg byte-identical, test kernel removed, Enforcing, 0 failed units).

@RyanTheTide

Copy link
Copy Markdown
Contributor

27.2-stub control row for this PR: #4207 d11e3303 + J473 (Mac mini M2, T8112, asahi,os-fw-version 27.2 / system 27.2) + PASS for this PR's part.

I can't run the legacy half on our J413 (M2 Air, 13.5 stub) yet, because another lane holds it. I'll post it when I get the Mac.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Correction to my control row above: our J413 turned out to be on a 27.2 OS stub too (asahi,os-fw-version 27.2), so it can't give the legacy half. It does add a second 27.2 control: on J413 at d11e3303 (with #3786), deep stays the default with no legacy warnings, and 3/3 committed deep sleeps pass (receipt on #3786). We have no M2 on a 13.5 stub, so the legacy half still needs a 13.x Mac (Sedmio's J313 covers T8103).

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

ORCH5 merge sweep: passes the six-point gate (CI green at f81e62a, independent review approval by aurora-silicon-review[bot], no taint, no Stage 1/LocalPolicy change).

@RyanTheTide
RyanTheTide merged commit e4e8d8a into aurora-silicon:main Dec 5, 2026
5 checks passed
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) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants