Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1735418 > unrolled thread
| Started by | Xu Yiping <xuyiping@hisilicon.com> |
|---|---|
| First post | 2017-09-20 05:30 +0200 |
| Last post | 2017-09-21 11:00 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] rtc: interface: set the next alarm event appropriately Xu Yiping <xuyiping@hisilicon.com> - 2017-09-20 05:30 +0200
Re: [PATCH] rtc: interface: set the next alarm event appropriately Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-09-20 11:20 +0200
Re: [PATCH] rtc: interface: set the next alarm event appropriately YiPing Xu <xuyiping@hisilicon.com> - 2017-09-20 11:40 +0200
Re: [PATCH] rtc: interface: set the next alarm event appropriately YiPing Xu <xuyiping@hisilicon.com> - 2017-09-21 08:50 +0200
Re: [PATCH] rtc: interface: set the next alarm event appropriately Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-09-21 11:00 +0200
| From | Xu Yiping <xuyiping@hisilicon.com> |
|---|---|
| Date | 2017-09-20 05:30 +0200 |
| Subject | [PATCH] rtc: interface: set the next alarm event appropriately |
| Message-ID | <urDS1-5Mi-9@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2017-09-20 11:20 +0200 |
| Message-ID | <urJkJ-11L-5@gated-at.bofh.it> |
| In reply to | #1735418 |
Hi,
On 20/09/2017 at 11:22:31 +0800, Xu Yiping wrote:
> 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.
>
Can you try this patch instead? I think it solves this issue:
http://patchwork.ozlabs.org/patch/792482/
> 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
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | YiPing Xu <xuyiping@hisilicon.com> |
|---|---|
| Date | 2017-09-20 11:40 +0200 |
| Message-ID | <urJE6-19d-11@gated-at.bofh.it> |
| In reply to | #1735658 |
Hi,
On 2017/9/20 17:16, Alexandre Belloni wrote:
> Hi,
>
> On 20/09/2017 at 11:22:31 +0800, Xu Yiping wrote:
>> 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.
>>
>
> Can you try this patch instead? I think it solves this issue:
> http://patchwork.ozlabs.org/patch/792482/
it looks work.
will it be merged into the main tree ?
>> 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
>>
>
[toc] | [prev] | [next] | [standalone]
| From | YiPing Xu <xuyiping@hisilicon.com> |
|---|---|
| Date | 2017-09-21 08:50 +0200 |
| Message-ID | <us3t8-5H4-15@gated-at.bofh.it> |
| In reply to | #1735658 |
On 2017/9/20 17:16, Alexandre Belloni wrote:
> Hi,
>
> On 20/09/2017 at 11:22:31 +0800, Xu Yiping wrote:
>> 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.
>>
>
> Can you try this patch instead? I think it solves this issue:
> http://patchwork.ozlabs.org/patch/792482/
We've tested this patch, it works too.
Will it be merged into the main tree?
>> 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
>>
>
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2017-09-21 11:00 +0200 |
| Message-ID | <us5uV-71k-1@gated-at.bofh.it> |
| In reply to | #1736406 |
Hi,
On 21/09/2017 at 14:45:17 +0800, YiPing Xu wrote:
>
>
> On 2017/9/20 17:16, Alexandre Belloni wrote:
> > Hi,
> >
> > On 20/09/2017 at 11:22:31 +0800, Xu Yiping wrote:
> > > 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.
> > >
> >
> > Can you try this patch instead? I think it solves this issue:
> > http://patchwork.ozlabs.org/patch/792482/
>
> We've tested this patch, it works too.
>
> Will it be merged into the main tree?
>
Yes, I will send it as a fix for 4.14.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web