[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1532669610-103892-1-git-send-email-xuyiping@hisilicon.com>
Date: Fri, 27 Jul 2018 13:33:30 +0800
From: Xu YiPing <xuyiping@...ilicon.com>
To: <xuyiping@...ilicon.com>, <tglx@...utronix.de>,
<john.stultz@...aro.org>, <sboyd@...nel.org>
CC: <linux-kernel@...r.kernel.org>
Subject: [PATCH] timers: fix offset calculation when the expires align with LVL_GRAN
when the expires of timer is align with LVL_GRAN(n), it will be trigged
in 'expires + LVL_GRAN(n)'.
Some drivers like power runtime use the timer to start a power down
of device, it could saves power if the timer is triggerd in time,
especially when LEVEL=0 with low expires.
Signed-off-by: Xu YiPing <xuyiping@...ilicon.com>
---
kernel/time/timer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index cc2d23e..76655e2 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -487,7 +487,8 @@ static inline void timer_set_idx(struct timer_list *timer, unsigned int idx)
*/
static inline unsigned calc_index(unsigned expires, unsigned lvl)
{
- expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
+ expires = (expires + LVL_GRAN(lvl) - 1) >> LVL_SHIFT(lvl);
+
return LVL_OFFS(lvl) + (expires & LVL_MASK);
}
--
2.7.4
Powered by blists - more mailing lists