Skip to content

arm64: apple: handle M4+ WFI/WFIT state loss by MIDR alone - #2796

Merged
DjDeveloperr merged 1 commit into
mainfrom
sweep-kcmd/wfx-v2
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
sweep-kcmd/wfx-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #2286 (same changes, commit trailers fixed).

Apple M4 and later cores (MIDR part 0x052 and up) can lose their general-purpose and FP/SIMD registers in WFI and WFIT. This kernel already handles that on every such part through midr_is_apple_m4_or_later(): cpu_do_idle() saves the registers around WFI, and cpuinfo records WFxT as absent, so ARM64_HAS_WFXT and HWCAP2_WFXT stay off. This PR removes the per-chip leftovers from before that predicate, plus the J700 device-tree boot argument.

What changes

Before After
has_wfxt() with a T8142/T6050/T8152 MIDR list has_cpuid_feature() / HWCAP_CAP(), as upstream. The sanitised ID_AA64ISAR2_EL1.WFxT already reads 0 on every M4+ part, so the list never changed the result.
__delay() busy-waits on T8142/T6050 only Every M4+ part takes the WFE event-stream loop. arm64.nowfxt selected that path on T8152 (0 bad SHA-256 runs in 288 under schedutil on J873), and T8140 and T6040 run it today. smp_cond_load_*() and the spinlocks already run WFE on these cores all the time.
A loader's idle=nop is ignored on T8142/T6050 only Ignored on every part that takes the register-saving WFI. apple_keep_idle_nop still keeps it for comparisons.
t8140-j700.dts /chosen bootargs = "arm64.nowfxt" ("Temporary") Removed. T8140 (0x060/0x061) has been matched by the predicate since the M4+ wait-state change.
midr_is_apple_m4_or_later() with a one-line comment The comment now gives the evidence per part and explains why parts nobody measured (T8132, T6041, the other T605x variants, later parts) are matched.

Who this affects

On EFI boots (U-Boot -> GRUB -> EFI stub), drivers/firmware/efi/libstub/fdt.c replaces /chosen/bootargs with the loader's command line. Neither the DT arm64.nowfxt nor the idle=nop arm64.nowfxt aura appends ever reached those kernels, and they already ran WFI with the register save and no WFxT. For them the only change is that __delay() on T8142/T6050 uses WFE instead of spinning.

Direct (non-EFI) boots from aura or m1n1 no longer depend on loader arguments. The companion aura change stops appending them: aurora-silicon/aura#453.

Testing

  • Built with the fleet74 configuration (7.3.0-aurora-fleet74, LLVM=1): arch/arm64/kernel/{idle,cpufeature,cpuinfo,setup,smp}.o and arch/arm64/lib/delay.o, using the new asm/cputype.h, with 0 warnings. has_wfxt and its MIDR table are gone from cpufeature.o.
  • t8140-j700.dtb: dtc shows 0 warnings. Its decompiled tree differs from the fleet74 DTB only in the removed bootargs line.
  • checkpatch --strict: 0 errors, 0 warnings.
  • No full Image was linked. The comment change in asm/cputype.h would rebuild most of the tree.

Rows from #2286

  • Lab rows on J700 (T8140), J616s (T6040), J316s (T6000) and J413 (T8112), default command line with no arm64.nowfxt/idle=nop: WFI register save on the M4+ parts, wfxt hidden, cpuidle entered on every CPU, SHA-256 loops 216/504/360/288 runs with 0 wrong, 0 failed units/AVC/oops/DART faults. Those boots were not direct (non-EFI) boots and did not cover s2idle.
  • satchlj's T6050 row (J775c): __delay() WFE path, WFxT off and s2idle, 70,768 + 37,539 (cpufreq stress) + 14,115 (after 3 freezes) SHA-256 runs with 0 wrong. Its idle.c was hand-merged with another T6050 change, so the idle=nop path on T6050 is not covered.

Hardware row still needed (MacBook Neo, T8140), on a direct boot with no arm64.nowfxt or idle=nop: /proc/cmdline without either, wfxt absent from /proc/cpuinfo Features, cpuidle usage counters increasing on every CPU, a SHA-256 correctness loop under schedutil, and s2idle. The idle and WFxT paths have no other per-chip logic left to test on J616s (T6040), M1 Pro or M2.

Apple M4 and later cores (MIDR part 0x052 and up) can come back from WFI
and WFIT with their general-purpose and FP/SIMD registers cleared. The
kernel already handles this on every such part through
midr_is_apple_m4_or_later(): cpu_do_idle() saves the registers around
WFI (d58647b, 34649b4) and cpuinfo records WFxT as absent
(5186d2e), so ARM64_HAS_WFXT and HWCAP2_WFXT stay off. Several
per-chip leftovers from before that predicate remained:

- has_wfxt() (848cb14, Thomas Glanzmann) kept a T8142/T6050/T8152
  MIDR list. The sanitised ID_AA64ISAR2_EL1 already reads WFxT as 0 on
  those parts and on every other M4+ part, so the list never changes the
  result. Go back to has_cpuid_feature() and HWCAP_CAP() for WFxT. Its
  comment also pointed at apple_m5_needs_wait_save(), which no longer
  exists.

- __delay() busy-waited on T8142 and T6050 only (dbb5e44), to stay
  off WFIT. WFIT cannot be reached there any more, and the WFE
  event-stream loop that remains is the same path arm64.nowfxt selected
  on T8152 (0 bad SHA-256 runs in 288 under schedutil on J873) and the
  path T8140 and T6040 run today. WFE is also what smp_cond_load_*()
  and the spinlocks run on these cores all the time. Drop the list.

- An idle=nop from the boot loader was ignored on T8142 and T6050 only
  (5c9cbb2, 72f8eec). Ignore it on every part that takes the
  register-saving WFI. Older aura and m1n1 append it on every M4+ chip,
  after the user's arguments; spinning idle costs 85-92 C against 43 C
  on T8140, about 90 C on T8142 and about 10 W on T6050.
  apple_keep_idle_nop still keeps it for comparisons.

- t8140-j700.dts set bootargs = "arm64.nowfxt" in /chosen, marked
  temporary until the kernel stopped using WFxT on T8140. The kernel
  already did (part 0x060/0x061 is matched). Remove it.

Document the per-part evidence at midr_is_apple_m4_or_later(), and why
parts nobody measured are matched (the same core generations, and later
parts by default).

On EFI boots (U-Boot -> GRUB -> EFI stub) the stub replaces
/chosen/bootargs with the loader's command line, so neither the DT
bootargs nor the arguments aura appends reached the kernel there. For
those users the only change is __delay() on T8142/T6050 using WFE instead
of spinning. Direct (non-EFI) boots stop depending on loader arguments.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 06633f4 (non-author, draft). No blocker found; ready once the direct-boot row and the T8142 row below are in.

  • Merges cleanly onto integration/aurora 6748d83. One commit, human sign-off only. arm64: apple: handle M4+ WFI/WFIT state loss by MIDR alone #2286 is closed.
  • has_wfxt() removal: __cpuinfo_store_cpu() clears ID_AA64ISAR2_EL1.WFxT for every CPU that midr_is_apple_m4_or_later() matches, before the sanitised register is built, so has_cpuid_feature() on the system-scope capability and HWCAP_CAP() give the same answer the removed list did, on the three listed chips and on the others. arm64.nowfxt still exists as a generic override and is no longer needed here.
  • __delay(): with ARM64_HAS_WFXT off, the only timed wait left in arch/arm64 (wfit/wfet in delay.c) is unreachable; the remaining path is the WFE event-stream loop, or cpu_relax() when the event stream is off.
  • idle=nop: apple_wfi_quirk_init() runs from smp_prepare_boot_cpu(), after parse_early_param(), so both idle= and apple_keep_idle_nop are known when it decides. The early return for non-matching parts keeps M1 to M3 untouched.
  • EFI boots: drivers/firmware/efi/libstub/fdt.c replaces /chosen/bootargs when the loader passes a command line, so the J700 DT arm64.nowfxt and the loader-appended arguments were not reaching those kernels; the rows on J700, J616s, J316s, J413 and the J775c row were effectively already run without them.
  • No per-SoC list is left in the idle, delay or WFxT paths; the one predicate is on the CPU part number, which is the same mechanism arm64 uses for core errata, and the header comment now states the evidence per part and why unmeasured and later parts are included.

Small points, not blocking:

  • T8142 (J813) changes behaviour and has no row at this head: __delay() there moves from the busy loop to WFE. The original T8142 failure was a cleared callee-saved register returning from a timed wait in the cpufreq transition poll (dbb5e44). Please add a J813 row with the E/P state sweep from that commit plus the SHA-256 loop under schedutil. T8152 has the WFE evidence only from arm64.nowfxt runs, and now also gets idle=nop ignored; one J873 row at this head would close that.
  • The predicate could in principle come from the loader (it knows whether the core's wait-state control was writable) as a /cpus property. I think MIDR is the right choice here because a missing property would mean silent register corruption rather than a missed optimisation, but it is worth saying so in the message, since the same question will come up for the next core generation.
  • apple_keep_idle_nop: once the loader stops appending idle=nop (aura#453), an idle=nop on the command line is the user's own, and it is now ignored on every M4+ part unless a second parameter is added. Consider dropping both the override and the parameter one release after the loader change, so idle=nop means what it says again.
  • t8142-j813-psci-idle.dtsi still describes its state as replacing idle=nop; the comment could be brought in line.
  • Rows still open, as listed: MacBook Neo on a direct boot with neither argument (/proc/cmdline, no wfxt in /proc/cpuinfo, cpuidle usage rising on every CPU, SHA-256 under schedutil, s2idle).

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan

Copy link
Copy Markdown
Contributor

J813 (MacBook Air 13-inch M5, T8142) exact-head row at 06633f4f6b39: PASS.

  • Kernel: 7.3.0-aurora-j813-pr2796+ built from exact PR head 06633f4f6b3996ee849eb1aa7200f6cfc (0 build warnings), guarded one-shot aura-try via enrolled Stage 1 (1.0.0b12-g693083b4-dirty, default J813 cmdline; note enrolled Stage 1 still passes idle=nop arm64.nowfxt and 06633f4f6b39 predates the 27.2 G17G firmware admission so the pre-existing GPU firmware image not admitted / fw-data overlap lines appear as expected on this base).
  • WFI / WFxT / idle=nop checks:
    • dmesg: Apple: preserving registers across WFI and Apple: idling in WFI, ignoring idle=nop.
    • /proc/cpuinfo Features: wfxt absent.
  • E/P cpufreq state sweep (dbb5e443c126 workload, __delay() WFE path):
    • policy0 (CPUs 0 7 8 9, 19 OPPs 300–4464 MHz) and policy1 (CPUs 1 2 3 4 5 6, 8 OPPs 300–2964 MHz) swept up and down for 5 full cycles under userspace while pinned integer workloads ran on all 10 CPUs: 270/270 transitions verified, 0 faults/oops.
  • schedutil SHA-256 correctness loops across all 10 CPUs:
    • Burst 1: 10 pinned CPUs × 100 rounds of 4 MiB SHA-256 (1,000 runs, 0.50 s, 0 wrong).
    • Burst 2 (20 s sleep/ramp soak under schedutil, random 5–40 ms idle gaps between 25-hash bursts): 123,300 runs (12,050–12,600 per CPU) of 1 MiB SHA-256, 0 wrong.
  • Health & restore: 0 oops, 0 kernel warnings, 0 DART faults, 0 failed systemd units, eDP-1 2560x1600. Cleaned up boot-pr2796 and restored M5 to default 7.3.0-aurora-j813-main+ (0 failed units).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J714s (MacBook Pro 14-inch M5 Pro, T6050) hardware row with this PR's 06633f4f6b39 unchanged: PASS.

  • Kernel: 7.3.0-m5-pr2796, built natively on the M5 from main bf03d7419ea8 with 06633f4f merged as is (249db124feb1), plus one commit on top (4a6c8c3fd405). That commit is the #2190 WFI deferral cut down to arch/arm64/kernel/idle.c; the pmgr-pwrstate commits are left out. idle.o, cpufeature.o, cpuinfo.o and delay.o rebuilt with 0 warnings, and has_wfxt is gone from System.map.
  • Boot: direct aura boot with the default DTB and command line. The default Stage 2 appends idle=nop arm64.nowfxt on T6050. This boot used a copy of it with only the arm64.nowfxt bytes blanked (12 bytes), so the loader still appends idle=nop and no arm64.nowfxt reaches the kernel.
check result
/proc/cmdline idle=nop present, no arm64.nowfxt
kernel log Apple: preserving registers across WFI, the deferral line, then Apple: idling in WFI, ignoring idle=nop (after built-in probes) at 0.299 s, before /init at 0.302 s
WFxT wfxt missing from Features on 18 of 18 CPUs; AT_HWCAP2 bit 31 clear
cpuidle usage went up on all 18 CPUs over 5 s (apple_idle)
idle power 9.8 W after the sleep, against 10.0 W on the default kernel; both idle in WFI
SHA-256 78,994 runs, 0 wrong. 75 s with one worker pinned to each CPU plus one unpinned, bursty with 1-20 ms sleeps, scaling_max_freq swept under schedutil: 14,601 cpufreq transitions
deep sleep one logind sleep (mem_sleep deep, RTC wake after 25 s), back in 38 s. After it: 25,220 SHA-256 runs with 0 wrong; vulkaninfo and a compute dispatch both work
health only tailscaled failed, as on the default. No Oops or WARN. Kernel error lines are the same set as the default kernel's, both before and after the same sleep

The default boot was restored afterwards, and the whole ESP is byte-identical to the start.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Mac mini, M4, T8132) exact-head row at 06633f4f6b39: PASS, no regression.

Kernel: current main (4abf0f83c290) with this PR merged (merge eabb62286e1e). The merge's diff against main has the same git patch-id as 06633f4f6b39. Our J773g config, booted on the 27.2 firmware (26B123) through aura over Wi-Fi, with the default command line (no idle=nop, no arm64.nowfxt). One device-tree change, unrelated to this PR and the same as in the #2776 row: apple,managed-sids removed from the Wi-Fi DART and pcie0 (and the DART's apple,dma-range and apple,sid16-page). Without it, current main doesn't bring up Wi-Fi on this Mac, and this Mac is only reachable over Wi-Fi.

