aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang Dongsheng <dongsheng.wang@freescale.com>2014-01-06 13:23:31 +0800
committerScott Wood <scottwood@freescale.com>2014-01-09 17:52:14 -0600
commitd2dc13b5339c657e526c405888df69d99322a016 (patch)
tree8c9c822cdeda7cc193a76c8fc5b4bc82d00d8d75
parentpowerpc/mpic_timer: fix the time is not accurate caused by GTCRR toggle bit (diff)
downloadlinux-dev-d2dc13b5339c657e526c405888df69d99322a016.tar.xz
linux-dev-d2dc13b5339c657e526c405888df69d99322a016.zip
powerpc/mpic_timer: fix convert ticks to time subtraction overflow
In some cases tmp_sec may be greater than ticks, because in the process of calculation ticks and tmp_sec will be rounded. Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> Signed-off-by: Scott Wood <scottwood@freescale.com>
-rw-r--r--arch/powerpc/sysdev/mpic_timer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/sysdev/mpic_timer.c b/arch/powerpc/sysdev/mpic_timer.c
index 70dcf9c5b8fb..9d9b06217f8b 100644
--- a/arch/powerpc/sysdev/mpic_timer.c
+++ b/arch/powerpc/sysdev/mpic_timer.c
@@ -97,8 +97,11 @@ static void convert_ticks_to_time(struct timer_group_priv *priv,
time->tv_sec = (__kernel_time_t)div_u64(ticks, priv->timerfreq);
tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq;
- time->tv_usec = (__kernel_suseconds_t)
- div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);
+ time->tv_usec = 0;
+
+ if (tmp_sec <= ticks)
+ time->tv_usec = (__kernel_suseconds_t)
+ div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);
return;
}