alarmtimer: Minimize wakeup time

Alarmtimer sets its wakeup timeout to 2s no matter the actual time
to nearest timer expiration. This can cause device to be awake for more
than needed.

To fix this set wakeup timeout to min + 1 ms for safety margin.

Tests revealed that average timer expiration is 1150ms in the future
which suggests there is a room avilable to minimize wakeup times.
Before this change device would enter sleep not earlier than 2s after
alarmtimer suspend error (-EBUSY). With this change average suspend
after alarmtimer suspend error time went down to 1.5s with a minimum of
0.248ms (after filtering results higher than 2.6s).

This should lead to noticeable power savings as Android uses alarmtimer
quite frequently.

Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
Andrzej Perczak 2022-01-05 11:54:23 +01:00 committed by azrim
parent b3fc0671f9
commit 1cceb97ee8
No known key found for this signature in database
GPG Key ID: 497F8FB059B45D1C

View File

@ -312,7 +312,7 @@ static int alarmtimer_suspend(struct device *dev)
return 0; return 0;
if (ktime_to_ns(min) < 2 * NSEC_PER_SEC) { if (ktime_to_ns(min) < 2 * NSEC_PER_SEC) {
__pm_wakeup_event(ws, 2 * MSEC_PER_SEC); __pm_wakeup_event(ws, ktime_to_ms(min) + 1);
return -EBUSY; return -EBUSY;
} }