Files
bananarchy/BATTERY-OPTIMIZATION-ANALYSIS.md
T
Luxferre 2ae4ef34a2 Implement 0010 RPM/L2/WCD/UART deep-standby, Adreno 304 ICC/SMMU fixes, and C11 autostart daemons
- patches/kernel/0010-msm8909-rpm-lpm-bimc-wcd-ldo-uart.patch and device DTS/DTB files (nokia-{argon,beatles,beatles-cover,coconut,sparkler,leo}): vMPM APSS RPM sleep, L2 SAW2 collapse, WCD-digital runtime PM, PM8909 LDO seeding, ttyMSM0 disable, dynamic msm_gpu gfx-mem BIMC interconnect scaling (mas_oxili), and qcom_iommu context restore + atomic TLB flush on resume.
- Replace Python/shell autostart loops with compiled C11 ARM ELF daemons (bananarchy-dsds, bananarchy-modemmonitor, bananarchy-soundmonitor, bananarchy-notifmonitor, bananarchy-run-aligned, bananarchy-session-loop) plus scripts/test-dsds-daemon.py.
- Update scripts/check-rebuild.sh, CHANGELOG.md, BATTERY-OPTIMIZATION-ANALYSIS.md, MANUAL.md, README.md, and AGENTS.md with verified a1114 (carbonara) image/archive pins and guards.
2026-11-13 18:23:14 +02:00

