From: Tony Lindgren <tony@atomide.com>
To: Paul Walmsley <paul@pwsan.com>
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Thomas Weber <thomas.weber.linux@googlemail.com>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Santosh Shilimkar <santosh.shilimkar@ti.com>,
Richard Woodruff <r-woodruff2@ti.com>
Subject: [PATCH] omap1: Fix sched_clock implementation when both MPU timer and 32K timer are used (Re: State of LDP3430 platform)
Date: Wed, 19 Jan 2011 10:43:21 -0800 [thread overview]
Message-ID: <20110119184321.GY4957@atomide.com> (raw)
In-Reply-To: <20110118232102.GU4957@atomide.com>
* Tony Lindgren <tony@atomide.com> [110118 15:20]:
> * Tony Lindgren <tony@atomide.com> [110118 14:34]:
> > For omap15xx and 730 we need to use the MPU timer
> > as the 32K timer is not available. For omap16xx
> > we want to use the 32K timer because of PM. Fix this
> > by allowing to build in both timers.
>
> This still needs one more patch to deal with the
> sched_clock for MPU timer..
And here's that patch to make sched_clock work with both
timers.
Tony
From: Tony Lindgren <tony@atomide.com>
Date: Tue, 18 Jan 2011 17:00:00 -0800
Subject: [PATCH] omap1: Fix sched_clock implementation when both MPU timer and 32K timer are used
Earlier patches select HAVE_SCHED_CLOCK for omaps. To have working sched_clock
also for MPU timer, we need to implement it in a way where the right one gets
selected during the runtime.
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -219,6 +219,24 @@ static struct clocksource clocksource_mpu = {
static DEFINE_CLOCK_DATA(cd);
+static inline unsigned long long notrace _omap_mpu_sched_clock(void)
+{
+ u32 cyc = mpu_read(&clocksource_mpu);
+ return cyc_to_sched_clock(&cd, cyc, (u32)~0);
+}
+
+#ifndef CONFIG_OMAP_32K_TIMER
+unsigned long long notrace sched_clock(void)
+{
+ return _omap_mpu_sched_clock();
+}
+#else
+static unsigned long long notrace omap_mpu_sched_clock(void)
+{
+ return _omap_mpu_sched_clock();
+}
+#endif
+
static void notrace mpu_update_sched_clock(void)
{
u32 cyc = mpu_read(&clocksource_mpu);
@@ -262,6 +280,30 @@ static inline void omap_mpu_timer_init(void)
}
#endif /* CONFIG_OMAP_MPU_TIMER */
+#if defined(CONFIG_OMAP_MPU_TIMER) && defined(CONFIG_OMAP_32K_TIMER)
+static unsigned long long (*preferred_sched_clock)(void);
+
+unsigned long long notrace sched_clock(void)
+{
+ if (!preferred_sched_clock)
+ return 0;
+
+ return preferred_sched_clock();
+}
+
+static inline void preferred_sched_clock_init(bool use_32k_sched_clock)
+{
+ if (use_32k_sched_clock)
+ preferred_sched_clock = omap_32k_sched_clock;
+ else
+ preferred_sched_clock = omap_mpu_sched_clock;
+}
+#else
+static inline void preferred_sched_clock_init(bool use_32k_sched_clcok)
+{
+}
+#endif
+
static inline int omap_32k_timer_usable(void)
{
int res = false;
@@ -283,8 +325,12 @@ static inline int omap_32k_timer_usable(void)
*/
static void __init omap_timer_init(void)
{
- if (!omap_32k_timer_usable())
+ if (omap_32k_timer_usable()) {
+ preferred_sched_clock_init(1);
+ } else {
omap_mpu_timer_init();
+ preferred_sched_clock_init(0);
+ }
}
struct sys_timer omap_timer = {
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -120,12 +120,24 @@ static DEFINE_CLOCK_DATA(cd);
#define SC_MULT 4000000000u
#define SC_SHIFT 17
-unsigned long long notrace sched_clock(void)
+static inline unsigned long long notrace _omap_32k_sched_clock(void)
{
u32 cyc = clocksource_32k.read(&clocksource_32k);
return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
}
+#ifndef CONFIG_OMAP_MPU_TIMER
+unsigned long long notrace sched_clock(void)
+{
+ return _omap_32k_sched_clock();
+}
+#else
+unsigned long long notrace omap_32k_sched_clock(void)
+{
+ return _omap_32k_sched_clock();
+}
+#endif
+
static void notrace omap_update_sched_clock(void)
{
u32 cyc = clocksource_32k.read(&clocksource_32k);
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -37,6 +37,7 @@ extern void omap_map_common_io(void);
extern struct sys_timer omap_timer;
extern bool omap_32k_timer_init(void);
extern int __init omap_init_clocksource_32k(void);
+extern unsigned long long notrace omap_32k_sched_clock(void);
extern void omap_reserve(void);
WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] omap1: Fix sched_clock implementation when both MPU timer and 32K timer are used (Re: State of LDP3430 platform)
Date: Wed, 19 Jan 2011 10:43:21 -0800 [thread overview]
Message-ID: <20110119184321.GY4957@atomide.com> (raw)
In-Reply-To: <20110118232102.GU4957@atomide.com>
* Tony Lindgren <tony@atomide.com> [110118 15:20]:
> * Tony Lindgren <tony@atomide.com> [110118 14:34]:
> > For omap15xx and 730 we need to use the MPU timer
> > as the 32K timer is not available. For omap16xx
> > we want to use the 32K timer because of PM. Fix this
> > by allowing to build in both timers.
>
> This still needs one more patch to deal with the
> sched_clock for MPU timer..
And here's that patch to make sched_clock work with both
timers.
Tony
From: Tony Lindgren <tony@atomide.com>
Date: Tue, 18 Jan 2011 17:00:00 -0800
Subject: [PATCH] omap1: Fix sched_clock implementation when both MPU timer and 32K timer are used
Earlier patches select HAVE_SCHED_CLOCK for omaps. To have working sched_clock
also for MPU timer, we need to implement it in a way where the right one gets
selected during the runtime.
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -219,6 +219,24 @@ static struct clocksource clocksource_mpu = {
static DEFINE_CLOCK_DATA(cd);
+static inline unsigned long long notrace _omap_mpu_sched_clock(void)
+{
+ u32 cyc = mpu_read(&clocksource_mpu);
+ return cyc_to_sched_clock(&cd, cyc, (u32)~0);
+}
+
+#ifndef CONFIG_OMAP_32K_TIMER
+unsigned long long notrace sched_clock(void)
+{
+ return _omap_mpu_sched_clock();
+}
+#else
+static unsigned long long notrace omap_mpu_sched_clock(void)
+{
+ return _omap_mpu_sched_clock();
+}
+#endif
+
static void notrace mpu_update_sched_clock(void)
{
u32 cyc = mpu_read(&clocksource_mpu);
@@ -262,6 +280,30 @@ static inline void omap_mpu_timer_init(void)
}
#endif /* CONFIG_OMAP_MPU_TIMER */
+#if defined(CONFIG_OMAP_MPU_TIMER) && defined(CONFIG_OMAP_32K_TIMER)
+static unsigned long long (*preferred_sched_clock)(void);
+
+unsigned long long notrace sched_clock(void)
+{
+ if (!preferred_sched_clock)
+ return 0;
+
+ return preferred_sched_clock();
+}
+
+static inline void preferred_sched_clock_init(bool use_32k_sched_clock)
+{
+ if (use_32k_sched_clock)
+ preferred_sched_clock = omap_32k_sched_clock;
+ else
+ preferred_sched_clock = omap_mpu_sched_clock;
+}
+#else
+static inline void preferred_sched_clock_init(bool use_32k_sched_clcok)
+{
+}
+#endif
+
static inline int omap_32k_timer_usable(void)
{
int res = false;
@@ -283,8 +325,12 @@ static inline int omap_32k_timer_usable(void)
*/
static void __init omap_timer_init(void)
{
- if (!omap_32k_timer_usable())
+ if (omap_32k_timer_usable()) {
+ preferred_sched_clock_init(1);
+ } else {
omap_mpu_timer_init();
+ preferred_sched_clock_init(0);
+ }
}
struct sys_timer omap_timer = {
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -120,12 +120,24 @@ static DEFINE_CLOCK_DATA(cd);
#define SC_MULT 4000000000u
#define SC_SHIFT 17
-unsigned long long notrace sched_clock(void)
+static inline unsigned long long notrace _omap_32k_sched_clock(void)
{
u32 cyc = clocksource_32k.read(&clocksource_32k);
return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
}
+#ifndef CONFIG_OMAP_MPU_TIMER
+unsigned long long notrace sched_clock(void)
+{
+ return _omap_32k_sched_clock();
+}
+#else
+unsigned long long notrace omap_32k_sched_clock(void)
+{
+ return _omap_32k_sched_clock();
+}
+#endif
+
static void notrace omap_update_sched_clock(void)
{
u32 cyc = clocksource_32k.read(&clocksource_32k);
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -37,6 +37,7 @@ extern void omap_map_common_io(void);
extern struct sys_timer omap_timer;
extern bool omap_32k_timer_init(void);
extern int __init omap_init_clocksource_32k(void);
+extern unsigned long long notrace omap_32k_sched_clock(void);
extern void omap_reserve(void);
next prev parent reply other threads:[~2011-01-19 18:43 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 12:55 State of LDP3430 platform Russell King - ARM Linux
2010-12-06 15:59 ` Tony Lindgren
2010-12-06 17:22 ` Russell King - ARM Linux
2010-12-06 18:02 ` Tony Lindgren
2010-12-06 18:19 ` Tony Lindgren
2010-12-06 18:27 ` Paul Walmsley
2010-12-07 8:37 ` Russell King - ARM Linux
2010-12-08 0:50 ` Paul Walmsley
2010-12-08 3:40 ` Paul Walmsley
2011-01-15 0:03 ` Tony Lindgren
2011-01-15 19:38 ` Paul Walmsley
2011-01-15 23:37 ` Russell King - ARM Linux
2011-01-16 0:04 ` Russell King - ARM Linux
2011-01-16 0:05 ` Woodruff, Richard
2011-01-16 0:30 ` Russell King - ARM Linux
2011-01-16 1:09 ` Paul Walmsley
2011-01-16 4:32 ` Paul Walmsley
2011-01-16 4:32 ` Paul Walmsley
2011-01-16 15:08 ` Thomas Weber
2011-01-16 15:08 ` Thomas Weber
2011-01-18 19:36 ` Paul Walmsley
2011-01-18 19:36 ` Paul Walmsley
2011-01-18 22:26 ` [PATCH] omap1: Fix sched_clock for the MPU timer (Re: State of LDP3430 platform) Tony Lindgren
2011-01-18 22:26 ` Tony Lindgren
2011-01-18 22:35 ` [PATCH] omap1: Fix booting for 15xx and 730 with omap1_defconfig " Tony Lindgren
2011-01-18 22:35 ` Tony Lindgren
2011-01-18 23:21 ` Tony Lindgren
2011-01-18 23:21 ` Tony Lindgren
2011-01-19 18:43 ` Tony Lindgren [this message]
2011-01-19 18:43 ` [PATCH] omap1: Fix sched_clock implementation when both MPU timer and 32K timer are used " Tony Lindgren
2011-01-19 18:44 ` [PATCH] omap1: Fix sched_clock for the MPU timer " Tony Lindgren
2011-01-19 18:44 ` Tony Lindgren
2011-01-19 13:43 ` State of LDP3430 platform Jarkko Nikula
2011-01-19 13:43 ` Jarkko Nikula
2011-01-18 1:25 ` Tony Lindgren
2011-01-18 1:25 ` Tony Lindgren
2011-01-18 19:24 ` Paul Walmsley
2011-01-18 19:24 ` Paul Walmsley
2011-01-15 23:47 ` Woodruff, Richard
2011-01-17 17:34 ` Tony Lindgren
2011-01-17 17:44 ` Woodruff, Richard
2011-02-12 16:02 ` Russell King - ARM Linux
2011-02-12 16:10 ` Russell King - ARM Linux
2011-02-23 22:50 ` Tony Lindgren
2011-02-23 23:22 ` Woodruff, Richard
2011-02-24 7:08 ` Rajendra Nayak
2011-02-24 13:07 ` Rajendra Nayak
2011-02-24 8:21 ` Janorkar, Mayuresh
2011-02-24 8:47 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110119184321.GY4957@atomide.com \
--to=tony@atomide.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=paul@pwsan.com \
--cc=r-woodruff2@ti.com \
--cc=santosh.shilimkar@ti.com \
--cc=thomas.weber.linux@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.