Browse files

bcm2708: use a constant SC_MULT / SC_SHIFT

The calculated values somehow don't agree with the sched_clock code and
we end up with warnings like:

sched_clock: wrong multiply/shift: 2097152000>>21 vs calculated 4194304000>>22
sched_clock: fix multiply/shift to avoid scheduler hiccups

So use the constant values much like arch/arm/mach-tegra/timer.c does.

Signed-off-by: Chris Boot <bootc@bootc.net>
  • Loading branch information...
1 parent f7287d5 commit 8f1d8e82a88abb9e6ea6ee007cc5724fca748d59 @bootc bootc committed with Dom Cobley Jul 15, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 arch/arm/mach-bcm2708/bcm2708.c
View
14 arch/arm/mach-bcm2708/bcm2708.c
@@ -141,9 +141,16 @@ void __init bcm2708_map_io(void)
iotable_init(bcm2708_io_desc, ARRAY_SIZE(bcm2708_io_desc));
}
-// The STC is a free running counter that increments at the rate of 1MHz
+/* The STC is a free running counter that increments at the rate of 1MHz */
#define STC_FREQ_HZ 1000000
+/*
+ * Constants generated by clocks_calc_mult_shift(m, s, 1MHz, NSEC_PER_SEC, 60).
+ * This gives a resolution of about 1us and a wrap period of about 1h11min.
+ */
+#define SC_MULT 4194304000u
+#define SC_SHIFT 22
+
static cycle_t stc_read_cycles(struct clocksource *cs)
{
/* STC: a free running counter that increments at the rate of 1MHz */
@@ -165,7 +172,6 @@ unsigned long frc_clock_ticks32(void)
static void __init bcm2708_clocksource_init(void)
{
- // calculate .shift and .mult values and register clocksource
if (clocksource_register_hz(&clocksource_stc, STC_FREQ_HZ)) {
printk(KERN_ERR "timer: failed to initialize clock "
"source %s\n", clocksource_stc.name);
@@ -176,7 +182,7 @@ unsigned long long sched_clock(void)
{
u32 cyc = clocksource_stc.read(&clocksource_stc);
return cyc_to_fixed_sched_clock(&cd, cyc, clocksource_stc.mask,
- clocksource_stc.mult, clocksource_stc.shift);
+ SC_MULT, SC_SHIFT);
}
static void notrace bcm2708_update_sched_clock(void)
@@ -703,7 +709,7 @@ static void __init bcm2708_timer_init(void)
setup_irq(IRQ_TIMER3, &bcm2708_timer_irq);
init_fixed_sched_clock(&cd, bcm2708_update_sched_clock, 32,
- STC_FREQ_HZ, clocksource_stc.mult, clocksource_stc.shift);
+ STC_FREQ_HZ, SC_MULT, SC_SHIFT);
timer0_clockevent.mult =
div_sc(STC_FREQ_HZ, NSEC_PER_SEC, timer0_clockevent.shift);

0 comments on commit 8f1d8e8

Please sign in to comment.