linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocksource: arm_generic: use integer math helpers
@ 2012-10-29 14:24 Linus Walleij
  2012-11-05 17:26 ` Catalin Marinas
  2012-11-13 19:06 ` John Stultz
  0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2012-10-29 14:24 UTC (permalink / raw)
  To: linux-arm-kernel

This will make the two crucial integer divisions in the generic
ARM arch timer used for ARMv8 use the kernel DIV_ROUND_CLOSEST()
helper inline from <linux/kernel.h> so they get more precise.

Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/clocksource/arm_generic.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
index c4d9f95..6cd1b30 100644
--- a/drivers/clocksource/arm_generic.c
+++ b/drivers/clocksource/arm_generic.c
@@ -127,7 +127,7 @@ static void __init arch_timer_calibrate(void)
 
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 
-	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
+	sched_clock_mult = DIV_ROUND_CLOSEST(NSEC_PER_SEC, arch_timer_rate);
 
 	pr_info("Architected local timer running at %u.%02uMHz.\n",
 		 arch_timer_rate / 1000000, (arch_timer_rate / 10000) % 100);
@@ -221,7 +221,7 @@ int __init arm_generic_timer_init(void)
 	clocksource_register_hz(&clocksource_counter, arch_timer_rate);
 
 	/* Calibrate the delay loop directly */
-	lpj_fine = arch_timer_rate / HZ;
+	lpj_fine = DIV_ROUND_CLOSEST(arch_timer_rate, HZ);
 
 	/* Immediately configure the timer on the boot CPU */
 	arch_timer_setup(per_cpu_ptr(&arch_timer_evt, smp_processor_id()));
-- 
1.7.7.6

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

* [PATCH] clocksource: arm_generic: use integer math helpers
  2012-10-29 14:24 [PATCH] clocksource: arm_generic: use integer math helpers Linus Walleij
@ 2012-11-05 17:26 ` Catalin Marinas
  2012-11-13 19:06 ` John Stultz
  1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2012-11-05 17:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 29, 2012 at 02:24:18PM +0000, Linus Walleij wrote:
> This will make the two crucial integer divisions in the generic
> ARM arch timer used for ARMv8 use the kernel DIV_ROUND_CLOSEST()
> helper inline from <linux/kernel.h> so they get more precise.
> 
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

BTW, would this go through John's tree? I'm happy to push it as well.

Thanks.

-- 
Catalin

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

* [PATCH] clocksource: arm_generic: use integer math helpers
  2012-10-29 14:24 [PATCH] clocksource: arm_generic: use integer math helpers Linus Walleij
  2012-11-05 17:26 ` Catalin Marinas
@ 2012-11-13 19:06 ` John Stultz
  1 sibling, 0 replies; 3+ messages in thread
From: John Stultz @ 2012-11-13 19:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/29/2012 07:24 AM, Linus Walleij wrote:
> This will make the two crucial integer divisions in the generic
> ARM arch timer used for ARMv8 use the kernel DIV_ROUND_CLOSEST()
> helper inline from <linux/kernel.h> so they get more precise.
>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied. Thanks
-john

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

end of thread, other threads:[~2012-11-13 19:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-29 14:24 [PATCH] clocksource: arm_generic: use integer math helpers Linus Walleij
2012-11-05 17:26 ` Catalin Marinas
2012-11-13 19:06 ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).