Skip to content

arm64: dts: exynos: google: zumapro: C2 idle states and the CPU energy model (Pixel 9a) - #280

Draft
den-kloot wants to merge 2 commits into
derekross:omamobilefrom
den-kloot:zumapro-c2-idle-em
Draft

den-kloot wants to merge 2 commits into
derekross:omamobilefrom
den-kloot:zumapro-c2-idle-em

Conversation

@den-kloot

Copy link
Copy Markdown
Contributor

Two commits for zumapro (Pixel 9a). Both only touch zumapro.dtsi.

  1. C2 idle states. Before this, cpuidle/current_driver read none and idle cores only ever sat in WFI. I took the per-cluster c2 states (hayes, hunter and hunterelp) from Google's zumapro-cpu.dtsi.
  2. CPU energy model. I added an opp-microwatt on all 39 CPU OPPs, from stock's pixel-em profile in zumapro-a1-ipop.dts ("default"), the same way zuma got its model in 82f31d3. That fixes EM: invalid perf. state: -22 at boot. It also lets EAS run and power_allocator bind, which came up in Pixel 9a: a full CPU load reaches the 105 °C critical trip in ~8 s and powers the phone off (big zone rises faster than step_wise throttles) omamobile#605. The two lowest cl0 OPPs (324 and 610 MHz) are missing from the profile. For those I scaled 820 MHz by frequency, which can only underestimate them.

Tested on a Pixel 9a over a 15 h boot on 7.3.0-rc6 (…-push1-g99b24b34811e), 2026-11-20/21. That kernel carries these same zumapro.dtsi hunks; only my unrelated local commits differ. This branch is the same change rebased onto today's omamobile (82e3cf0), a clean apply.

without idle states (night 14/15 Nov) with this (night 21 Nov, 02:01–07:01)
screen off, Wi-Fi up, modem registered (awake: suspend stays blocked with the modem up) Ø 560 mA, never under 490 Ø 464 mA, min 385
  • Full discharge on this kernel: 100 % → UPower's 2 % in 10 h 05 min, with 31 min of screen on. The screen-off minutes averaged 481 mA. The gauge ran on its POR defaults (power: supply: max77779: report the gauge after a power-on reset #234), so read the percentages loosely.
  • Cores 93 % idle, 68 % of that in c2. Every cluster enters c2 (state1/usage is non-zero on cpu0, cpu4 and cpu7).
  • No hang and no watchdog reset during that boot.
  • /sys/kernel/debug/energy_model lists cpu0, cpu4 and cpu7, and sched_energy_aware is 1. Writing power_allocator to big-thermal's policy now works; before, it failed with "cpufreq-cpu7 is not a power actor". I set it back to step_wise.
  • Performance: my benchmark, A/B with c2 disabled through cpuidle/state1/disable, came out −2.0 %, within its noise (mostly flash reads). I see no cost from c2.

Not shown: zumapro has no mainline MCT, so a core in c2 gets its tick from the broadcast hrtimer, and one core stays out of c2 for that. This also doesn't show whether the s2idle watchdog problem in derekross/omamobile#765 goes away. I couldn't test a suspend, because the modem inhibitor blocks it.

Checks: checkpatch.pl --strict reports 0/0/0 on both commits. make W=1 exynos/google/zumapro-tegu.dtb (LLVM) builds without warnings, and the built DTB has 8 cpu-idle-states and 39 opp-microwatt.

Measured on my phone with Claude.

🤖 Generated with Claude Code

zumapro.dtsi has no idle states, so on the Pixel 9a cpuidle has no
driver (current_driver reads "none") and an idle core only ever waits
in WFI.

Add the C2 state of each core type as Google's zumapro-cpu.dtsi has it
(android.googlesource.com kernel/devices/google/zumapro, 8831630): one
"c2" state per cluster with PSCI suspend parameter 0x0010000 and stock's
entry/exit latencies and minimum residencies, for the A520 (hayes), the
A720 (hunter) and the X4 (hunterelp).

