* [PATCH 0/2] Convert remaining platforms to common sched_clock()
@ 2012-01-16 12:05 Marc Zyngier
2012-01-16 12:05 ` [PATCH 1/2] ARM: davinci: convert to common sched_clock() implementation Marc Zyngier
2012-01-16 12:05 ` [PATCH 2/2] ARM: prima2: " Marc Zyngier
0 siblings, 2 replies; 4+ messages in thread
From: Marc Zyngier @ 2012-01-16 12:05 UTC (permalink / raw)
To: linux-arm-kernel
Only two platforms are left with their own sched_clock() implementation.
This patch series converts them, leading in both cases to some cleanup.
Compile tested only.
Marc Zyngier (2):
ARM: davinci: convert to common sched_clock() implementation
ARM: prima2: convert to common sched_clock() implementation
arch/arm/Kconfig | 2 ++
arch/arm/mach-davinci/time.c | 24 +++++++-----------------
arch/arm/mach-prima2/timer.c | 21 +++++++--------------
3 files changed, 16 insertions(+), 31 deletions(-)
--
1.7.7.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: davinci: convert to common sched_clock() implementation
2012-01-16 12:05 [PATCH 0/2] Convert remaining platforms to common sched_clock() Marc Zyngier
@ 2012-01-16 12:05 ` Marc Zyngier
2012-01-16 12:05 ` [PATCH 2/2] ARM: prima2: " Marc Zyngier
1 sibling, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2012-01-16 12:05 UTC (permalink / raw)
To: linux-arm-kernel
Davinci has its own sched_clock() implementation, which gets in the
way of a single zImage. Moving to the common sched_clock framework
makes the code slightly cleaner.
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-davinci/time.c | 24 +++++++-----------------
2 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 24626b0..cb75734 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -932,6 +932,7 @@ config ARCH_DAVINCI
select ARCH_REQUIRE_GPIOLIB
select ZONE_DMA
select HAVE_IDE
+ select HAVE_SCHED_CLOCK
select CLKDEV_LOOKUP
select GENERIC_ALLOCATOR
select GENERIC_IRQ_CHIP
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index e1969ce..187fcda 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -20,6 +20,7 @@
#include <linux/platform_device.h>
#include <mach/hardware.h>
+#include <asm/sched_clock.h>
#include <asm/mach/irq.h>
#include <asm/mach/time.h>
#include <mach/cputype.h>
@@ -272,19 +273,9 @@ static cycle_t read_cycles(struct clocksource *cs)
return (cycles_t)timer32_read(t);
}
-/*
- * Kernel assumes that sched_clock can be called early but may not have
- * things ready yet.
- */
-static cycle_t read_dummy(struct clocksource *cs)
-{
- return 0;
-}
-
-
static struct clocksource clocksource_davinci = {
.rating = 300,
- .read = read_dummy,
+ .read = read_cycles,
.mask = CLOCKSOURCE_MASK(32),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
@@ -292,12 +283,9 @@ static struct clocksource clocksource_davinci = {
/*
* Overwrite weak default sched_clock with something more precise
*/
-unsigned long long notrace sched_clock(void)
+static u32 notrace davinci_read_sched_clock(void)
{
- const cycle_t cyc = clocksource_davinci.read(&clocksource_davinci);
-
- return clocksource_cyc2ns(cyc, clocksource_davinci.mult,
- clocksource_davinci.shift);
+ return timer32_read(&timers[TID_CLOCKSOURCE]);
}
/*
@@ -397,12 +385,14 @@ static void __init davinci_timer_init(void)
davinci_clock_tick_rate = clk_get_rate(timer_clk);
/* setup clocksource */
- clocksource_davinci.read = read_cycles;
clocksource_davinci.name = id_to_name[clocksource_id];
if (clocksource_register_hz(&clocksource_davinci,
davinci_clock_tick_rate))
printk(err, clocksource_davinci.name);
+ setup_sched_clock(davinci_read_sched_clock, 32,
+ davinci_clock_tick_rate);
+
/* setup clockevent */
clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id];
clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC,
--
1.7.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ARM: prima2: convert to common sched_clock() implementation
2012-01-16 12:05 [PATCH 0/2] Convert remaining platforms to common sched_clock() Marc Zyngier
2012-01-16 12:05 ` [PATCH 1/2] ARM: davinci: convert to common sched_clock() implementation Marc Zyngier
@ 2012-01-16 12:05 ` Marc Zyngier
2012-01-17 8:46 ` Barry Song
1 sibling, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2012-01-16 12:05 UTC (permalink / raw)
To: linux-arm-kernel
Prima2 has its own sched_clock() implementation, which gets in the
way of a single zImage. Moving to the common sched_clock framework
makes the code slightly cleaner (the mapping hack in sched_clock()
goes away...).
Cc: Barry Song <baohua.song@csr.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-prima2/timer.c | 21 +++++++--------------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index cb75734..a18550e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -388,6 +388,7 @@ config ARCH_PRIMA2
select GENERIC_CLOCKEVENTS
select CLKDEV_LOOKUP
select GENERIC_IRQ_CHIP
+ select HAVE_SCHED_CLOCK
select MIGHT_HAVE_CACHE_L2X0
select USE_OF
select ZONE_DMA
diff --git a/arch/arm/mach-prima2/timer.c b/arch/arm/mach-prima2/timer.c
index b7a6091..0d024b1 100644
--- a/arch/arm/mach-prima2/timer.c
+++ b/arch/arm/mach-prima2/timer.c
@@ -18,6 +18,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <mach/map.h>
+#include <asm/sched_clock.h>
#include <asm/mach/time.h>
#define SIRFSOC_TIMER_COUNTER_LO 0x0000
@@ -165,21 +166,9 @@ static struct irqaction sirfsoc_timer_irq = {
};
/* Overwrite weak default sched_clock with more precise one */
-unsigned long long notrace sched_clock(void)
+static u32 notrace sirfsoc_read_sched_clock(void)
{
- static int is_mapped;
-
- /*
- * sched_clock is called earlier than .init of sys_timer
- * if we map timer memory in .init of sys_timer, system
- * will panic due to illegal memory access
- */
- if (!is_mapped) {
- sirfsoc_of_timer_map();
- is_mapped = 1;
- }
-
- return sirfsoc_timer_read(NULL) * (NSEC_PER_SEC / CLOCK_TICK_RATE);
+ return (u32)(sirfsoc_timer_read(NULL) & 0xffffffff);
}
static void __init sirfsoc_clockevent_init(void)
@@ -210,6 +199,8 @@ static void __init sirfsoc_timer_init(void)
BUG_ON(rate < CLOCK_TICK_RATE);
BUG_ON(rate % CLOCK_TICK_RATE);
+ sirfsoc_of_timer_map();
+
writel_relaxed(rate / CLOCK_TICK_RATE / 2 - 1, sirfsoc_timer_base + SIRFSOC_TIMER_DIV);
writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO);
writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_HI);
@@ -217,6 +208,8 @@ static void __init sirfsoc_timer_init(void)
BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, CLOCK_TICK_RATE));
+ setup_sched_clock(sirfsoc_read_sched_clock, 32, CLOCK_TICK_RATE);
+
BUG_ON(setup_irq(sirfsoc_timer_irq.irq, &sirfsoc_timer_irq));
sirfsoc_clockevent_init();
--
1.7.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ARM: prima2: convert to common sched_clock() implementation
2012-01-16 12:05 ` [PATCH 2/2] ARM: prima2: " Marc Zyngier
@ 2012-01-17 8:46 ` Barry Song
0 siblings, 0 replies; 4+ messages in thread
From: Barry Song @ 2012-01-17 8:46 UTC (permalink / raw)
To: linux-arm-kernel
2012/1/16 Marc Zyngier <marc.zyngier@arm.com>:
> Prima2 has its own sched_clock() implementation, which gets in the
> way of a single zImage. Moving to the common sched_clock framework
> makes the code slightly cleaner (the mapping hack in sched_clock()
> goes away...).
>
> Cc: Barry Song <baohua.song@csr.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Ack. Thanks, Marc.
-barry
> ---
> ?arch/arm/Kconfig ? ? ? ? ? ? | ? ?1 +
> ?arch/arm/mach-prima2/timer.c | ? 21 +++++++--------------
> ?2 files changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index cb75734..a18550e 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -388,6 +388,7 @@ config ARCH_PRIMA2
> ? ? ? ?select GENERIC_CLOCKEVENTS
> ? ? ? ?select CLKDEV_LOOKUP
> ? ? ? ?select GENERIC_IRQ_CHIP
> + ? ? ? select HAVE_SCHED_CLOCK
> ? ? ? ?select MIGHT_HAVE_CACHE_L2X0
> ? ? ? ?select USE_OF
> ? ? ? ?select ZONE_DMA
> diff --git a/arch/arm/mach-prima2/timer.c b/arch/arm/mach-prima2/timer.c
> index b7a6091..0d024b1 100644
> --- a/arch/arm/mach-prima2/timer.c
> +++ b/arch/arm/mach-prima2/timer.c
> @@ -18,6 +18,7 @@
> ?#include <linux/of.h>
> ?#include <linux/of_address.h>
> ?#include <mach/map.h>
> +#include <asm/sched_clock.h>
> ?#include <asm/mach/time.h>
>
> ?#define SIRFSOC_TIMER_COUNTER_LO ? ? ? 0x0000
> @@ -165,21 +166,9 @@ static struct irqaction sirfsoc_timer_irq = {
> ?};
>
> ?/* Overwrite weak default sched_clock with more precise one */
> -unsigned long long notrace sched_clock(void)
> +static u32 notrace sirfsoc_read_sched_clock(void)
> ?{
> - ? ? ? static int is_mapped;
> -
> - ? ? ? /*
> - ? ? ? ?* sched_clock is called earlier than .init of sys_timer
> - ? ? ? ?* if we map timer memory in .init of sys_timer, system
> - ? ? ? ?* will panic due to illegal memory access
> - ? ? ? ?*/
> - ? ? ? if (!is_mapped) {
> - ? ? ? ? ? ? ? sirfsoc_of_timer_map();
> - ? ? ? ? ? ? ? is_mapped = 1;
> - ? ? ? }
> -
> - ? ? ? return sirfsoc_timer_read(NULL) * (NSEC_PER_SEC / CLOCK_TICK_RATE);
> + ? ? ? return (u32)(sirfsoc_timer_read(NULL) & 0xffffffff);
> ?}
>
> ?static void __init sirfsoc_clockevent_init(void)
> @@ -210,6 +199,8 @@ static void __init sirfsoc_timer_init(void)
> ? ? ? ?BUG_ON(rate < CLOCK_TICK_RATE);
> ? ? ? ?BUG_ON(rate % CLOCK_TICK_RATE);
>
> + ? ? ? sirfsoc_of_timer_map();
> +
> ? ? ? ?writel_relaxed(rate / CLOCK_TICK_RATE / 2 - 1, sirfsoc_timer_base + SIRFSOC_TIMER_DIV);
> ? ? ? ?writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO);
> ? ? ? ?writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_HI);
> @@ -217,6 +208,8 @@ static void __init sirfsoc_timer_init(void)
>
> ? ? ? ?BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, CLOCK_TICK_RATE));
>
> + ? ? ? setup_sched_clock(sirfsoc_read_sched_clock, 32, CLOCK_TICK_RATE);
> +
> ? ? ? ?BUG_ON(setup_irq(sirfsoc_timer_irq.irq, &sirfsoc_timer_irq));
>
> ? ? ? ?sirfsoc_clockevent_init();
> --
> 1.7.7.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-17 8:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 12:05 [PATCH 0/2] Convert remaining platforms to common sched_clock() Marc Zyngier
2012-01-16 12:05 ` [PATCH 1/2] ARM: davinci: convert to common sched_clock() implementation Marc Zyngier
2012-01-16 12:05 ` [PATCH 2/2] ARM: prima2: " Marc Zyngier
2012-01-17 8:46 ` Barry Song
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).