From: Xu Yiping <xuyiping@hisilicon.com>
To: <a.zummo@towertech.it>, <alexandre.belloni@free-electrons.com>,
<linux-rtc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<roy.chenjun@hisilicon.com>, <colin.king@canonical.com>,
<wanghao24@huawei.com>
Subject: [PATCH] rtc: interface: set the next alarm event appropriately
Date: Wed, 20 Sep 2017 11:22:31 +0800 [thread overview]
Message-ID: <1505877751-26566-1-git-send-email-xuyiping@hisilicon.com> (raw)
From: Xu YiPing <xuyiping@hisilicon.com>
After commit 2b2f5ff00f63 ("rtc: interface: ignore expired timers when
enqueuing new timers"), the rtc_timer_enqueue will not reprogram the RTC
when there is any non-expired timers in the timerqueue. If we set a
RTC_TIMER between now and the next non-expired timers, it won't go into
effect in time.
So, besides ignoring the expired timers, we should take the next effect
timer into account, and reprogram the RTC timer appropriately.
Signed-off-by: Xu YiPing <xuyiping@hisilicon.com>
Signed-off-by: Chen Jun <roy.chenjun@hisilicon.com>
---
drivers/rtc/interface.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 8cec9a0..e237166 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -766,20 +766,23 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
struct rtc_time tm;
ktime_t now;
+ ktime_t next_effect = KTIME_MAX;
timer->enabled = 1;
__rtc_read_time(rtc, &tm);
now = rtc_tm_to_ktime(tm);
- /* Skip over expired timers */
+ /* Skip over expired timers, get next effect timer */
while (next) {
- if (next->expires >= now)
+ if (next->expires >= now) {
+ next_effect = next->expires;
break;
+ }
next = timerqueue_iterate_next(next);
}
timerqueue_add(&rtc->timerqueue, &timer->node);
- if (!next) {
+ if (timer->node.expires < next_effect) {
struct rtc_wkalrm alarm;
int err;
alarm.time = rtc_ktime_to_tm(timer->node.expires);
--
2.7.4
next reply other threads:[~2017-09-20 3:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 3:22 Xu Yiping [this message]
2017-09-20 9:16 ` [PATCH] rtc: interface: set the next alarm event appropriately Alexandre Belloni
2017-09-20 9:36 ` YiPing Xu
2017-09-21 6:45 ` YiPing Xu
2017-09-21 8:57 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505877751-26566-1-git-send-email-xuyiping@hisilicon.com \
--to=xuyiping@hisilicon.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=colin.king@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=roy.chenjun@hisilicon.com \
--cc=wanghao24@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox