Skip to content
32 changes: 28 additions & 4 deletions PLAN.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Plan

Last updated 2026-11-26. RESEARCH.md is the lab notebook: what we found. This
Last updated 2026-11-27. RESEARCH.md is the lab notebook: what we found. This
file is what we do next, in order. Update it at the end of every session, in
the PR with that session's work.

## Pick up here (2026-11-26)
## Pick up here (2026-11-27)

Read this first. "Where things stand" below is the long record and its order of work is superseded by
this section where they differ.
Expand Down Expand Up @@ -58,7 +58,31 @@ this section where they differ.
that state, read under the m1n1 hypervisor in both systems, showed 54 words differing (Naeem Malik,
2026-11-16).

**Next, in this order:**
**2026-11-27: the reference sleeps and wakes this Mac** (RESEARCH.md, "The reference on this Mac").
Ante042's kernel branch with their second stage and the *stock* first stage: the mailbox found, one deep
sleep of about 64 s, an RTC wake back into the session, in a safe boot with the enclave's store read-only.
The stock loader is back. The same day olivergreg reported the same working on a J314s as a profile for
upstream's `sleep.c` with stock aura (aurora-silicon/linux#2198). So the entry's question (E2) is answered
by other people's code, and **no further one-way replay run is planned**; `e1-hook/` stays as it is. What
is next, in this order, replacing item 1 below (kept as the record of how it was reached):
- **Tell the thread** (Corey's OK each time): a second J314s, the same firmware, their stage 2 with the
stock stage 1, the GPU driver's name as the one thing that had to change for this distribution's Mesa.
- **Measure it here.** What the project set out to fix is the drain: a deep sleep's power on this Mac
Comment thread
CoreyH marked this conversation as resolved.
Resolved
against s2idle's 1.97 W (Ante042: 130 to 170 mW over a night, from battery voltage, since the gauge stops
counting at those currents). First a second and third sleep in one boot and a 15-minute one
Comment thread
CoreyH marked this conversation as resolved.
Resolved
(`ref-sleep go 900`), then how to measure a night: the safe boot keeps everything in RAM and the nights'
power-off hook does nothing there, so a night needs its own steps.
- **What daily use would take on this Mac**, to put to Corey before any of it is built: the reference
loader installed for good (every boot through it; a package update's `update-m1n1` writes the stock one
back), a kernel outside the package manager rebuilt at each update, the enclave's store read-only (no
Touch ID), and deep sleeps outside a safe boot. Or waiting for the upstream form.
- **The upstream form** is olivergreg's: `sleep-t6000.h` for `sleep.c`, the loader's mailbox from aura.
This Mac boots through m1n1-aurora, whose stock second stage publishes no mailbox, so on Omarchy it needs
either aura or a mailbox in that m1n1: a question for omacom (omacom/linux-aurora#290 is the open ask
there), not something Claude writes. Trying olivergreg's branch here would mean aura as the loader: a
bigger boot-chain change than the one file of 11-27, not asked and not OK'd.

**Next, in this order (as of 2026-11-26):**
1. **Decide how to converge on the reference** (RESEARCH.md, "The `sep_ro=1` run", 2026-11-26). The
tenth run, the last of the strategy review's ten, had the enclave gated, the SEP's wait bit cleared
and read back clear, no `a2_pre=1` and no late reads of the four fabric-group words, and ended as
Expand Down Expand Up @@ -208,7 +232,7 @@ this section where they differ.
5. The nights on the charger (installed 2026-11-19) haven't been seen on the Mac: the log will show
`pre armed ... ac_online=1` and `post cleared why=on-charger` every 25 minutes of a closed lid.