Measured on a Pixel 9a with this on 7.3.0-rc6 (2026-11-20/21, menu
governor): psci_idle registers WFI and c2 on all eight cores, and c2 is
entered on every cluster. In a night with the screen off, Wi-Fi
associated and the modem registered (suspend stays blocked with the
modem up, so the phone is awake), the battery drew 464 mA on average
(minimum 385 mA, 5 h, 5-minute samples), against 560 mA (never under
490 mA) in a comparable night without idle states; the cores were 93 %
idle, 68 % of that in c2. A full discharge from 100 % to UPower's 2 %
took 10 h 05 min with 31 min of screen-on time; the screen-off minutes
averaged 481 mA. No hang or watchdog reset in the 15 h of that boot.

zumapro has no mainline MCT (stock uses its own exynos-mct-v3 at
0x100d0000), so with local-timer-stop the tick of a core in c2 goes
through the broadcast hrtimer, which keeps one core out of c2.

Assisted-by: LLM
Signed-off-by: kloot <1522975+den-kloot@users.noreply.github.com>

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this, and for doing it carefully. I checked both commits against Google's files at 8831630: the three idle states match zumapro-cpu.dtsi line for line, and 37 of the energy model's 39 values are exactly the "default" profile in zumapro-a1-ipop.dts, the other two being your estimates. Each commit builds without a dtc warning, and CI is green on today's branch.

The energy model first, because it's the easy one. With these numbers the kernel's energy model finds every little-core OPP below 1197 MHz less efficient than 1197 itself (Google's power barely rises from 820 to 1197 MHz), marks them inefficient, and schedutil then skips them, so the little cores run at 1197 MHz and above. That follows Google's data and is probably part of the saving you measured, but it is a real change for every 9a, so could you say it in the commit message, and post cpu0's cpufreq/stats/time_in_state from a boot with the commit? It also means the two estimated values don't matter in practice.

C2 is the part I need to think about. On the 9a, C2 during s2idle is one of the known causes of the silent no-wake, and what keeps it out of a sleep today is the device package's sleep hook (0.2.11 and later), which every logind sleep runs; a write to /sys/power/state or rtcwake -m mem doesn't. The 9a's sleep plan also left one question for exactly this moment: zuma's PMU data has no CPU hint handshake, which exynos-pmu.c describes as needed for CPU idle states on gs101, and the plan asked for that comparison before idle states came to a PR. I'll look at that and decide whether C2 goes in on this footing. Either way, before it merges I'd like one attended sleep run on this kernel: RTC-woken systemctl suspend sleeps with the modem off, on the charger, with the hook's /var/log/omamobile/cpuidle-sleep.log lines, each CPU's cpuidle/state1/time before and after each sleep (it should grow by far less than the sleep's length), and the wake source and length of each. Please also give the blob id of zumapro.dtsi in the kernel you ran, and what else that tree carries: the boot so far had no sleep in it.

If C2 takes longer, the energy model can land on its own once its message says what it does to the little cores; tell me if you'd like to split it.

The zumapro CPU OPPs carry only opp-hz: ACPM sets the voltage, so there
is no opp-microvolt. The OPP core computes the energy model's power
from dynamic-power-coefficient and the voltage, gets nothing, and at
boot every CPU fails with "EM: invalid perf. state: -22". So there is no
energy-aware scheduling, and the power_allocator thermal governor
refuses to bind ("cpufreq-cpu7 is not a power actor").

As was done for zuma, give every OPP an opp-microwatt taken from
stock's pixel-em profile. The Pixel 9a is an A1 part in the IPOP
package (bootconfig hw.soc.rev=1, pkg_mode=1), so the values are the
"default" profile of Google's zumapro-a1-ipop.dts (kernel/devices/
google/zumapro, 8831630). That profile has no entries for the two
lowest cl0 OPPs, 324 and 610 MHz; those two are 820 MHz's power scaled
by frequency (14600 and 27500 uW), which can only underestimate them.

Measured on a Pixel 9a (2026-11-20/21): no "EM: invalid perf. state"
at boot, /sys/kernel/debug/energy_model lists cpu0, cpu4 and cpu7 with
these values, sched_energy_aware reads 1, and power_allocator now binds
to big-thermal (written to its policy and back to step_wise).

This changes the little cores' frequencies on every Pixel 9a. In
Google's profile the A520's power rises little from 820 to 1197 MHz, so
the energy model finds each cl0 OPP below 1197 MHz less efficient than
1197 MHz itself and marks it inefficient, and schedutil skips those
(324, 610, 820, 955 and 1098 MHz): the A520 cores run at 1197 MHz and
above. On a boot with this (1 h 28 min, screen on and off, schedutil,
scaling_min_freq 324000), cpu0's time_in_state is 0 at each of those
five and 3772 s at 1197 MHz. So the two estimated values above aren't
used in practice. The A720 and X4 clusters keep their lowest OPPs
(cpu4 spent most of that boot at 357 MHz, cpu7 at 700 MHz).

Assisted-by: LLM
Signed-off-by: kloot <1522975+den-kloot@users.noreply.github.com>
@den-kloot

Copy link
Copy Markdown
Contributor Author

@derekross, the energy model part is in c9270eb1 (only its message changed, the tree is the same as 35b857ab): a paragraph says that the cl0 OPPs below 1197 MHz are marked inefficient and skipped, so the A520 cores run at 1197 MHz and above on every 9a, and that the two estimated values aren't used in practice.

cpu0's cpufreq/stats/time_in_state on a boot with the commit (1 h 28 min up, screen on and off, schedutil, scaling_min_freq 324000), in 10 ms units:

324000 0
610000 0
820000 0
955000 0
1098000 0
1197000 377185
1328000 48092
1425000 14827
1548000 12289
1696000 26644
1849000 9442
1950000 39766

The other clusters keep their lowest OPPs: cpu4 spent 366407 at 357 MHz, cpu7 248023 at 700 MHz.

The kernel I ran. zumapro.dtsi in it is blob a51460f417917134440879b7f4a58dbc87d8a7c8; on this PR's branch it is 5cd2bbf72af4fcdbe16c115e2dd75b94f6581417. The difference is 80 added lines, all of them the ISP front end's camera nodes (sysreg_ispfe, csis0/1/6, the DC-PHY), none of them about CPUs, idle states, OPPs or timers. The tree is omamobile 82e3cf0b7 plus this PR's two commits plus:

I checked zumapro-tegu.dts's changes for CPU, idle, OPP and thermal lines: the only cpu nodes it adds are the sound card's DAI links.

The attended sleep run isn't done yet. It needs the modem off for the boot, and that's the owner's call on this phone, so it'll come in a later comment with everything you listed: the hook's cpuidle-sleep.log lines, each CPU's state1/time before and after each sleep, and the wake source and length of each sleep.

On splitting: either way is fine with me. If C2 needs the PMU hint question settled first, I'll split the energy model out as soon as you say so.

Measured on my phone with Claude.

@derekross

Copy link
Copy Markdown
Owner

Decision: the energy model can land on its own. The C2 idle states wait for SLEEP-PLAN item 4 (the CPU hotplug handshake) and a sleep series, because C2 entered through s2idle is a known cause of the 9a not waking and today only the sleep hook keeps it out.

@den-kloot

Copy link
Copy Markdown
Contributor Author

Following your decision, the energy model is now on its own in #300 (the same commit, rebased onto today's omamobile without conflicts, all checks ok). This PR stays open for the C2 idle states until SLEEP-PLAN item 4 and the sleep series are done. Once #300 is in I'll rebase it to the C2 commit alone.

Posted from the owner's account by an AI coding agent (Claude Code), at the owner's request.

@den-kloot
den-kloot marked this pull request as draft November 25, 2026 19:57

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @den-kloot, for the split and the answers. Everything round 66 asked about the energy model is now in #300, and the tested tree's blob ids and contents are exactly what I needed. This one stays as decided: the C2 states wait for the CPU hotplug handshake question in the 9a's SLEEP-PLAN (item 4) and the attended sleep series. Once #300 is in, a plain rebase onto omamobile will drop the energy-model commit here by itself, since it's the same patch.

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.

2 participants