Commit 6528b889 authored by Xunlei Pang's avatar Xunlei Pang Committed by Linus Torvalds

rtc: refine rtc_timer_do_work() to consider other set alarm failures

rtc_timer_do_work() only judges -ETIME failure of__rtc_set_alarm(), but
doesn't handle other failures like -EIO, -EBUSY, etc.

If there is a failure other than -ETIME, the next rtc_timer will stay in
the timerqueue.  Then later rtc_timers will be enqueued directly because
they have a later expires time, so the alarm irq will never be programmed.

When such failures happen, this patch will retry __rtc_set_alarm(), if
still can't program the alarm time, it will remove current rtc_timer from
timerqueue and fetch next one, thus preventing it from affecting other rtc
timers.
Signed-off-by: default avatarXunlei Pang <pang.xunlei@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c594d678
...@@ -899,11 +899,24 @@ void rtc_timer_do_work(struct work_struct *work) ...@@ -899,11 +899,24 @@ void rtc_timer_do_work(struct work_struct *work)
if (next) { if (next) {
struct rtc_wkalrm alarm; struct rtc_wkalrm alarm;
int err; int err;
int retry = 3;
alarm.time = rtc_ktime_to_tm(next->expires); alarm.time = rtc_ktime_to_tm(next->expires);
alarm.enabled = 1; alarm.enabled = 1;
reprogram:
err = __rtc_set_alarm(rtc, &alarm); err = __rtc_set_alarm(rtc, &alarm);
if (err == -ETIME) if (err == -ETIME)
goto again; goto again;
else if (err) {
if (retry-- > 0)
goto reprogram;
timer = container_of(next, struct rtc_timer, node);
timerqueue_del(&rtc->timerqueue, &timer->node);
timer->enabled = 0;
dev_err(&rtc->dev, "__rtc_set_alarm: err=%d\n", err);
goto again;
}
} else } else
rtc_alarm_disable(rtc); rtc_alarm_disable(rtc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment