* [PATCH] fix clocksource parameter for low frequency timer.
@ 2006-10-26 14:09 Atsushi Nemoto
2006-10-27 15:57 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Atsushi Nemoto @ 2006-10-26 14:09 UTC (permalink / raw)
To: linux-mips; +Cc: ralf, m_lachwani, creideiki+linux-mips
The current shift value in clocksource was not suitable for low
frequency timer. Find the shift value in runtime to avoid undesirable
overflow. Also calculate a somewhat reasonable rating value based on
its frequency.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 2c6d52b..e535f86 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -324,22 +324,29 @@ static cycle_t read_mips_hpt(void)
static struct clocksource clocksource_mips = {
.name = "MIPS",
- .rating = 250,
.read = read_mips_hpt,
- .shift = 24,
.is_continuous = 1,
};
static void __init init_mips_clocksource(void)
{
u64 temp;
+ u32 shift;
if (!mips_hpt_frequency || mips_hpt_read == null_hpt_read)
return;
- temp = (u64) NSEC_PER_SEC << clocksource_mips.shift;
- do_div(temp, mips_hpt_frequency);
- clocksource_mips.mult = (unsigned)temp;
+ /* Calclate a somewhat reasonable rating value */
+ clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
+ /* Find a shift value */
+ for (shift = 32; shift > 0; shift--) {
+ temp = (u64) NSEC_PER_SEC << shift;
+ do_div(temp, mips_hpt_frequency);
+ if ((temp >> 32) == 0)
+ break;
+ }
+ clocksource_mips.shift = shift;
+ clocksource_mips.mult = (u32)temp;
clocksource_mips.mask = mips_hpt_mask;
clocksource_register(&clocksource_mips);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fix clocksource parameter for low frequency timer.
2006-10-26 14:09 [PATCH] fix clocksource parameter for low frequency timer Atsushi Nemoto
@ 2006-10-27 15:57 ` Ralf Baechle
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2006-10-27 15:57 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips, m_lachwani, creideiki+linux-mips
On Thu, Oct 26, 2006 at 11:09:37PM +0900, Atsushi Nemoto wrote:
> The current shift value in clocksource was not suitable for low
> frequency timer. Find the shift value in runtime to avoid undesirable
> overflow. Also calculate a somewhat reasonable rating value based on
> its frequency.
Looks fine to me and even Thomas Gleixner loves the idea of having code
to find the factor automatically, so it may become generic code after
2.6.19.
Ralf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-10-27 22:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-26 14:09 [PATCH] fix clocksource parameter for low frequency timer Atsushi Nemoto
2006-10-27 15:57 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox