All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] MIPS: Don't overflow cevt-r4k.c calculations at high clock rates.
@ 2010-05-19 17:40 David Daney
  2010-05-19 17:42 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: David Daney @ 2010-05-19 17:40 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: David Daney, Thomas Gleixner

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: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mips/kernel/cevt-r4k.c |    5 ++---
 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);
 
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] MIPS: Don't overflow cevt-r4k.c calculations at high clock rates.
  2010-05-19 17:40 [PATCH v2] MIPS: Don't overflow cevt-r4k.c calculations at high clock rates David Daney
@ 2010-05-19 17:42 ` Thomas Gleixner
  2010-05-20 21:38   ` Ralf Baechle
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2010-05-19 17:42 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf

On Wed, 19 May 2010, David Daney wrote:

> 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: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Thomas Gleixner <tglx@linutronix.de>

> ---
>  arch/mips/kernel/cevt-r4k.c |    5 ++---
>  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);
>  
> -- 
> 1.6.6.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] MIPS: Don't overflow cevt-r4k.c calculations at high clock rates.
  2010-05-19 17:42 ` Thomas Gleixner
@ 2010-05-20 21:38   ` Ralf Baechle
  0 siblings, 0 replies; 3+ messages in thread
From: Ralf Baechle @ 2010-05-20 21:38 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: David Daney, linux-mips

On Wed, May 19, 2010 at 07:42:44PM +0200, Thomas Gleixner wrote:

> >  arch/mips/kernel/cevt-r4k.c |    5 ++---
> >  1 files changed, 2 insertions(+), 3 deletions(-)

Diffstat says it must be good :)

Thanks folks, applied!

  Ralf

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-05-20 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19 17:40 [PATCH v2] MIPS: Don't overflow cevt-r4k.c calculations at high clock rates David Daney
2010-05-19 17:42 ` Thomas Gleixner
2010-05-20 21:38   ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.