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
|
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 |
|
Blockers: 2. The burst and pen changes read correctly:
Nit: HW row: after the parameters are removed, J815 and J813 on the default command line (no Assisted-by: LLM (Claude:Opus 5.5) |
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>
8e270f6 to
ac12cac
Compare
|
@RyanTheTide done.
Rebase note: integration's dynamic-debug start trace landed in HW rows (J815 + J813, defaults, 3 alarm + 1 lid wake each) to follow. Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-review of ac12cac: No blockers. Earlier points: 1 resolved: The new code reads correctly. Nit: sleep.c:8307-8310: the block comment on the SoC/DCS perf-state words now has nothing under it, because the constants it described were removed. Delete it with them. HW row (still owed): J815 and J813 on this head with the default command line: 3+ alarm wakes and 1 lid wake each, "9 cores started in one burst" + 9 "Booted secondary processor" per wake, CPUs 0-9 online, Assisted-by: LLM (Claude:Opus 5.5) |
… 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:
- At the end of the wake, start the cores that were online when the
sleep began, in one burst with those 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. The per-core start stays for
runtime hotplug. T8142's data has no cpu_clusters, so the cluster
comes from the MPIDR.
- Clear only the clusters' on bits at the commit.
- Drop the SoC/DCS perf-state step (t8142_perf_down()) and the
apple_sleep.perf_down switch that chose it.
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" and nine "Booted
secondary processor", all CPUs back, display, NVMe, Wi-Fi and Bluetooth
up; the read-modify-write and no perf-state step in a third sleep of
366 s before that. On two J813s (sithglan, gig3m) alarm and lid wakes
with the same behaviour. Reverting this commit is how to go back.
Signed-off-by: Nick <nekreshen@yandex.ru>
ac12cac to
8be9e73
Compare
|
Re-review of 8be9e73: no blockers. The only change since ac12cac is the removal of the leftover perf-state block comment (old drivers/soc/apple/sleep.c:8307-8310), so the earlier points stay resolved. HW row (still owed, at 8be9e73, default command line): J815 and J813, 3+ alarm wakes and 1 lid wake each. Each wake should show "9 cores started in one burst" and 9 "Booted secondary processor", CPUs 0-9 online, Assisted-by: LLM (Claude:Opus 5.5) |
|
@RyanTheTide nit done in The J815/J813 rows on the default command line are still owed. Assisted-by: LLM (Claude:Opus 5.5) |
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:
.begin; they wait in the holding pen and each bring-up only releases its core. The per-core start insleep_cpu_on()stays for runtime hotplugt8142_perf_down()and its call are goneT8142's data has no
cpu_clusters, so the burst takes the cluster from the MPIDR.Changed on this head (review):
apple_sleep.cpu_burst,cluster_rmwandperf_downare removed. The defaults they had (burst Y, RMW Y, perf-down N) are now the only behaviour, which is what the J815 and both J813 rows ran. Reverting the commit is how to go back. The per-core "released from the pen" line is nowpr_debug, next to integration's dynamic-debug start trace. The "N cores started in one burst" line stays.t8142_cpu_burst()moved abovet8142_wake()'s comment. Rebased ontointegration/auroracc14570.Tested on J815 (MacBook Air 15" M5), on the previous head with the defaults:
J813: sithglan (alarm and lid wakes) and gig3m ran the defaults; their rows are in the comments.
Checks:
W=1adds no warnings indrivers/soc/apple/at either commit;checkpatch --strictis clean on this commit.Still owed (HW rows): J815 and J813 on this head with the default command line: 3+ alarm wakes and 1 lid wake each, "9 cores started in one burst" + 9 "Booted secondary processor" per wake, CPUs 0-9 online,
suspend_statsfail 0, 0 AVC, 0 failed units, 0 new kernel errors.Part of the J815 bring-up; board results are summarised in #135.
Assisted-by: LLM (Claude:Opus 5.5)