Skip to content

omamobile-device-tegu: keep the cores out of C2 through a sleep (the 9a's silent no-wake) - #591

Merged
derekross merged 2 commits into
derekross:mainfrom
W4HO-ham:tegu-sleep-cpuidle-hook
Nov 10, 2026
Merged

derekross merged 2 commits into
derekross:mainfrom
W4HO-ham:tegu-sleep-cpuidle-hook

Conversation

@W4HO-ham

@W4HO-ham W4HO-ham commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

The fix for the second of the Pixel 9a's two suspend failures (device/tegu SLEEP-PLAN S1, #409): the silent no-wake. With every core in the core power-down state (C2) entered through s2idle's own path, the palmtop sometimes never woke, not from the RTC alarm and not from the power key, after 6 to 135 sleeps. With C2 off for the sleep, 300 of 300 RTC-woken sleeps came back. This is the sleep hook the review of kernel #224 suggested in place of that PR's google,no-s2idle property.

/usr/lib/systemd/system-sleep/omamobile-tegu-cpuidle: before a sleep it disables every idle state deeper than state0 that is enabled, on every CPU, and notes which; after the wake it enables the noted ones again, so the cores still power down while the palmtop is awake. A state disabled by hand stays disabled. On a kernel without deeper states (the published zumapro device tree has none yet) it does nothing, and it only logs while /etc/omamobile/cpuidle-keep-across-sleep exists, for testing C2 in the sleep on purpose. Like the NFC hook, it covers a systemd sleep only.

This hook has been here before. #255 proposed the same hook under the same name on 11-01 and I withdrew it the same day: its reason then, sleeps that ended after a second, was my measurement error (dmesg deltas across a suspend). The reason now is a different and measured one, the no-wake above, with the 300 of 300 behind it. What #255's closing note said about cost still holds: with WFI only, the s2idle loop doesn't freeze the tick, so the sleep is shallower than C2 would make it. On this kernel that costs nothing measurable yet (the drain asleep is about 300 mA either way, because nothing below the CPUs sleeps), and a sleep that always wakes comes first; when C2's wake path is understood (the PMU handshake the review of kernel #224 points at), the hook goes away or turns into the keep flag's default.

On the palmtop (2026-11-09)

The owner's integration kernel, 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty build #100, whose C2 states carry the old google,no-s2idle property. Each row is one 60 s RTC-woken systemctl suspend with every CPU's cpuidle/state0 and state1 usage and time read just before and just after (device/tegu/bringup/sleep-cpuidle-check.sh on #409's branch; the maintainer's read-only check):

Sleep state1 (C2) per core over the sleep state0 (WFI) per core Woke
Without the hook, as that kernel ships 19.9 to 57.1 s, 99 to 210 entries the rest RTC alarm, no UFS line
state1/disable set by hand for the sleep 0.0 s, 0 entries 61.8 to 62.0 s RTC alarm, no UFS line
With this hook installed, nothing by hand 0.7 to 2.3 s (the awake seconds inside the two snapshots) 61.9 to 63.5 s RTC alarm, no UFS line

The hook's log for the third: pre: 8 deeper idle states disabled for the sleep, post: 8 idle states enabled again; state1/disable read 0 on all eight CPUs before and after. The first row is also the answer to the review's question on kernel #224: with enter_s2idle cleared, the cores did spend the sleep in C2 through the ordinary idle path.

What this rests on from before: the 300 of 300 with state1 disabled for the whole run (#96, 2026-11-07/08), and the no-wakes with C2 through s2idle's own path (18, 6 and up to 135 sleeps). A long series with the hook itself, in place of the by-hand disable, hasn't run yet; it is the same sysfs write, and I'll run one and add it here.

Tests

test/sleep-hooks (a scratch /sys with two CPUs and two deeper states: disabled before, the hook's own enabled again after, a hand-disabled one left alone, no note left; the keep flag; a kernel without deeper states), test/all (staged and executable), tools/pr-check origin/main, shellcheck -S warning.

The version is yours at merge; I used 0.2.11, which #372 and #590 also pass.

With every core in the core power-down state (C2) entered through s2idle's own path the Pixel 9a sometimes never woke, after 6 to 135 sleeps; with C2 off for the sleep 300 of 300 RTC-woken sleeps came back. A systemd-sleep hook disables every idle state deeper than state0 before the sleep and enables the ones it disabled after the wake, so the cores still power down while awake. It does nothing on a kernel without deeper states (the published device tree has none yet) or while /etc/omamobile/cpuidle-keep-across-sleep exists, and a sleep written straight to /sys/power/state skips it, as it skips the NFC hook.
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. This is the hook I had in mind, and the three-row table
is the right evidence for it: 0.7 to 2.3 s of state1 with the hook
installed, against 19.9 to 57.1 s without, read through systemctl suspend,
so the hook really ran. I read the kernel side too: a state disabled through
sysfs is skipped by both idle-state searches, so the sleep falls through to
WFI on the ordinary path, which is what #96 had. Thank you also for saying up
front that #255 was the same hook and why the reason is different this time.

I ran the checks and the sleep-hooks test on a merge with today's main; all
pass. Two things before I merge it:

  1. A second pre without a post loses the note. pre starts with
    rm -f "$N". If post didn't run after the previous pre (systemd-sleep
    killed or timed out between the two passes), the next pre deletes the
    note, sees every deeper state already disabled, takes them for
    hand-disabled, and post then restores nothing: C2 stays off for the rest
    of the boot with no log line saying so. I tried it on a scratch /sys
    with two CPUs: after pre, pre, post, both state1/disable files
    still read 1. It fails in the safe direction, but restoring is what the
    hook promises. Could pre keep an existing note (append, then sort -u)
    instead of deleting it, with a pre; pre; post line in the test?
  2. The series through the hook. You say it's still to come, and I'd like
    it in before the merge: a few dozen RTC-woken systemctl suspend cycles
    with the hook installed and nothing set by hand, the first run attended,
    with the hook's log and state1/disable read back at the end.

Smaller, not blocking: post could log a failed write the way pre does.
And since your published-tip run on kernel #224 had a no-wake on a kernel
with no idle states at all, I'll word the merge message as "keeps C2 out of
the sleep" rather than "the fix" until the rerun tells us what that was. The
README row and the header say only what was measured, so they're fine as
they are.

I'll set the version at merge (0.2.11 is free today).

…'s states before a new sleep

A pre pass whose post pass never ran left its note behind, and the next pre deleted it, took the states it had disabled itself for hand-disabled ones, and the post then restored nothing: C2 stayed off for the rest of the boot with no log line. The pre pass now enables a leftover note's states first, which also keeps the keep flag honest, and both passes log a write that fails. The test runs pre, pre, post, the keep flag after a leftover, and a state that can't be written.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Both points are in.

1. A second pre without a post (0ad07b22). You're right, and I went one step past "append and sort -u": pre now enables a leftover note's states first, then starts fresh. That gives the same end state for pre; pre; post, and it also keeps the keep flag honest: with a leftover note and the flag set since, appending would have left the earlier sleep's states off through the kept sleep. The leftover is logged ("the note of a sleep whose post pass never ran"). The test runs pre; pre; post (all three states back, the hand-disabled one untouched), the leftover with the keep flag set since, and a state that can't be written. post logs a failed write now, as pre did; while there I found the 2>/dev/null didn't cover a failed open of the sysfs file, so both writes are wrapped.

2. The series through the hook (2026-11-09, 19:32 to 20:17 MST, 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty build #100, the hook file identical to this head's, installed in the palmtop's package build; on the charger, cable in, modem off for the boot, Wi-Fi kept loaded; the owner in the room for the start, not watching the screen):

  • sleep-series-loop.sh with WFI=0, so the series set nothing by hand: state1/disable read 00000000 at the start, no keep flag.
  • 40 of 40 RTC-woken systemctl suspend sleeps of 60 s (59.0 to 60.5 s by dmesg), every one on the alarm (pm_wakeup_irq 56 on this kernel), no UFS line, no oops, suspend_stats 40 and 0.
  • The hook's log has exactly 80 lines: 40 pre: 8 deeper idle states disabled for the sleep and 40 post: 8 idle states enabled again, nothing else.
  • Read back at the end: state1/disable 00000000 on all eight CPUs, the note gone, and the runtime C2 counter had kept counting between the sleeps (27758 entries before the first sleep, 83252 after the last), so the cores still power down while the palmtop is awake.

On the wording: agreed on "keeps C2 out of the sleep" rather than "the fix". The published-tree no-wake hasn't come back in 73 sleeps there (kernel #224), but it isn't explained either.

@W4HO-ham W4HO-ham mentioned this pull request Nov 10, 2026
10 of 14 tasks
@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham. Both points are in, and your fix for the leftover note
is better than the one I suggested: enabling its states first and then
starting fresh also keeps the keep flag honest, which appending wouldn't
have. The test walks pre; pre; post, the leftover with the flag set since,
and the state that can't be written.

The series is what I asked for: 40 of 40 through the hook with nothing set by
hand, 40 pre and 40 post lines in its log, every state1/disable back at 0
at the end, and the runtime C2 counter still counting between the sleeps.

I ran the checks and the sleep-hooks test on a merge with today's main; all
pass, and 0.2.11 is still free. I'll merge it as "omamobile-device-tegu
0.2.11: keep the cores out of C2 through a sleep", with the body saying it
keeps C2 out of the sleep, as we agreed. Last night's no-wake on the
published kernel doesn't change anything here: that kernel has no idle
states, so the hook had nothing to do.

@derekross
derekross merged commit 853be2b into derekross:main Nov 10, 2026
2 checks passed
W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Nov 10, 2026
Main took 0.1.17 (derekross#568) and 0.3.33 (derekross#569) for other changes and
omamobile-device-tegu 0.2.11 (derekross#591), so this branch's packages move to
the next numbers and the README names the modem package version the
stop command comes with.
derekross pushed a commit that referenced this pull request Nov 11, 2026
… failures and the sleep series scripts (#409)

The Pixel 9a's sleep record through 2026-11-10: dead storage after a wake traced to the UFS pads coming back as inputs (kernel #224, in review), the silent no-wake with C2 entered through s2idle (the hook of #591), and an open no-wake on the published kernel (one in 22, then one in 213 with a console that shows one core not answering).

Adds the series, loop and check scripts under device/tegu/bringup/. AGENTS.md and the Suspend cell in DEVICES carry the open no-wake and the rule that the first run of any new kernel, module or script is attended.
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
derekross#591)

A sleep hook for the Pixel 9a keeps the cores out of the C2 idle state through a systemd sleep and gives it back afterwards.

Measured by the contributor on the 9a: 19.9 to 57.1 s of state1 per core through a sleep without the hook, 0.7 to 2.3 s with it, and 40 of 40 sleeps woke through the hook. It keeps C2 out of the sleep; it is not a fix for the sleeps that never woke. A repeated "pre" no longer loses the saved state.
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
… failures and the sleep series scripts (derekross#409)

The Pixel 9a's sleep record through 2026-11-10: dead storage after a wake traced to the UFS pads coming back as inputs (kernel derekross#224, in review), the silent no-wake with C2 entered through s2idle (the hook of derekross#591), and an open no-wake on the published kernel (one in 22, then one in 213 with a console that shows one core not answering).

Adds the series, loop and check scripts under device/tegu/bringup/. AGENTS.md and the Suspend cell in DEVICES carry the open no-wake and the rule that the first run of any new kernel, module or script is attended.
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