VM-BMS sanity fix and configurable runtime power policies
Kernel (source-only, ABI-preserving, patch 0007): - pm8916_bms_vm.c: bound VADC raw samples to 8000..16000 (~2.34-4.69 V) with a 3.7 V nominal fallback in raw_to_uv(); reject out-of-window FIFO samples in the IRQ handler and probe pre-read. Fixes the 19.2 V / "Over voltage" / 100% misreport from an uninitialised 0xffff sample after a hard reset (also covers the OCV register reads on probe/resume). - wcn36xx: listen_interval becomes a module parameter (1-10, default 5, was hardcoded 3) so the beacon skip is configurable at module load. Runtime power policy (/etc/bananarchy-power-policy.conf): - WIFI_LISTEN_INTERVAL drives /etc/modprobe.d/10-bananarchy-power.conf. - MODEM_DRX_MODE (0 or 6-9) applies Qualcomm AT$QCDRX at boot and on wake. Standard AT+CPSMS / AT+CEDRXS are unsupported on this modem firmware. - DSDS_SECONDARY_MODE=eco parks the secondary GW provisioning session after DSDS_PARK_DELAY seconds of a dark panel and restores it on wake, capturing the actual slot and AID. Uses QMI provisioning sessions, not SIM power-off (which clears PIN verification). Default active keeps both SIMs reachable. - New bananarchy-power-policy.sh, OpenRC default-runlevel service, doas rule, and hooks in sxmo_wm.sh display off/on. Live-verified on nokia-argon: DRX 6 readback, eco park/unpark round-trip, Wi-Fi param 5, status output, module vermagic match, both SIMs registered. Rebuilt image with --mkinitfs: initramfs and rootfs carry the new modules (SHA-256 match), boot.img keeps the byte-identical known-good zImage + DTB. Docs updated (BATTERY-OPTIMIZATION-ANALYSIS.md section 15, CHANGELOG, MANUAL, README, AGENTS).
This commit is contained in:
1 parent
b5a1e0c5f9
commit
bc1c19a483
20 files changed
+470
-2
No files matched your search
@@ -669,3 +669,118 @@ and Wi-Fi layers:
|
||||
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`.
|
||||
Reference in new issue
Block a user