The problem seems to be that the first WiFi scan after wake-up always fails, and with a default scan time of 16 seconds the reconnection time is very long. This is configurable through sysfs though, at:
/sys/module/8723cs/parameters/rtw_scan_interval_thr
Brief testing by cutting the scan time 10x dramatically increased reconnection speed after deep sleep. The most obvious solution would be to add a CRUST wakeup hook that sets a very short scan time, waits some seconds, then sets it back to something much longer to preserve battery. It is of course not user-writable by default though, so a OpenRC startup script to chmod a+w the file would also be necessary. I have not had time to produce a MWE though.
jfyi there's a wakeup hook already.
~/.config/sxmo/hooks/postwake
On 21-01-01 04:50, ~kgp445 wrote:
The problem seems to be that the first WiFi scan after wake-up always fails, and with a default scan time of 16 seconds the reconnection time is very long. This is configurable through sysfs though, at:
/sys/module/8723cs/parameters/rtw_scan_interval_thr
Brief testing by cutting the scan time 10x dramatically increased reconnection speed after deep sleep. The most obvious solution would be to add a CRUST wakeup hook that sets a very short scan time, waits some seconds, then sets it back to something much longer to preserve battery. It is of course not user-writable by default though, so a OpenRC startup script to chmod a+w the file would also be necessary. I have not had time to produce a MWE though.
Thanks! This is a very useful insight, I was bothered by the same issue. I just submitted a patch that should deal with this, based on your suggestion.
--
Maarten van Gompel (proycon) https://proycon.anaproy.nl
proycon, where did you submit the patch? It would be great to have this upstream in postmarketOS, for all UIs :)
This was implemented in our own sxmo_screenlock.c in the second patch of this patch series: https://lists.sr.ht/~mil/sxmo-devel/patches/19911 , it simply increases the scan interval after wakeup for a while. So this is a pretty sxmo-specific solution, but I guess other UIs could implement something similar.
Thanks!
I've done some experiments, and found that if I disable power saving, the wifi comes back instantly after resume. To do that, simply let the phone charge, as we disable power saving then: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/1863
I thought about how to implement this in an UI-agnostic way, and came up with having a lightweight daemon that would disable wifi power saving for a few seconds after resume (like proposed above, but disable powersaving completely, instead of just changing the rtw_scan_interval_thr): https://gitlab.com/postmarketOS/pmaports/-/issues/973
On a related note, I saw that Sxmo is not using elogind. eg25-manager subscribes to suspend/resume events from elogind, and uses these events to verify that the modem came up after resume. And if it did not (there's a timer), it resets the modem. So this part of eg25-manager is currently not working in Sxmo, I'm not sure if Sxmo's own modem monitor replaces this functionality or not.
The UI agnostic solution I proposed in the upstream issue would also use elogind, since that appears to be the standard for suspend / resume events, and Plasma Mobile and Phosh are using it.