Measurement-corrected battery optimization pass (DSDS + Wi-Fi)

Re-analyzed the running nokia-argon (a1105, 43 h uptime, DSDS + Wi-Fi on) and
implemented the corrected kernel/userspace optimization list. No sleep state
existed at all (/sys/power/state was 0 bytes) and cpuinfo_transition_latency
was UINT_MAX, while the CPU cores were already ~98% power-collapsed.

Kernel (K1-K14)
- Enable CONFIG_SUSPEND / SUSPEND_FREEZER / PM_WAKELOCKS / PM_AUTOSLEEP and
  build the zImage from the tuned config; ship it as overlay/rootfs/boot/vmlinuz
  plus config and System.map. Add wakeup-source to the WCNSS pronto remoteproc.
- Add clock-latency-ns to cpu-opp-table in all 5 device trees (fixes
  CPUFREQ_ETERNAL at its source instead of a userspace rate_limit_us override).
- New patch 0006: wcn36xx keep-alive 30s->120s, listen_interval=3, VM-BMS
  sample interval 10s->30s, power_supply_changed() only on real capacity
  changes, GPU devfreq polling_ms 50->100.
- Retune the config for idle (HZ=100, PREEMPT_VOLUNTARY, TEO cpuidle governor,
  no ftrace/perf/kprobes/BPF-JIT-always-on/debug options, no serial console,
  DRM_FBDEV_OVERALLOC=0, lz4 zram, ENERGY_MODEL) and drop earlycon /
  console=ttyMSM0 from every kernel cmdline.
- net.ipv6.conf.default.disable_ipv6=1 to stop ND/MLD multicast on new
  interfaces; keep NETFILTER/IPV6/CGROUPS and FRAMEBUFFER_CONSOLE for
  VPN/tethering, elogind and plymouth.

Userspace (U1-U14)
- Idle blanking without the passcode locker (bananarchy-idle-blank.sh +
  idle_locker resume hook, SXMO_UNLOCK_IDLE_TIME=60, sxmo.noidle opts out).
- Guarded deep standby (bananarchy-suspend.sh / -deep-standby.sh /
  sxmo_autosuspend.sh / sxmo_suspend.sh), AllowSuspend=yes, doas rule, no
  infinite wakelock, no sxmo.nosuspend. Shipped disabled via
  /etc/bananarchy-no-deep-standby until the new kernel is boot-tested; freeze
  is preferred, mem is opt-in.
- statusbar_periodics 60s->300s, no mmcli/nmcli/rfkill polls, xsetroot only on
  change; battery udev rule filtered and no 2 s recheck fork.
- On-demand QMI DPM port, longer DSDS/modemmonitor backoffs, chrony long polls,
  NM wifi.scan-interval=600, bluetooth AutoEnable=false, tmpfs on /tmp,
  zero-log superd, GPU devfreq governor on screen-off, longer SIP/Tox timers.
- Fix the cosmetic wpa_supplicant yesno typo; withdraw the disproven duplicate
  wpa_supplicant and soundmonitor 5 s loop items.

Rebuilt images/bananarchy-nokia-argon.img with --mkinitfs: boot.img contains
the new zImage + DTB byte-for-byte and no serial-console cmdline. Deployed the
userspace overlay to the connected phone and verified shell/Python syntax, the
idle-blank round trip, the statusbar hook and the deep-standby guard.
check-rebuild.sh and sync-prebuilt-overlay.sh --check both pass.

Docs: BATTERY-OPTIMIZATION-ANALYSIS.md (measurement-corrected, with
implementation status), CHANGELOG.md, MANUAL.md, README.md, AGENTS.md.
This commit is contained in:
Bantam committed 2026-11-07 17:03:12 +02:00
1 parent 2ea2db443d
commit ad3461babf
169 files changed
+151574 -333

No files matched your search

