aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2010-05-19 10:40:53 -0700
committerRalf Baechle <ralf@linux-mips.org>2010-08-05 13:25:39 +0100
commit4d2b11252b92c6aca9f9222ee05e00f7262c2e53 (patch)
tree7d9f51b5ecc324c6ea45f55105a4e1b74f3c7b70
parent6165df980801e1be7a5b65686bd52f55e0407db1 (diff)
downloadkernel_samsung_smdk4412-4d2b11252b92c6aca9f9222ee05e00f7262c2e53.zip
kernel_samsung_smdk4412-4d2b11252b92c6aca9f9222ee05e00f7262c2e53.tar.gz
kernel_samsung_smdk4412-4d2b11252b92c6aca9f9222ee05e00f7262c2e53.tar.bz2
MIPS: Don't overflow cevt-r4k.c calculations at high clock rates.
The 'mult' element of struct clock_event_device must never be wider than 32-bits. If it were, it would get truncated when used by clockevent_delta2ns() when this calls do_div(). We can meet this requirement by using clockevent_set_clock() to set the MULT and SHIFT values. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/1253/ Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/kernel/cevt-r4k.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 0b2450c..2a4d50f 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -163,7 +163,6 @@ int c0_compare_int_usable(void)
int __cpuinit r4k_clockevent_init(void)
{
- uint64_t mips_freq = mips_hpt_frequency;
unsigned int cpu = smp_processor_id();
struct clock_event_device *cd;
unsigned int irq;
@@ -188,9 +187,9 @@ int __cpuinit r4k_clockevent_init(void)
cd->name = "MIPS";
cd->features = CLOCK_EVT_FEAT_ONESHOT;
+ clockevent_set_clock(cd, mips_hpt_frequency);
+
/* Calculate the min / max delta */
- cd->mult = div_sc((unsigned long) mips_freq, NSEC_PER_SEC, 32);
- cd->shift = 32;
cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd);
cd->min_delta_ns = clockevent_delta2ns(0x300, cd);