[PATCH] MIPS: provide sched_clock based on c0 counter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Provide a high-resolution sched_clock() based on the C0 counter using
the generic sched_clock infrastructure.

Signed-off-by: Rabin Vincent <rabin.vincent@xxxxxxxx>
---
 arch/mips/Kconfig           |    1 +
 arch/mips/kernel/csrc-r4k.c |    7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index f43aa53..8068259 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -924,6 +924,7 @@ config CSRC_IOASIC
 	bool
 
 config CSRC_R4K
+	select GENERIC_SCHED_CLOCK
 	bool
 
 config CSRC_GIC
diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
index decd1fa..318fec6 100644
--- a/arch/mips/kernel/csrc-r4k.c
+++ b/arch/mips/kernel/csrc-r4k.c
@@ -6,6 +6,7 @@
  * Copyright (C) 2007 by Ralf Baechle
  */
 #include <linux/clocksource.h>
+#include <linux/sched_clock.h>
 #include <linux/init.h>
 
 #include <asm/time.h>
@@ -22,6 +23,11 @@ static struct clocksource clocksource_mips = {
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+static u64 c0_hpt_read_sched_clock(void)
+{
+	return read_c0_count();
+}
+
 int __init init_r4k_clocksource(void)
 {
 	if (!cpu_has_counter || !mips_hpt_frequency)
@@ -31,6 +37,7 @@ int __init init_r4k_clocksource(void)
 	clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
 
 	clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
+	sched_clock_register(c0_hpt_read_sched_clock, 32, mips_hpt_frequency);
 
 	return 0;
 }
-- 
1.7.10.4






[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux