Files
bananarchy/BATTERY-OPTIMIZATION-ANALYSIS.md
T
Bantam 0dbb37fba3 Fix unbootable image: restore kernel/module ABI compatibility
The previous battery pass rebuilt the kernel image from a retuned config and
produced an image stuck on the lk2nd logo. Two incompatibilities with the
linux-postmarketos-qcom-msm8916 module tree (which this repo does not rebuild)
were identified:

1. Vermagic: CONFIG_PREEMPT_VOLUNTARY removes CONFIG_PREEMPT_BUILD, so the
   rebuilt kernel reported "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, so the
   display never initialises.
2. Struct layout: CONFIG_SUSPEND selects CONFIG_PM_SLEEP, which adds fields to
   struct dev_pm_info. Modules built without it use wrong dev->power offsets,
   so matching vermagic alone is not enough.

Restored the known-good kernel config, the serial-console cmdline and the DTB
wakeup-source additions. The kernel image is still cross-compiled by
build-kernel-audio.sh but from the original config, so vermagic and struct
layouts match every module in the rootfs. Reverted the config-level items K1,
K6, K7, K8, K13 and K14; implementing them requires vendoring and rebuilding
the entire pmaports kernel module tree.

Kept: K2 clock-latency-ns, K3/K4/K5 via patch 0006 (rebuilt with the original
config), K10 IPv6 sysctl, and all U1-U14 userspace changes.

Rebuilt the kernel image/modules/DTBs and images/bananarchy-nokia-argon.img
with --mkinitfs. Verified: all modules (package + rebuilt) now report identical
vermagic, boot.img contains the new zImage + DTB byte-for-byte, the console
cmdline is restored, check-rebuild.sh passes and artifact drift is 0.

Docs: CHANGELOG.md (recovery section), MANUAL.md, README.md, AGENTS.md,
BATTERY-OPTIMIZATION-ANALYSIS.md (section 11).
2026-11-07 17:32:03 +02:00

40 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.