* [PATCH] m68knommu: fix ColdFire slice timer to handle clock counter wrapping
@ 2011-11-18 6:32 gerg
0 siblings, 0 replies; only message in thread
From: gerg @ 2011-11-18 6:32 UTC (permalink / raw)
To: linux-m68k, uclinux-dev; +Cc: Greg Ungerer
From: Greg Ungerer <gerg@uclinux.org>
The read function for the ColdFire slice timer doesn't deal with the
hardware timer count register wrapping while we are reading it to get an
accurate snapshot of the time.
Re-read the timer a second time and see if it has wrapped, adjust the
total count as required.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
arch/m68k/platform/coldfire/sltimers.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/m68k/platform/coldfire/sltimers.c b/arch/m68k/platform/coldfire/sltimers.c
index b7f822b..1249367 100644
--- a/arch/m68k/platform/coldfire/sltimers.c
+++ b/arch/m68k/platform/coldfire/sltimers.c
@@ -98,16 +98,17 @@ static struct irqaction mcfslt_timer_irq = {
static cycle_t mcfslt_read_clk(struct clocksource *cs)
{
unsigned long flags;
- u32 cycles;
- u16 scnt;
+ u32 cycles, scnt;
local_irq_save(flags);
scnt = __raw_readl(TA(MCFSLT_SCNT));
cycles = mcfslt_cnt;
+ if (scnt < __raw_readl(TA(MCFSLT_SCNT)))
+ cycles += mcfslt_cycles_per_jiffy;
local_irq_restore(flags);
/* subtract because slice timers count down */
- return cycles - scnt;
+ return cycles + ((mcfslt_cycles_per_jiffy - 1) - scnt);
}
static struct clocksource mcfslt_clk = {
--
1.7.0.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-11-18 6:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 6:32 [PATCH] m68knommu: fix ColdFire slice timer to handle clock counter wrapping gerg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox