Commit Graph

7 Commits

Author SHA1 Message Date
ArenM
2691b8cca6 Refactor presuspend checks to run infrequently
autosuspend calls the presuspend check when the kernel locks are clear,
and it hasn't been called recently. If we always call it, there's a risk
that running all checks could take too long and we'll fail to suspend
often.

Successfully exiting means that there is nothing going on, so the system is
free to suspend within a reasonable timeframe (something like < 10 seconds).

All the checks currently use the (default) delay wait mechanism, but I
would like to try to write others. For example `playerctl -F` could be
used when playerctl is blocking suspend. Unfortunately managing spawned
jobs and race conditions is harder than it seems at first glance.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
2023-04-28 11:39:32 +02:00
Peter John Hartman
be0bb09739 cleanup check_state_mutex (rename to wakelock)
Mostly a cleanup. We now have sxmo_wakeup.sh so the hook should bear
that name somehow (although sxmo_hook_suspendblockers might fit too)

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
2023-03-12 08:17:23 +01:00
Willow Barraco
73fdb6140d Remove debug logs 2023-02-24 09:42:45 +01:00
ArenM
3ab2b5480f Read wakeup_count instead of using sxmo_wakeafter
The approach sxmo_wakeafter uses is flawed because the kernel isn't
obligated to pass control to it after suspend. I'm pretty sure it
normally gets called when the kernel updates the system clock.

Since we're waiting for some time after every suspend we're not actually
using opportunistic suspend. It's much simpler to read wakeup_count to
ask the kernel to wait until there's no active locks.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
2023-02-24 09:42:44 +01:00
Willow Barraco
b8e6cf3330 Centralize wakelock management in sxmo_wakelock.sh
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Peter John Hartman <peterjohnhartman@gmail.com>
2023-02-23 17:12:36 -06:00
Willow Barraco
4cfdfa3b26 Drop now useless wakeup management
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Peter John Hartman <peterjohnhartman@gmail.com>
2023-02-23 17:11:50 -06:00
Willow Barraco
89a77e6057 Rely on /sys/power/wake_lock
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Peter John Hartman <peterjohnhartman@gmail.com>
2023-02-23 17:11:48 -06:00