Skip to contentSkip to conversation

clocksource: arm_generic: use integer math helpers

PATCH New Linus Walleij 3 participants 3 messages Oct 29, 2012 – Nov 13, 2012 Clocksource, clockevent drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: arm_generic: use integer math helpers

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 <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 drivers/clocksource/arm_generic.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/arm_generic.c +2 -2
index c4d9f95..6cd1b30 100644
@@ -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()));
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 1/1 clocksource: arm_generic: use integer math helpers

Quoted 7 lines · Linus Walleij

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 <[email protected]>
Cc Catalin Marinas <[email protected]>

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

Thanks.

Signature · 1 line
Catalin
Applied
#2 lore raw

PATCH 1/1 clocksource: arm_generic: use integer math helpers

In reply to Linus Walleij
Quoted 7 lines · Linus Walleij

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 <[email protected]>
Cc Catalin Marinas <[email protected]>

Applied. Thanks
-john