Files
geminux/POWER-OPTIMIZATION.md
T
Luxferre 983d529ec3 Sync GTK4/libadwaita/Qt/Tk gtkTtk themes, add Tcl/Tk, and fix lid-close input leak
- Extend geminux-sync-gtk-theme and geminux-apply-theme to synchronize GTK4/libadwaita (dconf + ADW_DISABLE_PORTAL=1), qt6ct (QT_QPA_PLATFORMTHEME=qt6ct:gtk3), Kvantum, and live classic/ttk Tk apps
- Preinstall dconf, gtk+2.0, tcl, tcl-lib, tcl-tls, tk, and custom zero-glycin geminux-gtkttk (GtkTtk 0.9 with XImage blitting, RESOURCE_MANAGER live reload, and *TkTheme: gtkTtk)
- Add kernel patch 0011 to open gemini-lid keyboard/touchscreen handles for synchronous raw Hall GPIO66 input filtering, inhibit SSD2092 touch while closed, and set 1 ms hall-switch / 10 ms keyboard-matrix debounce in DT
2026-11-25 20:09:34 +02:00

10 KiB

Power optimization

Battery endurance and deep idle efficiency are first-class design requirements across the kernel, daemons, radios, display, audio, and storage stack in Geminux.

Kernel-level optimizations

Configured in kernel/configs/geminux-mt6797x.config and built into 7.3.5-geminux:

  • CONFIG_HZ_100=y: 100 Hz tick rate cuts periodic timer interrupt overhead compared to 250 Hz / 1000 Hz kernels while remaining responsive for interactive X11 workloads.
  • CONFIG_RCU_LAZY=y: Batches RCU callbacks during idle periods to extend CPU C-state residency.
  • CONFIG_SUSPEND=y: Enables deep Suspend-to-RAM (mem / deep) via mt6797-spm-sleep (sodi_idle=0 pmic_modes=0 timer_sec=600 in etc/modprobe.d/geminux.conf) triggered on Gemini PDA lid close (SW_LID), battery idle timeout, or power button press. Keeping pmic_modes=0 avoids asserting MT6351 VCORE sleep voltage (0.600 V) while CPU0 remains powered in WFI, spm_enter() bounds silent PCM timer rollovers cleanly without .suspend_again, mtk-eint clears hardware debounce when switching wakeup pins such as SW_LID (EINT5) to edge-sensitive mode, mtk-pmic-keys reports pm_wakeup_event() on wakeup keypresses, and 0011-gemini-lid-sync-filter-and-debounce.patch tunes Hall EINT debounce to 1 ms (keypad 10 ms) while synchronously filtering spurious keystrokes/touches and inhibiting both matrix keypad and touchscreen whenever the lid magnet closes.
  • CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y: Uses scheduler utilization feedback (schedutil) across the MT6797X tri-cluster topology instead of static performance governors. etc/init.d/geminux-hwinit loads clk-mt6797-mcusys and cpufreq-dt by default (GEMINUX_ENABLE_CPUFREQ="yes" in etc/conf.d/geminux-hwinit) independently of experimental Cortex-A72 bring-up (GEMINUX_ENABLE_A72="no"), enabling policy0 (221..897 MHz) and policy4 (325..1209 MHz) frequency scaling and soc-thermal cooling throttling.
  • mt6797-gate-unused: Loaded at the end of geminux-hwinit (GEMINUX_GATE_UNUSED_CLOCKS="yes") to gate ~25 unused bootloader peripheral leaf clocks (unused SPI, UART, PWM, IRTX, ICUSB, ANC_MD32, etc.) left enabled due to clk_ignore_unused while leaving active display/I2C clocks untouched.
  • Sensor IR LED gating: stk3310 is blacklisted in etc/modprobe.d/geminux.conf (GEMINUX_ENABLE_SENSORS="no") because its probe unconditionally enables continuous ALS and proximity IR LED polling with no userspace consumer.
  • CONFIG_ZRAM_DEF_COMP_LZ4=y with 2 GiB LZ4 zram swap (etc/conf.d/zram-init) and vm.swappiness=100 (etc/sysctl.d/99-geminux-power.conf): avoids slow, power-hungry flash swap I/O on eMMC and pairs with commit=60,noatime mount options (etc/fstab).
  • CONFIG_CRYPTO_AES_ARM64_CE_BLK=y paired with --allow-discards in initramfs: runs optional LUKS2 dm-crypt (aes-xts-plain64) encryption using ARMv8 hardware AES Cryptography Extensions with negligible battery overhead.

Zero-poll userspace daemons

All background system services avoid wake-up timers and polling loops:

  • geminux-powerd: Sleeps indefinitely in epoll_wait() over /dev/input/event* (SW_LID, KEY_POWER, keyboard/touch/pointer activity), KOBJECT_UEVENT netlink (filtered strictly to input, power_supply, and drm subsystems), /run/geminux/powerd.sock, and a lazy-rearming timerfd; caches applied CPUfreq/profile state to avoid redundant sysfs and /run/geminux/power-profile rewrites; implements two-stage screensaver dimming and auto-lock/blank or suspend strictly timed from the last active user input (dim_timeout_s / suspend_timeout_s). Before entering /sys/power/state, it unloads mt6797_consys (and reverse dependents btmt6797, radio_mt6797, gnss_mt6797, mac) so mt6797_consys_prepare() no longer refuses suspend with -EBUSY and the CONN/VCN* rails power down cleanly; on resume, it uses retry-hardened async CONSYS reload while preserving Bluetooth rfkill soft-block state and verifies SW_LID before re-enabling the backlight. In hardware Airplane Mode (Fn+F / geminux-power-ctl airplane on, persisted under /var/lib/geminux/airplane-mode), geminux-powerd keeps the CONSYS Wi-Fi/BT kernel modules unloaded and places MD1 in AT+CFUN=4 flight mode while leaving usb0 active.
  • geminux-statusd: Uses signalfd (SIGUSR1), RTMGRP_LINK netlink, filtered KOBJECT_UEVENT (power_supply and net only), inotify, and a minute-aligned timerfd; deduplicates root WM_NAME updates (XStoreName) so dwm never repaints when the bar text is unchanged, with zero child shell forks.
  • Display & terminal idle efficiency: 10-geminux-gpu.conf uses AccelMethod "none" + ShadowFB "true" + TearFree "true" for rotated SSD2092 scanout, avoiding Glamor fence spin-waits, and st disables its cursor-blink timeout when unfocused so idle XLibre CPU usage remains near 0%.
  • geminux-touchd: Event-driven XInput 2.2 multi-touch gesture recognizer with zero polling loops.
  • geminux-ccci-daemon, geminux-modem-ctl & geminux-imsd: Event-driven epoll_wait() over /dev/ccci_*, filtered ccci uevents, AT port, /run/geminux/imsd.sock, SIP/ESP sockets, and netlink; enter completely idle sleep when no modem activity is pending, and geminux-imsd arms its 20 ms RTP timerfd strictly during active calls.
  • geminux-bt-obex, geminux-leds & geminux-lock: Event-driven GLib/GDBus and epoll_wait() + KOBJECT_UEVENT control without periodic polling. geminux-leds keeps the back AW9120 cover strip (rgb:indicator-1..5) off (0 mA) when idle or at 100% charge, lighting only rgb:indicator-6 during active battery charging unless manually overridden. geminux-lock uses a 15 s refresh interval once input is grabbed and redraws only when clock minute/date or battery status changes.

Cluster gating and profiles

geminux-power-ctl (and geminux-control) switches between three profiles managed in src/geminux-daemons/geminux-power-policy.c:

Profile Governor A72 big cores (cpu8..9) A53 LL (policy0) / L (policy4) max freq Battery idle (dim -> lock+suspend) AC idle (lock+blank screensaver)
eco schedutil Offline (0) 624 MHz / 832 MHz 60 s -> 180 s 180 s
balanced schedutil Online (1) 806 MHz / 1092 MHz (bat), 897 MHz / 1209 MHz (AC) 120 s -> 300 s 300 s
performance schedutil Online (1) 1547 MHz / 1846 MHz (clamped to DT cpuinfo_max_freq) 180 s (lock+blank, no suspend) 600 s

All idle thresholds above are measured from the last active keyboard, touchscreen, pointer, or lid-open event (CLOCK_MONOTONIC) and are not reset by periodic battery power_supply uevents.

Closing the Gemini PDA clamshell (SW_LID = 1) suspends immediately to RAM (mem), unless inhibited by an active voice call (inhibit add call), an explicit inhibitor, or a connected external HDMI monitor (SiI9024).

Audio, radios, and storage defaults

  • Audio: PipeWire uses default.clock.min-quantum = 1024 and quantum = 2048 (10-geminux-power.conf); WirePlumber suspends idle ALSA and BlueZ nodes after 3 seconds (50-geminux-suspend.conf) so audio DSP clocks gate quickly.
  • Bluetooth: BlueZ disables automatic adapter enable and fast page scan (AutoEnable = false, FastConnectable = false in etc/bluetooth/main.conf), and geminux-hwinit runs rfkill block bluetooth after loading btmt6797; users toggle Bluetooth on demand via geminux-net.
  • Wi-Fi & NTP: NetworkManager configures wifi.powersave = 2 (10-geminux-power.conf) to keep CONSYS Wi-Fi awake while associated so GTK rekeys, ARP, and DNS never stall; geminux-powerd powers down CONSYS cleanly across system suspend. etc/chrony/sources.d/10-geminux.sources caps NTP pool peers (maxsources 2) and lengthens polling (minpoll 10 maxpoll 14), paired with an offline hook on down|vpn-down in 30-geminux-chrony.
  • GTK / Qt / Tk / XSETTINGS / D-Bus: etc/profile.d/10-geminux-env.sh exports NO_AT_BRIDGE=1 so GTK/Qt/webarchy never auto-activate AT-SPI accessibility bridge daemons and sets QT_QPA_PLATFORMTHEME=qt6ct:gtk3 for zero-daemon-overhead Qt5/Qt6 theme routing; geminux-session runs xsettingsd as an event-driven X11 XSETTINGS daemon (SIGHUP on theme switch) with zero polling timers, gtkTtk reacts purely to X11 RESOURCE_MANAGER PropertyNotify events without polling, and dconf-service activates over session D-Bus only when gsettings writes color-scheme.
  • Storage: noatime,commit=60 in etc/fstab alongside vm.dirty_writeback_centisecs=1500 reduces eMMC write amplification and wakes; microSD mounts at /media/sdcard likewise mount with noatime and rely purely on eudev hotplug events (95-geminux-sdcard.rules) with zero background polling when idle or empty.

Auditing on device

Run the bundled C11 audit utility at any time:

geminux-power-audit
geminux-power-audit --json

It prints the live power profile, battery capacity/voltage/current, online CPU count (including A72 cluster gating status), CPUfreq governor, policy0/policy4 max frequency caps, Bluetooth rfkill soft-block status, ZRAM compression algorithm, and supported /sys/power/mem_sleep modes. Live idle current draw and multi-hour standby battery endurance benchmarks must be measured on physical Gemini PDA (x27) hardware after flashing.