* [PATCH] Alchemy: override loops_per_jiffy detection
@ 2009-08-22 16:09 Manuel Lauss
2009-08-27 10:57 ` Ralf Baechle
0 siblings, 1 reply; 3+ messages in thread
From: Manuel Lauss @ 2009-08-22 16:09 UTC (permalink / raw)
To: Linux-MIPS, Ralf Baechle; +Cc: Manuel Lauss
The loops_per_jiffy detection in generic calibrate_delay is a bit off
(by ~0.5% usually); calculate the correct value based on detected core
clock. BogoMIPS value will now reflect cpu core clock correctly.
(Blatantly stolen from the SH port).
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
arch/mips/Kconfig | 2 +-
arch/mips/alchemy/common/setup.c | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3ca0fe1..56c8139 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -700,7 +700,7 @@ config GENERIC_HWEIGHT
config GENERIC_CALIBRATE_DELAY
bool
- default y
+ default y if !MACH_ALCHEMY
config GENERIC_CLOCKEVENTS
bool
diff --git a/arch/mips/alchemy/common/setup.c b/arch/mips/alchemy/common/setup.c
index 3f036b3..5ea7e1a 100644
--- a/arch/mips/alchemy/common/setup.c
+++ b/arch/mips/alchemy/common/setup.c
@@ -74,6 +74,17 @@ void __init plat_mem_setup(void)
iomem_resource.end = IOMEM_RESOURCE_END;
}
+void __cpuinit calibrate_delay(void)
+{
+ loops_per_jiffy = (get_au1x00_speed() >> 1) / HZ;
+
+ printk(KERN_INFO "Calibrating delay loop (skipped)... "
+ "%lu.%02lu BogoMIPS PRESET (lpj=%lu)\n",
+ loops_per_jiffy/(500000/HZ),
+ (loops_per_jiffy/(5000/HZ)) % 100,
+ loops_per_jiffy);
+}
+
#if defined(CONFIG_64BIT_PHYS_ADDR)
/* This routine should be valid for all Au1x based boards */
phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size)
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Alchemy: override loops_per_jiffy detection
2009-08-22 16:09 [PATCH] Alchemy: override loops_per_jiffy detection Manuel Lauss
@ 2009-08-27 10:57 ` Ralf Baechle
2009-08-27 12:08 ` Manuel Lauss
0 siblings, 1 reply; 3+ messages in thread
From: Ralf Baechle @ 2009-08-27 10:57 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Linux-MIPS, Manuel Lauss
On Sat, Aug 22, 2009 at 06:09:12PM +0200, Manuel Lauss wrote:
> The loops_per_jiffy detection in generic calibrate_delay is a bit off
> (by ~0.5% usually); calculate the correct value based on detected core
> clock. BogoMIPS value will now reflect cpu core clock correctly.
It think this is pretty much solving a non-problem. The BogoMIPS number
should only be used for various delay functions and the only give a
guarantee for a minimum delay but barely any promise about accuracy of
the delay. Due to interrupts consuming some CPU time and potencially
producing extra cache misses the measured BogoMIPS value is expected to
be a bit lower than what a naive calculation based on the CPU clock is
predicting; effects that not only impact the calculation of the BogoMIPS
number but also delays based on the BogoMIPS number.
Here's an even easier solution:
#include <linux/jiffies.h>
...
preset_lpj = <loops_per_jiffie_value>;
Avoid the change to Kconfig that eventually will become messy if other
systems continue along this line.
Ralf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Alchemy: override loops_per_jiffy detection
2009-08-27 10:57 ` Ralf Baechle
@ 2009-08-27 12:08 ` Manuel Lauss
0 siblings, 0 replies; 3+ messages in thread
From: Manuel Lauss @ 2009-08-27 12:08 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Linux-MIPS, Manuel Lauss
Hi Ralf,
On Thu, Aug 27, 2009 at 12:57 PM, Ralf Baechle<ralf@linux-mips.org> wrote:
> On Sat, Aug 22, 2009 at 06:09:12PM +0200, Manuel Lauss wrote:
>
>> The loops_per_jiffy detection in generic calibrate_delay is a bit off
>> (by ~0.5% usually); calculate the correct value based on detected core
>> clock. BogoMIPS value will now reflect cpu core clock correctly.
>
> It think this is pretty much solving a non-problem.
Pretty much, yeah, and it doesn't solve it completely either. With certain
frequencies the printed rate is wrong due to rouding ;-)
> Here's an even easier solution:
>
> #include <linux/jiffies.h>
> ...
> preset_lpj = <loops_per_jiffie_value>;
>
> Avoid the change to Kconfig that eventually will become messy if other
> systems continue along this line.
Ah, much better. I'll resend a tested new version in a few hours.
Thanks!
Manuel Lauss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-27 12:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-22 16:09 [PATCH] Alchemy: override loops_per_jiffy detection Manuel Lauss
2009-08-27 10:57 ` Ralf Baechle
2009-08-27 12:08 ` Manuel Lauss
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).