Skip to content

cpufreq: apple-soc: enable lazy verification fast-switch on T6050 - #3397

Merged
RyanTheTide merged 11 commits into
mainfrom
feat/cpufreq-t6050-lazy-verify
Nov 29, 2026
Merged

RyanTheTide merged 11 commits into
mainfrom
feat/cpufreq-t6050-lazy-verify

Conversation

@erikwb

@erikwb erikwb commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: Enable lazy_verify fast-switch DVFS on T6050 (apple,t6050-cluster-cpufreq) to eliminate sugov kthread wakeups and cross-CPU IPIs, while enforcing live QoS/thermal caps across fast-switch, cap-lift, zero-ceiling pending-request replay, policy-worker reconciliation, suspend transitions, cpufreq_stats accounting, scheduler frequency-invariance scale updates, and power:cpu_frequency trace emission.
Tested: Modular (=m) and built-in (=y) host checks plus live modular hardware at 3653dfe88ef8 (aurora_defconfig, CONFIG_CPU_FREQ_STAT=y; full details and earlier 085f7d94fce2 runs in Evidence):

  • Host checks: W=1 KCFLAGS="-Werror" clean on all 5 touched C files and full Image + modules link (=m modpost exports freq_qos_read_value, topology_set_freq_scale, cpufreq_stats_record_transition; =y Image clean); arm64 QEMU KUnit (apple-soc-cpufreq.kunitconfig) 90/90 passed (72/72 apple_soc_cpufreq* + 18 apple-clpc*, after an earlier transient QEMU timing race in cft_test_stats_busy_suspend_fail under host load); checkpatch.pl --strict 0/0/0; git diff --check and merge-tree vs origin/main clean.
  • J716c (M5 Max, T6050, fw 27.2, =m): batched 3545ebecb76f (8/8 PR files blob-identical, default cmdline): apple_soc_cpufreq.ko loaded, 0 sugov threads across all steps, initial inventory policy0/6 300 MHz..4.38 GHz and policy12 300 MHz..4.608 GHz (apple-cpufreq, schedutil); policy0 clamped to 300 MHz (cur=300 MHz under load), ceiling restored to 4.38 GHz (unpinned load still read cur=300 MHz after lift; pinned all-policy lift passed at 085f7d94fce2), policy0 governor handoffs performance (4.38 GHz) -> powersave (300 MHz) -> schedutil (1.644 GHz) clean; 4× pm_test=devices + 2× pm_test=platform clean; 6-item smoke pass (aurora-peripherals.service warm-reboot baseline failure also on default/control).
  • J713 (M4 Air, T8132, fw 27.2, =m): combined #3546 + #3397 trial (8/8 #3397 files blob-identical including kernel/power/qos.c, default cmdline + panic=10): apple-soc-cpufreq.ko linked via modpost (proving EXPORT_SYMBOL_GPL(freq_qos_read_value)), booted via one-shot GRUB, loaded in lsmod (65,536 B), and passed 8-item boot smoke (0 failed units, 0 AppArmor denials); ktb.sh cpufreq was not run before the combined #3546+#3397 candidate became unreachable during #3546's hot s2idle retest (cause unresolved; baseline default kernel survived the same hot s2idle procedure, while fast-switch kprobes and s2idle previously passed as =y at 085f7d94fce2).
    Risk: two-way door · T6050 Macs (J716c, J714s/c, K114/K116), shared lazy_verify path on T8140, and shared apple-soc-cpufreq / cpufreq_driver_fast_switch() CPUFREQ_DRIVER_UPDATES_CUR / freq_qos_read_value() path across Apple Silicon Macs
    Revert: git revert the PR merge commit (all changes are in-memory cpufreq core, QoS export, stats, frequency-invariance, and driver state; no persistent on-disk, ESP, or firmware state is modified).
    Not yet: J713 (T8132) modular (CONFIG_ARM_APPLE_SOC_CPUFREQ=m) ktb.sh cpufreq governor/clamp/kprobe/s2idle re-check at 3653dfe88ef8 (ktb.sh cpufreq was not run before the combined #3546+#3397 candidate became unreachable during #3546's hot s2idle retest; cause unresolved while baseline survived the same procedure; fast-switch kprobes and s2idle passed as =y at 085f7d94fce2, and apple-soc-cpufreq.ko linked/booted/loaded as =m at 3653dfe88ef8); J313 (T8103) second-family non-regression row at 3653dfe88ef8 (J313 became unreachable on baseline main deep sleep); T8140 (J700) regression run and board with apple,fast-die-effort active (no T8140 or J714s hardware on site; covered by 72/72 arm64 QEMU KUnit apple_soc_cpufreq* tests).
Details
  • Sets .lazy_verify = true on soc_t6050_info, adds CPUFREQ_NEED_UPDATE_LIMITS and CPUFREQ_DRIVER_UPDATES_CUR on apple_soc_cpufreq_driver.
  • Adds CPUFREQ_DRIVER_UPDATES_CUR (include/linux/cpufreq.h) so drivers that update hardware from asynchronous limit or timer paths publish policy->cur, record cpufreq_stats_record_transition(), and update arch_set_freq_scale() themselves while cpufreq_driver_fast_switch() reads READ_ONCE(policy->cur) and skips duplicate post-return stats and frequency-scale writes, preventing a concurrent clamp's policy->cur, cpufreq_stats, or scheduler frequency invariance from being overwritten by an older ->fast_switch() completion; exports cpufreq_stats_record_transition() (drivers/cpufreq/cpufreq_stats.c), topology_set_freq_scale() (drivers/base/arch_topology.c), and freq_qos_read_value() (kernel/power/qos.c) for modular builds.
  • apple_soc_cpufreq_clamp_pstate() resolves live freq_qos min/max bounds (qos_max >= 0, qos_min >= 0, so 0 from store_scaling_max_freq()/store_scaling_min_freq() is honored immediately via freq_qos_read_value(&policy->constraints, ...)) against policy->freq_table with cpufreq's maximum-first OPP semantics (including ceilings below the lowest OPP) plus priv->cap_pstate.
  • Extracts apple_soc_cpufreq_record_cur(), apple_soc_cpufreq_publish_cur(), apple_soc_cpufreq_drop_pending(), and apple_soc_cpufreq_lazy_reconcile() so lazy-path hardware-accepted transitions (apple_soc_cpufreq_lazy_request(), apple_soc_cpufreq_lazy_cap(), apple_soc_cpufreq_verify_policy(), and pending-request replay in apple_soc_cpufreq_verify()) keep hardware, policy->cur, cpufreq_stats, and arch_set_freq_scale() synchronized under priv->lock, while busy-queued requests update policy->cur optimistically without charging cpufreq_stats or arch_set_freq_scale() unless hardware later accepts the P-state; every pending-request discard path (apple_soc_cpufreq_drop_pending() via apple_soc_cpufreq_fail(), apple_soc_cpufreq_drain(), apple_soc_cpufreq_verify(), and apple_soc_cpufreq_get_rate(), with apple_soc_cpufreq_lazy_set() keeping pending_pstate intact until apple_soc_cpufreq_lazy_write() succeeds) restores policy->cur to expected_pstate. Outside priv->lock, apple_soc_cpufreq_suspend() calls apple_soc_cpufreq_set_pstate() first: a failed suspend leaves cpufreq_stats, arch_set_freq_scale(), and tracepoints untouched (restoring policy->cur when policy->suspend_freq is set), a configured policy->suspend_freq frequency change reports via cpufreq_freq_transition_begin()/cpufreq_freq_transition_end(..., 0), and a !policy->suspend_freq or same-frequency suspend calls apple_soc_cpufreq_record_cur(); non-lazy apple_soc_cpufreq_fast_switch() records under the core's fast-switch serialization contract.
  • apple_fast_die_work() re-applies apple_fast_die_cap() under fd->lock after freq_qos_update_request() publishes a lifted limit so tickless clusters whose asked_pstate has not been overwritten by a post-reconcile capped fast_switch() restore immediately without waiting for policy->update or overwriting a concurrent lower thermal sample; once policy->max has clamped and fast_switch() has recorded the capped frequency as asked_pstate, restoration waits for the next scheduler utilization callback after policy->update.
  • apple_soc_cpufreq_suspend() drains pending lazy writes, snapshots the accepted expected_pstate frequency, clamps policy->suspend_freq / current state against the live ceiling, calls apple_soc_cpufreq_set_pstate(), and on a successful policy->suspend_freq frequency change reports it via cpufreq_freq_transition_begin() / cpufreq_freq_transition_end(..., 0) (emitting power:cpu_frequency, transition notifiers, cpufreq_stats, policy->cur, and arch_set_freq_scale() once, while leaving failed or same-frequency suspends free of spurious transitions/traces).
  • apple-soc-cpufreq.kunitconfig enables CONFIG_CPU_FREQ_STAT=y and CONFIG_TRACEPOINTS (CONFIG_FTRACE=y + CONFIG_ENABLE_DEFAULT_TRACERS=y), and apple-soc-cpufreq-test.c wires apple_soc_cpufreq_verify_policy and CPUFREQ_DRIVER_UPDATES_CUR into cft_live_driver, updates cft_test_lazy_policy_limits_and_handoff and cft_test_verify_policy_cap_lift, and adds cft_test_verify_policy_ceiling_drop, cft_test_fast_switch_reconcile_race, cft_test_stats_clamp_and_race (with arch_scale_freq_capacity() checks), cft_test_stats_busy_then_discard, cft_test_stats_busy_suspend_fail (with power:cpu_frequency tracepoint assertions), and cft_test_stats_idle_mismatch_discard.
  • Overlapping PRs in drivers/cpufreq/apple-soc-cpufreq.c: aurora-silicon/linux#2302 (sweep/cpufreq-lazy, which removes lazy_verify and keys on verify_transition) and aurora-silicon/linux#3471 (pr/apple-cpufreq-fast-die-hz). Whichever lands first will require reconciling drivers/cpufreq/apple-soc-cpufreq.c in the remaining PRs.
Evidence
  • Local checks at 3653dfe88ef8:

    • git diff --check 124e30a6718d..HEAD: clean
    • ./scripts/checkpatch.pl --strict --git 085f7d94fce2..HEAD: 0 errors / 0 warnings / 0 checks on 3653dfe88ef8 (earlier 124e30a6718d..085f7d94fce2 10 commits also 0/0/0)
    • git merge-tree --write-tree origin/main HEAD (against b897ccb4e71c): clean (f85ee42b936a)
    • Modular build (aurora_defconfig, CONFIG_ARM_APPLE_SOC_CPUFREQ=m, CONFIG_CPU_FREQ_STAT=y):
      • make O=_build_m ARCH=arm64 LLVM=1 W=1 KCFLAGS="-Werror" -j32 kernel/power/qos.o drivers/cpufreq/cpufreq.o drivers/cpufreq/cpufreq_stats.o drivers/base/arch_topology.o drivers/cpufreq/apple-soc-cpufreq.o: clean
      • make O=_build_m ARCH=arm64 LLVM=1 -j32 Image modules: clean (_build_m/drivers/cpufreq/apple-soc-cpufreq.ko 486K; Module.symvers exports freq_qos_read_value, topology_set_freq_scale, and cpufreq_stats_record_transition as EXPORT_SYMBOL_GPL)
    • Built-in build (aurora_defconfig with CONFIG_ARM_APPLE_SOC_CPUFREQ=y, CONFIG_CPU_FREQ_STAT=y):
      • make O=_build_m ARCH=arm64 LLVM=1 W=1 KCFLAGS="-Werror" -j32 kernel/power/qos.o drivers/cpufreq/cpufreq.o drivers/cpufreq/cpufreq_stats.o drivers/base/arch_topology.o drivers/cpufreq/apple-soc-cpufreq.o: clean
      • make O=_build_m ARCH=arm64 LLVM=1 -j32 Image: clean (65M)
    • ./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/cpufreq/apple-soc-cpufreq.kunitconfig --build_dir=_build_kunit --jobs=32: 90/90 passed (72/72 apple_soc_cpufreq* subtests + 18 apple-clpc* subtests; one earlier run hit a transient QEMU hrtimer/busy-timeout timing race in cft_test_stats_busy_suspend_fail while the host was loaded before passing 90/90 on re-run)
  • Live modular (CONFIG_ARM_APPLE_SOC_CPUFREQ=m) hardware at 3653dfe88ef8 (2026-11-28):

    • J716c (16-inch M5 Max, T6050, firmware 27.2) in batched candidate 3545ebecb76f (origin/main b897ccb4e71c + 18 PRs, AC power, default command line; 8/8 PR files blob-identical to 3653dfe88ef8, which is an ancestor of the booted tree):
      • Hashes: Image.gz SHA-256 d56efde4c7232208bd29d5c4e5890319e0050595dd4f4b1c3844df6656a08312, t6050-j716c.dtb SHA-256 d2f0db7a5026ae9cc4e1cff61dca38b4d1b363d47e5bad696ef65c7d715517e0, modules SHA-256 9d5782bcf02ea60a225278c9319431f902b495f6beb485d79d127c0fb2fccc92, one-shot aura-try Stage 2 SHA-256 b7d99286395ddd7dadccc6d9593f4bd55391d9e787af97c18b45f58688d9885d (default Stage 2 21edee972e1ff1718c6f41c32b91ee151afdc58cbb69f16f2f6a4d8d4c722170, default kernel bf2582ab357573db64031f39e7bc9d617eb574c6b221364ff417810bbddf4c87, default DTB ffe7604c98ad23849b2aff19eb161bec712f8b367a9bc87339fabb6d7dc1276c unchanged).
      • Module & DVFS: apple_soc_cpufreq.ko loaded (65,536 B, used by macsmc_hwmon), 0 sugov threads before and after all steps; initial policy inventory policy0 (300 MHz..4.38 GHz), policy6 (300 MHz..4.38 GHz), and policy12 (300 MHz..4.608 GHz) all on driver apple-cpufreq, governor schedutil; policy0 scaling_max_freq clamped to minimum (300 MHz; scaling_cur_freq 300 MHz under load) and restored to 4.38 GHz (an unpinned load still read cur=300 MHz after ceiling lift because it was not pinned to policy0's CPUs; pinned all-policy lift across policy0/6/12 already passed at 085f7d94fce2); policy0 governor handoffs performance (4.38 GHz) -> powersave (300 MHz) -> schedutil (1.644 GHz) clean.
      • Suspend & smoke: 2× freeze + 2× mem pm_test=devices and 2× pm_test=platform clean (rc=0, fail=0); eDP-1 3456x2234@120 enabled, 4 input devices, wlan0 0% loss, AppleJ716 + AppleJ716HPAI enumerated (speakerguardd-v2 active), Borealis Apple M5 Max (G17C B1) + vkcube --c 180 OK, 0 failed user units, 0 LSM denials, 0 Oops/BUG/fault (aurora-peripherals.service warm-reboot baseline failure also on control/default; 40 err+ lines pre-existing vs 55-line default boot except PM: suspend debug and 3 DPMS IOAVVideoInterface open failed syslog lines).
    • J713 (M4 MacBook Air, T8132, firmware 27.2) trial kernel combining the J713 daily base (8dbfa2895b93), #3546, and #3397 (8/8 #3397 files blob-identical to 3653dfe88ef8, including kernel/power/qos.c via b68cb02f62fb, CONFIG_ARM_APPLE_SOC_CPUFREQ=m, default command line + panic=10):
      • Hashes: kernel image SHA-256 cebaa4e73e6268f14de680996a76fa94d301be8a675b7614044da050d4223f73, initramfs SHA-256 fb26adb095b714a902ef195b5bfa9e1217e4c61649f472829e88d9a51183e914, apple-soc-cpufreq.ko SHA-256 d57969517ec3c01db5a4d0d3075b62aefa3e37d016fc6e949c82eda355d934e5, default Stage 2 3b2d2f059858d1891b225910864c02d68afb1b42893667e0afa8666491651071 unchanged.
      • Modular link, boot & load: 3653dfe88ef8 resolved the freq_qos_read_value modpost failure (kernel/power/qos.c's EXPORT_SYMBOL_GPL(freq_qos_read_value) proven by apple-soc-cpufreq.ko linking via modpost and loading); apple-soc-cpufreq.ko booted cleanly via one-shot GRUB and appeared loaded in lsmod (65,536 B, 2 users: macsmc_hwmon, apple_pmp_thermal); boot smoke passed (eDP-1 2560x1664 enabled, Borealis Apple M4 (G16G B0) glmark2 5,066, speakerguardd-v2 protected tone rc 0, 0 failed units, 0 AppArmor denials, 3 baseline err+ lines only).
      • ktb.sh cpufreq was not run: the modular ktb.sh cpufreq governor handoff, clamp/lift, fast-switch kprobe, and s2idle re-check did not run before the combined #3546+#3397 candidate became unreachable during #3546's hot s2idle retest (cause unresolved; the baseline default kernel survived the same hot s2idle procedure, while no #3397-only control ran; fast-switch kprobes and s2idle previously passed as =y at 085f7d94fce2 below, and 3653dfe88ef8 only adds EXPORT_SYMBOL_GPL(freq_qos_read_value)).
  • Earlier local & CI checks at 085f7d94fce2 (prior to 3653dfe88ef8):

    • ./scripts/checkpatch.pl --strict --git 124e30a6718d..085f7d94fce2: 0 errors / 0 warnings / 0 checks across all 10 commits (f735894bca19, ebb208262921, c858fe9190fb, 0b0f4932776b, 8d590f14110f, 5c269a610a54, 8cdb8aea6864, db5b9826138b, e4d2c89e02e2, 085f7d94fce2)
    • CONFIG_CPU_FREQ_STAT=n (_build with W=1 KCFLAGS="-Werror"): clean at e4d2c89e02e2 for both CONFIG_ARM_APPLE_SOC_CPUFREQ=m and CONFIG_ARM_APPLE_SOC_CPUFREQ=y; CONFIG_CPU_FREQ_STAT=y with CONFIG_ARM_APPLE_SOC_CPUFREQ=y also clean (085f7d94fce2 touches drivers/cpufreq/apple-soc-cpufreq-test.c only).
    • GitHub CI at 085f7d94fce2: 21 successful checks (apple-build, 16 KUnit jobs, host-tests 738/738, etc.) + 2 cancelled (pr-text, readiness); 3653dfe88ef8 is not yet pushed to GitHub.
  • Earlier live J716c (16-inch M5 Max, T6050) at 085f7d94fce2 in batched candidate c3da8eed6f72 (over main 9af21b007425, default cmdline, default Stage 2, Linux 7.3.0, AC 100%; prior to 3653dfe88ef8):

    • ps -eo pid,comm | grep sugov: 0 threads
    • policy0/policy6/policy12: drv=apple-cpufreq gov=schedutil
    • scaling_max_freq clamp to 1344000 kHz (policy12: 1308000 kHz, its OPP-table value) applied within 50 ms, e.g. policy0 cur=2964000 -> 1344000
    • Standalone clamp updated stats/total_trans and time_in_state immediately (6590 -> 6593 within 50 ms)
    • Restore of the original scaling_max_freq worked on all 3 policies, and again after each of 2x pm_test=devices suspend/resume cycles
  • Earlier live J716c governor handoff at 085f7d94fce2 (four-PR batched candidate f59b93fb961f over main 9af21b007425, default command line, default Stage 2, Linux 7.3.0, AC 100%; policy0 cpu0-5, policy6 cpu6-11, policy12 cpu12-17; apple-cpufreq; prior to 3653dfe88ef8):

    • Per policy: schedutil -> powersave (scaling_governor=powersave, cur=300000 kHz, also under a pinned busy loop) -> performance (cur 4380000 kHz on policy0/policy6, 4608000 kHz on policy12) -> schedutil; every write succeeded and ps -e -o comm | grep -c '^sugov' was 0 at every step.
    • stats/total_trans: policy0 1,074 -> 1,100, policy6 1,322 -> 1,345, policy12 2,306 -> 2,344.
    • Clamp: scaling_max_freq 1344000 kHz (policy12: 1308000) under a pinned busy loop: cur=1344000 (policy12 1308000); restoring the original maximum under load: cur=4380000 (policy12 4608000); two more powersave -> schedutil handoffs with the clamp set kept scaling_max_freq at the clamp; all scaling_governor=schedutil, scaling_min_freq=300000, scaling_max_freq 4380000/4380000/4608000 restored afterwards.
    • 0 new error-level dmesg lines during the run; whole boot 0 panics/Oops/BUG/SErrors/DART faults/GPU faults/WARNING lines/LSM denials.
  • Earlier-head J716c run at f735894bca19 (default cmdline):

    • ps -eo pid,comm | grep sugov: 0 threads
    • policy0/policy6/policy12: drv=apple-cpufreq gov=schedutil
    • policy6 clamp to 3504000 kHz -> cur=300000 <= 3504000, powersave -> cur=300000, restore schedutil + 4380000 kHz clean
    • pm_test=devices (echo freeze > /sys/power/state): exit 0, 0 DVFS errors/warnings
  • Earlier live J713 (M4 Air, T8132) at 085f7d94fce2 in batched candidate 76649338a1bc (the J713 default kernel source 8dbfa2895b93 plus the heads of drm/asahi: g16 + t8132: scale CLPC memory states by GPU busy share #3491, arm64: dts: apple: t6050-j716c: wire HPM SPMI interrupts and SMC power sensors #3291, cpufreq: apple-soc: enable lazy verification fast-switch on T6050 #3397, drm/apple: enable static-frame idle caching on firmware 27 panels #3289, ASoC: apple: enable J716c (16-inch M5 Max) AOP audio, v2-only speakers, jack and mic array #3085, phy: apple: atc: enable runtime idle power-off on T8103 #3223, arm64: dts: apple: t6050: allow idle ps_isp_sys domain to power off #3329, PCI/ASPM: add sleep L1SS suppression and deferred D0 PM recheck #3495, thermal: apple-pmp: avoid P-core wakeups for cool idle polling #3546 and drm/asahi: g16: lower governed GPU floor from S3 to S2 #3548, with drm/apple: drive a two-display dock from the firmware-27.2 T8132 dcpexts #3273, drm/apple: soft power-off firmware-27 internal panel on DPMS off #3294 and serial: apple-dockchannel: stop idle console drain timer, back off RX, and add sleep PM #3335 already included; default command line plus panic=10; prior to 3653dfe88ef8), all seven PR files blob-identical, CONFIG_ARM_APPLE_SOC_CPUFREQ=y:

    • scaling_driver=apple-cpufreq, governor schedutil; policy0 cur 1.26 GHz idle, 3.468 GHz under load; policy1 2.892 GHz under load, 0.9-1.08 GHz idle.
    • kprobe events over the load window: cpufreq_driver_fast_switch 69 hits, apple_soc_cpufreq_fast_switch 79 hits, power:cpu_frequency 328 events.
    • one 15 s s2idle cycle: resumed, 0 DVFS errors/warnings, 0 failed units.
    • Booted kernel and Stage 2 hashes: booted kernel image SHA-256 e8e9fd2813dd6347176d0e4a55a70d1c694bdab75817c3ab83c441c203140491, one-shot Stage 2 SHA-256 f7d4e2f7ebbfb423bd71f233f1aef7af0a39091b288a749d25f9250eb80adbfa (default Stage 2 and kernel untouched).
    • Smoke: display (eDP-1 2560x1664@60 enabled; no external monitor or dock attached), input (Apple MTP keyboard and trackpad devices enumerated, not exercised remotely), networking (wlan0 connected, gateway ping 0% loss), permitted audio sink (speakerguardd-v2 active, 1 s tone at -26 dB through the protected default sink, rc 0), GPU rendering (Borealis Apple M4 (G16G B0), Vulkan 1.4.363, glmark2 score 5,099), 0 failed units, 0 AppArmor denials (no SELinux on this userland). err-level dmesg: the three lines the default kernel also logs (apple-dcp 30ae00000.dcp: AFK[ep:20]: failed to extract init props: -2, unsupported DFB layout 2560x1664 format=0x62336138 compression=3 (-22), an apple_sep ... matching unavailable this boot notice) plus one brcmfmac 0000:01:00.0: brcmf_pcie_ring_mb_update_rptr: ring 4: r_ptr 0 outside depth 0 at 9.2 s that no PR in the batch touches.
    • Module build with CONFIG_ARM_APPLE_SOC_CPUFREQ=m at 085f7d94fce2 failed modpost on freq_qos_read_value, resolved by 3653dfe88ef8.

T6050 shares the command-state readback DVFS interface with T8140, where
schedutil fast-switch requests are verified asynchronously by timer
rather than blocking in ->target_index().

Before enabling .lazy_verify = true on soc_t6050_info, tighten two edge
cases in the lazy-verify path:
- Clamp deferred pending_pstate writes in the verify timer and restored
  asked_pstate writes in apple_soc_cpufreq_lazy_cap() against the
  current policy->min / policy->max bounds as well as the thermal
  ceiling.
- Drop any queued pending_pstate and mark waited when fast-switch
  ownership ends (policy->fast_switch_enabled becomes false), so a
  pending schedutil request cannot fire after switching to a static
  governor such as powersave whose target already equals policy->cur.

Enable .lazy_verify = true on soc_t6050_info so schedutil uses
fast-switch without per-cluster sugov threads while ->target_index()
paths keep synchronous verification. Add KUnit coverage for deferred
policy-limit clamping and fast-switch handoff.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team as code owners November 27, 2026 14:40
@erikwb
erikwb requested review from Acelogic and malik-na November 27, 2026 14:40

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

apple_soc_cpufreq_clamp_pstate() ignores a live QoS maximum of zero because it only consumes qos_max > 0. The core's store_scaling_max_freq() passes zero through to freq_qos_update_request(). Before asynchronous policy reconciliation, a busy command's deferred replay can therefore use the previous higher bound, defeating the live-cap promise. Apply zero as a real ceiling and use the lowest valid OPP, consistent with the helper's below-table rule. Please test a pending fast request when the cap falls to zero, including verification before the policy worker runs. The T8140 and active fast-die rows also remain open.

@github-actions github-actions Bot added area:power Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 3653dfe8: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 3653dfe8
Conflicts ok none
PR text ok Risk: two-way · T6050 Macs (J716c, J714s/c, K114/K116), shared lazyverify path on T8140, and shared apple-soc-cpufreq / cpufreqdriverfastswitch() CPUFREQDRIVERUPDATESCUR / freqqosreadvalue() path across Apple Silicon Macs Revert: git revert the PR merge commit (all changes are in-memory cpufreq core, QoS export, stats, frequency-invariance, and driver state; no persistent on-disk, ESP, or firmware state is modified).

Areas: area:power

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

store_scaling_max_freq() and store_scaling_min_freq() pass 0 through to
freq_qos_update_request(), so freq_qos_read_value() returns 0 rather than
a positive frequency when a ceiling or floor is set to 0. Consume
qos_max >= 0 and qos_min >= 0 in apple_soc_cpufreq_clamp_pstate() so a
zero ceiling enforces the lowest valid OPP and a zero floor drops back to
cpuinfo.min_freq immediately, before the asynchronous policy->update
worker runs.

Extend cft_test_verify_policy_cap_lift() to queue a pending fast-switch
request, drop the userspace FREQ_QOS_MAX request to 0 while holding
policy->rwsem so policy->update stays blocked, and verify that both timer
replay and subsequent fast-switch requests clamp to the lowest valid OPP.

Signed-off-by: Erik Bourget <[email protected]>
When fast-switch is enabled, schedutil's ->limits() callback only marks
limits_changed instead of invoking cpufreq_policy_apply_limits(), so a
QoS ceiling drop below an already-accepted high P-state leaves hardware
above the ceiling until the next scheduler utilization callback runs.

Extract apple_soc_cpufreq_lazy_reconcile() and call it from
apple_soc_cpufreq_verify_policy() so the policy worker clamps an active
or pending P-state immediately when new policy bounds tighten, even with
no pending request and no scheduler callback. Narrow the comment in
apple_fast_die_work() to note that immediate restore applies when
asked_pstate has not been overwritten by a post-reconcile capped
fast_switch().

Wire apple_soc_cpufreq_verify_policy into cft_live_driver, add
cft_test_verify_policy_ceiling_drop covering high accepted P-state
clamping with no pending request and no scheduler callback, and update
cft_test_verify_policy_cap_lift to test against the reconciled
policy->max.

Signed-off-by: Erik Bourget <[email protected]>
…lication

When the verify timer replays a pending fast-switch request after a QoS
ceiling drops, apple_soc_cpufreq_verify() commands the clamped P-state
without updating policy->cur, leaving policy->cur stale even after
policy->update runs when expected_pstate is already within bounds.

Additionally, cpufreq_driver_fast_switch() writes policy->cur after
->fast_switch() returns, so a concurrent policy->update or lazy_cap()
reconciliation running right after priv->lock is released can publish
the lower frequency before cpufreq_driver_fast_switch() overwrites
policy->cur with the older value.

Add CPUFREQ_DRIVER_UPDATES_CUR so drivers that synchronize hardware and
policy->cur under an internal lock publish policy->cur directly and
cpufreq_driver_fast_switch() reads READ_ONCE(policy->cur) instead of
overwriting it. Extract apple_soc_cpufreq_publish_cur(), call it from
pending-request replay when the command is accepted, publish policy->cur
under priv->lock in apple_soc_cpufreq_lazy_request() and in
apple_soc_cpufreq_fast_switch(), and add KUnit coverage for both the
zero-ceiling replay without a follow-up fast switch and the
unlock-to-core reconciliation race.

Signed-off-by: Erik Bourget <[email protected]>
Standalone QoS ceiling drops, thermal lazy_cap() updates, and clamped
pending-request replays update hardware and policy->cur under priv->lock
without notifying cpufreq_stats, so stats/time_in_state keeps charging
residency to the old frequency until another transition occurs.

Have drivers setting CPUFREQ_DRIVER_UPDATES_CUR record cpufreq_stats under
their own lock alongside policy->cur instead of calling
cpufreq_stats_record_transition() after ->fast_switch() returns in
cpufreq_driver_fast_switch(), preventing an older fast-switch completion
from overwriting a concurrent clamp's stats. Export
cpufreq_stats_record_transition() for modular builds, extract
apple_soc_cpufreq_record_cur() so fast_switch, async verify replays,
policy->update reconciliations, lazy_cap(), and suspend fallthrough all
update policy->cur and cpufreq_stats atomically under priv->lock, enable
CONFIG_CPU_FREQ_STAT in apple-soc-cpufreq.kunitconfig, and add KUnit
coverage for standalone QoS/thermal/replay clamps and fast-switch races.

Signed-off-by: Erik Bourget <[email protected]>
When DVFS is busy, apple_soc_cpufreq_lazy_set() queues pending_pstate
without writing hardware or updating expected_pstate. Recording
cpufreq_stats alongside optimistic policy->cur publication in
apple_soc_cpufreq_lazy_request() and apple_soc_cpufreq_lazy_reconcile()
caused stats/time_in_state to charge residency to a queued frequency
that hardware never entered if the request was later clamped or dropped
at the verify deadline.

Separate cpufreq_stats_record_transition() from optimistic policy->cur
updates so lazy-path requests and reconciliations only record stats when
hardware accepts the P-state (an immediate non-busy write, an accepted
timer replay, or an idle cluster whose expected_pstate already matches),
while busy-queued requests update policy->cur only. Add KUnit coverage
for busy-then-discarded requests and accepted timer replays.

Signed-off-by: Erik Bourget <[email protected]>
…scale

When a fast-switch request is queued behind busy DVFS, policy->cur holds
the optimistic queued frequency while hardware and cpufreq_stats remain
on the last accepted P-state. Dropping that request on drain or timer
failure left policy->cur optimistic, and calling
cpufreq_freq_transition_begin()/end() across a failing suspend wrote the
unissued suspend target and rolled cpufreq_stats back to the discarded
queued frequency.

Restore policy->cur to expected_pstate when dropping a queued request on
drain or failure, and settle lazy-verify suspend via
apple_soc_cpufreq_set_pstate() before calling
apple_soc_cpufreq_record_cur() so a failed suspend keeps policy->cur and
cpufreq_stats strictly on the last accepted hardware state.

Also update arch_set_freq_scale() from apple_soc_cpufreq_record_cur() on
accepted transitions (exporting topology_set_freq_scale() for modular
builds) and move the core arch_set_freq_scale() call under the
!CPUFREQ_DRIVER_UPDATES_CUR branch in cpufreq_driver_fast_switch() so
standalone clamps and replays update scheduler frequency invariance
immediately without being overwritten by a concurrent fast-switch
completion. Add KUnit coverage for failed suspend with a queued request
and frequency-scale updates across clamps, replays, and races.

Signed-off-by: Erik Bourget <[email protected]>
When a fast-switch request is queued behind busy DVFS, policy->cur holds
the optimistic queued frequency while hardware and cpufreq_stats remain
on expected_pstate. In apple_soc_cpufreq_lazy_set(), clearing
pending_pstate before apple_soc_cpufreq_lazy_write() prevented
apple_soc_cpufreq_fail() from restoring policy->cur to expected_pstate
when a subsequent fast-switch or limit update found an idle register
with an unexpected P-state. Three non-fast-switch discard paths in
apple_soc_cpufreq_get_rate() and apple_soc_cpufreq_verify() also
cleared pending_pstate without restoring policy->cur.

Extract apple_soc_cpufreq_drop_pending() to clear pending_pstate and
restore policy->cur to expected_pstate without charging cpufreq_stats or
frequency scale, use it across all discard paths, and defer clearing
pending_pstate in apple_soc_cpufreq_lazy_set() until
apple_soc_cpufreq_lazy_write() succeeds. Update the governor handoff
KUnit test to expect expected_pstate instead of the discarded queued
frequency, and add KUnit coverage for idle-mismatch discards across
fast_switch(), lazy_cap(), policy->update, and verify timer replay.

Signed-off-by: Erik Bourget <[email protected]>
In lazy-verify suspend, calling apple_soc_cpufreq_set_pstate() followed
by apple_soc_cpufreq_record_cur() kept failed suspends out of
cpufreq_stats and scheduler frequency scale, but skipped
cpufreq_freq_transition_begin()/end() on successful suspend frequency
changes, dropping cpufreq transition notifications and the
power:cpu_frequency trace event.

Snapshot the accepted hardware frequency before calling
apple_soc_cpufreq_set_pstate() in apple_soc_cpufreq_suspend(). When
policy->suspend_freq is set and the hardware transition succeeds at a
different frequency, report it via cpufreq_freq_transition_begin() and
cpufreq_freq_transition_end(..., 0) so power:cpu_frequency, transition
notifiers, cpufreq_stats, policy->cur, and arch_set_freq_scale() are all
updated once without touching stats or tracepoints when suspend fails.

Enable CONFIG_TRACEPOINTS via CONFIG_FTRACE and
CONFIG_ENABLE_DEFAULT_TRACERS in apple-soc-cpufreq.kunitconfig and extend
cft_test_stats_busy_suspend_fail() to verify power:cpu_frequency trace
emission on failed, successful, and no-op suspends.

Signed-off-by: Erik Bourget <[email protected]>
KUnit runs deferred cleanup actions in a separate thread after the test
function returns, so passing a stack-allocated cft_freq_trace to
register_trace_cpu_frequency() risks dereferencing an expired stack
object before cft_unregister_freq_trace() unregisters and synchronizes
the tracepoint.

Allocate trace_ctx in cft_test_stats_busy_suspend_fail() with
kunit_kzalloc() before registering the cleanup action so LIFO teardown
runs unregister_trace_cpu_frequency() and
tracepoint_synchronize_unregister() before the trace context is freed.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb

erikwb commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in ebb208262921, c858fe9190fb, 0b0f4932776b, 8d590f14110f, 5c269a610a54, 8cdb8aea6864, db5b9826138b, e4d2c89e02e2, and 085f7d94fce2 (include/linux/cpufreq.h, drivers/base/arch_topology.c, drivers/cpufreq/cpufreq.c, drivers/cpufreq/cpufreq_stats.c, drivers/cpufreq/apple-soc-cpufreq.c, drivers/cpufreq/apple-soc-cpufreq.kunitconfig, and drivers/cpufreq/apple-soc-cpufreq-test.c).

  • Zero QoS bounds (ebb208262921): apple_soc_cpufreq_clamp_pstate() now consumes qos_max >= 0 and qos_min >= 0 (drivers/cpufreq/apple-soc-cpufreq.c:723-730), so a 0 request from store_scaling_max_freq()/store_scaling_min_freq() enforces the lowest valid OPP (600 MHz / P-state 1 in the test table) or drops the floor back to policy->cpuinfo.min_freq before policy->update runs.
  • Ceiling drop with accepted P-state and no scheduler callback (c858fe9190fb): extracted apple_soc_cpufreq_lazy_reconcile() (drivers/cpufreq/apple-soc-cpufreq.c:930-949) and called it from apple_soc_cpufreq_verify_policy() (drivers/cpufreq/apple-soc-cpufreq.c:1016-1049), so policy->update clamps an active or pending P-state and updates policy->cur immediately when new bounds tighten even though sugov_limits() skips cpufreq_policy_apply_limits() under fast_switch_enabled. Wired apple_soc_cpufreq_verify_policy into cft_live_driver and added cft_test_verify_policy_ceiling_drop() (drivers/cpufreq/apple-soc-cpufreq-test.c:1750-1799) covering a high accepted P-state (15), pending_pstate == -1, QoS ceiling drops (1200 MHz and 0), and flush_work(&policy->update) with the governor stopped.
  • Reconciled policy->max on cap lift (c858fe9190fb): updated cft_test_verify_policy_cap_lift() (drivers/cpufreq/apple-soc-cpufreq-test.c:1801-2024) to remove the manual policy->max overrides and test both cases against the core-reconciled policy->max: immediate restore on thermal lift when no post-reconcile fast_switch() overwrote asked_pstate (tickless cluster), and remaining at 1.2 GHz until the next fast_switch() after policy->update once a post-reconcile fast_switch() recorded asked_pstate = 4.
  • Clamped pending-request replay policy->cur publication (0b0f4932776b): apple_soc_cpufreq_publish_cur() (drivers/cpufreq/apple-soc-cpufreq.c:663-678) is called from apple_soc_cpufreq_verify() (drivers/cpufreq/apple-soc-cpufreq.c:814-817) when a pending fast-switch replay is accepted (!priv->transition_failed), covering both register writes and cases where expected_pstate already matches the clamped state. Updated cft_test_verify_policy_cap_lift() (drivers/cpufreq/apple-soc-cpufreq-test.c:1955-2006) to assert policy->cur == 600000U immediately on replay and after flush_work(&policy->update) with no further cpufreq_driver_fast_switch() call.
  • Core fast-switch vs reconciliation policy->cur ordering (0b0f4932776b): added CPUFREQ_DRIVER_UPDATES_CUR (include/linux/cpufreq.h:495) and updated cpufreq_driver_fast_switch() (drivers/cpufreq/cpufreq.c:2230-2237) to read READ_ONCE(policy->cur) rather than overwriting policy->cur after ->fast_switch() releases priv->lock; apple_soc_cpufreq_lazy_request() (drivers/cpufreq/apple-soc-cpufreq.c:915-917) and apple_soc_cpufreq_fast_switch() (drivers/cpufreq/apple-soc-cpufreq.c:1177-1178) publish policy->cur directly. Added cft_test_fast_switch_reconcile_race() (drivers/cpufreq/apple-soc-cpufreq-test.c:2069-2102) exercising both policy->update and apple_soc_cpufreq_lazy_cap() between priv->lock unlock and cpufreq_driver_fast_switch() completion, and updated cft_test_lazy_policy_limits_and_handoff() (drivers/cpufreq/apple-soc-cpufreq-test.c:1347-1380) for the direct policy->cur update and pending discard restoration.
  • cpufreq_stats accounting on async clamps, fast-switch serialization, busy queueing, and failed suspend (8d590f14110f, 5c269a610a54, 8cdb8aea6864): extracted apple_soc_cpufreq_record_cur() (drivers/cpufreq/apple-soc-cpufreq.c:647-660) to separate optimistic WRITE_ONCE(policy->cur, cur) publication from cpufreq_stats_record_transition(policy, cur), and exported cpufreq_stats_record_transition() (drivers/cpufreq/cpufreq_stats.c:290) for modular builds. Updated cpufreq_driver_fast_switch() (drivers/cpufreq/cpufreq.c:2230-2237) so drivers setting CPUFREQ_DRIVER_UPDATES_CUR handle policy->cur and stats themselves while the core skips the unlocked post-return cpufreq_stats_record_transition(), preventing an older fast-switch completion from overwriting a concurrent clamp's stats. Under priv->lock, apple_soc_cpufreq_lazy_set() (drivers/cpufreq/apple-soc-cpufreq.c:841-882) reports @accepted so apple_soc_cpufreq_lazy_request() (drivers/cpufreq/apple-soc-cpufreq.c:915-917), apple_soc_cpufreq_lazy_reconcile() (drivers/cpufreq/apple-soc-cpufreq.c:943-948), and accepted timer replays in apple_soc_cpufreq_verify() (drivers/cpufreq/apple-soc-cpufreq.c:814-817) call cpufreq_stats_record_transition() only when hardware accepts the P-state, while busy-queued requests update policy->cur only. apple_soc_cpufreq_suspend() (drivers/cpufreq/apple-soc-cpufreq.c:1106-1135) calls apple_soc_cpufreq_set_pstate() first (restoring policy->cur to priv->expected_pstate on failure when policy->suspend_freq is set), so a failed suspend keeps policy->cur and cpufreq_stats (total_trans, trans_table, time_in_state) strictly on the last accepted hardware state; after a successful configured policy->suspend_freq frequency change it reports the transition through cpufreq_freq_transition_begin()/cpufreq_freq_transition_end(..., 0) (drivers/cpufreq/apple-soc-cpufreq.c:1130-1131, detailed in the suspend bullet below) rather than recording it directly, and only a same-frequency or !policy->suspend_freq suspend calls apple_soc_cpufreq_record_cur() (:1133). Enabled CONFIG_CPU_FREQ_STAT=y in drivers/cpufreq/apple-soc-cpufreq.kunitconfig and added cft_test_stats_clamp_and_race() (drivers/cpufreq/apple-soc-cpufreq-test.c:2254-2431), cft_test_stats_busy_then_discard() (drivers/cpufreq/apple-soc-cpufreq-test.c:2439-2600), and cft_test_stats_busy_suspend_fail() (drivers/cpufreq/apple-soc-cpufreq-test.c:2608-2709).
  • Cpufreq-based frequency invariance scale updates (8cdb8aea6864): Apple Silicon arm64 clusters have no AMU counters and use cpufreq-based frequency invariance (arch_set_freq_scale() -> topology_set_freq_scale()). Updated apple_soc_cpufreq_record_cur() (drivers/cpufreq/apple-soc-cpufreq.c:647-660) to call arch_set_freq_scale(policy->related_cpus, cur, max_freq) (using arch_scale_freq_ref(policy->cpu) ?: policy->cpuinfo.max_freq) alongside cpufreq_stats_record_transition() on accepted transitions, exported topology_set_freq_scale() (drivers/base/arch_topology.c:163) for modular builds, and moved arch_set_freq_scale() into the !CPUFREQ_DRIVER_UPDATES_CUR branch of cpufreq_driver_fast_switch() (drivers/cpufreq/cpufreq.c:2223-2237, include/linux/cpufreq.h:490-495) so standalone clamps and timer replays update scheduler frequency invariance immediately without an older ->fast_switch() return overwriting it. Verified arch_scale_freq_capacity() across fast-switch, standalone clamps, timer replays, unlock-to-core races, busy discards, and suspend in cft_test_stats_clamp_and_race(), cft_test_stats_busy_then_discard(), and cft_test_stats_busy_suspend_fail().
  • Restore policy->cur on all pending-request discards (db5b9826138b): extracted apple_soc_cpufreq_drop_pending() (drivers/cpufreq/apple-soc-cpufreq.c:683-692) to clear pending_pstate and restore policy->cur to expected_pstate without touching cpufreq_stats or frequency scale across apple_soc_cpufreq_fail() (drivers/cpufreq/apple-soc-cpufreq.c:581-588), apple_soc_cpufreq_drain() (drivers/cpufreq/apple-soc-cpufreq.c:1002), apple_soc_cpufreq_get_rate() (drivers/cpufreq/apple-soc-cpufreq.c:441), and the non-fast-switch discard branches of apple_soc_cpufreq_verify() (drivers/cpufreq/apple-soc-cpufreq.c:792-807), and deferred clearing priv->pending_pstate in apple_soc_cpufreq_lazy_set() (drivers/cpufreq/apple-soc-cpufreq.c:871-881) until apple_soc_cpufreq_lazy_write() succeeds so an idle-mismatch failure inside apple_soc_cpufreq_fail() always restores policy->cur from expected_pstate. Updated cft_test_lazy_policy_limits_and_handoff() (drivers/cpufreq/apple-soc-cpufreq-test.c:1340-1378) to assert policy->cur == 1800000U after governor handoff discards a pending request (both idle and busy) and added cft_test_stats_idle_mismatch_discard() (drivers/cpufreq/apple-soc-cpufreq-test.c:2799-2897) covering idle-mismatch discards across fast_switch(), lazy_cap(), policy->update, and verify timer replay.
  • Suspend power:cpu_frequency transition notifications (e4d2c89e02e2, 085f7d94fce2): apple_soc_cpufreq_suspend() (drivers/cpufreq/apple-soc-cpufreq.c:1106-1135) now snapshots the accepted expected_pstate frequency before calling apple_soc_cpufreq_set_pstate(), and when policy->suspend_freq is set and the hardware transition succeeds at a different frequency, reports it via cpufreq_freq_transition_begin() and cpufreq_freq_transition_end(..., 0) instead of apple_soc_cpufreq_record_cur(), so power:cpu_frequency, transition notifiers, cpufreq_stats, policy->cur, and arch_set_freq_scale() update once without double-counting, while failed or same-frequency suspends emit no spurious transition or trace event. Enabled CONFIG_TRACEPOINTS via CONFIG_FTRACE=y and CONFIG_ENABLE_DEFAULT_TRACERS=y in drivers/cpufreq/apple-soc-cpufreq.kunitconfig and extended cft_test_stats_busy_suspend_fail() (drivers/cpufreq/apple-soc-cpufreq-test.c:2635-2771) with register_trace_cpu_frequency() assertions covering failed, successful, and no-op suspends, allocating trace_ctx via kunit_kzalloc() before registering the cleanup action (085f7d94fce2) so LIFO teardown unregisters and synchronizes the tracepoint before freeing trace_ctx.

Verified at 085f7d94fce2:

  • ./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/cpufreq/apple-soc-cpufreq.kunitconfig: 90/90 passed (72/72 in apple_soc_cpufreq + apple_soc_cpufreq_policy, with CONFIG_CPU_FREQ_STAT=y and CONFIG_TRACEPOINTS=y).
  • make ARCH=arm64 LLVM=1 O=.kunit W=1 KCFLAGS="-Werror" -j32 drivers/cpufreq/apple-soc-cpufreq.o clean at 085f7d94fce2 (make ARCH=arm64 LLVM=1 O=_build defconfig matrix with CONFIG_CPU_FREQ_STAT=y/n, CONFIG_ARM_APPLE_SOC_CPUFREQ=m/y, W=1 KCFLAGS="-Werror" clean at e4d2c89e02e2; 085f7d94fce2 touches drivers/cpufreq/apple-soc-cpufreq-test.c only).
  • ./scripts/checkpatch.pl --strict --git e4d2c89e02e2..HEAD: 0 errors, 0 warnings, 0 checks on 085f7d94fce2 (and 0/0/0 across f735894bca19..e4d2c89e02e2).

J716c live hardware at 085f7d94fce2 (batched candidate c3da8eed6f72, default command line): 0 sugov kthreads, apple-cpufreq with schedutil on policy0/6/12, a scaling_max_freq clamp to 1344000 kHz (policy12: 1308000 kHz) applied within 50 ms with stats/total_trans and time_in_state updated immediately on the standalone clamp (6590 -> 6593), and restore on all three policies including after 2x pm_test=devices suspend/resume. The schedutil -> powersave -> performance -> schedutil handoff was re-run on policy0/6/12 at 085f7d94fce2 (four-PR batched candidate f59b93fb961f, default command line): every step took effect with 0 sugov kthreads, stats/total_trans advanced on all three policies, a scaling_max_freq clamp held under load and lifted cleanly, the original governors and limits were restored, and the boot had 0 new error-level kernel lines, panics, Oops, BUG, SErrors, DART faults and LSM denials. T8140 and active apple,fast-die-effort hardware rows remain open because no T8140 or J714s hardware is on site.

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

Zero is now handled as a real QoS bound, including before core policy reconciliation. The revised core contract leaves accepted-state accounting and frequency invariance with the driver for its opt-in path, while default drivers retain core accounting. Code approved. The reported KUnit and J716c results cover clamp and governor handoff; T8140 and active fast-die-effort hardware coverage remains open.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 27, 2026
Modular cpufreq drivers that enforce live QoS bounds synchronously from
fast-switch or hrtimer paths before the asynchronous policy->update
worker runs need to read &policy->constraints directly via
freq_qos_read_value(). Without an export, building
CONFIG_ARM_APPLE_SOC_CPUFREQ=m fails modpost with undefined symbol
freq_qos_read_value.

Export freq_qos_read_value() with EXPORT_SYMBOL_GPL(), matching the
other freq_qos_* helpers in kernel/power/qos.c.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Hardware at 085f7d94fce2 on J713 (M4 Air, T8132, second family), batched candidate 76649338a1bc with all seven PR files blob-identical, booted kernel SHA-256 e8e9fd2813dd6347176d0e4a55a70d1c694bdab75817c3ab83c441c203140491, one-shot Stage 2 SHA-256 f7d4e2f7ebbfb423bd71f233f1aef7af0a39091b288a749d25f9250eb80adbfa:

  • apple-cpufreq with schedutil; policy0 reached 3.468 GHz and policy1 2.892 GHz under 8 busy loops and returned to 1.26 GHz and 0.9-1.08 GHz at idle.
  • kprobes over the load window: cpufreq_driver_fast_switch 69 hits, apple_soc_cpufreq_fast_switch 79 hits, power:cpu_frequency 328 events, so the fast-switch path is live on T8132.
  • 15 s s2idle resumed with 0 DVFS errors or warnings; 0 failed units, 0 LSM denials, display/input/networking/audio sink/GPU smoke clean.

At 085f7d94fce2, building with CONFIG_ARM_APPLE_SOC_CPUFREQ=m (the value in aurora_defconfig, defconfig, and asahi.config) failed at modpost with ERROR: modpost: drivers/cpufreq/apple-soc-cpufreq.ko: symbol 'freq_qos_read_value' undefined! because kernel/power/qos.c did not export freq_qos_read_value while apple_soc_cpufreq_clamp_pstate() calls freq_qos_read_value(&policy->constraints, ...) under priv->lock to read live QoS bounds before the asynchronous policy->update worker runs.

Follow-up commit 3653dfe88ef8 fixes the modular build by adding EXPORT_SYMBOL_GPL(freq_qos_read_value) in kernel/power/qos.c, matching the other freq_qos_* helpers exported there.

Local verification at 3653dfe88ef8:

  • aurora_defconfig modular (CONFIG_ARM_APPLE_SOC_CPUFREQ=m, CONFIG_CPU_FREQ_STAT=y): kernel/power/qos.o, drivers/cpufreq/cpufreq.o, drivers/cpufreq/cpufreq_stats.o, drivers/base/arch_topology.o, and drivers/cpufreq/apple-soc-cpufreq.o built cleanly with W=1 KCFLAGS="-Werror", and full Image modules (including modpost of drivers/cpufreq/apple-soc-cpufreq.ko) passed.
  • aurora_defconfig built-in (CONFIG_ARM_APPLE_SOC_CPUFREQ=y, CONFIG_CPU_FREQ_STAT=y): all five touched files built cleanly with W=1 KCFLAGS="-Werror" and Image linked cleanly.
  • arm64 QEMU KUnit (apple-soc-cpufreq.kunitconfig): 90/90 passed (72/72 apple_soc_cpufreq* subtests + 18 apple-clpc* subtests).
  • checkpatch.pl --strict --git 085f7d94fce2..HEAD (0/0/0), git diff --check 124e30a6718d..HEAD clean, and git merge-tree --write-tree origin/main HEAD clean (f85ee42b936a).

Live modular (CONFIG_ARM_APPLE_SOC_CPUFREQ=m) hardware at 3653dfe88ef8 (2026-11-28):

  • J716c (T6050, batched 3545ebecb76f, 8/8 PR files blob-identical, default cmdline): Image.gz d56efde4c7232208bd29d5c4e5890319e0050595dd4f4b1c3844df6656a08312, Stage 2 b7d99286395ddd7dadccc6d9593f4bd55391d9e787af97c18b45f58688d9885d; apple_soc_cpufreq.ko loaded (65,536 B, used by macsmc_hwmon), 0 sugov threads across all steps, initial policy inventory apple-cpufreq + schedutil on policy0/6 (300 MHz..4.38 GHz) and policy12 (300 MHz..4.608 GHz), policy0 scaling_max_freq clamped to 300 MHz (cur=300 MHz under load) and restored to 4.38 GHz (unpinned load still read cur=300 MHz after lift; pinned all-policy lift passed at 085f7d94fce2), policy0 performance (4.38 GHz) -> powersave (300 MHz) -> schedutil (1.644 GHz) handoffs clean, 4× pm_test=devices + 2× pm_test=platform clean, 6-item smoke pass (aurora-peripherals.service warm-reboot baseline failure also on default/control).
  • J713 (T8132, combined #3546+#3397 trial cebaa4e73e6268f14de680996a76fa94d301be8a675b7614044da050d4223f73, 8/8 PR files blob-identical including kernel/power/qos.c, default cmdline + panic=10): 3653dfe88ef8 fixed the freq_qos_read_value modpost failure; apple-soc-cpufreq.ko (d57969517ec3c01db5a4d0d3075b62aefa3e37d016fc6e949c82eda355d934e5) linked as =m, booted cleanly via one-shot GRUB, and loaded in lsmod (macsmc_hwmon, apple_pmp_thermal), with boot smoke passing (0 failed units, 0 AppArmor denials). ktb.sh cpufreq was not run before the combined #3546+#3397 candidate became unreachable during #3546's hot s2idle retest (cause unresolved; baseline default kernel survived the same hot s2idle procedure, while no #3397-only control ran; fast-switch kprobes and s2idle passed as =y at 085f7d94fce2, and 3653dfe88ef8 only adds EXPORT_SYMBOL_GPL(freq_qos_read_value)).

Still under **Not yet:**: J713 modular ktb.sh cpufreq re-check, J313 (T8103) non-regression row at 3653dfe88ef8, and T8140 / apple,fast-die-effort hardware rows.

@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 3653dfe8 once the queued CI checks pass.

Blockers: none in code (queued CI pending).

Checked: Delta commit 3653dfe88e (kernel/power/qos.c) over previously approved 085f7d94fc, modular (=m) and built-in (=y) link/build verification, KUnit results, and J716c + J713 hardware rows.

Evidence
  • Delta since approved 085f7d94fc (3653dfe88e): Single-line EXPORT_SYMBOL_GPL(freq_qos_read_value); in kernel/power/qos.c, matching adjacent freq_qos_* exports and resolving the CONFIG_ARM_APPLE_SOC_CPUFREQ=m modpost undefined-symbol failure.
  • Verification at 3653dfe88e: Clean W=1 KCFLAGS="-Werror" builds and full Image + modules link for both =m and =y, arm64 QEMU KUnit apple-soc-cpufreq.kunitconfig 90/90 (72/72 apple_soc_cpufreq* + 18 apple-clpc*), checkpatch --strict 0/0/0, live modular J716c (T6050) verification (0 sugov threads), and second-family J713 (T8132) live fast-switch (cpufreq_driver_fast_switch / apple_soc_cpufreq_fast_switch / power:cpu_frequency hits) + s2idle PASS.

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 3653dfe8. App approved (NEON-PR-REVIEW2); rows J716c-modular+host, export-only. Merges under the 6-point rule 1 h from now once hosted CI is green, unless you object.

@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) and removed blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) labels Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at 3653dfe8. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J716c-modular+host;export-only. (5) There's no blocking review. (6) Dj was pinged here 804 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 03d38e8 into main Nov 29, 2026
18 of 23 checks passed
@RyanTheTide
RyanTheTide deleted the feat/cpufreq-t6050-lazy-verify branch November 29, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:power Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants