~mil/sxmo-tickets#150: 
How to reduce WiFi reconnection time after deep sleep

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.

Status
REPORTED
Submitter
~kgp445
Assigned to
No-one
Submitted
4 years ago
Updated
3 years ago
Labels
No labels applied.

~trbl 4 years ago ยท edit

jfyi there's a wakeup hook already. ~/.config/sxmo/hooks/postwake

~proycon 4 years ago

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

~ollieparanoid 3 years ago

proycon, where did you submit the patch? It would be great to have this upstream in postmarketOS, for all UIs :)

~proycon 3 years ago

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.

~ollieparanoid 3 years ago

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.

https://gitlab.com/mobian1/devices/eg25-manager/-/blob/3bb6e15de0e14c08135c82dd71d9774ad02ffc1b/src/suspend.c#L20

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.

Register here or Log in to comment, or comment via email.