1495 lines
105 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Bananarchy battery-usage optimization analysis (measurement-corrected)
**Status:** analysis plus implemented changes (sections 15-21).
**Project:** `/home/lux/proj/bananarchy`, current release `a1111` / `lennon`.
**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 a1108` (codename `dejavu`, `msm8909`). Historical sections
below retain the build labels from their original measurement sessions; the
current shipped build is `a1111` / `lennon`.
**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`. `cmdport 0` closes the UDP command port but leaves chronyd's
root-only Unix socket (`/run/chrony/chronyd.sock`) available for privileged
`chronyc` commands (verified in section 16); 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 at the time was `a1105`; the power-relevant code is identical to HEAD `2ea2db4`. The current build is `a1111` / `lennon`.
---
## 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 `eval`s 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=dual`, 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; dual mode is required for LE HID profiles. |
| **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. **Refined in section 16**: removing `iburst` broke the initial sync entirely, so `iburst` was restored and a network-up hook was added; the long steady-state polls are unchanged. |
| **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 | `wakeup-source` on pronto; unconditional boot-time QMI DPM `--dpm-open-port` restored in `a1114` (section 20.3) because `MMPluginQcomSoc` requires `net/wwan0` to create `/org/freedesktop/ModemManager1/Modem/0` while `bam-dmux.c` already runtime-suspends in `1000 ms` (`pc_state=0`, DMA channels released) whenever idle. QMI NAS DRX/MICO withdrawn (C17); AT `$QCDRX=6` shipped in section 20. |
| 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 || NO_HZ_FULL`) and were dropped by `olddefconfig`, so they are not active. `rcu_nocbs=all` deliberately **not** added to the cmdline: on a 2-core MSM8905 it would add always-running `rcuo` kthreads, trading away the idle saving. |
| 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=dual`, 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` with `iburst` restored; `bananarchy-time-sync.sh` refreshes the pool on network-up (section 16). |
| 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 | `dsds-daemon` 600 s -> 1800 s poll (and `poll_timeout = None` while dark in section 20) plus 2 s -> 30 s error backoff; `sxmo_modemmonitor.sh` 10/120 s -> 30/600 s. Conditional DPM port gating reverted in section 20.3 (`bam-dmux` already runtime-suspends in `1000 ms` when idle, whereas omitting `net/wwan0` broke `ModemManager` on Wi-Fi-only setups). |
| 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`
(historical measurement; current build `a1111` / `lennon`),
`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; as root-caused and
fixed in section 20.3, `U9`'s conditional `--dpm-open-port` gating left
`net/wwan0` unregistered on Wi-Fi-only setups, causing `MMPluginQcomSoc` to
abort modem probing without affecting modem RF registration.
- 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`.
---
## 16. Network-up NTP synchronisation (U6 follow-up)
### 16.1 Symptom and measurement
U6 set `pool pool.ntp.org minpoll 12 maxpoll 16` and removed `iburst` to avoid
the startup packet burst. A later live check on the connected Nokia 8110 4G
found the clock at `Mon Jan 12 12:09:59 UTC 1970` with Wi-Fi connected to
`OffOurStreets_`, USB RNDIS up, DNS working (`getent hosts pool.ntp.org`
returned 3 addresses) and `chronyd` reported `started` by OpenRC:
| Probe | Result |
| --- | --- |
| `chronyd` processes | 2, `-f /etc/chrony/chrony.conf -F 1` |
| NTP/chrony UDP sockets | none (no source had an address) |
| `chronyc activity` over the root Unix socket | `4 sources online`, `4 sources with unknown address` |
| `chronyc tracking` | `Reference ID : 00000000 ()`, ref time 1970 |
| `/var/lib/chrony` | `root:root 0750`, empty; chronyd logged `Could not open /var/lib/chrony/chrony.drift.tmp : Permission denied` |
| `chronyd -Q -t 30 ... iburst` | clock wrong by `1793085783 s`, measured in 5 s |
| `chronyd -d -x -t 25 -F 1` with shipped config | no source activity for the whole 25 s |
Three independent causes combined:
1. **DNS is not ready when chronyd starts.** OpenRC's `need net` is satisfied
by NetworkManager `provide net` as soon as the service starts, not when a
connection has a working `resolv.conf`. chronyd resolves pool names once at
startup and does not retry; the four sources stay at `unknown address`.
2. **No `iburst` and `minpoll 12`.** Even with DNS working, the first poll is
scheduled up to 4096 s after startup. Restarting chronyd with the network
already up produced no NTP socket and no clock change within 15 s; adding
`iburst` produced four reachable sources at poll 12 within 6 s.
3. **`cmdport 0` was assumed to disable chronyc entirely.** It only closes the
UDP command port. chronyd 4.9 keeps a root/chrony-only Unix socket at
`/run/chrony/chronyd.sock`; `chronyc` defaults to that socket first, so
privileged commands (`refresh`, `burst`, `online`) work without any key or
network exposure. `chronyc -h 127.0.0.1 refresh` returns `501 Not
authorised`, while `chronyc -h /run/chrony/chronyd.sock refresh` returns
`200 OK`.
A Wi-Fi disconnect/reconnect confirmed NetworkManager dispatcher scripts do
run even though the `networkmanager-dispatcher` OpenRC service is stopped:
D-Bus activates `org.freedesktop.nm_dispatcher`. Events observed:
`connectivity-change`, `dns-change`, `down`, `dns-change`, `dhcp4-change`,
`up`, `connectivity-change`.
### 16.2 Fix
- `etc/chrony/chrony.conf` restores `iburst` and keeps `minpoll 12 maxpoll 16`,
`rtcsync`, `cmdport 0` and `makestep 1 -1`. The startup burst is 4 sources x
a few packets once per boot, negligible next to 4096 s of a wrong clock.
- `usr/bin/bananarchy-time-sync.sh` (root, `doas -n` re-exec) waits for the
chronyd Unix socket, calls `chronyc refresh` until `activity` reports
`0 sources with unknown address`, then `online` and `burst 2/4`. It only
writes its throttle stamp once the pool resolves, so a later network event
can retry. Throttling uses `/proc/uptime` (monotonic): 15 s between attempts
while unsynchronised, 300 s between source refreshes once synchronised, and
a non-blocking `flock` serialises the several dispatcher events that fire
for one connection. `status` and `force` are available from the CLI.
- `etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh` handles
`up`, `dhcp4-change`, `dhcp6-change`, `dns-change`, `connectivity-change`
and `vpn-up`. `etc/init.d/bananarchy-time-sync` (`need chronyd net`,
`after networkmanager`) covers the boot race where dispatcher events fire
before chronyd is ready; both are backgrounded so they never block NM or
OpenRC.
- `/var/lib/chrony` is chowned to the `chrony` uid/gid in both
`rebuild-image.sh` and `apply-bananarchy-overlay.sh`, so the driftfile is
written and the frequency estimate survives reboots.
- `scripts/check-rebuild.sh` guards the four new files, the `iburst` /
`cmdport 0` pair, the runlevel hook and both ownership fixes.
### 16.3 Verification
On the live phone, `chronyc refresh` followed by `chronyc burst 2/4` over
`/run/chrony/chronyd.sock` resolved all four pool sources and stepped the
clock from `1970-01-12` to `Sat Nov 7 19:40:25 UTC 2026` within seconds;
`chronyc tracking` then showed `Reference ID : 53A84595
(hosted-by.SkillHost.PL)` and `System time : 0.000000000 seconds fast of NTP
time`. No UDP chronyc port was opened. The steady-state poll interval remains
`minpoll 12 maxpoll 16`, so U6's battery saving is preserved; the only extra
traffic is one short burst at boot and on each network transition.
### 16.4 Reflashed boot: why autosync still took 80 s
The image was reflashed and the boot was measured from `/proc/uptime`,
NetworkManager's `timestamps` file, OpenRC's `/run/openrc/started` symlinks,
`chronyc sources` and the helper's `/run/bananarchy-time-sync/last` stamp.
The RTC held `1970-01-12 12:39:26 UTC` (epoch 995966), so all boot file
timestamps are on that fake date and map to uptime by subtracting 995966:
| Uptime | Event |
| --- | --- |
| 0 s | kernel sets the clock from `rtc-pm8xxx` to 1970-01-12 12:39:26 UTC |
| ~27 s | NetworkManager, `chronyd`, `bananarchy-time-sync` started; chronyd resolves the pool before DNS exists, so all 8 sources stay `unknown address` |
| ~30 s | dnsmasq, wlan0 DHCP lease, `resolv.conf`; Wi-Fi `OffOurStreets_` activated (NM timestamp 995997) |
| ~112 s | USB RNDIS (`usb0`) activated (NM timestamp 996078); helper stamp 112; first NTP samples; clock stepped to 2026-11-07 20:04:23 UTC |
So `chronyd` did autostart, but at boot rather than on Wi-Fi: OpenRC `need net`
is satisfied by NetworkManager `provide net` as soon as the daemon starts.
`chronyd` resolves `pool.ntp.org` once, at ~27 s, before dnsmasq is up; with
`minpoll 12` an unresolved pool produces no packets for up to 4096 s. The
network-up hook is meant to fix that, but none of the Wi-Fi dispatcher events
(`up`, `dns-change`, `dhcp4-change`) at ~30 s produced a burst: the boot
helper either held `/run/bananarchy-time-sync/lock` for its whole 60 s
`refresh` retry loop (so `flock -n 9` dropped them) or had already written its
15 s throttle stamp after `resolved()` mistook a zero-source `activity` report
for a resolved pool. The next event was `usb0 up` at ~112 s, which finally ran
the helper and synced the clock. A controlled reproduction
with `nameserver 127.0.0.9` showed chronyd does not re-resolve on its own
(8 unknown sources for 10 s after DNS was restored) while `chronyc refresh`
resolves them within ~4 s.
Fixes, without changing the long steady-state poll interval:
- `wait_chronyd()` and `wait_sources()` now run before the lock is taken; only
the stamp / `online` / `burst` section is serialised, with `flock -w 5`.
A slow boot retry can no longer swallow network-up events.
- `resolved()` requires at least one known source (online, offline or doing a
burst) in addition to `0 sources with unknown address`, so a chronyd that
has not created any pool sources yet cannot cause a no-op burst.
- `network-up` / `force` / `sync` get 8 retries (16 s) instead of 3 (6 s).
- `bananarchy-time-sync.sh sync` waits up to 15 s for `chronyc tracking` to
show a reference ID and prints `Network time synced: <UTC date>` or a clear
failure. **Config -> Sync net time** calls it via
`bananarchy-sync-net-time.sh` and shows a desktop notification, so the user
can always force a sync without a shell.
---
## 17. Battery longevity re-analysis (post-`85c6a7b` live measurement)
A fresh 60 s idle window was measured on 2026-11-08 at ~10.3 h uptime with the
panel dark (`brightness=0`, `bl_power=4`), Wi-Fi connected to
`OffOurStreets_`, USB RNDIS up, and both SIM applications `ready`. The phone
was charging at `540000` uA with no `current_now` and no coulomb counter, so
all results below are wakeup/IRQ/context-switch counts, not discharge mA.
`capacity` was 44%, `health=Good`, `voltage_now=4054397` uV and
`voltage_ocv` returned `No data available`.
### 17.1 Measurement caveat: modem registration anomaly
`msm-modem-uim-selection status` reported
`NAS_REG_STATE=not-registered-searching`, `SEC_NAS_REG_STATE=not-registered`,
`mmcli -L` returned `No modems were found`, and the slot mapping was
`PRIMARY_GW_SLOT=2` / `SECONDARY_GW_SLOT=1` (swapped relative to the earlier
verified `1` / `2` state). `AT+COPS?` returned `+COPS: 0` with no operator.
This is a separate functional issue; no PIN verification was attempted. A
searching modem can draw more RF current than a registered idle modem, so the
radio-related conclusions below are conservative and need a battery-powered
A/B run once registration is restored.
### 17.2 Baseline: the application processor is already near its floor
60 s, screen off, Wi-Fi up, both SIM applications ready:
| Source | Rate |
| --- | --- |
| `arch_timer` | 15.01/s |
| `arch_mem_timer` | 11.64/s |
| `mmc0` | 0.56/s |
| `smd-edge` | 0.52/s |
| `wcn36xx_rx` | 0.34/s |
| `wcn36xx_tx` | 0.11/s |
| `pm8916_vm_bms` | 0.02/s |
| CPU idle | 97.93% overall, 99.48% cpu0, 96.37% cpu1 |
| `cpu-sleep-0` entries | 12.47/s cpu0, 7.54/s cpu1 |
| WFI entries | 0.97/s cpu0, 1.05/s cpu1 |
Top context-switch deltas were kernel threads (`rcu_preempt` 5.35/s,
`kcompactd0` 1.97/s, four `kworker` threads 1.11/1.10/0.50/0.47/s), then
`NetworkManager` 0.37/s, `wpa_supplicant` 0.26/s, `nmcli device monitor`
0.11/s, `dbus-daemon` 0.11/s, `udevd` 0.06/s and `init` 0.06/s. All 26
preloaded `dwm-plugin` daemons and `Xorg` were absent from the top 30, which
confirms the zero-lag resident-plugin model is not the remaining drain.
Runtime PM was already effective: `1c00000.gpu`, both SDHCI hosts, SPI, DMA
controllers, IOMMU and the modem `bam-dmux` were suspended; genpd `mx`,
`mx_ao`, `cx` and all GDSCs were off, with only `cx_ao` on. GPU devfreq was
`simple_ondemand` at 409.6 MHz with a 100 ms poll. 21 clocks remained enabled,
including `bimc_ddr_clk_src`, `gcc_mss_q6_bimc_axi_clk`, USB HS clocks and the
serial-console `gcc_blsp1_uart1_apps_clk`. Regulators with users were the dummy
regulator, `s2`, `l5`, `l7`, `l8` and `l13`.
`/sys/power/state` was still 0 bytes, `/proc/device-tree/psci` absent,
cpuidle driver `qcom_spm` with WFI + `cpu-sleep-0`, `CONFIG_SUSPEND` off,
`CONFIG_NO_HZ_IDLE=y`, `CONFIG_HZ=300`, `CONFIG_PREEMPT=y`,
`CONFIG_PERF_EVENTS=y`, `CONFIG_FUNCTION_GRAPH_TRACER=y`,
`CONFIG_ENERGY_MODEL` off and `CONFIG_CPU_IDLE_GOV_MENU=y`. The ABI-breaking
config list from section 14 still applies; a full pmaports module tree rebuild
remains declined.
### 17.3 Two low-risk wins found and implemented
1. **The active zram swap used `zstd`, not the shipped `lz4` setting.**
`postmarketos-zram-swap` calls `/usr/bin/zramstart`, which sources
`/usr/share/misc/source_deviceinfo` and defaults
`deviceinfo_zram_swap_algo` to `zstd`; it ignores
`/etc/conf.d/zram-init`. Live `/sys/block/zram0/comp_algorithm` showed
`[zstd]`. All five `devices/*/deviceinfo*` files now set
`deviceinfo_zram_swap_algo="lz4"`, and the `zram-init` config carries a
compatibility note. This restores the intended U12/K13 CPU saving without
changing the kernel or module ABI.
2. **Proactive compaction kept `kcompactd0` awake.** The default
`vm.compaction_proactiveness=20` produced 1.97 context switches/s from
`kcompactd0`. A controlled 60 s A/B with
`vm.compaction_proactiveness=0` reduced that to 0.02/s and raised measured
CPU idle from 97.93% to 99.22%; combined timer IRQs fell from 26.65/s to
17.39/s. The A/B window also showed a 3.42/s `ci_hdrc_msm` USB IRQ from
SSH/charger activity, so this is a wakeup saving, not a measured mA
saving. `vm.compaction_proactiveness=0` is now set in
`etc/sysctl.d/99-bananarchy-power.conf` and
`etc/local.d/10-power-save.start`.
### 17.4 DSDS eco A/B was inconclusive without discharge current
With `DSDS_SECONDARY_MODE=eco` and `DSDS_PARK_DELAY=2`, the secondary GW
session parked cleanly (`secondary_parked=yes`, `SECONDARY_GW_SLOT=0`) and
restored on wake. The 60 s IRQ rates did not improve versus baseline
(`mmc0` 1.24/s, `wcn36xx_rx` 0.74/s, `smd-edge` 0.61/s), likely because the
modem was already searching and the measurement included policy/config file
writes. Eco mode remains an opt-in trade (SIM2 unreachable while parked); its
RF saving can only be quantified on battery power with a registered modem.
### 17.5 Remaining opportunities, in priority order
1. **Restore modem registration and the primary/secondary slot mapping.**
This is a functional prerequisite for any radio-power A/B measurement.
2. **Battery-powered A/B for `WIFI_LISTEN_INTERVAL=10`, `MODEM_DRX_MODE=6-9`
and `DSDS_SECONDARY_MODE=eco`.** All three are already configurable via
`/etc/bananarchy-power-policy.conf`; defaults stay conservative because
higher DRX modes and longer listen intervals delay inbound data, and
`AT$QCDRX=9` previously made the AT channel briefly unresponsive.
3. **Replace `nmcli device monitor` with NetworkManager dispatcher hooks.**
It accounts for 0.11 context switches/s and duplicates the dispatcher path
already used for DPM and time sync.
4. **`commit=60` on the rootfs mount.** Could cut a fraction of the 0.56/s
`mmc0` IRQs, but risks data loss on sudden power cut; deliberately not
shipped.
5. **Remove `earlycon console=ttyMSM0` from the cmdline.** Cmdline-only and
ABI-safe, would gate the 3.686 MHz UART clock, but removes the serial debug
lifeline; deliberately kept.
6. **PSCI `SYSTEM_SUSPEND` in lk2nd.** Still the only path to DDR self-refresh
and `mem` suspend. Until then `bimc_ddr_clk_src` stays enabled and no
kernel config change can fix it.
7. **AP-side Wi-Fi DTIM tuning.** Not controllable from the phone.
The AP and userspace are already close to their idle floor. Further 24 h
battery life has to come from modem/Wi-Fi RF policy, DDR self-refresh, or a
battery-powered measurement campaign; another kernel config trim or full
module tree rebuild is not justified.
---
## 18. No-tradeoff idle headroom: A/B sweep and event-driven process cleanup
This section answers a narrower question than section 17: what can still be
saved at idle **without** delaying UI wakeup, calls/SMS, Wi-Fi, or network
state changes? All measurements below were 45-60 s screen-off windows on the
same USB-charged phone, so they are wakeup/IRQ/context-switch counts rather
than discharge mA. `vm.compaction_proactiveness=0` from section 17 stayed
active throughout.
### 18.1 Kernel/VFS candidates that were measured and rejected
| Candidate | Baseline | Candidate result | Decision |
| --- | --- | --- | --- |
| `vm.stat_interval=120` (from 30) | 96.85% CPU idle, 30.07 timer IRQs/s | 96.10% idle, 36.38 timer IRQs/s, `mmc0` 0.89/s | Rejected; worse or noise |
| `vm.vfs_cache_pressure=50` (from 150) | 96.85% idle | 94.34% idle, 47.38 timer IRQs/s | Rejected |
| `vm.swappiness=100` (from 180) | 96.85% idle, `mmc0` 0.21/s | 96.47% idle, `mmc0` 1.69/s | Rejected |
| `kernel.sched_autogroup_enabled=0` | 96.85% idle | 95.46% idle, 37.50 timer IRQs/s | Rejected |
| `noatime` rootfs remount | first run 96.85% -> 97.38% idle | confirmation run 97.49% -> 95.90% idle | Rejected; contradictory A/B |
`kernel.timer_migration` was already `1`. `vm.page-cluster=0`,
`vm.dirty_writeback_centisecs=6000`, `vm.dirty_expire_centisecs=6000`,
`kernel.nmi_watchdog=0`, `workqueue.power_efficient=Y` and the SPI/GPU/CPU
runtime-PM settings from earlier sections were already active. Raising the
dirty writeback interval or adding `commit=` would risk data loss on a sudden
power cut, so neither was shipped. All rejected sysctls and `relatime` were
restored on the live phone.
### 18.2 Process management: remove the `nmcli device monitor` poller
`sxmo_networkmonitor.sh` kept a long-lived `nmcli device monitor` plus two
shell wrappers alive to translate NetworkManager device states into Sxmo
network hooks and status bar updates. It accounted for roughly 0.08-0.13
context switches/s and duplicated the dispatcher path already used for DPM
and time sync.
It is replaced by:
- `etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh`, which
reacts to `up`, `down`, `pre-up`, `pre-down`, VPN equivalents, and
connectivity/DHCP/DNS changes, then double-forks so NetworkManager never
waits for shell hooks.
- `usr/bin/bananarchy-network-event.sh`, re-executed as the X session user
via `su`, which resolves the device type and calls the same
`sxmo_hook_network_{up,down,pre_up,pre_down}.sh` and
`sxmo_hook_statusbar.sh network` hooks. Running as the user keeps
`sxmo_status` files, the root status name and the status bar cache
user-owned.
- Both `sxmo_hook_start.sh` copies now run
`superctl disable sxmo_networkmonitor` instead of starting the poller;
`scripts/check-rebuild.sh` guards this.
This does not stop NetworkManager, wpa_supplicant, dnsmasq, ModemManager,
rmtfs, q6voiced, the DSDS helper, chronyd, dunst, or any preloaded DWM plugin.
Incoming network events still wake the same hooks immediately; only the idle
poller and its two shell wrappers disappear. Live verification after a Wi-Fi
disconnect/reconnect logged `09:22:55 up wlan0 wifi` from a temporary user
`sxmo_hook_network_up.sh`, with `wlan0` back on `OffOurStreets_`,
`sxmo_networkmonitor` stopped, `network_monitor_device` gone and no
`nmcli device monitor` process. A 60 s screen-off window after the change
measured 97.78% CPU idle with no `nmcli device monitor` in the top context
switchers (it had been ~0.08-0.13/s before).
### 18.3 Still available, but deliberately not shipped
- **Longer `statusbar_periodics` interval**: 300 s could become 600 s because
dmenu and unlock now refresh the clock, but an on-screen idle clock could
then be up to 10 minutes stale. Not shipped.
- **Longer `dsds-daemon` / `sxmo_modemmonitor.sh` / Wi-Fi scan intervals**:
these would delay modem or roaming state changes. Not shipped.
- **Consolidating `sxmo_soundmonitor.sh` / `sxmo_modemmonitor.sh` shell
pipelines**: possible, but they are event-driven (`evtest`,
`pactl subscribe`, `dbus-monitor`) and rewriting them risks audio/call
routing regressions for sub-0.1/s savings. Not shipped.
- **Wi-Fi listen interval >5, `MODEM_DRX_MODE=6-9`, `DSDS_SECONDARY_MODE=eco`**:
these trade inbound latency or SIM2 reachability for RF saving, so they
stay opt-in via `/etc/bananarchy-power-policy.conf`.
- **Serial console removal, `commit=60`, ABI-breaking kernel configs, full
module tree rebuild**: rejected for the reasons in sections 14-17.
### 18.4 Verdict
After sections 17 and 18, the remaining no-tradeoff AP/userspace headroom is
very small: the kernel is already ~98-99% idle, the 26 preloaded plugins and
Xorg are asleep when dark, runtime PM has collapsed the GPU/SDHCI/SPI/DMA
domains, and the remaining periodic work is either event-driven or spaced
300-1800 s apart. Further meaningful 24 h gains still require radio firmware
policy, DDR self-refresh via lk2nd PSCI `SYSTEM_SUSPEND`, or a real
battery-powered discharge measurement; they cannot come from more idle
timer/sysctl trimming without hurting latency or connectivity.
---
## 19. Dual-target idle audit for upcoming build `a1114` / `carbonara` (`nokia-argon` and `nokia-beatles`)
After the Nokia 2720 Flip (`nokia-beatles`) lid/cover stack, Bluetooth HOGP/OBEX
gamepad bridge, and minute-fresh dark statusbar clock landed in `a1108`--`a1111`,
a fresh cross-target battery audit inspected every daemon, hook, DTB, kernel
module, and sysfs power knob across both active devices for upcoming build
`a1114` (codename `carbonara`).
### 19.1 Verified parity and clean subsystems
- **DTB and boot image parity**: `qcom-msm8905-nokia-beatles.dts` already matches
`qcom-msm8905-nokia-argon.dts` on `cpu-opp-table` `clock-latency-ns`
(`100000` ns), `spc` `cpu-idle-states`, peripheral `sleep` pinctrl states,
`wakeup-source` `gpio-keys`, and identical `vmlinuz` plus patched
`pm8916_bms_vm`, `pm8916_lbc`, and `wcn36xx` kernel modules.
- **Target isolation**: `apply-bananarchy-overlay.sh` writes `slider` vs `flip`
to `/usr/share/bananarchy/lid-profile` and disables all flip services, udev
rules, and mux modules on `nokia-argon`.
- **Desktop and drivers**: `dwm`, `dmenu`, preloaded `dwm` plugins,
`dsds-daemon`, PipeWire/WirePlumber, `sshd-debug`, `unudhcpd`, `msm8905-cam`,
and `leds-msm8905-torch` all rest at `0` wakeups/s when dark.
### 19.2 Six zero-regression optimizations implemented
1. **Event-driven steady state in `bananarchy-lid` (`nokia-beatles`)**:
`bananarchy-lid.c` previously ran `poll(..., 20)` (`50 Hz` = 3,000
wakeups/min), read `/sys/kernel/debug/gpio` to EOF at `10 Hz` (600 full SoC
GPIO register dumps/min), and every `2 s` globbed `/dev/input/event*`,
rewrote `/run/bananarchy/lid-state`, ran `sync_sw_lid()`, and sent
`CLOSED`/`OPEN` to `/run/bananarchy/cover.sock` (waking
`bananarchy-cover-idle` every 2 s). Because `hall-lid-open` (`gpio36`) and
`hall-lid-closed` (`gpio92`) are hardware-IRQ `gpio-keys` with
`wakeup-source`, `bananarchy-lid` now watches `/dev/input` via `inotify`,
retains the `20 ms` (`LID_LOOP_MS` / `LID_DEBOUNCE_MS` / `HALL_EDGE_MS`)
settle window on `EV_SW` edges plus one `+2 s` post-transition confirmation
broadcast, and then blocks in `poll(..., -1)` at `0` steady-state wakeups/s.
Flip-open and flip-close transitions also synchronize CPU `scaling_governor`,
`schedutil/rate_limit_us` (`40000`), and Adreno 304 `governor` directly in C.
2. **Event-driven `bananarchy-volume-keys` (`nokia-beatles`)**:
`bananarchy-volume-keys.c` replaced its `1,000 ms` `poll()` loop and `2,000 ms`
`/dev/input/event*` `glob()` with an `inotify` watch on `/dev/input` plus
`poll(..., -1)`, eliminating ~90 wakeups/min while keeping `BANANARCHY_INPUT_GLOB`
FIFO polling for host tests.
3. **Adreno 304 `devfreq` `powersave` permissions and `schedutil` `rate_limit_us`
restoration (both targets)**: `10-power-save.start` previously granted
`video`-group write permissions (`0664`) to CPU `scaling_governor` only, so
`sxmo_wm.sh`'s `[ -w /sys/class/devfreq/1c00000.gpu/governor ]` check failed
silently and left the GPU in `simple_ondemand` while dark. `10-power-save.start`
now applies `chgrp video` and `chmod 0664` to `1c00000.gpu/governor`,
`locker_plugin.cpp` toggles `1c00000.gpu/governor` on lockscreen idle-blank
and wake, and `bananarchy-display-power-sync` synchronizes `1c00000.gpu/governor`
and restores `schedutil/rate_limit_us = 40000` on both forced (`FORCE=1`) and
normal (`FORCE=0`) transitions.
4. **Lightweight per-minute clock maintenance (both targets)**:
`sxmo_hook_statusbar.sh` skips sourcing the 257-line `sxmo_hook_icons.sh`
table on `time` ticks and updates `099-time` directly in-shell when the
`sxmo_status` runtime directory already exists (avoiding spawning
`sxmo_status.sh` and two `mkdir -p` calls every minute while dark), and
`sxmo_status.sh` guards `mkdir -p "$ROOT"` with `[ -d "$ROOT" ]`.
5. **Avoid redundant ext4 eMMC write and no-op `sxmo_autosuspend.sh` fork on
blanking (both targets)**: `sxmo_wm.sh display off` now writes
`~/.config/sxmo/brightness` on ext4 only when brightness actually changed
(avoiding dirty-page eMMC writeback wakeups 60 s after blanking), and
`sxmo_hook_screenoff.sh` skips spawning `sxmo_autosuspend.sh` when
`/etc/bananarchy-no-deep-standby` is present.
6. **Event-driven `bananarchy-bt-obex` when Bluetooth is enabled (both
targets)**: replaced the `1.0 s` D-Bus/RFCOMM poll timeout and the `1.5--2.0 s`
`/dev/input` gamepad polling loop with a signal self-pipe, `ctypes` `inotify`
on `/dev/input`, and blocking `select.select(..., None)`, dropping Bluetooth
daemon idle wakeups from ~100/min to `0`/min and reducing gamepad hotplug
latency from `2 s` to `<5 ms`.
---
## 20. Hardware, kernel, and firmware deep-standby fixes after the 4-hour DSDS + Wi-Fi standby test (`a1114` / `carbonara`)
### 20.1 Real-world discharge measurement and root-cause decomposition
On-battery standby testing on `a1114` (`carbonara`) with the screen off, DSDS
active, and Wi-Fi connected measured **20% battery drain over 4 hours**
(`5.0%/h`, or **~75 mA** continuous average on the `1,500 mAh` battery). Because
section 19 had already reduced userspace idle wakeups to near zero and CPU cores
were spending ~98% of uptime in standalone power collapse (SPC), auditing the
`6.12.1-msm8916` kernel source, `.config`, DTBs, and radio policy uncovered five
hardware/firmware power floors keeping SoC buses, clocks, RF receivers, and the
display controller active continuously without `CONFIG_SUSPEND`:
1. **RPM bus clocks (`BIMC`, `PCNOC`, `SNOC`) pinned at `INT_MAX` (~533 MHz DDR
/ ~133 MHz NoC)**: `# CONFIG_INTERCONNECT_QCOM_MSM8909 is not set` and all
six MSM8905/MSM8909 DTS files lacked `interconnect@400000` (`bimc`),
`interconnect@500000` (`pcnoc`), and `interconnect@580000` (`snoc`) nodes.
Without an interconnect provider reaching `icc_sync_state`, `clk-smd-rpm.c`'s
`clk_smd_rpm_handoff()` voted `INT_MAX` in both `QCOM_SMD_RPM_ACTIVE_STATE`
and `QCOM_SMD_RPM_SLEEP_STATE` at boot and never released it (~22--30 mA).
In addition, `qnoc_probe()` in `drivers/interconnect/qcom/icc-rpm.c`
zero-initialized `qp->bus_clk_rate[]`, so `sleep_rate == 0` matched the
cached `0` and skipped sending a `0` sleep-set vote to RPM.
2. **WCN3620 Wi-Fi firmware lacking screen-off ARP/NS/GTK/DTIM offloads and
`conf.listen_interval` mismatch**: `wcn36xx/main.c` only enabled
`wcn36xx_smd_arp_offload()`, `wcn36xx_smd_ipv6_ns_offload()`,
`wcn36xx_smd_gtk_offload()`, and `wcn36xx_smd_set_power_params(ignore_dtim=true)`
inside `wcn36xx_suspend()`, which never runs with `CONFIG_SUSPEND=n`. In
addition, `0007` set `hw->max_listen_interval` without setting
`hw->conf.listen_interval`, leaving `conf.listen_interval` at `1` (~12--18 mA).
3. **ChipIdea USB controller (`ci_hdrc_msm` at `78d9000.usb`) missing runtime
PM**: `ci_hdrc_msm.c` had no `RUNTIME_PM_OPS` and omitted
`CI_HDRC_SUPPORTS_RUNTIME_PM`, leaving `usb_hs_ahb_clk` (`100 MHz`) and
`usb_hs_system_clk` (`80 MHz`) ungated whenever unplugged on battery (~4--6 mA).
4. **DSDS modem paging at default short DRX (`MODEM_DRX_MODE=0`) and single-port
`AT$QCDRX` application**: `bananarchy-power-policy.conf` shipped
`MODEM_DRX_MODE=0`, `msm-modem-uim-selection at auto` exited after the first
`/dev/wwan0at*` port without configuring the second DSDS AT channel, and
`dsds-daemon` checked only `/tmp/bananarchy_screen_locked` rather than raw
backlight state (~10--15 mA).
5. **GC9305 / ST7789V SPI panel controller left in active 60 Hz GRAM scan during
DPMS off**: `drivers/gpu/drm/tiny/panel-mipi-dbi.c` omitted a `.disable`
callback on `panel_mipi_dbi_pipe_funcs`, so `xset dpms force off` turned off
the PWM backlight without issuing `MIPI_DCS_SET_DISPLAY_OFF` (`0x28`) and
`MIPI_DCS_ENTER_SLEEP_MODE` (`0x10`) before disabling `vdd`/`io` (~3--6 mA on
boards with always-on or shared panel rails).
### 20.2 Five hardware, kernel, and firmware fixes implemented (`0008`)
1. **MSM8909 RPM interconnect scaling (`CONFIG_INTERCONNECT_QCOM_MSM8909=y`)**:
enabled `CONFIG_INTERCONNECT_QCOM=y`, `CONFIG_INTERCONNECT_QCOM_MSM8909=y`,
and `CONFIG_INTERCONNECT_QCOM_SMD_RPM=y` (built-in, preserving module
`vermagic` across all 580 `.ko.zst` modules), added `.keep_alive = true` on
`msm8909_bimc`, `msm8909_pcnoc`, and `msm8909_snoc` (`19.2 MHz` active floor,
`0` in `SLEEP_STATE`), initialized `qp->bus_clk_rate[*]` to `U32_MAX` in
`qnoc_probe()` so `icc_sync_state` clears the `INT_MAX` sleep handoff vote in
RPM, and wired `bimc`/`pcnoc`/`snoc` plus `cpus` `interconnects` and
`cpu-opp-table` `opp-peak-kBps` across all six MSM8905/MSM8909 DTS files.
2. **Live WCN3620 screen-off firmware offloads without freezing host RX**:
`wcn36xx` now initializes both `hw->max_listen_interval` and
`hw->conf.listen_interval` from `listen_interval` (clamped `1..10`, default
`5`) before `ieee80211_register_hw()`, and exposes
`/sys/module/wcn36xx/parameters/screen_off_offload` (toggled by
`bananarchy-display-power-sync`). When `1`, `wcn36xx` programs hardware
ARP offload (when a single IPv4 address is assigned, preserving DHCP), IPv6
NS offload, GTK rekey offload, `ignore_dtim = true`, and
`dynamic_ps_timeout = 40 ms` while keeping `rx_irq`/`tx_irq` enabled and
never sending `wlan_host_suspend_ind`, so inbound SSH/TCP/IM unicast packets
still wake the host immediately.
3. **ChipIdea USB runtime PM while unplugged**: `ci_hdrc_msm.c` enables
`CI_HDRC_SUPPORTS_RUNTIME_PM`, wraps `ci_hdrc_msm_por_reset()` in
`pm_runtime_resume_and_get()`/`pm_runtime_put()`, gates `iface_clk` and
`core_clk` in `RUNTIME_PM_OPS` when `vbus_extcon` is unplugged, and skips
`ci_ulpi_resume()`'s `ULPI_SYNC_STATE` viewport poll when
`CI_HDRC_OVERRIDE_PHY_CONTROL` is set so cable hotplug resumes cleanly before
`CI_HDRC_CONTROLLER_RESET_EVENT` powers the ULPI PHY.
4. **Default dual-port `MODEM_DRX_MODE=6` and dark-screen `dsds-daemon` sleep**:
`bananarchy-power-policy.conf` defaults to `MODEM_DRX_MODE=6` while keeping
`DSDS_SECONDARY_MODE=active` so both SIMs stay reachable;
`msm-modem-uim-selection` adds `at all` multi-port support and `screen_is_idle()`
in `dsds-daemon` (`poll_timeout = None` whenever locked, cover-lit, or
backlight off); and `bananarchy-power-policy.sh` serializes AT port access
with `flock`, waits past `ModemManager`'s startup port probe at boot, and
re-applies `AT$QCDRX=6` across all `/dev/wwan0at*` ports on `modem-ready`
(`sxmo_hook_modem.sh` `registered`/`connected` and post-PIN/switch
registration) with per-port devtmpfs inode caching in
`/run/bananarchy-power-policy/drx.<port>`.
5. **MIPI DCS `DISPOFF` + `SLPIN` on `panel-mipi-dbi` DPMS off**:
`panel_mipi_dbi_disable()` sends `0x28` (`msleep(20)`) and `0x10`
(`msleep(50)`) under `drm_dev_enter()` after `backlight_disable()`, halting
the panel boost converter and 60 Hz GRAM scan while leaving the 2720 Flip
`backend = kernel` cover path (`DPMS On` during closed cover wake) intact.
### 20.3 Post-test fix: unconditional BAM-DMUX `wwan0` registration for `ModemManager` and QMI VOICE USSD fallback
Live testing on a Nokia 2720 Flip (`nokia-beatles`) running on Wi-Fi without an
existing `type=gsm` NetworkManager connection profile surfaced `error: couldn't
find modem` when sending USSD queries on SIM 1:
- **Root cause**: `MMPluginQcomSoc` (`libmm-plugin-qcom-soc.so`) sets
`base-modem-data-net-supported = TRUE` and
`base-modem-data-tty-supported = FALSE`, so `ModemManager` refuses to export
`/org/freedesktop/ModemManager1/Modem/0` (`"Failed to find a data port in the
modem"`) unless `bam-dmux` has registered `net/wwan0`. `bam-dmux` only
creates `net/wwan0` after MPSS sends `BAM_DMUX_CMD_OPEN` in response to
`qmicli --dpm-open-port=hw-data-ep-type=bam-dmux,...`. Gating `--dpm-open-port`
on `type=gsm` `.nmconnection` files (`U9` / `K11`) broke `ModemManager`
discovery on Wi-Fi-only setups (the same `"No modems were found"` symptom
noted in section 14.1). Meanwhile, inspecting `drivers/net/ethernet/qualcomm/bam-dmux.c`
confirmed that `bam-dmux` already uses `BAM_DMUX_AUTOSUSPEND_DELAY = 1000` ms
runtime PM autosuspend, dropping `bam_dmux_pc_vote(dmux, false)` (`pc_state=0`)
and releasing TX/RX BAM DMA channels after 1 s of inactivity — so keeping the
DPM port open at boot adds zero idle power draw.
- **Fix**: `etc/init.d/msm8909-modem-wwan-port` (and `provision_slot()` /
`bananarchy-dpm.sh open`) now opens the BAM-DMUX QMI DPM port unconditionally
before `ModemManager` starts and waits for `/sys/class/net/wwan0` (triggering
`mmcli -S` if `wwan0` is opened late while `ModemManager` has no modem), and
`10-bananarchy-dpm.sh` no longer closes the DPM port on NetworkManager `down`
events. In addition, `msm-modem-uim-selection ussd` resolves `mm_modem` via
`mmcli -L` instead of `mmcli -m any` and falls back to direct QMI VOICE USSD
over `AF_QIPCRTR` (`QMI_SERVICE_VOICE = 9`, `sub = 0`) for the primary SIM
just like `sub = 1` on the secondary SIM, preserving interactive multi-step
`/tmp/sxmo_ussd_session_state` sessions even if `ModemManager` is unavailable.
---
## 21. Deep-standby SoC rail, RPM handoff, USB HS PHY, WCN3620 BET/host-suspend, and MIPI DBI reset fixes (`0009`)
Live benchmarking after `0008` improved screen-off DSDS + Wi-Fi standby from
`-20% / 4h` to `-40% / 8h` (`5.0%/h`), still well above stock KaiOS because five
kernel/build gaps kept SoC rails, RPM sleep votes, USB PHY regulators, WCN3620
beacon wakeups, and stale `drm_mipi_dbi.ko` active:
### 21.1 Five remaining standby root causes found after `0008`
1. **`fw_devlink` `sync_state` deadlock on driverless `/cpus/cpu@0..3` + 100 MHz
BIMC floor (`~30-50 mA`)**: `CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT` was unset in
`patches/kernel/config-bananarchy-msm8909.armv7`. Because `/cpus/cpu@0..3`
carry `qcom,msm8909-bimc` interconnect suppliers and `cpufreq-dt` does not
bind CPU platform devices via `fw_devlink`, `fw_devlink_probing_done()`
never completed. Consequently, `rpmpd_sync_state()` never fired (leaving
`VDD_CX` and `VDD_MX` pinned at `SUPER_TURBO` from boot), and `icc_sync_state()`
(`qnoc_sync_state`) never cleared RPM's `INT_MAX` bus floor. In addition, the
200 MHz idle CPU OPP (`opp-199999951`) requested `opp-peak-kBps = <0xc3500>`
(`800,000` kBps = `100 MHz` BIMC) instead of `<0x25800>` (`153,600` kBps =
`19.2 MHz` XO floor).
2. **Unclaimed `clk-smd-rpm` active and sleep-set handoff votes (`~10-20 mA`)**:
`rpm_smd_clk_probe()` (`drivers/clk/qcom/clk-smd-rpm.c`) wrote `INT_MAX`
boot-handoff rates to both `QCOM_SMD_RPM_ACTIVE_STATE` and
`QCOM_SMD_RPM_SLEEP_STATE`. Unclaimed clocks such as `qdss_clk` / `qdss_a_clk`
and `qpic_clk` / `qpic_a_clk` kept `ACTIVE_STATE` votes alive indefinitely,
and all unclaimed RPM clocks kept `SLEEP_STATE` handoff votes (`INT_MAX` or `1`)
preventing RPM sleep-set collapse.
3. **Unplugged ChipIdea USB HS PHY staying powered (`~5-10 mA`)**:
`ci_hdrc_msm_probe()` lacked `pm_runtime_set_autosuspend_delay` /
`pm_runtime_use_autosuspend` and never shut down the ULPI `phy-qcom-usb-hs`
on runtime suspend when unplugged (`vbus_extcon` disconnected), leaving
`pm8909_l13` (`3.075 V`), `pm8909_l7` (`1.8 V`), `xo`, and PHY clocks on.
Meanwhile `ci_hdrc_probe()` did not enable runtime autosuspend on the child
`ci_hdrc` device when `CI_HDRC_SUPPORTS_RUNTIME_PM` was set.
4. **Incomplete `wcn36xx` screen-off offload (`~10-15 mA`)**: `0008` enabled
ARP/NS/GTK offload and `ignore_dtim`, but left Beacon Early Termination
disabled (`enable_bet = 0`, `bet_interval = 0`), left `dtim_period` unaligned
with `listen_interval`, left broadcast/multicast firmware filtering disabled
(`bcast_mcast_filter = 0`), and never sent `WCN36XX_HAL_HOST_SUSPEND_IND`
when entering screen-off offload or `HOST_RESUME_REQ` on screen wake.
5. **Unpatched `drm_mipi_dbi.ko` shipped from May 30 (`panel-mipi-dbi` sync
gap)**: `scripts/build-kernel-audio.sh`, `rebuild-image.sh`, and
`scripts/apply-bananarchy-overlay.sh` exported `panel-mipi-dbi.ko.zst` and
`msm.ko.zst`, but never rebuilt or packaged `drivers/gpu/drm/drm_mipi_dbi.ko`
(`CONFIG_DRM_MIPI_DBI=m`).
### 21.2 Five deep-standby fixes implemented (`0009`)
1. **Unblock `rpmpd_sync_state()` + `icc_sync_state()` and drop idle BIMC floor
to `19.2 MHz`**: enabled `CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT=y` in
`patches/kernel/config-bananarchy-msm8909.armv7`, added the `drivers/base/core.c`
`fw_devlink_sync_state_timeout` relaxation after init (`10 s` timeout
guarantee), and lowered `opp-199999951` `opp-peak-kBps` from `<0xc3500>` to
`<0x25800>` (`153,600 kBps`) across all six MSM8905/MSM8909 DTS files.
2. **Release unclaimed `clk-smd-rpm` active (`QDSS`/`QPIC`) and sleep-set handoff
votes**: `0009` adds `late_initcall_sync(rpm_smd_clk_late_cleanup)` in
`drivers/clk/qcom/clk-smd-rpm.c` to drop active votes on unclaimed `QDSS` and
`QPIC` RPM clocks and clear `QCOM_SMD_RPM_SLEEP_STATE` handoff votes on all
unclaimed RPM clocks (`PCNOC`, `SNOC`, `BIMC`, `IPA`, `QPIC`, `QDSS`,
`BB_CLK1`, `RF_CLK1`, `DIFF_CLK1`, `DIV_CLK1`) without touching `ACTIVE_STATE`
on modem-critical `BB_CLK1` or `RF_CLK1`.
3. **Shut down `phy-qcom-usb-hs` and autosuspend `ci_hdrc` while unplugged**:
`0009` updates `ci_hdrc_msm.c` and `core.c` to hold parent runtime PM across
`ci_hdrc_add_device()`, configure a `200 ms` autosuspend delay on both parent
and child `ci_hdrc` devices, call `usb_phy_shutdown()` on runtime suspend when
`vbus_extcon` is disconnected (and re-initialize on resume/connect), and end
probe with `pm_runtime_put_autosuspend()`.
4. **Enable WCN3620 BET, `dtim_period` sync, multicast filter, and
`HOST_SUSPEND_IND` / `HOST_RESUME_REQ` in `screen_off_offload`**:
`wcn36xx/{wcn36xx.h,smd.c,main.c}` now program `enable_bet = 1`,
`bet_interval = listen_interval`, `dtim_period = listen_interval`,
`bcast_mcast_filter = 3`, and send `wcn36xx_smd_wlan_host_suspend_ind()` /
`HOST_RESUME_REQ` on screen-off / screen-on transitions while keeping host
`rx_irq`/`tx_irq` armed for immediate inbound SSH/IM wake.
5. **Build and ship `drm_mipi_dbi.ko.zst` cleanly**: `scripts/build-kernel-audio.sh`,
`rebuild-image.sh`, `scripts/apply-bananarchy-overlay.sh`, and
`scripts/check-rebuild.sh` now build, compress, install into `overlay/rootfs`
and target rootfs/initramfs, and verify `drm_mipi_dbi.ko.zst` alongside
`panel-mipi-dbi.ko.zst`.
---
## 22. Pass 1 + Pass 2 RPM sleep (`vMPM` + L2 SAW2), BIMC PLL / WCD-digital / LDO cleanup, and UART/Wi-Fi standby optimizations (`0010`)
On-device clock and genpd telemetry after `0009` (`pm_genpd_summary` +
`clk_summary`, losing ~`4.8%/h`) exposed the remaining blockers preventing XO/CX/MX
and BIMC DDR from collapsing during deep idle (while revealing that an active `mas_oxili` GPU without a `gfx-mem` interconnect vote starved when `cpu0` dropped to `19.2 MHz` BIMC XO):
`qcom_stats`/`qcom_rpm_master_stats` were not wired in DT, `gpu@1c00000` lacked `gfx-mem` BIMC scaling,
`gcc_blsp1_uart1_apps_clk` (`ttyMSM0` / `serial@78af000`) kept `gpll0` active
at `enable_count = 3`, and `cpuidle-qcom-spm` stopped at per-core `SPC` without
vMPM timer programming or last-man L2 SAW2 shutdown.
1. **RPM LPM handoff (`qcom,mpm` vMPM + last-man `cpuidle-qcom-spm` + L2 SAW2,
Pass 2)**: `0010` wires MSM8909 `qcom,mpm` (`sram@60000` sub-slices `0x150`
APSS, `0x1d0` vMPM, `0x1150` MPSS, `0x2150` PRONTO; wakeup-parent on TLMM;
`qcom,msm8916-rpm-stats` + `CONFIG_QCOM_RPM_MASTER_STATS=y` `rpm-master-stats`),
adds the L2 SAW2 node (`power-manager@b012000`, `qcom,msm8909-saw2-v3.0-scu`)
linked via `l2-cache` `qcom,saw` across all six MSM8905/MSM8909 DTS files,
fixes SAW2 v3.0 `0x3B` / `PC_MODE` / `SLP_CMD_MODE` indexing and XPU-locked
L2 readback guards, guards `qcom_mpm_handler()` against `NULL` `irq_desc`
mappings for pre-enabled MPM pins (`49`, `58`, `62`), keeps per-CPU SPM in
`PM_SLEEP_MODE_SPC` even when `l2_sleep=0`, and teaches
`cpuidle-qcom-spm` to enter APSS RPM/vMPM sleep (`rpm_sleep=1`,
`rpm_min_residency_us=3000`) and L2 SAW2 collapse (`l2_sleep=1`,
`QCOM_SCM_CPU_PWR_DOWN_L2_OFF`) when the last online CPU enters idle, gated on
`/sys/module/cpuidle_qcom_spm/parameters/screen_off` (toggled by
`bananarchy-display-power-sync` and `bananarchy-power-policy.sh`) plus
`qcom_msm8909_gdsc_is_active()` in `gcc-msm8909.c` so RPM/L2 collapse never
fires while `oxili_gdsc`/`mdss_gdsc`/`venus_gdsc`/`vfe_gdsc` or the panel
are active, uses `ktime_sub(tick_nohz_get_next_hrtimer(), ktime_get())` to
avoid `tick_nohz` warnings, and keeps zero `vermagic`/`Module.symvers` ABI
changes (`# CONFIG_SUSPEND is not set` unchanged).
2. **Adreno 304 `gfx-mem` interconnect scaling, `qcom_iommu` non-genpd resume/TLB
fix, GDSC recovery cycle, WCD-digital runtime PM, and PM8909 LDO seeding
(Pass 1)**:
- `qcom-msm8909.dtsi` and all six device DTS files wire `gpu@1c00000`
`interconnects` (`MAS_OXILI -> SLV_EBI`, `"gfx-mem"`). Instead of holding
BIMC at `400 MHz` statically from probe, `msm_gpu_pm_resume()` votes
`Bps_to_icc(gpu->fast_rate) * 8` before enabling GPU clocks and
`msm_gpu_pm_suspend()` drops the vote to `0` after disabling clocks so
idle/screen-off BIMC still reaches `19.2 MHz` XO while active rendering
and DPMS transitions never starve the GPU.
- `qcom_iommu.c` wraps blocking `qcom_iommu_map()` calls with runtime PM
and saves/restores non-secure context bank registers + flushes
`ARM_SMMU_CB_S1_TLBIASID` in `qcom_iommu_resume()` even when
`dev->pm_domain` is `NULL` (`VDD_CX` collapse on `1f08000.iommu`).
- `gcc-msm8909.c` exposes `qcom_msm8909_gdsc_is_active()`, and
`adreno_gpu.c` (`adreno_recover()`) cycles `dev_pm_genpd_synced_poweroff()`
+ `pm_runtime_put_sync()`/`pm_runtime_get_sync()` on the GPU device so
`oxili_gdsc` resets cleanly on ringbuffer lockups.
- `msm8916-wcd-digital.c` sets `.idle_bias_on = 0`, adds `REGCACHE_FLAT` and
`200 ms` runtime PM autosuspend + `RUNTIME_PM_OPS`.
- `qcom_smd-regulator.c` seeds `vreg->is_enabled = 1` for PM8909 `l14`,
`l15`, and `l18` in `rpm_regulator_init_vreg()` so unused rails drop cleanly
after `regulator_late_cleanup`.
3. **Serial UART console (`ttyMSM0` / `serial@78af000`) disabled**: disabled
`serial@78af000` and cleared `chosen/stdout-path` in all kernel and device
DTS files and removed `console=ttyMSM0,115200` from all `kernel-cmdline.conf`
and `50-device-*.conf` fragments so `blsp1_uart1_apps_clk` no longer holds
`gpll0` (`enable_count = 0`).
4. **Runtime policy & telemetry additions (`bananarchy-power-policy.conf` /
`.sh`)**: added `CPU_RPM_SLEEP=1`, `CPU_L2_SLEEP=1`,
`WIFI_SCREEN_OFF_IPV6_MUTE=1` (mutes unsolicited IPv6 RAs on `wlan0` during
screen-off whenever `wlan0` already holds an IPv4 address, restored on wake),
and opt-in `WIFI_STANDBY_RAT=keep|gsm` (parks QMI NAS mode preference to GSM
after 30 s dark while `wlan0` is `up`, restored on wake), plus `status`
readouts for `cpuidle_qcom_spm`, `/sys/kernel/debug/qcom_stats/*`, and
`/sys/kernel/debug/qcom_rpm_master_stats/*`.
5. **Compiled C11 autostart daemons (`bananarchy-dsds`, monitors, session)**:
replaced `python3 - dsds-daemon`, `sxmo_modemmonitor.sh`,
`sxmo_soundmonitor.sh` (`evtest`), `sxmo_notifs.sh monitor` (`inotifywait`),
`sxmo_run_aligned.sh` (`sxmo_aligned_sleep`), and the
`bananarchy-x11-session.sh` tail loop with 0%-CPU compiled C11 ARM ELF
binaries (`poll(..., -1)` / `inotify` / `nanosleep`) built by
`scripts/build-bananarchy-daemons.sh`.