+83
View File
@@ -9,6 +9,89 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
---
## Unreleased — measurement-corrected battery optimization pass
Analysis: `BATTERY-OPTIMIZATION-ANALYSIS.md` (corrected against the connected `nokia-argon`,
`a1105`, 43 h uptime, DSDS + Wi-Fi on). No sleep state existed at all: `/sys/power/state` was
0 bytes and `cpuinfo_transition_latency` was `4294967295`; the CPU cores were already ~98 %
power-collapsed, so the drain came from always-on SoC rails, display and radios, not busy loops.
### Rebuilt and verified image
- Rebuilt `images/bananarchy-nokia-argon.img` (1.6 GiB) with `./rebuild-image.sh nokia-argon --mkinitfs`: the regenerated `/boot/boot.img` contains the newly cross-compiled `zImage` plus the updated `qcom-msm8905-nokia-argon.dtb` (verified byte-for-byte), and its cmdline no longer carries `earlycon` or `console=ttyMSM0,115200`. `check-rebuild.sh` and `sync-prebuilt-overlay.sh --check` both pass (0 artifact drift).
- Deployed the userspace overlay to the connected `nokia-argon` over SSH and verified: all 39 shell scripts pass `sh -n`, all 5 embedded Python heredocs parse, the U1 idle-blank round trip drives `brightness 10 -> 0 -> 10`, `bl_power 0 -> 4 -> 0`, `DPMS On -> Off -> On` and `schedutil -> powersave -> schedutil`, the statusbar periodic hook returns 0, and deep standby stays correctly gated (the running kernel has no sleep states, so the suspend helper is a no-op).
### Kernel (K1-K14)
- Enabled `CONFIG_SUSPEND`, `CONFIG_SUSPEND_FREEZER`, `CONFIG_PM_WAKELOCKS(_LIMIT/GC)` and
`CONFIG_PM_AUTOSLEEP`; `build-kernel-audio.sh` now cross-compiles the `zImage` from
`config-bananarchy-msm8909.armv7` and ships it as `overlay/rootfs/boot/vmlinuz` together with
the resolved `config` and `System.map`, so the tuned config actually reaches the boot image.
`wakeup-source` added to the WCNSS/pronto remoteproc in all 5 device trees.
- Added `clock-latency-ns = <100000>` to `cpu-opp-table` in all 5 device trees: fixes
`CPUFREQ_ETERNAL` at its source instead of overriding `schedutil/rate_limit_us` from userspace.
- New `patches/kernel/0006-msm8909-battery-wifi-gpu-power.patch` (applied by
`build-kernel-audio.sh`): wcn36xx null-data keep-alive 30 s -> 120 s, `listen_interval = 3`,
VM-BMS FIFO sample interval 10 s -> 30 s, `power_supply_changed()` emitted only on a real
capacity change, GPU devfreq `polling_ms` 50 -> 100.
- Retuned the kernel config for idle: `HZ=100`, `PREEMPT_VOLUNTARY`, `SCHED_HRTICK`,
`CPU_FREQ_STAT`, `IRQ_TIME_ACCOUNTING` and `SCHED_SMT` off, `CPU_IDLE_GOV_TEO=y`; disabled
ftrace/function tracer/dynamic debug/perf events/profiling/kprobes/uprobes/BPF JIT always-on,
firmware-loader debug, thermal emulation, Magic SysRq, printk timestamps, DRM GPU state dump,
boot logo and the MSM serial console; `DRM_FBDEV_OVERALLOC=0`; removed unused input classes
and LED triggers; `ZRAM_DEF_COMP=lz4`; enabled `ENERGY_MODEL`; `RCU_NOCB_CPU`/`RCU_LAZY` are gated behind `RCU_EXPERT || NO_HZ_FULL` and were dropped by `olddefconfig`.
`FRAMEBUFFER_CONSOLE`, `NETFILTER`, `IPV6` and `CGROUPS` are deliberately kept (plymouth,
Tor/WireGuard/tethering, elogind).
- Removed `earlycon` and `console=ttyMSM0,115200` from every `kernel-cmdline.conf` and from the
shipped `usr/lib/kernel-cmdline.d/50-device-*.conf` files.
- `net.ipv6.conf.default.disable_ipv6=1` (sysctl.d + `10-power-save.start`) stops ND/MLD
multicast on newly created interfaces; `CONFIG_IPV6=m` stays for VPNs and `::1` on `lo`.
### Userspace (U1-U14)
- **Idle blanking (U1)**: `bananarchy-idle-blank.sh` blanks/restores the panel without the
passcode locker; `sxmo_hook_unlock.sh` starts `idle_locker` at `SXMO_UNLOCK_IDLE_TIME`
(default 60 s) with a `resume` hook, and `bananarchy-x11-session.sh` no longer forces
`sxmo.noidle`. Create `~/.cache/sxmo/sxmo.noidle` to restore the old "never blank" policy.
- **Deep standby (U2)**: `bananarchy-suspend.sh`, `bananarchy-deep-standby.sh`,
`sxmo_autosuspend.sh` and `sxmo_suspend.sh` implement a guarded suspend after screen-off;
`AllowSuspend=yes`, a doas rule, no infinite `sxmo_not_suspendable` wakelock, no
`sxmo.nosuspend`, and cancel hooks on unlock/postwake. `freeze` (s2idle, any-IRQ wake) is
preferred; `mem` needs `/etc/bananarchy-allow-mem-suspend`. **Shipped disabled** via
`/etc/bananarchy-no-deep-standby` until the new kernel has been boot-tested.
- **Statusbar (U3)**: 60 s -> 300 s `statusbar_periodics`; the periodic hook no longer runs
`mmcli`/`nmcli`/`rfkill` and only calls `xsetroot` when the status string changes.
- **Battery uevents (U4)**: udev rule filtered to the two PM8916 supplies; removed the
`(sleep 2; ... recheck)` fork from `sxmo_hook_battery.sh`.
- **Bluetooth (U5)**: `AutoEnable=false`, 60 s discoverable/pairable timeouts, `bredr` only,
3 reconnect attempts (latent: BT was already soft-blocked on the device).
- **chronyd (U6)**: `minpoll 12 maxpoll 16`, no `iburst`.
- **NetworkManager (U8)**: `wifi.scan-interval=600`.
- **Modem/DSDS (U9/K11)**: QMI BAM-DMUX data port is now opened on demand
(`bananarchy-dpm.sh` + NM dispatcher) instead of unconditionally at boot; `dsds-daemon`
stored-SMS poll 600 s -> 1800 s and error backoff 2 s -> 30 s; `sxmo_modemmonitor.sh`
10/120 s -> 30/600 s. `mmcli`'s `drx-cycle`/`mico-mode` are 5G NR fields and were removed
from the optimization list as inapplicable to this LTE modem.
- **Timers (U11)**: `sip_plugin.cpp` 15 s -> 60 s; `tox_plugin.cpp` clamp 250-1000 ms ->
1000-2000 ms; `sxmo_soundmonitor.sh` restart backoff 2 s -> 10 s.
- **Storage (U12/K13)**: `tmpfs` on `/tmp`, zram `lz4` + `noatime`, `size1=256`.
- **Zero-log (U13)**: shipped user/skel `sxmo_hook_start.sh` now uses `superd -l /dev/null`
with `/dev/null` log symlinks, matching the default hook.
- **Xorg (U14)**: skip `xrdb`/`feh`/dunst-theme work on dwm restart while the panel is dark;
`sxmo_wm.sh display off/on` also switches the GPU devfreq governor to
`powersave`/`simple_ondemand`.
- Fixed the cosmetic `yesno "{wpa_supplicant_dbus}"` typo in `etc/init.d/wpa_supplicant`
(C1: the running service already had `-u`; OpenRC's `yesno()` dereferences the literal).
- Withdrawn as disproven by the live device: duplicate `wpa_supplicant`/respawn storm (U7)
and the `sxmo_soundmonitor.sh` 5 s loop (U10).
### Deferred with justification
- **K12** (damage/partial-window updates in `panel-mipi-dbi`) needs panel-specific GC9305/GC9307
commands and risks display corruption; U3 delivers the equivalent userspace saving.
- **`rcu_nocbs=all`** (K14) was not added to the cmdline: on a 2-core MSM8905 it would add
always-running `rcuo` kthreads, trading away the idle saving.
- **`msm8905-cam`** stays in `/etc/modules` (K9): its out-of-tree platform driver has no udev
autoload path, so removing it would break `xcamera`.
---
## Unreleased — display power, cpufreq, and Bantam agent update
### Updated Bantam agent to upstream `c168955`