Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f67fe86 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "timers: Fix usleep_range() in the context of wake_up_process()"

parents 2f996ae5 c51fd636
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -1784,16 +1784,6 @@ unsigned long msleep_interruptible(unsigned int msecs)

EXPORT_SYMBOL(msleep_interruptible);

static void __sched do_usleep_range(unsigned long min, unsigned long max)
{
	ktime_t kmin;
	u64 delta;

	kmin = ktime_set(0, min * NSEC_PER_USEC);
	delta = (u64)(max - min) * NSEC_PER_USEC;
	schedule_hrtimeout_range(&kmin, delta, HRTIMER_MODE_REL);
}

/**
 * usleep_range - Drop in replacement for udelay where wakeup is flexible
 * @min: Minimum time in usecs to sleep
@@ -1801,7 +1791,14 @@ static void __sched do_usleep_range(unsigned long min, unsigned long max)
 */
void __sched usleep_range(unsigned long min, unsigned long max)
{
	ktime_t exp = ktime_add_us(ktime_get(), min);
	u64 delta = (u64)(max - min) * NSEC_PER_USEC;

	for (;;) {
		__set_current_state(TASK_UNINTERRUPTIBLE);
	do_usleep_range(min, max);
		/* Do not return before the requested sleep time has elapsed */
		if (!schedule_hrtimeout_range(&exp, delta, HRTIMER_MODE_ABS))
			break;
	}
}
EXPORT_SYMBOL(usleep_range);