Repository navigation
soc: apple: sleep: T8142: start the cores and write the cluster words as XNU (on #2192) - #2193
m0d16l14n1 wants to merge 2 commits into
Conversation
secondary_holding_pen_release is written with a CPU's MPIDR to let it out of the pen and never reset, so after boot it still names the last CPU released. secondary_data.task likewise keeps that CPU's idle task: __cpu_up() only clears it on failure. With the restartable spin table (aurora,rvbar-spin-table) a CPU comes back through the pen whenever the SoC restarts it at its reset vector: after a system sleep's commit, and at the wake. The CPU whose MPIDR is still in the pen walks straight through into secondary_startup, ahead of its own bring-up, and runs secondary_start_kernel() as that CPU with the stale task. The hotplug state machine has not started it, so no STARTING callback runs (no arch timer, no tick device), yet it marks itself online and completes cpu_running, so the real bring-up returns at once. It idles quietly while cpuidle is paused and faults at the first menu_select() after cpuidle_resume(): Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 CPU: 9 UID: 0 PID: 0 Comm: swapper/9 pc : tick_nohz_get_sleep_length+0x68/0xd4 Call trace: tick_nohz_get_sleep_length+0x68/0xd4 (P) menu_select+0x414/0x774 cpuidle_select+0x1c/0x28 do_idle+0x1e8/0x310 cpu_startup_entry+0x34/0x38 secondary_start_kernel+0x198/0x1bc Kernel panic - not syncing: Attempted to kill the idle task! Seen on a J815 (MacBook Air 15" M5) when every core was started at the end of the wake, as macOS does, instead of one by one at its bring-up. Reset the release to INVALID_HWID in the released CPU's cpu_postboot, which runs before complete(&cpu_running), so it can't race with the next bring-up; and again before a suspend's hold and after the wake, before any CPU is started. Clear secondary_data.task after a successful bring-up too, as kernels before 5.x did, so a core that still reaches __secondary_switched without a bring-up of its own waits in __secondary_too_slow instead of running as another CPU. Tested on J815: two real deep sleeps (256 s and 172 s) with all nine secondary cores started together at the wake, all back online, where the same kernel without this change panicked on the first wake. Signed-off-by: Nick <nekreshen@yandex.ru> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Nick <nekreshen@yandex.ru>
… as XNU
A traced macOS 27.2 sleep on a J813 (boot, a 40 s sleep, the wake and
three more entries) differs from ours in three places:
- The wake: 16.5 ms after it, right after the memory side and the WD2
stop, the boot core starts all nine other cores in one 0.23 ms burst,
three words each (+4 the core's bit, +8 the E core's bit or 0, +0xc
the P core's bit or 0). We started each core later, from its own
bring-up, with two words.
- The commit: the clusters' words are read-modify-written. The first
sleep after boot reads 0xf and writes 0; every commit after a wake
reads 0x2f and writes 0x20, keeping bit 5. We wrote 0 every time.
- The SoC/DCS perf-state page is never accessed.
Do the same, each behind a parameter:
- apple_sleep.cpu_burst (default Y): at the end of the wake, start the
cores that were online when the sleep began, in one burst with XNU's
three words. They come up through the boot object into the kernel's
holding pen and wait there; each bring-up only releases its core.
T8142's data has no cpu_clusters, so the cluster comes from the MPIDR.
- apple_sleep.cluster_rmw (default Y): clear only the clusters' on bits
at the commit.
- apple_sleep.perf_down: default N.
The burst depends on the holding pen being closed behind each released
CPU ("arm64: spin table: close the holding pen behind each released
CPU"); without it the last CPU booted runs ahead of its bring-up.
Tested on J815 (MacBook Air 15" M5): two real deep sleeps (256 s and
172 s), each with "9 cores started in one burst", nine "started in the
wake burst" and nine "Booted secondary processor", all CPUs back,
display, NVMe, Wi-Fi and Bluetooth up; cluster_rmw and perf_down=N in a
third sleep of 366 s before that. To go back for one sleep:
apple_sleep.cpu_burst=0 cluster_rmw=0 perf_down=1.
Signed-off-by: Nick <nekreshen@yandex.ru>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Nick <nekreshen@yandex.ru>
|
Tested the head (8e270f6, on Eight real deep sleeps on one boot, woken by the PMU alarm (
Not covered: a lid wake. |
|
Lid wake too, on the same boot with the defaults (
|
|
Tested on my J813 (macOS 27.2 / 26B123 stub, EL2 aura Six real deep sleeps on one boot, Hyprland on the internal panel:
The machine was on AC for these, so there's no power number yet. A lid-closed night on battery with 🤖 Generated with Claude Code |
Stacked on #2192 (the pen fix, the first commit here). The burst below needs it.
In a traced macOS 27.2 sleep on J813 (boot, a 40 s sleep, the wake and three more entries), XNU differs from us in three places. This PR does the same as XNU, each behind a parameter:
apple_sleep.cpu_burst(Y): burst for the cores online at.begin; they wait in the holding pen and each bring-up only releases its coreapple_sleep.cluster_rmw(Y)apple_sleep.perf_down(N)T8142's data has no
cpu_clusters, so the burst takes the cluster from the MPIDR.Tested on J815 (MacBook Air 15" M5):
cluster_rmwandperf_down=Nalone.checkpatch --strictis clean, and the change builds withW=1onintegration/aurora.To go back for one sleep:
apple_sleep.cpu_burst=0 cluster_rmw=0 perf_down=1.@sithglan, @gig3m: it comes from your g01 trace and runs on J813 too. Could you give it a few deep sleeps there? If the wake misbehaves, try
cpu_burst=0first.Part of the J815 bring-up; board results are summarised in #135.
🤖 Generated with Claude Code