Skip to content

Commit

Permalink
time: Don't use hrtimer overlay when pm_freezing since some drivers s…
Browse files Browse the repository at this point in the history
…till don't correctly use freezable timeouts.

Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
ckolivas authored and xanmod committed Jun 28, 2021
1 parent c885e05 commit 1e6491a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kernel/time/hrtimer.c
Expand Up @@ -2258,7 +2258,7 @@ long __sched schedule_msec_hrtimeout(long timeout)
* (yet) better than Hz, as would occur during startup, use regular
* timers.
*/
if (jiffs > 4 || hrtimer_resolution >= NSEC_PER_SEC / HZ)
if (jiffs > 4 || hrtimer_resolution >= NSEC_PER_SEC / HZ || pm_freezing)
return schedule_timeout(jiffs);

secs = timeout / 1000;
Expand Down
9 changes: 5 additions & 4 deletions kernel/time/timer.c
Expand Up @@ -44,6 +44,7 @@
#include <linux/slab.h>
#include <linux/compat.h>
#include <linux/random.h>
#include <linux/freezer.h>

#include <linux/uaccess.h>
#include <asm/unistd.h>
Expand Down Expand Up @@ -2059,12 +2060,12 @@ void msleep(unsigned int msecs)
* Use high resolution timers where the resolution of tick based
* timers is inadequate.
*/
if (jiffs < 5 && hrtimer_resolution < NSEC_PER_SEC / HZ) {
if (jiffs < 5 && hrtimer_resolution < NSEC_PER_SEC / HZ && !pm_freezing) {
while (msecs)
msecs = schedule_msec_hrtimeout_uninterruptible(msecs);
return;
}
timeout = msecs_to_jiffies(msecs) + 1;
timeout = jiffs + 1;

while (timeout)
timeout = schedule_timeout_uninterruptible(timeout);
Expand All @@ -2081,12 +2082,12 @@ unsigned long msleep_interruptible(unsigned int msecs)
int jiffs = msecs_to_jiffies(msecs);
unsigned long timeout;

if (jiffs < 5 && hrtimer_resolution < NSEC_PER_SEC / HZ) {
if (jiffs < 5 && hrtimer_resolution < NSEC_PER_SEC / HZ && !pm_freezing) {
while (msecs && !signal_pending(current))
msecs = schedule_msec_hrtimeout_interruptible(msecs);
return msecs;
}
timeout = msecs_to_jiffies(msecs) + 1;
timeout = jiffs + 1;

while (timeout && !signal_pending(current))
timeout = schedule_timeout_interruptible(timeout);
Expand Down

0 comments on commit 1e6491a

Please sign in to comment.