Pinephone: reduce WiFi reconnection time after deep sleep
After suspending with crust, the PinePhone takes pretty long to reconnect to WiFi.
EDIT 7 months later: the approach below will probably not work (I think I tested wrong, it would only "fix" this if waking up right after suspend -> not relaly fix it). But fixing this somehow would be great.
I found that with power saving disabled, it reconnects almost instantly. I tested this by simply suspending while having the charger plugged, as of !1863 (merged) power saving is disabled then (and it does make SSH much more responsive).
There is also a downstream issue in Sxmo with a Sxmo specific solution: https://todo.sr.ht/~mil/sxmo-tickets/150
I suggest we implement the following ui-agnostic (and device-agnostic, though other devices typically don't have this problem) solution:
- write a "wifi-power-manager" daemon (other name suggestions welcome)
- let it disable power save if the device is charging
- let it disable power save for ~5 seconds after suspend, so wifi can reconnect quickly (find a good value by experiment)
We could create a lightweight C program based on the eg25-manager source, because it already has code to:
- connect to udev and trigger on events (it triggers when the modem unbinds, we would need to check if
POWER_SUPPLY_ONLINEchanges, see the udev rule in !1863 (merged).
- connect to elogind and set up a callback for resume
- starts a timer on resume (we'll need a similar timer to enable power save ~5 seconds after resume, unless the phone is charging)
write wifi-power-manager based on eg25-manager source
strip down the eg25-manager code to only the suspend and udev code
let it print log messages when related events arrive
change the udev code to trigger on POWER_SUPPLY_ONLINE
let the code disable / enable wifi power management
implement the timer to enable it after a few seconds after resume (unless phone is charging)
put in git repo
package in pmOS
replace pine64-pinephone's udev rule with this daemon