T8132 (part 0x052/0x053) was already matched by midr_is_apple_m4_or_later(), so on this boot path nothing should change. The row checks that.

  • WFxT: wfxt is missing from Features on 10 of 10 CPUs, AT_HWCAP2 bit 31 (HWCAP2_WFXT) is 0, and there's no "WFx with timeout" capability line. Apple: preserving registers across WFI is printed once.
  • Idle: apple_idle driver with the menu governor. State usage rose on all 10 CPUs over a 10 s idle window, both before and after sleep.
  • cpufreq: schedutil on both policies. Under load the P cluster ran 1260 to 4464 MHz and the E cluster 1860 to 2892 MHz (349 and 1096 transitions during the run).
  • SHA-256: 10 workers, one pinned to each CPU, for 15 s. Each worker alternates 200 ms busy bursts with 20 rounds of a hash and a 0.5 to 3 ms sleep, so every core keeps going in and out of WFI with live FP/SIMD state. 310,243 digests, 0 wrong. A float-math check in each worker also gave 0 mismatches. The kernel printed nothing during the run: no soft lockup, RCU stall, hung task or cpufreq error. This ran after the s2idle cycle below, in the same boot.
  • s2idle: rtcwake -d /dev/rtc1 -m freeze -s 10 woke on the alarm (suspend_stats success 1, fail 0), and SSH was back over Wi-Fi 16 s after the trigger, the 10 s alarm included. The only new err-level lines after sleep are dwc3-apple ...: genpd_prepare returns -11 for the two USB controllers. This Mac prints those on every s2idle: on our production kernel too, and on a main-based kernel without this PR.
  • Health: 0 failed units, display-manager active, 0 BUG/Oops/WARNING/lockup lines over the boot. 6 err-level lines, the same set the main-based soc: apple: rtkit: allocate endpoint 7 buffers only for clients that ask for them #2776 kernel prints (AOP firmware region, Bluetooth calibration blob, Type-C cable revalidation). GPU health shows 0 failures and 0 recoveries.

Not covered: this boot chain doesn't pass idle=nop on T8132, so the new path that ignores it there didn't run. Also not covered: EFI boot, the T8142/T6050 __delay() change and the J700 device tree.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 24, 2026 23:32
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 23:32
@DjDeveloperr
DjDeveloperr merged commit b177bc7 into main Nov 24, 2026
4 of 5 checks passed
@DjDeveloperr
DjDeveloperr deleted the sweep-kcmd/wfx-v2 branch November 24, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants