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

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

Merge "hrtimer: update timer->state with 'pinned' information"

parents f3914bc4 06d47459
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ enum hrtimer_restart {
 *
 * 0x00		inactive
 * 0x01		enqueued into rbtree
 * 0x02		timer is pinned to a cpu
 *
 * The callback state is not part of the timer->state because clearing it would
 * mean touching the timer after the callback, this makes it impossible to free
@@ -71,6 +72,8 @@ enum hrtimer_restart {
 */
#define HRTIMER_STATE_INACTIVE	0x00
#define HRTIMER_STATE_ENQUEUED	0x01
#define HRTIMER_PINNED_SHIFT	1
#define HRTIMER_STATE_PINNED	(1 << HRTIMER_PINNED_SHIFT)

/**
 * struct hrtimer - the basic hrtimer structure
+14 −5
Original line number Diff line number Diff line
@@ -843,7 +843,7 @@ static int enqueue_hrtimer(struct hrtimer *timer,

	base->cpu_base->active_bases |= 1 << base->index;

	timer->state = HRTIMER_STATE_ENQUEUED;
	timer->state |= HRTIMER_STATE_ENQUEUED;

	return timerqueue_add(&base->active, &timer->node);
}
@@ -863,11 +863,9 @@ static void __remove_hrtimer(struct hrtimer *timer,
			     u8 newstate, int reprogram)
{
	struct hrtimer_cpu_base *cpu_base = base->cpu_base;
	u8 state = timer->state;

	timer->state = newstate;
	if (!(state & HRTIMER_STATE_ENQUEUED))
		return;
	if (!(timer->state & HRTIMER_STATE_ENQUEUED))
		goto out;

	if (!timerqueue_del(&base->active, &timer->node))
		cpu_base->active_bases &= ~(1 << base->index);
@@ -884,6 +882,13 @@ static void __remove_hrtimer(struct hrtimer *timer,
	if (reprogram && timer == cpu_base->next_timer)
		hrtimer_force_reprogram(cpu_base, 1);
#endif

out:
	/*
	* We need to preserve PINNED state here, otherwise we may end up
	* migrating pinned hrtimers as well.
	*/
	timer->state = newstate | (timer->state & HRTIMER_STATE_PINNED);
}

/*
@@ -962,6 +967,10 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
	/* Switch the timer base, if necessary: */
	new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);

	/* Update pinned state */
	timer->state &= ~HRTIMER_STATE_PINNED;
	timer->state |= !!(mode & HRTIMER_MODE_PINNED) << HRTIMER_PINNED_SHIFT;

	leftmost = enqueue_hrtimer(timer, new_base);
	if (!leftmost)
		goto unlock;