**As things are left:** the nights on at 25 minutes; `e1_hook.ko` built for 7.2.11-15 from `main`;
**As things are left:** the stock loader live and `boot.bin.stock` kept beside it; the test kernel `s2rref` (7.3.0-s2rref, the GPU driver's DRM name patched to "asahi") installed safe-only and not selected; the reference bundle and the builds in `~/.local/share/sleep-drain/ref-20261126/`; the nights on at 25 minutes; `e1_hook.ko` built for 7.2.11-15 from `main`;
`--m1-sep-ro` the latest launcher option (run 2026-11-26; `--m1-ll-retn` and `--m1-sep-pg` built, neither run); the PMU's record bytes all zero; scratch that must outlast
a restart in `~/.local/share/sleep-drain/`.

Expand Down
49 changes: 49 additions & 0 deletions RESEARCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -5426,6 +5426,55 @@ alarm_at=1795002065 try=1`, `12:41:11 finish power-off-asked`. The alarm ended t
the drivers six seconds in (`done: rtc0, wakealarm present, wakeup enabled`), and the clock was right: a
power-off keeps the PMU's RTC, which only a flat battery loses. The setting is back at 25.

### The reference on this Mac: Ante042's kernel and second stage sleep and wake it, with the stock first stage (2026-11-27)

One deep sleep of about 64 s, woken by the PMU's RTC alarm, back into the running session
Comment thread
CoreyH marked this conversation as resolved.
Resolved
(`results/ref-boot-20261127/`). The first sleep on this Mac that isn't s2idle.

- **What ran.** Ante042/linux `t600x-s2r-reference` at 3acb8cf, built here from the running kernel's
configuration with `CONFIG_APPLE_S2R=y` (release `7.3.0-s2rref`), installed safe-only with `test-kernel`;
Ante042/m1n1 `t600x-s2r-reference` at 4143b8e, built unchanged, as the second stage in a 5.5 MB `boot.bin`
with the kernel branch's six M1 Pro and Max device trees (`ref-loader`; the stock file kept). **The first
stage stayed the stock m1n1 v1.6.1**: every sleep in Ante042's notes ran with a thin first stage of their
own, and whether the stock one works they couldn't say (their answer of 11-26). It does here.
- **The boot.** A safe boot (read-only root under RAM overlays) with `apple_sep.xart_writes=0
apple_sep.provision_keybag=0`; the driver's log says "writes disabled". At boot: `apple-s2r: m1n1 mailbox
at 0x10004cfca40, 8 CPUs, CPU hotplug through m1n1`.
- **The sleep.** `ref-sleep check` passed its five findings; `ref-sleep go 60` enabled the driver ("deep
sleep available"), selected `deep`, armed rtc1 and wrote `mem`: `PM: suspend entry (deep)` at 13:11:26,
`apple-s2r: full wake: wakeup event` at 13:12:30, `PM: suspend exit` at 13:12:32. Corey: "the 60 second
sleep worked."
- **After the wake**, in the log: `apple_sep ... hwrng: read produced nothing (ENODEV)`, two Bluetooth
`hci0` command failures, "set affinity failed(-38)" for four IRQs as the cores went down, and the driver's
own notes that two fabric words and the P cores' words "stay off" as it restores the PMGR. None looked
at further.
- **The same firmware** as Ante042's Mac: iBoot2 iBoot-8422.141.2, OS firmware 13.5.
- **One thing had to change to get a desktop.** The first boot of that kernel stopped at the splash after
the disk's password (it kept no log: a safe boot). In the branch the GPU's DRM driver calls itself
"aurora", and this system's Mesa looks for "asahi", as the regular kernel's driver is called; Ante042's
notes say they made the same rename locally. One line (`results/ref-boot-20261127/local-drm-name.patch`),
a rebuild, and the second boot came up. That the name was the cause is inferred from that.
- **The stock loader is back** (`ref-loader restore` from the test boot; verified from the partition in the
next regular boot). In between, the regular kernel booted once through the reference loader, after the
first test boot hung, and ran normally.

**What it means.**
- The entry completes on this Mac, and the wake works, with code that someone else wrote and with no change
to the first stage. So nothing about this Mac or its firmware was in the way: the ten one-way runs stalled
on what the replay didn't do, not on the hardware. Which of the untried differences it was isn't known
from this, and doesn't need to be.
- Measured here: one sleep of a minute. Not measured: its power, a longer sleep, a second sleep in one
boot, a wake by key or lid, anything with the store writable or outside a safe boot.

**The same day, upstream** (aurora-silicon/linux#2198): olivergreg reports S2R working on a J314s as a
`sleep-t6000.h` profile for upstream's `drivers/soc/apple/sleep.c`, with stock aura (1.0.0b17) as the loader
and nothing changed in the boot chain, crediting Ante042's branch as the reference: 26 RTC wakes in one
boot on one build, 30 s and 1 h sleeps on the current tree; NVMe, Wi-Fi, Bluetooth, GPU, panel, keyboard,
trackpad and Touch ID working after a wake. Open before a draft PR: one SoC reset on a wake from a 1 h
sleep on battery, the ANS RTKit buffer issue (#3379), and "event-log source 19" after every wake. Branch:
olivergreg/linux `t6000-suspend-to-ram`. Their report, not reproduced here: this Mac boots through
m1n1-aurora, not aura, and its stock second stage publishes no mailbox.

### The `sep_ro=1` run: the enclave gated, the wait bit cleared, and the same stall (2026-11-26)

`run-floor --no-reading --m1-sep-ro` in a safe boot started with `sleep-drain-safe boot --sep-ro`, on battery
Expand Down
14 changes: 14 additions & 0 deletions results/ref-boot-20261127/loader-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
the stock recipe (update-m1n1's, from /etc/default/update-m1n1): /usr/lib/asahi-boot//m1n1.bin (3866624 bytes), 115 device trees, /usr/lib/asahi-boot//u-boot-nodtb.bin gzip'd (312383 bytes), 0 configuration lines
rebuilt from the installed inputs: sha256 1f1640d71cd50c3252f48fbee26e0eaaefcd7f9a3840517d2c107e2edcc856ed (9804783 bytes)
/boot/m1n1/boot.bin as it is: sha256 1f1640d71cd50c3252f48fbee26e0eaaefcd7f9a3840517d2c107e2edcc856ed (9804783 bytes), confirmed on the partition (synced, then read from the device)
match: the live boot.bin is exactly what the recipe builds, confirmed on the partition (synced, then read from the device)
kept the stock loader as /boot/m1n1/boot.bin.stock (sha256 1f1640d71cd50c3252f48fbee26e0eaaefcd7f9a3840517d2c107e2edcc856ed, read from the device)
installed: /boot/m1n1/boot.bin is now the bundle (sha256 96f6e465d30baab1dbfe99efa11529df63bf710155f0cedf4435a4a091d0bbfd, 5475525 bytes, read from the device)
the stock loader is /boot/m1n1/boot.bin.stock (sha256 1f1640d71cd50c3252f48fbee26e0eaaefcd7f9a3840517d2c107e2edcc856ed)
Until the stock is put back, every start of Linux on this Mac goes through this loader and gets its device trees:
the regular kernel too, not only a test kernel.
To go back:
from Linux, in a regular boot or a safe boot: pkexec ref-loader restore
from macOS, if Linux doesn't start: mount the EFI partition (ref-loader recovery-notes says which one), copy
m1n1/boot.bin.stock over m1n1/boot.bin, eject, restart
A package update that runs update-m1n1 also writes a stock loader over it (and keeps this bundle as boot.bin.old).
13 changes: 13 additions & 0 deletions results/ref-boot-20261127/local-drm-name.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git i/drivers/gpu/drm/asahi/driver.rs w/drivers/gpu/drm/asahi/driver.rs
index ba6301fa1..f9244660e 100644
--- i/drivers/gpu/drm/asahi/driver.rs
+++ w/drivers/gpu/drm/asahi/driver.rs
@@ -95,7 +95,7 @@ pub(crate) struct AsahiDrmRegistrationData<'drm> {
major: 1,
minor: 0,
patchlevel: 0,
- name: c"aurora",
+ name: c"asahi",
desc: c"Aurora GPU for Apple AGX",
};

44 changes: 44 additions & 0 deletions results/ref-boot-20261127/sleep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
13:07:13.605566 Linux version 7.3.0-s2rref (...) (clang version 23.1.4, LLD 23.1.4) #1 SMP PREEMPT_DYNAMIC Thu Nov 26 11:53:07 CET 2026
13:07:13.606297 Kernel command line: BOOT_IMAGE=/aurora-test/s2rref/vmlinuz root=UUID=... rw rootflags=subvol=@ cryptdevice=UUID=...:root:allow-discards loglevel=3 quiet splash appledrm.show_notch=1 apple_sep.xart_writes=0 apple_sep.provision_keybag=0 sleepdrain.safe
13:07:13.606645 apple-s2r: m1n1 mailbox at 0x10004cfca40, 8 CPUs, CPU hotplug through m1n1
13:08:38.924678 apple_sep 396400000.sep: xART: APFS-resolved .gl extent (...); writes disabled
13:11:03.821046 pkexec[4688]: Executing command [COMMAND=ref-sleep check]
13:11:26.079723 pkexec[4852]: Executing command [COMMAND=ref-sleep go 60]
13:11:26.101713 apple-s2r: deep sleep available, select it in /sys/power/mem_sleep
13:11:26.407805 ref-sleep: attempt 4852-1795781486: mem_sleep deep, wake armed 60 s from now
13:11:26.410701 PM: suspend entry (deep)
13:12:30.370906 Freezing user space processes
13:12:30.371346 Freezing user space processes completed (elapsed 0.001 seconds)
13:12:30.371375 Freezing remaining freezable tasks
13:12:30.371386 Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
13:12:30.373912 Disabling non-boot CPUs ...
13:12:30.373918 IRQ133: set affinity failed(-38).
13:12:30.373924 IRQ135: set affinity failed(-38).
13:12:30.373942 IRQ147: set affinity failed(-38).
13:12:30.373947 IRQ148: set affinity failed(-38).
13:12:30.373953 IRQ133: set affinity failed(-38).
13:12:30.373958 IRQ135: set affinity failed(-38).
13:12:30.373965 IRQ147: set affinity failed(-38).
13:12:30.374121 IRQ148: set affinity failed(-38).
13:12:30.374138 IRQ133: set affinity failed(-38).
13:12:30.374143 IRQ135: set affinity failed(-38).
13:12:30.374148 Enabling non-boot CPUs ...
13:12:30.374165 CPU1 is up
13:12:30.374182 CPU2 is up
13:12:30.374215 CPU3 is up
13:12:30.374232 CPU4 is up
13:12:30.374389 CPU5 is up
13:12:30.374482 CPU6 is up
13:12:30.374516 CPU7 is up
13:12:30.374521 apple-s2r: ps_all: afnc1_lw0 stays off (0x1000030f, was 0x1f0003ff)
13:12:30.374527 apple-s2r: ps_all: afnc1_lw1 stays off (0x1000030f, was 0x1f0000ff)
13:12:30.374533 apple-s2r: ps_all: pcpu1_0 stays off (0x100, was 0x1f0)
13:12:30.374538 apple-s2r: ps_all: pcpu1_0 stays off (0x100, was 0x1f0)
13:12:30.375496 apple-s2r: full wake: wakeup event
13:12:30.380022 Restarting tasks: Starting
13:12:30.380028 Restarting tasks: Done
13:12:30.380050 apple_sep 396400000.sep: hwrng: read produced nothing (ENODEV); further failures will not be logged
13:12:30.654935 Bluetooth: hci0: Opcode 0x0c01 failed: -19
13:12:32.679302 Bluetooth: hci0: Opcode 0x0c1a failed: -110
13:12:32.680523 PM: suspend exit
(43 more apple-s2r ps_all lines of the same two kinds left out)