ARM: smp_twd: use clockevents_update_freq to update frequency
authorColin Cross <ccross@android.com>
Sat, 29 Oct 2011 21:06:07 +0000 (14:06 -0700)
committer黄涛 <huangtao@rock-chips.com>
Wed, 22 Feb 2012 06:09:45 +0000 (14:09 +0800)
clockevents_reconfigure was an older api that doesn't handle
updating the max time between ticks when the frequency changes.
Under some conditions, the boot value of max_delta_ns scaled
by the mult/shift values for the current frequency can result
in a value of 0x200000004 selected as the number of cycles to
program for a long tick, which gets wrapped to 0x4.

Also switch to the matching clockevents_config_and_register
function to register the clockevent, which handles converting
the min/max ticks to ns during init.

Change-Id: I6ca659c309e7bb031cdb1954767b5aa7a022ff44
Signed-off-by: Colin Cross <ccross@android.com>
arch/arm/kernel/smp_twd.c

index 27761cacd7b0a039e1db5cb20199327f76bd0f86..350a125f8cd690435a75f8565dbac00569d8194f 100644 (file)
@@ -25,8 +25,6 @@
 #include <asm/smp_twd.h>
 #include <asm/hardware/gic.h>
 
-#define TWD_MIN_RANGE 4
-
 /* set up by the platform code */
 void __iomem *twd_base;
 
@@ -96,8 +94,7 @@ static void twd_update_frequency(void *data)
 {
        twd_timer_rate = clk_get_rate(twd_clk);
 
-       clockevents_reconfigure(__get_cpu_var(twd_ce), twd_timer_rate,
-                       TWD_MIN_RANGE);
+       clockevents_update_freq(__get_cpu_var(twd_ce), twd_timer_rate);
 }
 
 static int twd_cpufreq_transition(struct notifier_block *nb,
@@ -193,15 +190,10 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
        clk->set_mode = twd_set_mode;
        clk->set_next_event = twd_set_next_event;
 
-       clockevents_calc_mult_shift(clk, twd_timer_rate, TWD_MIN_RANGE);
-
-       clk->max_delta_ns = clockevent_delta2ns(0xffffffff, clk);
-       clk->min_delta_ns = clockevent_delta2ns(0xf, clk);
-
        /* Make sure our local interrupt controller has this enabled */
        gic_enable_ppi(clk->irq);
 
        __get_cpu_var(twd_ce) = clk;
 
-       clockevents_register_device(clk);
+       clockevents_config_and_register(clk, twd_timer_rate, 0xf, 0xffffffff);
 }