Skip to content

omamobile-device-husky 0.1.22: power off at a critical battery - #997

Draft
gitColinX wants to merge 3 commits into
derekross:mainfrom
gitColinX:husky-upower-critical
Draft

gitColinX wants to merge 3 commits into
derekross:mainfrom
gitColinX:husky-upower-critical

Conversation

@gitColinX

Copy link
Copy Markdown
Contributor

What and why

The 8 Pro's critical-battery action is a suspend: GetCriticalAction reads Sleep. Eight boots on my phone between 2026-11-11 and 11-21 end there: upowerd's suspend requested, then PM: suspend entry (deep on 11-11, s2idle on the other seven), and no resume line after it. The journal doesn't say whether the battery ran flat or the phone hung. The second commit lists all eight in SUSPEND-PLAN section 4 (the 11-13 one was already there). The 7 Pro has had this drop-in since device-cheetah 0.1.55 (#730). On #724 I offered this change, and you said you'd come back to it once power off works (#578). derekross/linux-omamobile#262 is merged and I have run it on my phone, so here it is.

This is the 7 Pro's two settings, PercentageAction=3 and CriticalPowerAction=PowerOff, in /etc/UPower/UPower.conf.d/50-omamobile-critical.conf, kept across upgrades by backup=. It follows device/cheetah SUSPEND-PLAN 6.6. upower reads the file when it next starts (the next boot, or systemctl restart upower). The test checks the staged file, that its name is one upower reads, its settings against cheetah's, and backup=. The second commit puts my runs in NOTES.md and SUSPEND-PLAN.md.

This is a draft on purpose. The fix is on omamobile, but no kernel tag has it yet: kernel-2026.11.15 is the newest and doesn't. I'll mark this ready when a kernel-YYYY.MM.DD tag exists whose history contains d832a9890f63. 8 Pro owners flash their own kernels, so the tag is the signal, not a guarantee that a given phone has the fix, and nothing in the package can check.

The file is not harmless on an older kernel. Before derekross/linux-omamobile#262 the PMIC restarts the phone after a power off (#578, and #975 saw it on a 9a), so at 3 % I expect this file to restart it, spending one slot B try each time, until slot B falls back to slot A. That fall back wiped userdata on Somnius's phone twice (#252). I have not run this file on a kernel without the fix: that is an expectation, not a result.

One thing I found on the way: upower 1.91.5 cuts each percentage to a whole number (up_config_get_double() in src/up-config.c keeps the value in an int). My first test run used 99.8, 99.5 and 99.0, which read as 99, 99 and 99. They aren't descending, so upower reset all three to 20, 5 and 2 and the warning level stayed none. The drop-in's 3 is a whole number, and the comment in the file says to write whole numbers.

Version: main has 0.1.20; #880, #899, #483 and #946 also name husky versions, so I took 0.1.22. If the order changes I'll rebase and renumber. #975 proposes a power off drop-in for the 9a, also once a kernel has the fix; its file sets only CriticalPowerAction=PowerOff, so it is a different file from this one.

Device and build

Checks (no phone needed)

  • tools/pr-check origin/main passes
  • tests/all passes: one test fails in my WSL, "an install declined after the slot check: exactly the expected fastboot calls". It fails the same way on a clean origin/main (61308cdd), so it isn't this change.
  • tests/packages passes for the package I touched, omamobile-device-husky. The full run fails four other suites in my WSL (omamobile-omarchy needs jq; omamobile-settings, omamobile-shell and omamobile-speaker-tuning), and the same four fail when I run them on a clean origin/main (61308cdd).
  • Each changed package has its version bumped, and the new version is in the commit subject
  • Commits have area prefixes and bodies that say why; any AI help is a Co-Authored-By: or Assisted-by: trailer, never a Signed-off-by:

On the phone

  • I ran this on my own phone, booted into this build: the kernel above, and the package built on the phone from this change with tools/phone-install-package and installed with pacman -U (0.1.16 to 0.1.22; the only other change in that range that installs files is omamobile-device-husky 0.1.20: the omarchy-trace Plymouth theme (#266) #945's omarchy-trace theme, for Boot splash for the 8 Pro: an Omarchy-style animated trace (two previews, can I send a PR?) #266, installed but not the active theme)
  • Steps I ran (no repo runbook covers these; they follow cheetah's P7 and 6.6 with the cable out, and the results are in this PR's NOTES.md entry), all on 2026-11-21, times in MST, slot B on 2 tries before each:
    • systemctl poweroff, cable out: the journal ends 14:59:56 and there is no boot until I held Power 1 h 4 min later: pass
    • upowerd's power off from a runtime-only config in /run with CriticalPowerAction=PowerOff and the percentages raised to 99, 98 and 97 (the battery read 100 %, so the drop-in's 3 did not act itself; /etc untouched), cable out: at 17:25:41 logind logged poweroff requested from client PID … ('upowerd'), the journal stopped at 17:25:43, and the phone stayed off 21 min until Power: pass
    • the package built on the phone from this change and installed, then systemctl restart upower: GetCriticalAction read Sleep before and PowerOff after, the file is the committed one byte for byte, pacman -Qkk reports 0 altered files: pass
  • What I did not test:
    • a real 3 %: on my phone the gauge has no battery model (Pixel 8 Pro (husky): charging stops at 92 %, the cause and a plan for review #761), so what 3 % holds in mAh isn't known
    • this file on a kernel without the fix (see above)
    • power off with the cable in on my phone (Somnius ran it for rtc: s5m: disarm the S2MPG14's WTSR and SMPL restarts at power off too linux-omamobile#262)
    • upower at 3 % with the cable in: it acts on the battery's own Discharging reading, not on the cable, and with the cable in at full charge my battery read Discharging at times, with the current within 7 mA of zero. On a weak port the file could power the phone off while it is plugged in, as the 7 Pro's would (device/cheetah SUSPEND-PLAN 6.6). I haven't seen that at 3 %
    • what plugging in the powered-off phone does: the 7 Pro starts a dark charging boot for that (omamobile-charger.target), this package has none, and a start from off spends a slot B try
    • akita and tegu (this is a husky package)
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1). The package writes only its own files. My runs flashed slot B and refilled its tries with fastboot set_active b, and read the RTC regmap's bytes 0x02 and 0x03 through debugfs after each start (the RTC block, not the PMU, as rtc: s5m: disarm the S2MPG14's WTSR and SMPL restarts at power off too linux-omamobile#262's description does); 0e and 0f after a start is expected, the kernel clears them only at power off.
tools/phone-smoke report

phone-smoke: husky

Kernel 7.3.0-rc6-omamobile-push1-gd832a9890f63, tools at b63f95cc, 2026-11-22T01:49Z.

Check Result Detail
boot (required) ok kernel 7.3.0-rc6-omamobile-push1-gd832a9890f63, slot b, up 3554s
storage guard (required) ok 62 partitions; only userdata and slot b's boot images writable
root (required) ok ext4 on userdata, 96G free
kernel health (required) ok no oops or BUG; 0 WARN, 50 error lines in dmesg (47 known, 3 new)
new dmesg errors not ok brcmfmac: brcmf_c_process_txcap_blob: TxCap blob found, loading x1; N N: sending dcs data N N eb failed: N x1; N N: N: join (N, chanspec N, N bytes) failed: firmware error N x1
systemd units ok none failed
first boot units not ok failed on the first boot: systemd-firstboot.service
USB gadget (required) ok bound to 11210000.usb
display ok card2-DSI-1 connected, 1344x2992
GPU ok render node on panthor
session (required) ok Hyprland and the Omarchy shell running
lock ok PAM file present, the shell can lock (passwordPam true, locked true)
touch ok SALIXP Touchscreen
buttons ok gpio-keys
Wi-Fi ok wlp1s0 on brcmfmac, link up
Bluetooth ok hci0, powered true
battery ok 100% Discharging, 22 °C
sound cards skip none
sensors skip no sensor proxy
cameras skip no libcamera tools
thermal ok hottest zone 52 °C

Packages: hyprland 0.57.0-3.2, libcamera 0.7.2-4.23, mesa 1:26.2.4-1.4, omacam 0.3.3-1, omamessages 0.2.2-1, omamobile-apps 0.2.2-1, omamobile-audio 0.5.18-1, omamobile-device-husky 0.1.22-1, omamobile-firstboot 0.1.3-1, omamobile-keyring 20261026-1, omamobile-mirror 0.1.1-1, omamobile-omarchy 0.1.38-1, omamobile-owl-widgets 0.1.2-1, omamobile-shell 0.2.108-1, omamobile-voice 0.1.0-1, omaphone 0.2.3-1, omarchy 4.0.6-1, omatel-agent 0.2.4-2, quickshell 0.3.2.r7.g2b4501a-1

The two not ok lines are older than this change. The same three dmesg lines are in each of the 8 boots I compared, one of each per boot, including the three on the previous kernel 82f31d3a7. systemd-firstboot.service failed once, on the phone's first boot on 2026-11-10 (Failed to set up standard input: No such device), and hasn't run since.

gitColinX and others added 2 commits November 21, 2026 20:29
upower's default critical action is a suspend. On my Pixel 8 Pro it has
ended eight boots (2026-11-11 to 11-21) with the journal stopping at
upowerd's suspend request and "PM: suspend entry". Add the 7 Pro's
drop-in (device-cheetah 0.1.55, SUSPEND-PLAN 6.6): PercentageAction=3
and CriticalPowerAction=PowerOff, installed to
/etc/UPower/UPower.conf.d/50-omamobile-critical.conf and kept across
upgrades by backup=.

Power off stays off on the S2MPG14 only with linux-omarchy-mobile#262
(SMPL and WTSR disarmed at power off). Before it the PMIC restarts the
phone, so this must not ship ahead of a kernel that has it (derekross#578).

Tested: packages/omamobile-device-husky/test/all. On the phone, with
linux-omarchy-mobile#262: upowerd powered it off at 97 % from a
runtime-only config (CriticalPowerAction=PowerOff, percentages raised
to 99, 98 and 97 because the battery read 100 %) and it stayed off 21
minutes; the package was then installed and upower reads PowerOff.
Not tested: a real 3 %, a power off with the cable in, and this file
on a kernel without linux-omarchy-mobile#262.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…wer at a critical battery

NOTES gets the 2026-11-21 runs on Colin's phone (power off by hand and
by upower, cable out) and the finding that upower 1.91.5 cuts
fractional percentages to whole numbers and then resets all three.
SUSPEND-PLAN's bullet on UPower's critical action said husky waits as
cheetah keeps its drop-in off; cheetah has had the drop-in since 0.1.55
and husky now has it, so the bullet says that, and section 4 gets the
result.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.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, Colin. This is the right shape: the 7 Pro's two settings in the same place, kept by backup=, pinned against the 7 Pro's file in the test, and a record that says exactly what ran and what didn't. I checked the upower detail you found in its source for 1.91.5, and it holds: the percentages are stored as whole numbers. Waiting for a kernel tag with #262 is right.

One thing I want to think about before this leaves draft, and it's mine to answer rather than yours: 8 Pro owners flash their own kernels, so a tag tells us a fixed kernel exists, not that a given phone runs one, and on an older kernel this file would turn every 3 % into a restart and spend slot B's tries. I'll come back to you on whether the tag and the README line are enough, or whether the package should check something the kernel shows before the drop-in takes effect. Nothing to change until then.

@derekross

Copy link
Copy Markdown
Owner

Decision: a kernel tag isn't enough of a gate. 8 Pro owners flash their own kernels, and on an older one this file restarts the phone at 3 % and spends slot B tries; a fallback there has wiped userdata before. Please have the package check that the running kernel supports it and do nothing otherwise.

@gitColinX

Copy link
Copy Markdown
Contributor Author

Understood. The package will check the kernel it is running and do nothing otherwise. Thank you for the kernel-2026.11.24 tag: it has both commits of derekross/linux-omamobile#262, and kernel-2026.11.15 doesn't.

I looked for something the kernel shows for that fix and found nothing. The two commits add no log line, sysfs file, module parameter or debugfs file. The files they change are built in, so there is no module to read, as omamobile-modem-sleep-policy does for derekross/linux-omamobile#232. uname -r ends in a commit hash, not a number, so it can't be ordered. My description says nothing in the package can check; that was too strong.

There is a side effect. The RTC regmap's debugfs access file lists, per register, whether it is readable, writable, volatile and precious. The first commit widens the write table from CTRL..UPDATE to CTRL..WTSR, so registers 02 (SMPL) and 03 (WTSR) read as writable only with it. The file comes from the driver's tables and reads nothing from the PMIC. It shows that the first commit is in, not the shutdown change; both are in the same PR. On my phone, on d832a9890f63, lines 02 and 03 read y y y n.

Two ways to go:

  1. The package reads /sys/kernel/debug/regmap/firmware:power-management:pmic-1-rtc/access and does nothing unless 02 and 03 are writable, or if it can't read the file. It works on any kernel with the commit, tagged or self-built. A small unit would run before upower starts and put the drop-in in place only on a yes.
  2. A small change in linux-omamobile that adds something the package can read directly, for example a read-only parameter. Cleaner, but it needs a kernel PR and a new tag, and no kernel built before it has it, kernel-2026.11.24 included, so the file would stay off there until the next tag.

I lean to 1. Which do you want, 1 or 2? #997 stays a draft until you say.

…-merge

# Conflicts:
#	packages/omamobile-device-husky/version

@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, Colin, for looking so carefully. I checked your option 1: the regmap access file is printed from the driver's tables and reads nothing from the PMIC, so it's a safe read, and it does show b756aa54c41a. It doesn't show the power-off change itself, but the two came in one PR and every tag has both or neither. Option 2 would test the fix itself, but no kernel before the next tag would ever pass.

I lean towards option 1 and will confirm here. If it goes that way, a few things for the next push: since the drop-in sits under /etc and backup= today, I'd rather the package shipped it outside /etc and the unit put it into place only on a pass, and took it away on a fail, so a kernel downgrade also turns it off; the unit runs before upower and fails closed when the file is missing, unreadable or named differently; and a test with a fake access file for each of those. The branch also conflicts with main on version only; I'll set the number at merge.

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