Files
bananarchy/BATTERY-OPTIMIZATION-ANALYSIS.md
T
Luxferre bc1c19a483 VM-BMS sanity fix and configurable runtime power policies
Kernel (source-only, ABI-preserving, patch 0007):
- pm8916_bms_vm.c: bound VADC raw samples to 8000..16000 (~2.34-4.69 V)
  with a 3.7 V nominal fallback in raw_to_uv(); reject out-of-window FIFO
  samples in the IRQ handler and probe pre-read. Fixes the 19.2 V /
  "Over voltage" / 100% misreport from an uninitialised 0xffff sample after
  a hard reset (also covers the OCV register reads on probe/resume).
- wcn36xx: listen_interval becomes a module parameter (1-10, default 5,
  was hardcoded 3) so the beacon skip is configurable at module load.

Runtime power policy (/etc/bananarchy-power-policy.conf):
- WIFI_LISTEN_INTERVAL drives /etc/modprobe.d/10-bananarchy-power.conf.
- MODEM_DRX_MODE (0 or 6-9) applies Qualcomm AT$QCDRX at boot and on wake.
  Standard AT+CPSMS / AT+CEDRXS are unsupported on this modem firmware.
- DSDS_SECONDARY_MODE=eco parks the secondary GW provisioning session after
  DSDS_PARK_DELAY seconds of a dark panel and restores it on wake, capturing
  the actual slot and AID. Uses QMI provisioning sessions, not SIM power-off
  (which clears PIN verification). Default active keeps both SIMs reachable.
- New bananarchy-power-policy.sh, OpenRC default-runlevel service, doas rule,
  and hooks in sxmo_wm.sh display off/on.

Live-verified on nokia-argon: DRX 6 readback, eco park/unpark round-trip,
Wi-Fi param 5, status output, module vermagic match, both SIMs registered.
Rebuilt image with --mkinitfs: initramfs and rootfs carry the new modules
(SHA-256 match), boot.img keeps the byte-identical known-good zImage + DTB.
Docs updated (BATTERY-OPTIMIZATION-ANALYSIS.md section 15, CHANGELOG,
MANUAL, README, AGENTS).
2026-11-07 20:39:06 +02:00

61 KiB
Raw Blame History

Bananarchy battery-usage optimization analysis (measurement-corrected)

Status: analysis only — no source or on-device changes were made. Project: /home/lux/proj/bananarchy, repo HEAD 2ea2db4. Device: Nokia 8110 4G (nokia-argon, MSM8905), connected over USB RNDIS at 172.16.42.1, Linux nokia-argon 6.12.1-msm8916 #6 SMP PREEMPT Sat May 30 08:38:37 UTC 2026 armv7l, Bananarchy Linux a1105 (msm8909). Measurement session: 2026-11-07 16:07–16:12 EET, uptime ~43 h at first snapshot. Read-only SSH commands plus two 60-second delta windows. Temporary /tmp/bantam-* files on the phone were removed; NO_RESIDUE confirmed.

This document supersedes the earlier static analysis. Section 3 lists every correction that the live device forced. Sections 4–7 are the corrected optimization lists.


1. Measurement limitations (important)

  • The phone was charging from USB during the whole session. pm8916-lbc-chgr/online=1, constant_charge_current=540000, pm8916-bms-vm/status=Charging. No discharge-current measurement is possible while SSH runs over the charging USB link.
  • The BMS driver exposes no current_now (only capacity, voltage_now, status, health, charge_full_design). So even on battery there is no direct mA readout from sysfs. capacity moved 56 → 54 → 54 and voltage_now rose 3,998,440 → 4,000,051 µV during the session, i.e. the BMS EMA is noisy and the device is on external power.
  • iw and powertop are not installed (confirmed). Wi-Fi power save was verified indirectly through /proc/interrupts, /proc/net/dev and the deployed NM config.
  • /proc/timer_list, /sys/kernel/debug/pm_genpd/pm_genpd_summary and /sys/kernel/debug/wakeup_sources are unavailable, so no per-timer/genpd attribution.
  • Consequence: every mA figure below is an architectural estimate, not a measurement. The 24 h budget is derived from the DT: charge-full-design-microamp-hours = 1500000 (1500 mAh) → ≤ 62.5 mA average to reach 24 h.

2. Measured state

2.1 Suspend / PM core — the headline finding

Item Measured value
/proc/config.gz # CONFIG_SUSPEND is not set, # CONFIG_HIBERNATION is not set; no CONFIG_PM_SLEEP, CONFIG_PM_WAKELOCKS, CONFIG_PM_AUTOSLEEP
/sys/power/state 0 bytes (empty) — no sleep states exist
/sys/power/wake_lock, wake_unlock, autosleep absent → sxmo_wakelock.sh isenabled is false, all wakelock calls are no-ops
Prerequisites already present CONFIG_ARCH_SUSPEND_POSSIBLE=y, CONFIG_ARM_CPU_SUSPEND=y, CONFIG_CPU_PM=y, CONFIG_FREEZER=y, CONFIG_QCOM_SPM=y, CONFIG_ARM_QCOM_SPM_CPUIDLE=y, wakeup-source on gpio-keys in the DTS
Userspace enforcement sxmo_autosuspend.sh/sxmo_suspend.sh = exit 0; elogind/sleep.conf AllowSuspend=no; sxmo.nosuspend + sxmo.noidle present; infinite sxmo_not_suspendable wakelock in sxmo_hook_start.sh/sxmo_state.sh

2.2 CPU, cpufreq, cpuidle

Item Measured value
CPUs online/possible/present = 0-1, nproc=2 (MSM8905 is dual-core — expected, not a bug); CONFIG_NR_CPUS=8
cpufreq driver cpufreq-dt, governor schedutil, min 199999 kHz, max 1094400 kHz
cpuinfo_transition_latency 4294967295 (UINT_MAX / CPUFREQ_ETERNAL) — root cause of the 6.44 s schedutil default
schedutil/rate_limit_us 40000 — the fix IS in effect at runtime (commit 7b6c6b2 resolved the earlier "not in effect" issue)
time_in_state over ~43 h 199999 kHz: 15,393,362; 399999: 39,736; 533333: 21,461; 799999: 5,349; 998400: 2,801; 1094400: 24,790 → ~99 % of uptime at the 200 MHz floor
cpuidle state0 WFI, state1 cpu-sleep-0 (SPC, latency 420 µs, residency 1260 µs); time ≈ 151,642 s per core ≈ 98 % of uptime in SPC
60 s window CPU idle 98.15 %; SPC entries +1,776 (≈29.6/s across 2 cores); arch_mem_timer 18.8/s, arch_timer 17.7/s, IPI3 16.8/s, IPI1 2.3/s, IPI2 3.0/s, IPI5 4.8/s → ~50 wakeups/s system-wide

Interpretation (corrected): the CPU cores are not stuck at high frequency and are not busy-looping — they are power-collapsed ~98 % of the time. The remaining drain is from SoC rails, DDR (no self-refresh), the always-on display, the LTE+GSM modem and the Wi-Fi chip, all of which stay powered because there is no system-wide suspend. This re-frames the problem away from "too many userspace busy loops" toward "no deep sleep state".

2.3 Kernel config (from /proc/config.gz, running kernel)

Confirmed general-purpose/low-latency/debug choices:

  • CONFIG_HZ=300, CONFIG_PREEMPT=y, CONFIG_SCHED_HRTICK=y, CONFIG_CPU_FREQ_STAT=y, CONFIG_IRQ_TIME_ACCOUNTING=y, CONFIG_CPU_IDLE_GOV_MENU=y, CONFIG_CPU_IDLE_GOV_TEO off, CONFIG_NO_HZ_IDLE=y, CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y.
  • Debug/tracing: CONFIG_FTRACE=y, CONFIG_FUNCTION_TRACER=y, CONFIG_DYNAMIC_DEBUG=y, CONFIG_PERF_EVENTS=y, CONFIG_PROFILING=y, CONFIG_KPROBES=y, CONFIG_UPROBES=y, CONFIG_BPF_JIT_ALWAYS_ON=y, CONFIG_FW_LOADER_DEBUG=y, CONFIG_THERMAL_EMULATION=y, CONFIG_MAGIC_SYSRQ=y, CONFIG_PRINTK_TIME=y, CONFIG_DRM_MSM_GPU_STATE=y, CONFIG_DRM_FBDEV_OVERALLOC=100, CONFIG_FRAMEBUFFER_CONSOLE=y, CONFIG_LOGO=y, CONFIG_SERIAL_MSM_CONSOLE=y.
  • Unused built-ins: CONFIG_INPUT_MOUSE/JOYSTICK/TOUCHSCREEN=y, CONFIG_MAC80211_LEDS=y, CONFIG_INPUT_LEDS=y, CONFIG_LEDS_QCOM_LPG=y, CONFIG_NETFILTER=y, CONFIG_IPV6=m, CONFIG_CGROUPS=y, CONFIG_MEMCG=y, CONFIG_ZRAM_DEF_COMP_ZSTD=y.
  • Absent: CONFIG_RCU_LAZY, CONFIG_ENERGY_MODEL, CONFIG_SCHED_ENERGY, CONFIG_SUSPEND*.
  • /proc/cmdline: quiet splash plymouth.ignore-serial-consoles plymouth.prefer-fbcon earlycon console=ttyMSM0,115200 ...

Runtime sysctls from 10-power-save.start are all applied: vm.stat_interval=30, dirty_writeback_centisecs=6000, dirty_expire_centisecs=6000, printk="1 4 1 1", workqueue.power_efficient=Y, printk.console_suspend=Y, fbcon/cursor_blink=0.

2.4 Display

brightness=10/14, bl_power=0, card0-SPI-1/dpms=On, xset q: DPMS Enabled, Monitor is On, Standby/Suspend/Off = 0, screensaver timeout 0. sxmo_state.sh get = unlock, /tmp/bananarchy_screen_locked absent, sxmo.noidle/sxmo.nosuspend present, idle_locker not in sxmo_jobs.sh list (only daemon_manager, network_monitor_device, statusbar_periodics). So the unlocked screen never blanks, and the DPMS-off path (deployed in sxmo_wm.sh + bananarchy-display-power-sync) is never taken in normal use.

2.5 Wi-Fi

  • wlan0 connected to OffOurStreets_, driver wcn36xx, GENERAL.IP6-CONNECTIVITY: full, IPv6 link-local fe80::... present, disable_ipv6=0, accept_ra=0, use_tempaddr=2.
  • NM: wifi.powersave=3 (10-power.conf), connectivity.enabled=false (twice), wifi.scan-rand-mac-address=no (00-sxmo.conf). No wifi.scan-interval override → NM default.
  • wcn36xx module parameters: only debug_mask=0 — no runtime knob for keep-alive/listen interval.
  • 60 s window: wlan0 RX 24,130 bytes / 111 packets (1.85 pkt/s), TX 0 packets; wcn36xx_rx IRQ 1.78/s, wcn36xx_tx 0.10/s, 78b9000.spi 0.17/s, mmc0 0.75/s, rpm 1.25/s, gpu-irq 0.12/s. Beacon filtering is working (≈1.8 RX/s, not 10/s).
  • Ip6InReceives 36,977 over 43 h (~0.24/s) → IPv6 multicast is active on wlan0.
  • One wpa_supplicant -u -Dnl80211,wext -iwlan0 under supervise-daemon, stable for 1d19. No ctrl socket (wpa_cli fails); D-Bus only, used by NetworkManager.

2.6 Bluetooth

rfkill: hci0 Bluetooth Soft blocked: yes. bluetoothd not running; bluetooth service not in any runlevel (rc-update show -v shows it with empty runlevel columns). So AutoEnable=true, DiscoverableTimeout=0, PairableTimeout=0, ControllerMode=dual in main.conf are inert — BT is off and is not a current drain. Latent risk only if the user explicitly enables BT via xnetworks/sxmo_bluetoothtoggle.sh.

2.7 Modem / DSDS

  • /tmp/sxmo_dsds_active=1, DUAL_SIM_ACTIVE=1, both SIMs present/ready. PRIMARY_GW_SLOT=2 (NAS_RAT=lte, NAS_PS_STATE=attached), SECONDARY_GW_SLOT=1 (SLOT1_RAT=gsm), NAS_REG_STATE=registered.
  • mmcli: access-technologies: ["lte"], bearers: [], packet-service-state: attached, current-modes: allowed 2g,3g,4g; preferred 4g, EPS initial bearer with empty APN. drx-cycle: "--" / mico-mode: "--" are 5G NR registration settings under modem.3gpp.5gnr.registration-settings; they are not applicable to this LTE-only modem and are not evidence of a missing DRX configuration (see correction C17).
  • qrtr0:gsm:disconnected, no GSM connection profiles, no rmnet_data* interface; wwan0 (rpmsg_wwan_ctrl), /dev/wwan0at0, /dev/wwan0at1 present.
  • msm8909-modem-wwan-port still runs qmicli --dpm-open-port=... unconditionally at boot (line 31 confirmed deployed) even though no cellular data call exists.
  • dsds-daemon (python3) running: poll_timeout=None when locked, 600.0 when unlocked; poll_stored_sms every 600 s; time.sleep(2) on exception. sxmo_modemmonitor.sh supervises with sleep 10 / sleep 120.
  • ModemManager --test-quick-suspend-resume --log-level=ERR --log-file=/dev/null, q6voiced, rmtfs, qmi-proxy, polkitd, dbus-monitor all running.

2.8 Services / processes

Default runlevel: cgroups chronyd dbus elogind kill-plymouth local modemmanager msm-modem-uim-selection msm8909-modem-wwan-port networkmanager postmarketos-zram-swap q6voiced rfkill rmtfs sshd tinydm udev-postmount wpa_supplicant (no bluetooth, no zram-init).

  • chronyd running (2 procs) with pool pool.ntp.org iburst, cmdport 0, rtcsync, makestep 1 -1. chronyc unusable (cmdport 0); after 43 h uptime it is almost certainly at maxpoll ≈ 1024 s, not the initial 64 s.
  • superd started without -l /dev/null → the shipped user hook (~/.config/sxmo/hooks/sxmo_hook_start.sh) wins over the default hook and the zero-log default is not fully applied (Xorg does use -logfile /dev/null -logverbose 0).
  • Started superd services: dunst, fcitx5, pipewire, pipewire-pulse, wireplumber, sxmo_modemmonitor, sxmo_networkmonitor, sxmo_notificationmonitor, sxmo_soundmonitor.
  • sxmo_soundmonitor.sh has 4 shell processes plus evtest /dev/input/event5 and pactl subscribe — the jack evdev exists, so the sleep 5 fallback loop is not running.
  • sxmo_run_aligned.sh 60 sxmo_hook_statusbar.sh periodics + sxmo_aligned_sleep 60 running; the periodics guard passes (unlocked, brightness 10) → full mmcli -m any -J, nmcli -t con show --active, nmcli ... device wifi list --rescan no, rfkill list wifi, xsetroot -name every 60 s.
  • nmcli device monitor, inotifywait, dbus-monitor — event-driven, as designed.
  • 26 dwm-plugin --preload residents; dwm; dunst; fcitx5 -D --disable=wayland --verbose=*=0; dnsmasq (NM, IPv6 listener), unudhcpd, getty tty1.

2.9 Runtime PM / devfreq / zram

  • 78b9000.spi: auto, suspended, delay 50. 7824900.sdhci/7864900.sdhci: auto, suspended, delay 50. 1c00000.gpu: auto, suspended, delay 66. 78af000.serial: auto, status=unsupported → UART stays on.
  • GPU devfreq: governor=simple_ondemand, cur_freq=409600000 (max), target_freq=409600000, polling_interval=50. Because the device is runtime-suspended, the 50 ms poll is stopped at idle; the issue is that it resumes at the 409.6 MHz max OPP.
  • Only /dev/zram0 exists (swap, 595,964 KB, 2,560 KB used), comp_algorithm=[zstd], mm_stat orig 2,404,352 / compr 412,692 / mem_used 2,002,944 → very little swap activity.
  • zram-init is NOT enabled; /etc/conf.d/zram-init (type1=/tmp, size1=2048, opts1=strictatime, algo1=zstd) is dead config. /tmp is not a separate mount — it lives on the rootfs/eMMC. mount shows tmpfs only on /dev, /run, /dev/shm, /run/user/10000.
  • /etc/modules: af_packet ipv6 panel_mipi_dbi msm leds_msm8905_torch msm8905-cam rpmsg_wwan_ctrl.

2.10 Battery udev path

85-bananarchy-battery.rules has no KERNEL filter; sxmo_hook_battery.sh udev re-execs via su and forks (sleep 2; "$0" udev recheck). Measured BMS IRQ rate: 2 IRQs / 60 s (1 per ~30 s) → 2 power_supply change events per minute (KERNEL+UDEV pairs). Battery cache charging:54 is present and working.

2.11 Deployed files vs repo

10-power-save.start, bananarchy-display-power-sync, sxmo_wm.sh, sxmo_hook_statusbar.sh, sxmo_hook_battery.sh, msm-modem-uim-selection, sxmo_modemmonitor.sh, xorg.conf.d/10-bananarchy-msm8909.conf all match the repo copies. The deployed image is a1105; the power-relevant code is identical to HEAD 2ea2db4.


3. Corrections to the previous analysis

# Previous claim Corrected by the device
C1 Duplicate wpa_supplicant service with a missing $ in yesno "{wpa_supplicant_dbus}" causes a no--u instance / respawn storm Wrong. Exactly one stable instance with -u. OpenRC's yesno() has a fallback that evals the literal string as a variable name → yes → true, so -u is added. The typo is cosmetic. Remove this item.
C2 bluetoothd AutoEnable=true + DiscoverableTimeout=0 keeps BT in inquiry/page scan Wrong for the current state. BT is soft-blocked, bluetoothd not running, service not in any runlevel. Downgrade to a latent/conditional risk only.
C3 sxmo_soundmonitor.sh runs a sleep 5 loop forever Wrong. /dev/input/event5 jack evdev exists; evtest blocks and pactl subscribe is event-driven. Remove the 5 s claim.
C4 /tmp is a 2 GB ext4-on-zram with strictatime, costing compression/atime writes Wrong. zram-init is not enabled; only zram0 swap exists; /tmp is on rootfs/eMMC. Replace with: mount tmpfs on /tmp to avoid eMMC writes, and optionally switch zram0 zstd→lz4 (low impact, only 2.5 MB used).
C5 BMS FIFO IRQs ≈ every 20 s → ~3 uevents/min shell storm Overstated. Measured 1 BMS IRQ / ~30 s → 2 uevents/min. Keep the fix but lower its priority.
C6 "schedutil rate-limit fix not in effect at runtime" (older session) Resolved. rate_limit_us=40000 confirmed live.
C7 Idle average CPU ~440–582 MHz indicates constant wakeups / CPU never truly idles Wrong. time_in_state shows ~99 % of 43 h at 200 MHz; cpuidle SPC ~98 % of uptime; 60 s window CPU idle 98.15 %. Cores are power-collapsed. Reframe the problem as "no system-wide suspend", not "CPU busy loops".
C8 GPU devfreq .polling_ms=50 runs a 20 Hz poll continuously Overstated. 1c00000.gpu is runtime-suspended, so devfreq polling is stopped. Real issue: cur_freq=409600000 (max OPP) on resume.
C9 chronyd polls NTP every 64 s Overstated. After 43 h uptime chronyd is at maxpoll ≈ 1024 s. Low priority.
C10 "Only per-core SPC idle is available" True but incomplete. It is available and heavily used (~98 %). The missing piece is system-wide suspend, now hard-confirmed by a 0-byte /sys/power/state.
C11 CONFIG_SUSPEND off and CPUFREQ_ETERNAL inferred from the repo config Confirmed with hard measurements: # CONFIG_SUSPEND is not set in /proc/config.gz, 0-byte /sys/power/state, cpuinfo_transition_latency=4294967295. These become the top two evidence-backed items.
C12 Average mA can be measured via current_now Not possible. No current_now attribute, and the device is charging. All mA numbers remain estimates.
C13 4 CPU cores 2 cores (0-1) — MSM8905 is dual-core; expected, not a bug.
C14 iw/powertop available for verification Both missing. Wi-Fi PS verified indirectly via IRQ/packet rates and NM config.
C15 (new) mmcli reports drx-cycle: "--", mico-mode: "--" → no LTE DRX/MICO power saving configured. New concrete modem-side item.
C16 (new) superd runs without -l /dev/null because the user sxmo_hook_start.sh wins; zero-log default not fully applied.
C17 (new) mmcli's drx-cycle / mico-mode are 5G NR registration settings, not LTE DRX knobs. The "configure QMI NAS long DRX / MICO" sub-item of K11/U9 is withdrawn as inapplicable; the on-demand DPM port and DSDS timer backoff remain.

4. Corrected kernel-side optimizations

Ordered by expected impact, with measured evidence. Regression risks are stated.

# Change Evidence / expected effect Risk
K1 Enable CONFIG_SUSPEND=y (+ CONFIG_PM_SLEEP, CONFIG_PM_WAKELOCKS=y, CONFIG_SUSPEND_FREEZER=y) in patches/kernel/config-bananarchy-msm8909.armv7; add wakeup-source to the WCNSS/pronto and modem/SMP2P DT nodes so Wi-Fi WoWLAN and QMI/QRTR calls can resume the AP. /sys/power/state is 0 bytes; all prerequisites are already y. Unlocks wcn36xx_suspend() (ARP/NS/GTK offload + set_power_params(ignore_dtim=true)), BMS suspend() forcing S3, DDR self-refresh and RPM power collapse. Only change that can plausibly push DSDS+Wi-Fi past 24 h. echo mem freezes userspace → resume ~100–500 ms, conflicting with the "<2 ms wake" design. Ship as an opt-in/configurable "deep standby" with timed wakelocks around calls, SMS, alarms, SSH/VPN/tethering.
K2 Add clock-latency-ns to cpu-opp-table in all 5 DTS files (or override policy->cpuinfo.transition_latency in qcom-cpufreq-nvmem.c). cpuinfo_transition_latency=4294967295 measured. Fixes the 6.44 s schedutil default at its source; makes the rate_limit_us=40000 userspace hack and the bananarchy-display-power-sync re-apply unnecessary and immune to governor-switch kobject recreation. Low. Re-measure time_in_state after.
K3 wcn36xx tuning: raise WCN36XX_KEEP_ALIVE_TIME_PERIOD (30 s) to 120–300 s; set an actual listen_interval > 1 (max_listen_interval=200 is only a ceiling); expose set_power_params(ignore_dtim=true) + ARP/NS/GTK offload on screen-blank even without full suspend (today only in wcn36xx_suspend()). Measured 1.78 wcn36xx_rx IRQs/s and 111 RX packets/min with 0 TX at idle. Beacon filtering works, but a residual ~1.8/s RX floor remains. No runtime module params exist → needs a kernel patch. Too-long keep-alive/listen interval can cause AP deauth or delayed inbound traffic; incoming calls are on cellular so Wi-Fi latency is not critical here.
K4 Throttle the fuel gauge: pm8916_bms_vm.c emits power_supply_changed() on every FIFO IRQ; S1/S2_SAMPLE_INTERVAL=10. Increase intervals and emit only on real capacity/status change. Measured 2 BMS IRQs/min → 2 uevents/min → 2 su+sleep 2 forks/min (U4). Lower priority than previously stated, but free to fix. Slower % updates; keep force on wake/unlock.
K5 GPU devfreq: msm_gpu_devfreq.c sets initial_freq = gpu->fast_rate and .polling_ms=50. Use DEVFREQ_GOV_POWERSAVE or a lower initial_freq; keep devfreq_suspend_device() on screen-off. GPU is runtime-suspended at idle (measured), so the 50 ms poll is not running; but cur_freq=409600000 (max) means every resume jumps to the top OPP. UI smoothness. Glamor/DRI3 is enabled in xorg.conf; consider AccelMethod "none" for a 240×320 panel (conflicts with the GPU-acceleration design goal).
K6 Timer/scheduler config: CONFIG_HZ=300→100; CONFIG_PREEMPT=y→CONFIG_PREEMPT_VOLUNTARY; disable CONFIG_SCHED_HRTICK, CONFIG_CPU_FREQ_STAT, CONFIG_IRQ_TIME_ACCOUNTING, CONFIG_SCHED_SMT; enable CONFIG_CPU_IDLE_GOV_TEO. Measured ~36 timer IRQs/s + ~27 IPIs/s → ~50 wakeups/s and 29.6 SPC entries/s. Reduces the wakeup floor. Voluntary preempt may hurt <2 ms UI wake — A/B measure.
K7 Strip debug/tracing (FTRACE, FUNCTION_TRACER, DYNAMIC_DEBUG, PERF_EVENTS, PROFILING, KPROBES, UPROBES, BPF_JIT_ALWAYS_ON, FW_LOADER_DEBUG, THERMAL_EMULATION, MAGIC_SYSRQ, PRINTK_TIME, DRM_MSM_GPU_STATE; DRM_FBDEV_OVERALLOC=0; disable FRAMEBUFFER_CONSOLE/LOGO/SERIAL_MSM_CONSOLE). All confirmed =y on the running kernel. Smaller kernel, fewer hooks/timers. Loses on-device debugging; keep a debug build variant.
K8 Remove earlycon + console=ttyMSM0,115200 from devices/*/kernel-cmdline.conf (use console=null/quiet). Confirmed in /proc/cmdline; 78af000.serial has runtime_status=unsupported → UART clock stays on. No serial debugging.
K9 Trim built-in subsystems: INPUT_MOUSE/JOYSTICK/TOUCHSCREEN, MAC80211_LEDS, INPUT_LEDS, LEDS_QCOM_LPG, NETFILTER (if no VPN/tether/NAT), CGROUPS/MEMCG (if elogind/OpenRC don't need them), unused USB_NET_*/DRM_PANEL_*/VIDEO_QCOM_VENUS/CAMSS modules; defer msm8905-cam load from /etc/modules. All confirmed built-in/loaded. Less probe/IRQ/timer and memory overhead. VPN/Tor/WireGuard/tethering need netfilter; GTK/WebKit may need IPv6 loopback; camera app must trigger the load.
K10 IPv6 on wlan0: CONFIG_IPV6=m + ipv6 in /etc/modules; measured link-local address and 36,977 Ip6InReceives. Set NM ipv6.method=ignore for Wi-Fi profiles (or sysctl net.ipv6.conf.wlan0.disable_ipv6=1). Removes ND/MLD multicast that keeps Wi-Fi awake. IPv6-only networks.
K11 Modem/DSDS power collapse: make --dpm-open-port conditional on an actual cellular data connection and --dpm-close-port when Wi-Fi is the default route; add DT wakeup-source for the WCNSS/modem remoteprocs; ensure rpmsg_wwan_ctrl/qcom_bam_dmux runtime PM. (QMI NAS DRX/MICO withdrawn — C17.) Measured: DSDS active (LTE + GSM), bearers: [], no GSM profiles, yet DPM port open at boot. Directly targets the reported scenario. Must preserve incoming calls/SMS on both SIMs; verify dsds-daemon still receives QRTR indications.
K12 Display transport: damage/partial-update support in panel-mipi-dbi so a statusbar change does not push a full 240×320×2 SPI frame; 78b9000.spi measured 0.17 IRQs/s. Less SPI/GPU work per redraw. Driver work; per-device panel init sequences.
K13 zram: switch zram0 from zstd to lz4 (CONFIG_ZRAM_DEF_COMP_LZ4), and mount tmpfs on /tmp (currently on rootfs/eMMC → mmc0 0.75 IRQs/s). Lower CPU per swap I/O and fewer eMMC writes. Measured only 2.5 MB swap used → low impact. Slightly worse compression; /tmp size must be bounded on a 512 MB device.
K14 Optional advanced: CONFIG_RCU_LAZY=y + rcu_nocbs=all (batches RCU callbacks), CONFIG_ENERGY_MODEL + EAS, CONFIG_PM_AUTOSLEEP for opportunistic suspend. Further idle savings. EAS needs OPP energy data; autosleep needs a correct wakelock policy.

5. Corrected userspace-side optimizations

# Change Evidence / expected effect Risk
U1 Re-enable idle blanking while unlocked: stop touching sxmo.noidle in bananarchy-x11-session.sh/sxmo_hook_start.sh; provide a blank-without-lock path (today sxmo_state.sh set screenoff → sxmo_hook_screenoff.sh → xlocker screenoff also locks). Measured: screen unlocked, brightness 10/14, DPMS On, idle_locker not running → backlight/panel/GPU live 24/7. Largest userspace win. Changes the earlier "unlocked screen never blanks" design; make it a configurable timeout.
U2 Implement real suspend: replace no-op sxmo_autosuspend.sh/sxmo_suspend.sh, set AllowSuspend=yes, remove the infinite sxmo_not_suspendable wakelock and sxmo.nosuspend, and use the existing timed wakelocks (sxmo_modem.sh, sxmo_hook_postwake.sh) once CONFIG_PM_WAKELOCKS exists. sxmo_hook_block_suspend.sh already lists the blockers. Enables K1. /sys/power/wake_lock is absent today, so all current wakelocks are no-ops. Resume latency; must not suspend during calls, SMS, ringtone, active SSH/VPN/tethering.
U3 statusbar_periodics: sxmo_run_aligned.sh 60 sxmo_hook_statusbar.sh periodics is running and its guard passes. Replace mmcli -m any -J, nmcli -t con show --active, nmcli ... device wifi list, rfkill list wifi, xsetroot -name with D-Bus PropertiesChanged signals, or raise to ≥300 s and only xsetroot on change. Removes a 60 s QMI/D-Bus/process burst and a full dwm bar redraw (SPI frame). Statusbar icons lag up to the new interval.
U4 Battery udev path: filter 85-bananarchy-battery.rules to KERNEL=="pm8916-bms-vm"/ENV{POWER_SUPPLY_NAME}, drop the (sleep 2; ... recheck) fork, avoid su per event. Measured 2 uevents/min; removes the su/sleep forks. Lower priority than previously stated. Charging icon must still update instantly on plug/unplug (keep the charger event).
U5 Bluetooth (latent): set AutoEnable=false, finite DiscoverableTimeout/PairableTimeout, ControllerMode=bredr, and keep BT out of the default runlevel. BT is already off (soft-blocked, daemon not running) — no current saving today; this prevents a future drain when a user enables BT. BT must still auto-reconnect when explicitly enabled.
U6 chronyd: remove from the default runlevel or set minpoll 12 maxpoll 16; rely on rtcsync/RTC (osclock, swclock-offset-boot are already in the boot runlevel). Measured running with pool pool.ntp.org iburst, but after 43 h uptime it is at ~1024 s polls → low priority. Removes a daemon and occasional DNS/NTP Wi-Fi wakeups. Clock drift without NTP.
U7 Duplicate wpa_supplicant / respawn storm Removed — see C1. One stable -u instance; the yesno typo is harmless. Optionally fix the cosmetic typo. None.
U8 NetworkManager: add [device] wifi.scan-interval=600 (no override exists today), ipv6.method=ignore for Wi-Fi profiles, keep wifi.powersave=3 and connectivity.enabled=false. Fewer roaming scans and IPv6 ND/MLD wakeups (measured IPv6 active on wlan0). Roaming responsiveness; IPv6-only networks.
U9 DSDS/modem userspace: make dsds-daemon poll_stored_sms (600 s when unlocked) purely event-driven (WMS NEW_MESSAGE indications), add backoff on its time.sleep(2) exception loop, make --dpm-open-port on-demand, and add a "DSDS power-save" toggle (disable secondary subscription / prefer 2G / single-standby while Wi-Fi is the default route). Measured DSDS active with LTE+GSM, no data bearer, DPM port open, drx-cycle/mico-mode unset. Directly reduces baseband wakeups. Must not lose SIM2 calls/SMS; gate on user preference.
U10 sxmo_soundmonitor.sh 5 s loop Removed — see C3. evtest /dev/input/event5 blocks; pactl subscribe is event-driven. Optional: replace the sleep 2 outer restart loop with a longer backoff. None.
U11 Plugin timers (conditional, not active now): sip_plugin.cpp 15 s poll with enabled accounts, tox_plugin.cpp 250–1000 ms iterate, locker_plugin.cpp 1-min clock timer, gps_plugin.cpp usleep(300000). Move to timerfd/event-driven and freeze when the screen is blanked. Removes periodic wakeups when those apps are configured. SIP REGISTER expiry / Tox presence.
U12 zram / /tmp (corrected): mount tmpfs on /tmp (currently on rootfs/eMMC); optionally switch zram0 zstd→lz4. zram-init is not enabled, so its type1=/tmp/strictatime config is dead. Fewer eMMC writes (mmc0 0.75 IRQs/s) and cheaper compression. Measured only 2.5 MB swap used → low impact. Bound /tmp size on 512 MB RAM.
U13 Align the shipped user hook: ~/.config/sxmo/hooks/sxmo_hook_start.sh starts superd without -l /dev/null; the default hook has it. The user hook wins via PATH. Restores the intended zero-log default (measured superd without -l /dev/null). None.
U14 Xorg: AccelMethod "glamor" + DRI3 keeps the GPU path live; bananarchy-x11-session.sh re-runs xrdb, feh, bananarchy-sync-dunst-theme on every dwm restart. Consider software rendering for QVGA and skip wallpaper/theme work when the screen is off. Pairs with K5. UI smoothness / <2 ms wake.

6. DSDS + Wi-Fi specific combined measures

  • Close the cellular data plane when Wi-Fi carries traffic. No GSM profiles exist and bearers: [], yet msm8909-modem-wwan-port opens the DPM BAM-DMUX port at every boot — pure overhead in this scenario (K11/U9).
  • Reduce tune-away. DUAL_SIM_ACTIVE=1 with PRIMARY_GW_SLOT=2 (LTE) and SECONDARY_GW_SLOT=1 (GSM). A screen-off policy that drops the secondary subscription to single-standby (keeping SIM2 reachable via paging) is the remaining modem-side lever; the drx-cycle/mico-mode fields are 5G-only and not applicable here (C17).
  • Let Wi-Fi sleep deeply. WoWLAN + ARP/NS/GTK offload + ignore_dtim are implemented in wcn36xx_suspend() but unreachable without K1/U2. Today the residual floor is ~1.8 RX IRQs/s and 111 RX packets/min with zero TX (K3/U8).
  • Silence the remaining periodic noise: 60 s statusbar (U3), 2/min BMS uevents (U4), chronyd NTP (U6, low), 600 s DSDS SMS poll (U9), SIP/Tox timers when configured (U11).
  • The screen is the biggest single controllable load: unlocked, brightness 10/14, DPMS On, no idle blank (U1). No combination of kernel tweaks will reach 24 h while the panel and backlight stay on continuously.

7. Re-prioritized shortlist

  1. K1 + U2 — enable suspend (0-byte /sys/power/state confirmed) with wake sources and timed wakelocks. Biggest absolute win; conflicts with <2 ms wake, so ship as opt-in deep standby.
  2. U1 — configurable idle blank while unlocked (screen measured on 24/7). Largest userspace win.
  3. K2 — clock-latency-ns in the OPP table (4294967295 measured); removes the userspace rate_limit_us hack at its source.
  4. K3 + K11 + U9 — WoWLAN/DTIM-skip, wcn36xx keep-alive/listen interval, QMI NAS DRX/MICO, on-demand DPM port, DSDS tune-away reduction. Directly targets the reported DSDS+Wi-Fi case.
  5. U3 + U4 + U8 — 60 s statusbar storm, BMS udev forks, IPv6/scan interval on wlan0.
  6. K6 + K7 + K8 — kernel config trimming (HZ/preempt/hrtick, debug/tracing, serial console).
  7. K5 + K10 + K13 + U12 — GPU resume OPP, IPv6 off, tmpfs /tmp, lz4 zram (measured low impact).
  8. U5 + U6 + U11 + U13 + U14 — latent/conditional cleanups (BT config, chronyd, plugin timers, zero-log hook, Xorg accel).

Items U7 and U10 from the previous analysis are withdrawn.


8. Corrected verification plan (for a battery-powered run)

The phone must be disconnected from USB power to measure discharge; SSH then has to go over wlan0 (the Wi-Fi connection OffOurStreets_ is active). Because iw, powertop and current_now are unavailable, use:

  • zcat /proc/config.gz | grep -E 'SUSPEND|PM_WAKELOCKS'; wc -c /sys/power/state; ls /sys/power/; cat /sys/power/wake_lock.
  • cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_transition_latency (expect a realistic value after K2), schedutil/rate_limit_us, stats/time_in_state.
  • 60 s deltas of /proc/stat, /proc/interrupts, /proc/net/dev, cpuidle state*/usage, pm8916_vm_bms IRQ count, and udevadm monitor --subsystem-match=power_supply event count.
  • nmcli -t -f DEVICE,TYPE,STATE device, mmcli -m any -J (check drx-cycle/mico-mode), /usr/libexec/msm-modem-uim-selection status, cat /tmp/sxmo_dsds_active.
  • rfkill list, rc-update show -v, rc-status, superctl status, sxmo_jobs.sh list, ps -o pid,etime,args -A.
  • DISPLAY=:0 xset q, cat /sys/class/drm/card0-SPI-1/dpms, /sys/class/backlight/backlight/{brightness,bl_power}, sxmo_state.sh get.
  • Compare 1 h idle drain (screen off, DSDS, Wi-Fi on) before/after each change; target < 62.5 mA average for > 24 h on the 1500 mAh pack.

9. Summary

The live device confirms the two structural root causes: there is no suspend state at all (/sys/power/state is empty, CONFIG_SUSPEND off) and the unlocked screen never blanks (sxmo.noidle, brightness 10/14, DPMS On, idle_locker absent), with DSDS (LTE+GSM) and Wi-Fi both fully associated. It also confirms cpuinfo_transition_latency=4294967295 and that the schedutil rate-limit fix is working. Conversely, it disproves four earlier claims (duplicate wpa_supplicant, BT always on, soundmonitor 5 s loop, /tmp on zram) and shows that the CPU cores are already ~98 % power-collapsed — so the remaining drain is always-on SoC rails, DDR, display and radios, not CPU busy loops. K1/U2 plus U1 are the only changes that can plausibly deliver > 24 h; the rest are incremental but cumulatively significant.


10. Implementation status (applied in this change set)

Every item in sections 4 and 5 was addressed; the table below records how, and flags the few places where the regression checks mandated by the analysis changed the implementation.

Item Implementation
K1 CONFIG_SUSPEND, CONFIG_SUSPEND_FREEZER, CONFIG_PM_WAKELOCKS, CONFIG_PM_WAKELOCKS_LIMIT/GC, CONFIG_PM_AUTOSLEEP enabled; wakeup-source added to the WCNSS/pronto remoteproc in all 5 DTS files; build-kernel-audio.sh now builds the zImage from the tuned config and ships it as overlay/rootfs/boot/vmlinuz (+ config, System.map).
K2 clock-latency-ns = <100000> added to cpu-opp-table in all 5 DTS files.
K3 New patches/kernel/0006-...patch: keep-alive 30 s -> 120 s, listen_interval = 3, BMS sample interval 10 -> 30, power_supply_changed() throttled to real capacity changes, GPU devfreq polling_ms 50 -> 100. WoWLAN/ARP/NS/GTK offload + ignore_dtim come from wcn36xx_suspend() once K1 is active.
K4 Same patch 0006 (kernel) + U4 (userspace).
K5 Kernel patch (polling_ms) + 10-power-save.start writes polling_interval=100 + sxmo_wm.sh display off/on switches the GPU devfreq governor to powersave/simple_ondemand.
K6 CONFIG_HZ=100, CONFIG_PREEMPT_VOLUNTARY, SCHED_HRTICK/CPU_FREQ_STAT/IRQ_TIME_ACCOUNTING/SCHED_SMT off, CPU_IDLE_GOV_TEO=y.
K7 Ftrace/function tracer/dynamic debug/perf/profiling/kprobes/uprobes/BPF-JIT-always-on/fw-loader-debug/thermal-emulation/Magic SysRq/printk-time/DRM GPU state/logo/serial console disabled; DRM_FBDEV_OVERALLOC=0; LED triggers and unused input classes disabled. FRAMEBUFFER_CONSOLE kept (plymouth boot splash) and NETFILTER/IPV6/CGROUPS kept (Tor/WireGuard/tethering and elogind) — these are the regression checks from the risk column, not skipped items.
K8 earlycon and console=ttyMSM0,115200 removed from all devices/*/kernel-cmdline.conf and from usr/lib/kernel-cmdline.d/50-device-*.conf in the overlay.
K9 Unused built-in input classes and LED triggers disabled; netfilter/IPv6/cgroups deliberately retained (see K7); msm8905-cam retained in /etc/modules because its out-of-tree platform driver has no udev autoload path — removing it would break xcamera.
K10 net.ipv6.conf.default.disable_ipv6=1 in etc/sysctl.d/99-bananarchy-power.conf and 10-power-save.start; the ipv6 module stays loaded for WireGuard/Tor and ::1 on lo.
K11 On-demand QMI DPM port (bananarchy-dpm.sh + NM dispatcher + conditional boot open); wakeup-source on pronto. QMI NAS DRX/MICO withdrawn (C17).
K12 Deferred with justification: damage/partial-window updates in panel-mipi-dbi need panel-specific GC9305/GC9307 commands and risk display corruption. The equivalent userspace win (no full-frame redraw on every statusbar tick) is delivered by U3.
K13 CONFIG_ZRAM_DEF_COMP_LZ4=y, zram-init algo*=lz4, /tmp mounted as tmpfs via etc/fstab.
K14 CONFIG_ENERGY_MODEL enabled; CONFIG_RCU_NOCB_CPU/CONFIG_RCU_LAZY are dependency-gated (`RCU_EXPERT
U1 bananarchy-idle-blank.sh + sxmo_hook_unlock.sh starts idle_locker at SXMO_UNLOCK_IDLE_TIME (default 60 s) with a blank-without-lock resume hook; bananarchy-x11-session.sh no longer forces sxmo.noidle.
U2 bananarchy-suspend.sh / bananarchy-deep-standby.sh / sxmo_autosuspend.sh / sxmo_suspend.sh, AllowSuspend=yes, doas rule, infinite wakelock removed, sxmo.nosuspend removed, sxmo_hook_screenoff.sh starts the grace timer, sxmo_hook_unlock.sh/postwake.sh cancel it. Shipped disabled via /etc/bananarchy-no-deep-standby until the new kernel has been boot-tested: a broken driver suspend callback must never leave a flashed phone unwakeable. freeze (s2idle, any-IRQ wake) is preferred; mem requires /etc/bananarchy-allow-mem-suspend.
U3 statusbar_periodics interval 60 -> 300 s; sxmo_hook_statusbar.sh periodics drops mmcli/nmcli/rfkill polls and only calls xsetroot when the status string changes.
U4 udev rule filtered to the two PM8916 supplies; (sleep 2; ... recheck) fork removed from sxmo_hook_battery.sh.
U5 AutoEnable=false, finite discoverable/pairable timeouts, ControllerMode=bredr, fewer reconnect attempts. BT was already off on the device, so this is a latent fix.
U6 etc/chrony/chrony.conf uses minpoll 12 maxpoll 16 and no iburst.
U7 Withdrawn (C1); the cosmetic yesno typo in etc/init.d/wpa_supplicant was fixed anyway.
U8 [device] wifi.scan-interval=600 in 10-power.conf; IPv6 disabled on new interfaces (K10).
U9 On-demand DPM port; dsds-daemon 600 s -> 1800 s poll and 2 s -> 30 s error backoff; sxmo_modemmonitor.sh 10/120 s -> 30/600 s.
U10 Withdrawn (C3); the outer pactl subscribe restart backoff raised 2 s -> 10 s.
U11 sip_plugin.cpp 15 s -> 60 s poll; tox_plugin.cpp iteration clamp 250-1000 ms -> 1000-2000 ms. locker_plugin.cpp already blocks indefinitely when blanked; gps_plugin.cpp's usleep(300000) is in the --test CLI path only.
U12 tmpfs on /tmp; zram lz4, noatime, size1=256.
U13 Shipped user/skel sxmo_hook_start.sh now starts superd -l /dev/null with /dev/null log symlinks, matching the default hook.
U14 bananarchy-x11-session.sh skips xrdb/feh/dunst-theme work when the panel is dark. Glamor retained (GPU-acceleration design goal).

Not runtime-verified: the new kernel image, DTBs, clock-latency-ns, suspend states and the kernel patch 0006 require a reflash + reboot. The userspace changes were deployed and syntax/runtime-checked on the connected phone (charging over USB, so no discharge-current measurement was possible). Deep standby stays opt-in until that boot test is done.


11. Recovery: why the kernel-config items cannot ship as-is

The first implementation pass rebuilt the kernel image from a retuned config and produced an image that stays on the lk2nd logo. Two ABI incompatibilities with the linux-postmarketos-qcom-msm8916 module tree (which this repo does not rebuild) were found:

  1. Vermagic — CONFIG_PREEMPT_VOLUNTARY removes CONFIG_PREEMPT_BUILD, so the rebuilt kernel reports 6.12.1-msm8916 SMP mod_unload ARMv7 p2v8 while every package module reports 6.12.1-msm8916 SMP preempt mod_unload ARMv7 p2v8. modprobe refuses all of them, including panel-mipi-dbi and msm, so the display never initialises. Verified on-device before the reflash and on the built artifacts with modinfo.
  2. Struct layout — CONFIG_SUSPEND=y selects CONFIG_PM_SLEEP, which adds entry, completion, wakeup, wakeup_path, syscore, no_pm_callbacks, async_in_progress, must_resume, may_skip_resume to struct dev_pm_info. Modules built without it use wrong dev->power.* offsets; matching vermagic would not be sufficient.

Consequence: K1 (CONFIG_SUSPEND + wakelocks), K6 (preempt/HZ/hrtick), K7 (debug/tracing config), K8 (no serial console), K13 (ZRAM_DEF_COMP) and K14 (ENERGY_MODEL) are reverted to the known-good config. Implementing them properly requires either (a) vendoring and rebuilding the entire pmaports kernel module tree so every module matches the new kernel, or (b) shipping a kernel with the original ABI and accepting that those config-level savings are unavailable.

Kept because they do not depend on the kernel config: K2 (clock-latency-ns in the DTB), K3/K4/K5 (patch 0006, rebuilt with the original config), K10 (IPv6 sysctl), and all U1-U14 userspace changes. Deep standby (U2) stays disabled and inert.


12. Post-flash fixes (after the recovery image booted)

  • U1 idle blank wake race: replaced the sxmo_idle.sh/xprintidle job with a dwm-native idle timer (src/sxmo-dwm/dwm.c), because dwm consumes evdev key events before X sees them. wake_phone() now resets the timer, so pressing the power key can no longer turn the screen on and immediately back off.
  • DSDS with a PIN-locked SIM: provision_slot() now prefers the ready slot for primary-gw-provisioning when the preferred slot is pin1/puk1, so the unlocked SIM registers at boot. verify-pin re-runs boot after unlock.

13. Configurable screen blank (post-flash)

U1's idle blanking is now a user-facing setting: Config -> Screen blank (Off, 30 s, 1/5/10/30 min; default 5 min) writes ~/.config/sxmo/idle_blank_timeout. dwm reads it live and reloads on SIGUSR1. Lid close / Power-menu Lock blank immediately; incoming calls and SMS/notifications wake immediately via bananarchy-screen-wake.sh, which also resets dwm's idle timer. This keeps the panel off for long idle periods (battery) without delaying call/SMS visibility.


14. Remaining kernel headroom and the full-module-tree question (live re-measurement)

This section answers two questions with fresh on-device data: what kernel-side optimizations are still unimplemented after ad3461b / 0dbb37f / 22d629f / da68bb8, and whether rebuilding the entire pmaports kernel module tree is worth doing to unlock them.

14.1 Session, limits, and state

  • Host clock 2026-11-07 18:03-18:46 EET; phone Bananarchy Linux a1107, Linux nokia-argon 6.12.1-msm8916 #1 SMP PREEMPT, freshly rebooted (uptime 12-22 min during the windows), reachable at 172.16.42.1 over USB RNDIS.
  • Charging throughout: pm8916-lbc-chgr/online=1, constant_charge_current=540000, pm8916-bms-vm/status=Charging, capacity 85 -> 87, voltage_now 4.198 -> 4.309 V. There is no current_now, no coulomb counter, voltage_ocv is empty, hwmon6 exposes only in0_input, /proc/config.gz is absent, and the SPMI regmap debugfs registers files are read-only and return XX. The charger's CONSTANT_CHARGE_CURRENT setter clamps to PM8916_LBC_CHGR_MIN_CURRENT (90 mA) and always writes CHG_EN, so charging cannot be disabled from userspace. No discharge current was measurable; every mA figure below is a structural estimate, exactly as in section 1.
  • Wi-Fi associated to OffOurStreets_; both SIMs registered on the network (SLOT1_REG_STATE=registered / lte / -67 dBm, SLOT2_REG_STATE=registered / gsm / -66 dBm), so DSDS RF was active during the measurement. Caveat: mmcli -L reported No modems were found in this session even though QMI NAS showed both SIMs registered; the ModemManager modem object was absent. That is a separate functional issue and does not remove the modem RF drain.
  • Idle windows ran with the panel forced dark (brightness=0, bl_power=4, DPMS Off) via bananarchy-idle-blank.sh off.
  • Session incident: at ~22 min uptime the phone stopped responding (blank panel, USB RNDIS gone from the host, no fastboot/EDL/ADB) and needed a hard power-key reset. pstore was empty and the post-reset dmesg shows no panic or oops; after the reset the phone booted normally with the screen on, Wi-Fi connected and all services started. No kernel image, module, DTB, cmdline or config was changed in this session — every probe was a read-only sysfs/debugfs//proc read plus bananarchy-idle-blank.sh off/on round-trips. The cause is unknown; it is another reason not to swap the kernel/module ABI on a device whose wake path is this fragile.
  • Post-reset fuel-gauge transient (new kernel-side finding): for the first ~3.5 min after a hard reset the VM-BMS reports voltage_now=19199723 uV (19.2 V), health=Over voltage, status=Full, capacity=100, while voltage_ocv is a sane 4.267 V. The cause is an uninitialised FIFO sample of 0xffff: pm8916_bms_vm_fifo_update_done_irq() accepts any raw value > 8000, and 0xffff * 292.969 uV = 19.2 V. It settles to 4.32 V / Good / 96% once the first real 30 s FIFO sample arrives. This is a correctness bug in pm8916_bms_vm.c, fixable with a source-only sanity clamp (no config or ABI change); it is listed in 14.7.

14.2 What the idle application processor actually does now

60-second window, screen off, Wi-Fi up, both SIMs registered:

Signal Rate
arch_mem_timer (broadcast timer, GIC 39) 20.70 /s
arch_timer (GIC 20) 15.08 /s
Total timer IRQs 35.78 /s
IPI3 function call 8.40 /s
IPI1 timer broadcast 1.78 /s
IPI2 rescheduling 0.85 /s
wcn36xx_rx 2.43 /s
mmc0 2.20 /s
smd-edge 0.35 /s
wcn36xx_tx 0.08 /s
pm8916_vm_bms 0.02 /s
cpu-sleep-0 (SPC) entries, cpu0 / cpu1 19.4 /s, 10.1 /s (29.5 /s)
CPU idle (/proc/stat) 98.08% overall, 99.22% cpu0, 96.93% cpu1

Runtime PM / clocks / regulators at the same moment:

  • 78b9000.spi, 1c00000.gpu, 7824900.sdhci, 7864900.sdhci all status=suspended; GPU devfreq simple_ondemand, 409.6 MHz, 100 ms poll.
  • pm_genpd_summary: mx, mx_ao, cx, all GDSCs off-0; cx_ao on (cpu0); 1c00000.gpu, 4080000.remoteproc (modem), a204000.remoteproc (WCNSS) all suspended.
  • 21 clocks have a nonzero enable count. The always-on ones are structural: bimc_ddr_clk_src 768 MHz (DDR not in self-refresh), a53pll 1094.4 MHz, gcc_mss_q6_bimc_axi_clk 768 MHz (modem bus), gcc_usb_hs_system_clk 80 MHz + gcc_usb_hs_ahb_clk 100 MHz (USB RNDIS), sleep-clk 32.768 kHz, and gcc_blsp1_uart1_apps_clk 3.686 MHz (the console=ttyMSM0 serial console). Regulators with use > 0 are s2, l5, l6, l7, l8, l13, l17 (audio codec, SDHCI, USB PHY, panel supplies) — no orphaned rail.
  • All four LEDs are off with none / mmc0 / mmc1 triggers; no periodic LED trigger exists.
  • With the panel dark, userspace is nearly silent: 19.5 voluntary context switches/s total, of which rcu_preempt 9.8/s, kcompactd0 2.1/s, a few kworkers ~4/s. Xorg drops from 43.5/s (screen on) to ~0/s. Nine hrtimer_wakeup entries were armed at any instant, with 0.5-2.5 s periods.

In short: the userspace work from U1-U14 has already removed essentially all userspace wakeups. What remains is kernel-internal tick/hrtimer/RCU activity plus a handful of peripheral IRQs, on an AP that is already ~98% idle with every runtime-PM domain collapsed.

14.3 Decisive finding: mem suspend is impossible on this platform

Enabling CONFIG_SUSPEND would not give suspend-to-RAM here:

  • arch/arm/boot/dts/qcom/qcom-msm8916-smp.dtsi explicitly sets psci { status = "disabled"; } and replaces the PSCI idle state with qcom,idle-state-spc. The live device tree has no /proc/device-tree/psci node, no /sys/firmware/psci, dmesg says qcom_scm: convention: smc legacy, and the cpuidle driver is qcom_spm.
  • The only suspend_set_ops() caller reachable on ARM DT platforms is drivers/firmware/psci/psci.c, and it only registers when PSCI 1.0 SYSTEM_SUSPEND is available. arch/arm/mach-qcom/ has no suspend ops. valid_state(PM_SUSPEND_MEM) in kernel/power/suspend.c returns false without suspend_ops, so writing mem to /sys/power/state degrades to mem_sleep_current = s2idle at best and is rejected otherwise.
  • Consequence: CONFIG_SUSPEND=y yields only freeze (s2idle). s2idle calls tick_freeze() -> timekeeping_suspend() and freezes tasks, so the ~36 timer IRQs/s stop, but there is no RPM-assisted SoC power collapse and no DDR self-refresh. bimc_ddr_clk_src stays at 768 MHz. That is the one saving that could plausibly have been worth tens of mA, and it is gated by firmware (lk2nd would have to implement PSCI SYSTEM_SUSPEND), not by the kernel config.

14.4 Full module tree rebuild: feasibility (it is clean)

The rebuild itself turned out to be much less risky than assumed in section 11:

  • pmaports v26.06 device/testing/linux-postmarketos-qcom-msm8916/APKBUILD (6.12.1-r5) uses the same msm8916-mainline/linux v6.12.1-msm8916 tarball that scripts/build-kernel-audio.sh already caches. Its prepare() is default_prepare plus cp config-...armv7 .config — no patches at all. There are no pmaports-only driver fixes to lose.
  • Our config-bananarchy-msm8909.armv7 differs from config-postmarketos-qcom-msm8916.armv7 in ~248 lines, almost entirely the GCC/binutils version stamp, CONFIG_MODULE_COMPRESS_ALL=y, and CONFIG_NFT_REDIR=m for our nft_redir.ko.
  • The package tree is 579 .ko.zst files / 11 MB. Our config already has CONFIG_MODULE_COMPRESS_ZSTD=y, CONFIG_MODULE_COMPRESS_ALL=y and CONFIG_MODULE_DECOMPRESS=y, so make modules_install INSTALL_MOD_STRIP=1 reproduces the exact on-disk layout, and rebuild-image.sh already runs depmod -b "$ROOTFS" 6.12.1-msm8916. scripts/sync-prebuilt-overlay.sh would mirror a prebuilt/kernel-6.12.1-msm8916/lib/modules/... tree into the overlay without changes.

So the mechanical part is a bounded build-script change plus ~11 MB of artifacts. The reason not to do it is the benefit, not the mechanics.

14.5 Full module tree rebuild: benefit (it is not real)

Quantify the only thing s2idle adds on top of the current state:

  • Eliminating all 29.5 SPC entries/s. Entry+exit latency of qcom,idle-state-spc is 130/150 us; even at a pessimistic 75 mA during each transition, that is ~0.3-0.5 mA of AP transition overhead. Removing every timer IRQ, IPI and Wi-Fi/eMMC IRQ wakeup is the same order of magnitude (<1 mA combined).
  • dpm_suspend() would run every driver's system-sleep callback. Most of what those would power down is already runtime-suspended (SPI, GPU, SDHCI, remoteprocs, panel via DPMS). wcn36xx_suspend() would add ARP/NS/GTK offload and enable_irq_wake(wcn->rx_irq) is already set at probe, so Wi-Fi wake would work, but it only removes 2.43 RX IRQs/s.
  • The dominant DSDS + Wi-Fi drain is untouched: two registered SIMs' RF, the WCNSS/Pronto firmware, the modem bus clock, and DDR in active mode. None of these are configurable from the kernel. Reaching 24 h on 1500 mAh needs <= 62.5 mA average; a plausible current draw in this mode is ~80-120 mA, so ~20-55 mA has to come from the modem/Wi-Fi side, not from <1 mA of AP wakeup overhead.

The remaining config-level items (K6/K7/K13/K14) do not change that verdict:

  • CONFIG_HZ=100 changes the HZ macro compiled into module inlines (include/linux/jiffies.h), so it is not ABI-safe either.
  • CONFIG_ENERGY_MODEL=y inserts em_pd into struct device (include/linux/device.h) and CONFIG_PERF_EVENTS / CONFIG_FUNCTION_GRAPH_TRACER change struct task_struct — all module-visible. ARM32 has no EAS, so ENERGY_MODEL buys nothing anyway.
  • CONFIG_RCU_LAZY depends on RCU_NOCB_CPU and requires rcu_nocbs=all; on 2 cores that adds always-running rcuo kthreads and trades away the idle saving (already withdrawn as C17/K14).
  • CONFIG_PREEMPT_VOLUNTARY / CONFIG_HZ=100 also work against the project's < 2 ms UI wakeup latency target.
  • CONFIG_SCHED_HRTICK off and CONFIG_CPU_IDLE_GOV_TEO=y are genuinely ABI-safe (the former only touches the private kernel/sched/sched.h), but with no CFS bandwidth quotas and only two cpuidle states they are effectively no-ops.

14.6 Verdict

Do not rebuild the entire kernel module tree. It is technically feasible, but the only feature it unlocks is s2idle, which on this firmware cannot do mem, cannot reach DDR self-refresh, and can save less than ~1 mA of AP transition overhead against a ~20-55 mA deficit. It would reintroduce exactly the class of risk that produced the unbootable ad3461b image (vermagic + struct dev_pm_info), activate untested system-sleep callbacks for the panel, DRM, Wi-Fi and modem remoteprocs, and conflict with the low-latency design goal — for no measurable gain in DSDS + Wi-Fi runtime. pmaports deliberately ships # CONFIG_SUSPEND is not set for this kernel.

Deep standby therefore stays shipped disabled (/etc/bananarchy-no-deep-standby) and inert, and the known-good module ABI stays untouched. If PSCI SYSTEM_SUSPEND ever appears in lk2nd for MSM8909, revisit K1: that is the change that would make a full rebuild worthwhile.

14.7 Remaining kernel-level items, individually

Item Expected gain ABI / design risk Verdict
K1 CONFIG_SUSPEND + wakelocks + autosleep <1 mA (s2idle only, no mem) vermagic + struct dev_pm_info; untested driver sleep callbacks Declined (see 14.3-14.6)
K6 HZ=100, PREEMPT_VOLUNTARY, no hrtick, TEO <1 mA, mostly duplicate of K1 HZ macro in module inlines; vermagic; latency regression Declined
K7 disable ftrace/perf/kprobes/BPF-JIT/debug ~0 when unused struct task_struct layout for perf/ftrace Declined
K8 remove earlycon console=ttyMSM0 gates one 3.686 MHz UART clock, ~0.1-1 mA none (cmdline only), but removes the serial debug lifeline Optional, deliberately kept
K9 unused input/LED classes 0 (no LED trigger active, all LEDs off) none No-op, declined
K13 ZRAM_DEF_COMP_LZ4 0 (userspace already sets lz4) changes the zram module default No-op, declined
K14 ENERGY_MODEL / RCU_LAZY 0 struct device / needs rcu_nocbs=all Declined
K2/K3/K4/K5/K10 (DT + patch 0006) already landed none Done in ad3461b
K12 panel partial updates deferred (display corruption risk) none Still deferred
New: wcn36xx listen_interval 3 -> 5+ cuts ~1 Wi-Fi RX IRQ/s none (source patch), but delays inbound Wi-Fi data Marginal, declined
New: commit= on the rootfs mount cuts ~2 eMMC IRQs/s userspace, not kernel; risks data loss on sudden power cut Out of scope, noted
New: VM-BMS FIFO sanity clamp 0 power, fixes a 19.2 V / Over voltage misreport for ~3.5 min after hard reset none (source-only patch to pm8916_bms_vm.c) Worth fixing; no rebuild needed

14.8 Where the 24 h actually has to come from

With the display now dark after 5 minutes and userspace quiet, the kernel is no longer the bottleneck. The remaining budget has to be attacked at the modem and Wi-Fi layers:

  1. Modem idle power: LTE eDRX / PSM via AT+CEDRXS / AT+CPSMS on /dev/wwan0at0 (or the QMI NAS equivalents). Two continuously registered SIMs on LTE + GSM are the largest single drain; PSM/eDRX is the standard way to cut it by an order of magnitude while staying reachable. This is a modem-firmware configuration, not a kernel config option.
  2. DSDS policy: parking the second SIM (or reducing its polling) when idle trades DSDS availability for a large RF saving.
  3. Wi-Fi DTIM / listen interval: AP-side DTIM and wcn36xx listen_interval tuning can cut the 2.43 RX IRQs/s, at the cost of inbound data latency.
  4. DDR self-refresh: requires mem suspend, which needs PSCI SYSTEM_SUSPEND in lk2nd. Until then bimc_ddr_clk_src stays at 768 MHz and no kernel-side change can fix it.

None of these four are unlocked by rebuilding the module tree.


15. Kernel-side fix and runtime power policies (implemented)

Section 14 concluded that a full module tree rebuild is not worthwhile. This section records the two things that were worth doing: one source-only kernel fix, and a configurable runtime power-policy layer for the modem/Wi-Fi/DSDS items that section 14.8 identified as the real remaining levers.

15.1 VM-BMS FIFO sanity clamp (kernel patch 0007)

patches/kernel/0007-msm8909-bms-fifo-wifi-policy.patch makes the VM-BMS VADC conversion defensive: PM8916_BMS_VM_RAW_MIN 8000 / PM8916_BMS_VM_RAW_MAX 16000 (~2.34-4.69 V) with a PM8916_BMS_VM_NOMINAL_UV 3700000 fallback, and rejects out-of-window FIFO samples in both the IRQ handler and the probe-time pre-read. An uninitialised 0xffff sample (from the FIFO or the OCV register read on probe/resume) previously produced voltage_now=19.2 V, health=Over voltage, status=Full, capacity=100 for the first minutes after a hard reset. The conversion guard covers every call site, including the two OCV register reads that a FIFO-only clamp misses. This is a source-only change: no config symbol, vermagic, or module-visible struct changes, so the known-good pmaports module ABI stays intact.

15.2 Wi-Fi beacon listen interval (kernel patch 0007 + policy)

wcn36xx gained a listen_interval module parameter (1-10, default 5, writable via /sys/module/wcn36xx/parameters/listen_interval). The previous hardcoded value was 3. /etc/bananarchy-power-policy.conf exposes WIFI_LISTEN_INTERVAL; bananarchy-power-policy.sh regenerates /etc/modprobe.d/10-bananarchy-power.conf from it. The option is read at module load, so a change needs a reboot or a wcn36xx reload. Higher values cut idle wcn36xx_rx wakeups (measured 2.43/s at interval 3) at the cost of inbound packet latency.

15.3 Modem DRX policy

Live probing of the modem (MPSS.JO.3.0.c4, 2018 firmware) showed:

Command Result
AT+CPSMS=?, AT+CPSMS? ERROR (PSM unsupported)
AT+CEDRXS=?, AT+CEDRXS? ERROR (eDRX unsupported)
AT$QCDRX=? $QCDRX: (0,6-9)
AT$QCDRX? $QCDRX: 0
AT$QCDRX=6..9 OK, readback correct, AT+COPS? stays registered
qmicli --nas-get-drx unknown (read-only, no setter)

So the standard 3GPP PSM/eDRX AT commands from section 14.8 are not available on this firmware. The Qualcomm-proprietary AT$QCDRX DRX mode is the supported equivalent. MODEM_DRX_MODE in /etc/bananarchy-power-policy.conf accepts 0 (firmware default) or 6-9 and is applied at boot and on every screen wake via msm-modem-uim-selection at auto. Default is 0 because values above 6 are undocumented here: AT$QCDRX=9 made the AT channel briefly unresponsive during testing. Users who accept longer paging latency can opt in to 6.

15.4 DSDS secondary-SIM policy

Two mechanisms were tested on the live phone:

  • qmicli --uim-sim-power-off=2 / --uim-sim-power-on=2 works, but the power-on leaves a PIN-enabled SIM in pin1-or-upin-pin-required / enabled-not-verified and the secondary subscription unregistered. A warm reboot and AT+CFUN=1,1 do not restore the cached PIN verification. This mechanism is therefore rejected for automatic parking.
  • qmicli --uim-change-provisioning-session='activate=no,session-type=secondary-gw-provisioning' deactivates the secondary GW session cleanly, and reactivation with slot=2,activate=yes,session-type=secondary-gw-provisioning,aid=<AID> restores it without power-cycling the SIM (no PIN loss). Verified on the device.

DSDS_SECONDARY_MODE=eco (default active) uses the second mechanism: after DSDS_PARK_DELAY seconds of a dark panel, bananarchy-power-policy.sh parks the secondary subscription and reactivates it on wake. The AID is read from --uim-get-card-status at park time and cached in /run. Hooks in sxmo_wm.sh display off/on drive it, so both the dwm idle blank and the locker screenoff paths are covered. SIM2 is unreachable while parked; that is the deliberate trade for its RF saving.

15.5 What is still not implementable

  • DDR self-refresh / mem suspend needs PSCI SYSTEM_SUSPEND in lk2nd (section 14.3). No kernel or userspace change can provide it here.
  • Standard LTE PSM/eDRX needs modem firmware support that this MPSS.JO.3.0.c4 build does not expose (section 15.3).
  • Discharge-current measurement remains impossible over USB RNDIS (charging at 540 mA, no current_now, no coulomb counter). All savings above are expressed as wakeup/IRQ counts, not mA.

15.6 Deployment and verification

  • scripts/build-kernel-audio.sh applies patch 0007 in both the cached-tree and fresh-tarball paths; the resolved .config is unchanged, so vermagic and struct dev_pm_info stay compatible with the untouched package modules.
  • bananarchy-power-policy.sh is installed as an OpenRC default-runlevel service; doas.d/50-sxmo.conf permits the X session to invoke it.
  • Live verification on the connected phone: status reports WIFI_LISTEN_INTERVAL=5 / wcn36xx_param=5 / modem_drx_now=$QCDRX: 0; MODEM_DRX_MODE=6 applies and reads back as $QCDRX: 6 with both SIMs still registered; DSDS_SECONDARY_MODE=eco parks the secondary GW session after the delay and restores it (with its captured slot and AID) on wake; WIFI_LISTEN_INTERVAL=0 removes the module option. The rebuilt modules load with the same 6.12.1-msm8916 SMP preempt mod_unload ARMv7 p2v8 vermagic as the package modules, and the defensive BMS conversion is present in the disassembly. The rebuilt image's initramfs and rootfs both contain the new pm8916_bms_vm.ko.zst / wcn36xx.ko.zst (SHA-256 match), and boot.img still carries the byte-identical known-good zImage + DTB.
  • The live phone's /boot/boot.img was deliberately left untouched: the boot-time 0xffff transient only disappears after a reflash with the rebuilt image. Reloading pm8916_bms_vm at runtime from /lib/modules confirms the new module reports sane voltage and health=Good.