Skip to content
Snippets Groups Projects
Commit a04760d6 authored by Arve Hjønnevåg's avatar Arve Hjønnevåg Committed by Todd Poynor
Browse files

rtc: alarm: Update hrtimer if alarm at the head of the queue is reprogrammed


If an alarm was restarted with a value that moved it away from the head
of a queue, the hrtimer would not be updated. This would cause unnecessary
wakeups.

Change-Id: I7c6dc7e6085a1f03722b2fcb14a83987ef674917
Signed-off-by: default avatarArve Hjønnevåg <arve@android.com>
parent a122b2b5
No related merge requests found
...@@ -109,12 +109,15 @@ static void alarm_enqueue_locked(struct alarm *alarm) ...@@ -109,12 +109,15 @@ static void alarm_enqueue_locked(struct alarm *alarm)
struct rb_node *parent = NULL; struct rb_node *parent = NULL;
struct alarm *entry; struct alarm *entry;
int leftmost = 1; int leftmost = 1;
bool was_first = false;
pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n", pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function, ktime_to_ns(alarm->expires)); alarm->type, alarm->function, ktime_to_ns(alarm->expires));
if (base->first == &alarm->node) if (base->first == &alarm->node) {
base->first = rb_next(&alarm->node); base->first = rb_next(&alarm->node);
was_first = true;
}
if (!RB_EMPTY_NODE(&alarm->node)) { if (!RB_EMPTY_NODE(&alarm->node)) {
rb_erase(&alarm->node, &base->alarms); rb_erase(&alarm->node, &base->alarms);
RB_CLEAR_NODE(&alarm->node); RB_CLEAR_NODE(&alarm->node);
...@@ -134,10 +137,10 @@ static void alarm_enqueue_locked(struct alarm *alarm) ...@@ -134,10 +137,10 @@ static void alarm_enqueue_locked(struct alarm *alarm)
leftmost = 0; leftmost = 0;
} }
} }
if (leftmost) { if (leftmost)
base->first = &alarm->node; base->first = &alarm->node;
update_timer_locked(base, false); if (leftmost || was_first)
} update_timer_locked(base, was_first);
rb_link_node(&alarm->node, parent, link); rb_link_node(&alarm->node, parent, link);
rb_insert_color(&alarm->node, &base->alarms); rb_insert_color(&alarm->node, &base->alarms);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment