From 6b892c225acb0d6ca7a1a36def5879ba6732f587 Mon Sep 17 00:00:00 2001 From: Deng-Cheng Zhu Date: Sat, 7 Mar 2015 10:30:23 -0800 Subject: [PATCH 1/2] MIPS: Add sched_clock support This will provide sched_clock interface to implement individual read_sched_clock(). Not for CAVIUM_OCTEON_SOC as it defines its own sched_clock() directly (not using the sched_clock_register interface). [alex.smith@imgtec.com: Cherry-picked from commit 929de4cc9719398f3a7246854b6c254070e18b0a upstream.] Signed-off-by: Deng-Cheng Zhu Cc: linux-mips@linux-mips.org Cc: macro@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/9477/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9554a93eb48a02..356cda37e230c0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -43,6 +43,7 @@ config MIPS select GENERIC_SMP_IDLE_THREAD select BUILDTIME_EXTABLE_SORT select GENERIC_CLOCKEVENTS + select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC select GENERIC_CMOS_UPDATE select HAVE_MOD_ARCH_SPECIFIC select VIRT_TO_BUS From c47eed27f62f9b625892c5bdeec3fa090bfe0cf2 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Fri, 17 Jul 2015 09:14:41 +0100 Subject: [PATCH 2/2] clocksource: jz4780-tcu: Provide sched_clock() implementation Use sched_clock_register() to register an implementation of sched_clock() using the OST, the same as the clocksource. Without this sched_clock() is implemented using jiffies. This implementation provides much higher resolution, which benefits several things such as CPU time accounting, the ftrace local clock and printk timing information. Signed-off-by: Alex Smith --- drivers/clocksource/jz4780-tcu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/clocksource/jz4780-tcu.c b/drivers/clocksource/jz4780-tcu.c index 4db47f9d2e0229..0193030a931d7b 100644 --- a/drivers/clocksource/jz4780-tcu.c +++ b/drivers/clocksource/jz4780-tcu.c @@ -10,6 +10,7 @@ #include #include +#include #include "jz47xx-tcu.h" @@ -51,6 +52,11 @@ static cycle_t jz4780_tcu_clocksource_read(struct clocksource *cs) return jz47xx_tcu_read_channel_count(jz4780_tcu_clocksource.channel); } +static u64 notrace jz4780_tcu_sched_read(void) +{ + return jz47xx_tcu_read_channel_count(jz4780_tcu_clocksource.channel); +} + static void __init jz4780_tcu_init(struct device_node *np) { struct jz47xx_tcu *tcu; @@ -72,6 +78,7 @@ static void __init jz4780_tcu_init(struct device_node *np) err = clocksource_register_hz(&jz4780_tcu_clocksource.cs, rate); BUG_ON(err); + sched_clock_register(jz4780_tcu_sched_read, 64, rate); /* For local clock events */ err = jz47xx_tcu_setup_cevt(tcu, 5);