Skip to content

soc: apple: sleep, mfd: macsmc, drm/apple: Select the T8142 sleep paths by hardware, not J813 - #2384

Open
RyanTheTide wants to merge 7 commits into
mainfrom
spec-m5neo/t8142-air-parity-sleep
Open

RyanTheTide wants to merge 7 commits into
mainfrom
spec-m5neo/t8142-air-parity-sleep

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Three parts of the T8142 suspend path checked of_machine_is_compatible("apple,j813"), so the 15-inch Air (J815, same die, same SMC, ANS and DCP) was left out:

  • drivers/soc/apple/sleep.c apple_sleep_smc_defer_notice(): the final SMC MBSE/AP IDLE notice after the peer stops (f1aa5a5, "soc: apple: sleep: send J813's final SMC notice after peer stops"). The reason given there is the T8142 sequence: ANS fails its IOP IDLE handshake when the SMC is told first.
  • drivers/mfd/macsmc.c: the bounded, IRQ-independent SMC transport that the deferred notice needs (same commit).
  • drivers/gpu/drm/apple/dcp.c: the DCP firmware stop at system suspend (b29e3c7, "drm/apple: dcp: stop the J813 firmware during system suspend"). main has since dropped this board check itself (the DCP stop is on by default on J813 and J815), so this PR no longer changes dcp.c.

Change

  • struct apple_sleep_soc gets smc_notice_after_peers, set for apple,t8142-sleep. apple_sleep_smc_defer_notice() reads it instead of the board.
  • apple_sleep_smc_defer_notice_hw() answers the same from the DT (an available sleep controller whose profile has the flag), so macsmc can pick its transport at probe before the sleep driver binds. macsmc uses it instead of the board.

Testing

  • Compiled drivers/soc/apple/sleep.c, drivers/mfd/macsmc.c and drivers/gpu/drm/apple/dcp.c before and after with the release config's kbuild command line and W=1 (drm's extra warnings for dcp.c): no compiler warnings on either side. macsmc.o now references apple_sleep_smc_defer_notice_hw, which sleep.o exports.
  • At the current head (main merged in): sleep.o and macsmc.o build with W=1 (arm64, LLVM, asahi config) with no warnings.
  • Which boards are affected, from the DTs on main: J813 and J815 both include t8142-j813-j815-sleep.dtsi (apple,t8142-sleep). J813 keeps today's path; J815 gets the same deferred notice and bounded transport. J704 has no sleep controller node and stays as it is. T8140, T8132 and T6050 profiles leave the flag clear.

Still to run (at the current head, on the default command line)

  • @m0d16l14n1 (J815): boot, then one deep sleep and wake (rtcwake -m mem -s 20; deep is the default sleep state). Expected: dmesg shows the deferred SMC notice after the ANS stop, SMC commands work after the wake, the panel returns.
  • @sithglan, @gig3m, @DjDeveloperr (J813): the same row. Expected: unchanged from today.
Details
  • The TEST-ONLY switch apple_sleep.j813_smc_late keeps its name so existing command lines still work; only its description changes.
  • macsmc's T6050 board list (saved_enabled for j714s/j716c) is not touched here.
  • Credit: the deferred notice and the DCP suspend stop are sithglan's (f1aa5a5, b29e3c7).

The final SMC MBSE/AP IDLE notice waits for the peer stops because on
T8142 ANS fails its IOP IDLE handshake when the SMC is told first. That
is a property of the T8142 sleep sequence, but both the deferral
(apple_sleep_smc_defer_notice()) and macsmc's bounded transport for it
were selected by of_machine_is_compatible("apple,j813"), which leaves
out J815 with the same SoC, SMC and ANS.

Add smc_notice_after_peers to struct apple_sleep_soc, set it for
apple,t8142-sleep, and read it instead of the board. macsmc picks its
transport at probe, before the sleep controller binds, so add
apple_sleep_smc_defer_notice_hw(), which answers the same from the
device tree: an available sleep controller whose profile has the flag.

Only J813 has an apple,t8142-sleep node today, so no board changes
behaviour until a device tree adds one; T8140, T8132 and T6050 leave
the flag clear. The TEST ONLY switch keeps its name.

Fixes: f1aa5a5 ("soc: apple: sleep: send J813's final SMC notice after peer stops")
Suggested-by: Thomas Glanzmann <thomas@glanzmann.de>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The DCP firmware stop at system suspend skipped every DCP with derived
power words (hw.s2r_untested, T8142) unless the machine was J813. The
stop needs the display's power words, which the device tree gives the
DCP as apple,display-power, and dcp_s2r_capable() already requires
them: dcp_s2r_check_dt() clears hw.s2r without the property, and probe
clears it for derived words unless appledrm.s2r_untested is set on
firmware 27.0.

Drop the board check, so the property selects the path. Today only J813
has apple,display-power on a T8142 DCP, so nothing changes until a
device tree adds it (J815 shares J813's nodes); other SoCs were never
behind the check.

Fixes: b29e3c7 ("drm/apple: dcp: stop the J813 firmware during system suspend")
Suggested-by: Thomas Glanzmann <thomas@glanzmann.de>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@gig3m

gig3m commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

J813 (MacBook Air 13" M5), macOS 27.2 stub, with #2384 on #2135's merged head and the usual apple_sleep test switches plus appledrm.s2r_untested=1. No change from before.

Two deep cycles with a 30 s alarm: both clean (suspend_stats: success=2 fail=0). Each woke on NUB.SPMI0.SW3, resumes 0 -> 1 -> 2. After each wake, all 10 CPUs, Wi-Fi, Bluetooth, NVMe reads and a VP9 hardware decode (0 of 90 frames wrong) were fine.

With the board check gone, the DCP path is now selected by apple,display-power, and it still comes up at boot: apple-dcp 286e00000.dcp: firmware stop enabled (appledrm.s2r_untested).

Both cycles logged the deferred SMC notice after the N1 sleep handshake:

apple_centauri 0000:01:00.0: TEST: Alpha ACIPC host sleep: ret=0 status=3 exec=2 ipc=2
apple-sleep 380700000.sleep-controller: TEST: SMC notice after peer stops: 0
macsmc 38c600000.smc: wake record: MBSE 0x10650, ...

After a wake, the panel came back with wake: panel on in 55 ms (firmware 1 ms).

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks @gig3m. This is the J813 no-change row the PR asked for.

  • Two deep cycles clean, with the DCP firmware stop now selected by apple,display-power (firmware stop enabled at boot) and the deferred SMC notice logged after the peer stops on both cycles. That is the same path as before the board check went away.
  • Still open: the J815 deep cycle with arm64: dts: apple: t8142: Give J813 and J815 the same SoC nodes #2383 (@m0d16l14n1), which is the case this change exists for: the deferred SMC notice after the ANS stop, and the DCP stop and restart with the panel returning.

@gig3m

gig3m commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

J813 (MacBook Air 13" M5), macOS 27.2 stub, one s2idle cycle on the tree from my deep row (#2384 on #2135's merged head, appledrm.s2r_untested=1) plus #1906's new head. 2 min 23 s, woken by a key press.

  • DCP: the firmware takes the s2idle path selected by apple,display-power: IOMFB: power on -> off, the IOAV link closed, then RTKit: Initializing (protocol version 12) and power off -> on at the wake. The panel came back at the inherited 2560x1664 mode, with backlight and dpmsStatus: 1.
  • After the wake: all 10 CPUs, Wi-Fi (ping 3/3), Bluetooth, an NVMe read and a VP9 hardware decode (0 of 90 frames wrong). suspend_stats: success=1 fail=0.
  • One new line: dwc3-apple 40a280000.usb: PM: device_prepare(): genpd_prepare returns -11. It's the first time in 93 suspends on this machine since 11-17 (the others were deep), and the cycle still succeeded.

🤖 Generated with Claude Code

Conflict: drivers/mfd/macsmc.c (kept integration's new apple_smc_sleep_saved_woken(), reworded its following comment from J813 to the deferred notice as the PR does).

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged integration/aurora (d1b022d); conflict in drivers/mfd/macsmc.c resolved (kept the new apple_smc_sleep_saved_woken(), comment reworded as in the PR); sleep.o, macsmc.o and drm/apple dcp.o build (arm64 defconfig+asahi.config) without warnings.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 22, 2026 10:34

@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 §1–§6 pre-PR review at verified live head f9d03e8175e91ddd05622453e13ef57c43d00ddb against live integration/aurora (70a00e583b03, not superseded).

Verified Clean (§1–§4 Code Audit)

  • Hardware/DT selection (§1): Replacing of_machine_is_compatible("apple,j813") with t8142_sleep_soc.smc_notice_after_peers, apple_sleep_smc_defer_notice_hw(), and dcp_s2r_capable() is the right direction.
  • Locking/refcounting/Kconfig/section safety (§2–§3): apple_sleep_of_match is static const (not __initconst), for_each_matching_node_and_match() iterates to completion without refcount leaks, CONFIG_APPLE_SOC_SLEEP is bool (safe for both MFD_MACSMC=y and =m, with stub for =n), and T8142 is the sole .s2r_untested = true profile in drivers/gpu/drm/apple/dcp.c:10114.
  • Attribution (§4): All 3 commits carry human author/committer and human Signed-off-by: only (zero AI commit trailers); PR body discloses assistance.

Blockers Before APPROVE

  1. §5 Missing J815 hardware verification & exact-head regression triad (behaviour is now LIVE on J815):
    • Commit 5ef8284e21f6 (arm64: dts: apple: t8142-j815: Share J813's sleep and power nodes) already landed on live integration/aurora (70a00e583b03), so t8142-j815.dts already carries both apple,t8142-sleep (t8142-j813-j815-sleep.dtsi) and apple,display-power (t8142-j813-j815.dtsi:426).
    • Merging #2384 therefore immediately flips smc->saved_enabled = true on every default-cmdline J815 boot (switching macsmc to devm_apple_rtkit_init_m5_saved() and enabling apple_smc_saved_guard()/saved_pending on all SMC commands), activates the deferred SMC notice, and activates the DCP suspend firmware stop on J815 — yet there is zero J815 boot or deep/s2idle hardware run on this PR.
    • The J813 runs (gig3m, Nov 19–20) predated the Nov 22 conflict-resolution merge f9d03e8175e9 in drivers/mfd/macsmc.c, omitted the §5 regression triad (0 SELinux denials, 0 failed units, 0 new kernel errors), and noted a new dwc3-apple 40a280000.usb: PM: device_prepare(): genpd_prepare returns -11 line on s2idle.
    • Please post exact-head J815 (default-cmdline boot + deep/s2idle cycle) and J813 rows with the §5 regression triad.
  2. Stale/inaccurate commit messages (32ddf053cfe1 and 8407d407ba85):
    • Both commit messages still state "Only J813 has an apple,t8142-sleep node today, so no board changes behaviour until a device tree adds one" / "Today only J813 has apple,display-power on a T8142 DCP, so nothing changes until a device tree adds it", which is now factually wrong on live integration/aurora (5ef8284e21f6). Please update them to reflect that J815 already shares both nodes.
  3. §6 Missing current live CI checks:
    • Live integration/aurora added .github/workflows/apple-drm-kunit.yml (drivers/gpu/drm/apple/**) and .github/workflows/pmgr-pwrstate-kunit.yml (include/linux/soc/apple/**) on 2026-11-23; neither has run on f9d03e8175e9.
    • Please rebase/merge onto live integration/aurora so apple-drm-kunit, pmgr-pwrstate-kunit, sep-source, and host-tests all pass green on the updated head.

Non-Blocking Note

  • drivers/soc/apple/sleep.c:6410 still logs panic("J813 SMC notice failed after peer stops: %d", ret); and drivers/mfd/macsmc.c still names apple_smc_j813_saved_ops/apple_smc_j813_saved_end; worth generalizing while cleaning up the commit messages.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at b177c367: not ready yet

Check Detail
CI at head no failing: host-tests
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 b177c367
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:platform, area:power

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

DjDeveloperr
DjDeveloperr previously approved these changes Nov 24, 2026

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

Verdict: FINISH, then merge at f9d03e8175e9: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: J815 already carries apple,t8142-sleep and apple,display-power on main (5ef8284), so merging this turns the saved-context SMC path, the deferred notice and the DCP suspend firmware stop on for every J815 boot. Nothing has run on a J815 yet. Needed: one J815 boot at this head with a deep sleep and wake, SMC commands working after the wake, and the display back. The J813 runs predate the head; one J813 sleep at the head covers it too.

Checked: no Apple material. This removes the J813 board check: the paths are now chosen by the apple,t8142-sleep node and the DCP's apple,display-power, and apple_sleep_smc_defer_notice_hw is exported for macsmc. The builds before and after have no new warnings, and CI is green. This replaces my earlier review.

Evidence

Read f9d03e81 and checked t8142-j815.dts on main.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:43

Superseded by the review at f9d03e8

@github-actions github-actions Bot removed the changes-requested A reviewer requested changes (bot) label Nov 24, 2026
@aurora-silicon-review
aurora-silicon-review Bot removed the request for review from DjDeveloperr November 29, 2026 02:52
@sithglan

Copy link
Copy Markdown
Contributor

@RyanTheTide Quick follow-up: #3373 (ae0119904114) landed on main, while this branch is still at 4bbd481a549e (pre-#3373, so booting exact head on J813 still hits the unrelated centauri_beta_running() SError). Once you forward-merge main past ae0119904114, ping me and I will run the exact-head J813 deep-sleep row.

@aurora-silicon-review
aurora-silicon-review Bot requested review from joshuaswarren and removed request for satchlj November 30, 2026 14:22
@aurora-silicon-review
aurora-silicon-review Bot requested review from DjDeveloperr and satchlj and removed request for joshuaswarren and satchlj December 1, 2026 05:23
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 1, 2026
@aurora-silicon-review
aurora-silicon-review Bot requested review from joshuaswarren and satchlj and removed request for DjDeveloperr, joshuaswarren and satchlj December 1, 2026 13:35
@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
@aurora-silicon-review
aurora-silicon-review Bot requested review from DjDeveloperr and satchlj and removed request for DjDeveloperr and joshuaswarren December 2, 2026 01:52
Three conflicts, all from main's T8142 sleep work since the last merge:

- dcp.c: main already dropped the J813 gate from the DCP suspend path.
  Take main's comment, so this branch no longer changes dcp.c.
- macsmc.c: use apple_sleep_smc_defer_notice_hw() in place of main's
  J813 board check, and keep main's apple,t8112-smc compatible.
- sleep.c: keep main's .derived marking for T8142, which replaced
  .untested, and add this branch's .smc_notice_after_peers.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Merged main (ccb3d8bd) into this branch as b177c367, with a normal merge commit. The three conflicts all came from main's T8142 sleep work:

  • dcp.c: main already took the J813 gate out of the DCP suspend path, so this PR no longer changes dcp.c.
  • macsmc.c: apple_sleep_smc_defer_notice_hw() replaces main's J813 board check, and main's apple,t8112-smc stays.
  • sleep.c: main's T8142 profile is now .derived (it was .untested); .smc_notice_after_peers is added next to it.

The PR's own change is otherwise the same. This head is past #3373, so the J813 row can run on it. Still needed before merge: a J813 and a J815 deep sleep and wake at this head, with SMC commands working after the wake. J815 is the board this changes, since main still sends the late notice on J813 only.

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

Verdict: MERGE at b177c367e70f once a J813 and a J815 deep sleep and wake pass at this head. No blocking findings in the code.

Checked

  • The forward merge of main ccb3d8bd. The PR's net change in macsmc.c (+9/-9), sleep.c (+34/-2) and sleep.h (+4/-1) is line for line the same as at 4bbd481a. dcp.c dropped out correctly: at this head it is byte-identical to main, which already removed the J813 gate from the DCP suspend path and turns appledrm.s2r_untested on by default for J813 and J815.
  • The conflict resolutions. macsmc.c:773: apple_sleep_smc_defer_notice_hw() replaces main's J813 board check, and main's apple,t8112-smc line stays. sleep.c:10335: .smc_notice_after_peers sits next to main's .derived on the T8142 profile.
  • Which boards this reaches on main: t8142-j813.dts and t8142-j815.dts both include t8142-j813-j815-sleep.dtsi (apple,t8142-sleep), and J704 has no sleep controller node. J813 keeps today's path. J815 gets the deferred notice and the bounded SMC transport for the first time, so the J815 row is the one that matters.
  • apple_sleep_smc_defer_notice_hw() walks the whole match list without breaking out, so it leaves no node reference behind. The stub returns false when CONFIG_APPLE_SOC_SLEEP is off. The only switch is the existing test-only apple_sleep.j813_smc_late; the PR adds no new switch.
  • Commits: every non-merge commit is signed off by its human author, and there is no AI attribution in the commits or the body.

Local checks (pc, arm64, LLVM, asahi config, this head)

  • make W=1 drivers/soc/apple/sleep.o drivers/mfd/macsmc.o: builds, 0 warnings.
  • Host tests (the host-tests.yml container, run-host-tests.py, 998 runs): 996 passed. The two failures are centauri-scan-tests and its negative controls. They fail the same way on main ccb3d8bd alone (cen_rx_consume is undeclared in the extracted Bluetooth harness), so they come from main.
  • KUnit: CI's plan picks macsmc, dcp-topology and asahi (the last two only because sleep.h changed), and these need an arm64 VM. Compiled instead: macsmc.o with CONFIG_MFD_MACSMC_KUNIT_TEST=y, and sleep.o, both W=1 with 0 warnings.
  • Hosted apple-build, host-tests and KUnit plan are still queued.

I brought the description up to date with the code: dcp.c no longer changes, J815 needs no companion DT, and the rows run on the default command line.

Still owed: J813 and J815 deep sleep and wake at this head on the default command line: the SMC notice comes after the ANS stop, SMC commands work after the wake, and the panel returns. None of our lab Macs is a T8142.

@sithglan

sithglan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

J813 (M5 MacBook Air, apple,j813 / apple,t8142) exact-head deep-sleep & wake row at b177c367e70f032dd8730ddb3bb28f188113752e (7.3.0-aurora-pr2384+, one-shot aura-try boot): PASS.

  • Boot & probe: apple-sleep 380700000.sleep-controller: deep sleep is the default: boot object resumes 0, /sys/power/mem_sleep = s2idle [deep], apple_sleep.j813_smc_late=Y (default), apple-pmu-rtc registered as rtc0, macsmc-rtc registered as rtc1, apple_sep attached with xart_guard=1 trusted_keys=1 filevault_api=1, all 10 CPUs 0-9 online. (Note: air5 Stage 2 chosen.bootargs still passes apple_sleep.deep=1 nvme_apple.sleep_untested=1 appledrm.s2r_untested=1 from its default boot-deep-sleep config; no apple_sleep.j813_smc_late override was set, and apple_sleep.untested_commit=N.)
  • Deep sleep & wake (20 s CLOCK_BOOTTIME_ALARM via alarmtimer/rtc0 + echo mem > /sys/power/state):
    • Wall-clock delta 20.837 s (1796250847.255 -> 1796250868.092), monotonic delta 0.995 s.
    • apple-sleep 380700000.sleep-controller: 10 coprocessors up and stopped
    • apple-sleep 380700000.sleep-controller: TEST: SMC notice after peer stops: 0
    • apple-sleep: T8142 PMU alarm after the timer: 0 (counter 4025590, compare 4025610)
    • apple-sleep 380700000.sleep-controller: back from sleep, boot object resumes 0 -> 1 (wake source: NUB.SPMI0.SW3)
    • macsmc 38c600000.smc: wake record: MBSE 0x10650, MBSW 00 00 00 00 00 00 00 00
    • nvme-apple 4c5cc0000.nvme: ANS: on 169 ms after the run bit, resetting the controller before any I/O
    • apple_sep 30a600000.sep: the enclave is back from its sleep request
    • aurora 582600000.gpu: GPU domain after the wake: 0xf0003ff (floor 0, saved 0xf002300)
  • Post-wake verification:
    • SMC live reads working: macsmc-battery Full, 100%, 13297000 uV, 23.7 C; macsmc_soc_die thermal zone updating live (28546 -> 28562 mC).
    • Display: internal panel card1-eDP-1 returned (connected/enabled, brightness restored dbv: 44060).
    • Peripherals: Wi-Fi wlp1s0f0 reassociated (status=0, ping to gateway and 1.1.1.1 OK), 64 MiB direct NVMe read (4.2 GB/s), SEP attached / hwrng registered, all 10 CPUs 0-9 online, 0 oops/errors.

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

Checked: The description now matches the actual SMC and sleep-controller diff. The T8142 sleep profile replaces the J813-only condition, and macsmc discovers the matching available sleep-controller node before the driver binds. The existing T8103 path and the no-sleep-config stub are retained.

Follow-ups: This and #3736 change the same late-notice behavior. The merge train should land one path and reconcile the other.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

The red host-tests job at b177c367e70f is not this PR's code. It ran 996/998; the two failures are centauri-scan-tests and its negative controls (cen_rx_consume undeclared in the extracted Bluetooth harness). main had the same failure at this branch's base (ccb3d8bd) and fixed it in #3987.

Merged locally with main 49fa570626f5 (clean, same three files, same patch), in the CI-pinned container: centauri tests 22/22 (both centauri-scan runs pass), sleep tests 48/48, smc tests 1/1.

The J815 deep sleep and wake row at this head is still owed. Hosted KUnit is still queued.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants