* [patch 1/5] i8253: Create common clockevent implementation
2011-06-09 13:08 [patch 0/5] i8253: common clockevent Thomas Gleixner
@ 2011-06-09 13:08 ` Thomas Gleixner
2011-06-24 14:28 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
` (2 more replies)
2011-06-09 13:08 ` [patch 2/5] x86: Use common i8253 clockevent Thomas Gleixner
` (3 subsequent siblings)
4 siblings, 3 replies; 20+ messages in thread
From: Thomas Gleixner @ 2011-06-09 13:08 UTC (permalink / raw)
To: LKML; +Cc: Russell King, Ralf Baechle, Ingo Molnar, John Stultz
[-- Attachment #1: pit-clockevent-device.patch --]
[-- Type: text/plain, Size: 4567 bytes --]
arm, mips and x86 implement i8253 based clockevents. All the same code
copied. Create a common implementation in drivers/clocksource/i8253.c.
About time to rename drivers/clocksource/ to something else.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@arm.linux.org.uk>
---
drivers/clocksource/Kconfig | 5 +-
drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 98 insertions(+), 8 deletions(-)
Index: linux-2.6-tip/drivers/clocksource/Kconfig
===================================================================
--- linux-2.6-tip.orig/drivers/clocksource/Kconfig
+++ linux-2.6-tip/drivers/clocksource/Kconfig
@@ -1,11 +1,14 @@
config CLKSRC_I8253
bool
+config CLKEVT_I8253
+ bool
+
config I8253_LOCK
bool
config CLKBLD_I8253
- def_bool y if CLKSRC_I8253 || I8253_LOCK
+ def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK
config CLKSRC_MMIO
bool
Index: linux-2.6-tip/drivers/clocksource/i8253.c
===================================================================
--- linux-2.6-tip.orig/drivers/clocksource/i8253.c
+++ linux-2.6-tip/drivers/clocksource/i8253.c
@@ -1,13 +1,14 @@
/*
* i8253 PIT clocksource
*/
-#include <linux/clocksource.h>
+#include <linux/clockchips.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
#include <linux/module.h>
#include <linux/i8253.h>
+#include <linux/smp.h>
/*
* Protects access to I/O ports
@@ -49,15 +50,15 @@ static cycle_t i8253_read(struct clockso
* count), it cannot be newer.
*/
jifs = jiffies;
- outb_pit(0x00, PIT_MODE); /* latch the count ASAP */
- count = inb_pit(PIT_CH0); /* read the latched count */
- count |= inb_pit(PIT_CH0) << 8;
+ outb_p(0x00, PIT_MODE); /* latch the count ASAP */
+ count = inb_p(PIT_CH0); /* read the latched count */
+ count |= inb_p(PIT_CH0) << 8;
/* VIA686a test code... reset the latch if count > max + 1 */
if (count > LATCH) {
- outb_pit(0x34, PIT_MODE);
- outb_pit(PIT_LATCH & 0xff, PIT_CH0);
- outb_pit(PIT_LATCH >> 8, PIT_CH0);
+ outb_p(0x34, PIT_MODE);
+ outb_p(PIT_LATCH & 0xff, PIT_CH0);
+ outb_p(PIT_LATCH >> 8, PIT_CH0);
count = PIT_LATCH - 1;
}
@@ -99,3 +100,89 @@ int __init clocksource_i8253_init(void)
return clocksource_register_hz(&i8253_cs, PIT_TICK_RATE);
}
#endif
+
+#ifdef CONFIG_CLKEVT_I8253
+/*
+ * Initialize the PIT timer.
+ *
+ * This is also called after resume to bring the PIT into operation again.
+ */
+static void init_pit_timer(enum clock_event_mode mode,
+ struct clock_event_device *evt)
+{
+ raw_spin_lock(&i8253_lock);
+
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ /* binary, mode 2, LSB/MSB, ch 0 */
+ outb_p(0x34, PIT_MODE);
+ outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
+ outb_p(LATCH >> 8 , PIT_CH0); /* MSB */
+ break;
+
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ case CLOCK_EVT_MODE_UNUSED:
+ if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
+ evt->mode == CLOCK_EVT_MODE_ONESHOT) {
+ outb_p(0x30, PIT_MODE);
+ outb_p(0, PIT_CH0);
+ outb_p(0, PIT_CH0);
+ }
+ break;
+
+ case CLOCK_EVT_MODE_ONESHOT:
+ /* One shot setup */
+ outb_p(0x38, PIT_MODE);
+ break;
+
+ case CLOCK_EVT_MODE_RESUME:
+ /* Nothing to do here */
+ break;
+ }
+ raw_spin_unlock(&i8253_lock);
+}
+
+/*
+ * Program the next event in oneshot mode
+ *
+ * Delta is given in PIT ticks
+ */
+static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
+{
+ raw_spin_lock(&i8253_lock);
+ outb_p(delta & 0xff , PIT_CH0); /* LSB */
+ outb_p(delta >> 8 , PIT_CH0); /* MSB */
+ raw_spin_unlock(&i8253_lock);
+
+ return 0;
+}
+
+/*
+ * On UP the PIT can serve all of the possible timer functions. On SMP systems
+ * it can be solely used for the global tick.
+ */
+struct clock_event_device i8253_clockevent = {
+ .name = "pit",
+ .features = CLOCK_EVT_FEAT_PERIODIC,
+ .set_mode = init_pit_timer,
+ .set_next_event = pit_next_event,
+};
+
+/*
+ * Initialize the conversion factor and the min/max deltas of the clock event
+ * structure and register the clock event source with the framework.
+ */
+void __init clockevent_i8253_init(bool oneshot)
+{
+ if (oneshot)
+ i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
+ /*
+ * Start pit with the boot cpu mask. x86 might make it global
+ * when it is used as broadcast device later.
+ */
+ i8253_clockevent.cpumask = cpumask_of(smp_processor_id());
+
+ clockevents_config_and_register(&i8253_clockevent, PIT_TICK_RATE,
+ 0xF, 0x7FFF);
+}
+#endif
^ permalink raw reply [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] i8253: Create common clockevent implementation
2011-06-09 13:08 ` [patch 1/5] i8253: Create common clockevent implementation Thomas Gleixner
@ 2011-06-24 14:28 ` tip-bot for Thomas Gleixner
2011-06-25 20:03 ` [patch 1/5] " Stijn Devriendt
2011-07-01 8:40 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
2 siblings, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-06-24 14:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 9f9119424bbc4e1c4c8690ea418fa6129dc9fa04
Gitweb: http://git.kernel.org/tip/9f9119424bbc4e1c4c8690ea418fa6129dc9fa04
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:25 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 24 Jun 2011 16:22:54 +0200
i8253: Create common clockevent implementation
arm, mips and x86 implement i8253 based clockevents. All the same code
copied. Create a common implementation in drivers/clocksource/i8253.c.
About time to rename drivers/clocksource/ to something else.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130621.921710458@linutronix.de
---
drivers/clocksource/Kconfig | 5 ++-
drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++++++++++---
2 files changed, 98 insertions(+), 8 deletions(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 330343b..d8d3e02 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -1,11 +1,14 @@
config CLKSRC_I8253
bool
+config CLKEVT_I8253
+ bool
+
config I8253_LOCK
bool
config CLKBLD_I8253
- def_bool y if CLKSRC_I8253 || I8253_LOCK
+ def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK
config CLKSRC_MMIO
bool
diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c
index e594f52..27c49e6 100644
--- a/drivers/clocksource/i8253.c
+++ b/drivers/clocksource/i8253.c
@@ -1,13 +1,14 @@
/*
* i8253 PIT clocksource
*/
-#include <linux/clocksource.h>
+#include <linux/clockchips.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
#include <linux/module.h>
#include <linux/i8253.h>
+#include <linux/smp.h>
/*
* Protects access to I/O ports
@@ -47,15 +48,15 @@ static cycle_t i8253_read(struct clocksource *cs)
* count), it cannot be newer.
*/
jifs = jiffies;
- outb_pit(0x00, PIT_MODE); /* latch the count ASAP */
- count = inb_pit(PIT_CH0); /* read the latched count */
- count |= inb_pit(PIT_CH0) << 8;
+ outb_p(0x00, PIT_MODE); /* latch the count ASAP */
+ count = inb_p(PIT_CH0); /* read the latched count */
+ count |= inb_p(PIT_CH0) << 8;
/* VIA686a test code... reset the latch if count > max + 1 */
if (count > LATCH) {
- outb_pit(0x34, PIT_MODE);
- outb_pit(PIT_LATCH & 0xff, PIT_CH0);
- outb_pit(PIT_LATCH >> 8, PIT_CH0);
+ outb_p(0x34, PIT_MODE);
+ outb_p(PIT_LATCH & 0xff, PIT_CH0);
+ outb_p(PIT_LATCH >> 8, PIT_CH0);
count = PIT_LATCH - 1;
}
@@ -97,3 +98,89 @@ int __init clocksource_i8253_init(void)
return clocksource_register_hz(&i8253_cs, PIT_TICK_RATE);
}
#endif
+
+#ifdef CONFIG_CLKEVT_I8253
+/*
+ * Initialize the PIT timer.
+ *
+ * This is also called after resume to bring the PIT into operation again.
+ */
+static void init_pit_timer(enum clock_event_mode mode,
+ struct clock_event_device *evt)
+{
+ raw_spin_lock(&i8253_lock);
+
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ /* binary, mode 2, LSB/MSB, ch 0 */
+ outb_p(0x34, PIT_MODE);
+ outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
+ outb_p(LATCH >> 8 , PIT_CH0); /* MSB */
+ break;
+
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ case CLOCK_EVT_MODE_UNUSED:
+ if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
+ evt->mode == CLOCK_EVT_MODE_ONESHOT) {
+ outb_p(0x30, PIT_MODE);
+ outb_p(0, PIT_CH0);
+ outb_p(0, PIT_CH0);
+ }
+ break;
+
+ case CLOCK_EVT_MODE_ONESHOT:
+ /* One shot setup */
+ outb_p(0x38, PIT_MODE);
+ break;
+
+ case CLOCK_EVT_MODE_RESUME:
+ /* Nothing to do here */
+ break;
+ }
+ raw_spin_unlock(&i8253_lock);
+}
+
+/*
+ * Program the next event in oneshot mode
+ *
+ * Delta is given in PIT ticks
+ */
+static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
+{
+ raw_spin_lock(&i8253_lock);
+ outb_p(delta & 0xff , PIT_CH0); /* LSB */
+ outb_p(delta >> 8 , PIT_CH0); /* MSB */
+ raw_spin_unlock(&i8253_lock);
+
+ return 0;
+}
+
+/*
+ * On UP the PIT can serve all of the possible timer functions. On SMP systems
+ * it can be solely used for the global tick.
+ */
+struct clock_event_device i8253_clockevent = {
+ .name = "pit",
+ .features = CLOCK_EVT_FEAT_PERIODIC,
+ .set_mode = init_pit_timer,
+ .set_next_event = pit_next_event,
+};
+
+/*
+ * Initialize the conversion factor and the min/max deltas of the clock event
+ * structure and register the clock event source with the framework.
+ */
+void __init clockevent_i8253_init(bool oneshot)
+{
+ if (oneshot)
+ i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
+ /*
+ * Start pit with the boot cpu mask. x86 might make it global
+ * when it is used as broadcast device later.
+ */
+ i8253_clockevent.cpumask = cpumask_of(smp_processor_id());
+
+ clockevents_config_and_register(&i8253_clockevent, PIT_TICK_RATE,
+ 0xF, 0x7FFF);
+}
+#endif
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [patch 1/5] i8253: Create common clockevent implementation
2011-06-09 13:08 ` [patch 1/5] i8253: Create common clockevent implementation Thomas Gleixner
2011-06-24 14:28 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
@ 2011-06-25 20:03 ` Stijn Devriendt
2011-06-30 8:40 ` Masami Hiramatsu
2011-07-01 8:40 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
2 siblings, 1 reply; 20+ messages in thread
From: Stijn Devriendt @ 2011-06-25 20:03 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Russell King, Ralf Baechle, Ingo Molnar, John Stultz
> +/*
> + * Initialize the conversion factor and the min/max deltas of the clock event
> + * structure and register the clock event source with the framework.
> + */
> +void __init clockevent_i8253_init(bool oneshot)
> +{
> + if (oneshot)
> + i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
> + /*
> + * Start pit with the boot cpu mask. x86 might make it global
> + * when it is used as broadcast device later.
> + */
> + i8253_clockevent.cpumask = cpumask_of(smp_processor_id());
> +
> + clockevents_config_and_register(&i8253_clockevent, PIT_TICK_RATE,
> + 0xF, 0x7FFF);
> +}
> +#endif
>
Both this function and the i8253_clockevent declaration seem to be missing
from include/linux/i8253.h causing compile failures for at least x86.
I was just trying to compile tip of
git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git
Should be fixed by applying the following patch.
commit 0c24072a8d580acd5b4fc57009b72b217c0f23d9
Author: Stijn Devriendt <HIGHGuY@gmail.com>
Date: Sat Jun 25 22:04:53 2011 +0200
Fix missing declarations of i8253.
Signed-off-by: Stijn Devriendt <HIGHGuY@gmail.com>
diff --git a/include/linux/i8253.h b/include/linux/i8253.h
index 0770fc5..e6c032f 100644
--- a/include/linux/i8253.h
+++ b/include/linux/i8253.h
@@ -22,6 +22,10 @@
extern raw_spinlock_t i8253_lock;
+extern struct clock_event_device i8253_clockevent;
+
extern void setup_pit_timer(void);
+extern void clockevent_i8253_init(bool oneshot);
+
#endif /* __LINUX_I8253_H */
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [patch 1/5] i8253: Create common clockevent implementation
2011-06-25 20:03 ` [patch 1/5] " Stijn Devriendt
@ 2011-06-30 8:40 ` Masami Hiramatsu
0 siblings, 0 replies; 20+ messages in thread
From: Masami Hiramatsu @ 2011-06-30 8:40 UTC (permalink / raw)
To: Stijn Devriendt, Thomas Gleixner, Ingo Molnar
Cc: LKML, Russell King, Ralf Baechle, John Stultz, yrl.pp-manager.tt
(2011/06/26 5:03), Stijn Devriendt wrote:
>> +/*
>> + * Initialize the conversion factor and the min/max deltas of the clock event
>> + * structure and register the clock event source with the framework.
>> + */
>> +void __init clockevent_i8253_init(bool oneshot)
>> +{
>> + if (oneshot)
>> + i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
>> + /*
>> + * Start pit with the boot cpu mask. x86 might make it global
>> + * when it is used as broadcast device later.
>> + */
>> + i8253_clockevent.cpumask = cpumask_of(smp_processor_id());
>> +
>> + clockevents_config_and_register(&i8253_clockevent, PIT_TICK_RATE,
>> + 0xF, 0x7FFF);
>> +}
>> +#endif
>>
> Both this function and the i8253_clockevent declaration seem to be missing
> from include/linux/i8253.h causing compile failures for at least x86.
>
> I was just trying to compile tip of
> git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git
I've met same problem on latest tip tree.
> Should be fixed by applying the following patch.
We still need to expose clocksource_i8253_init() too
for CONFIG_X86_64=n.
So, could you update your patch (and send it as a patch mail)?
Thank you,
>
> commit 0c24072a8d580acd5b4fc57009b72b217c0f23d9
> Author: Stijn Devriendt <HIGHGuY@gmail.com>
> Date: Sat Jun 25 22:04:53 2011 +0200
>
> Fix missing declarations of i8253.
>
> Signed-off-by: Stijn Devriendt <HIGHGuY@gmail.com>
>
> diff --git a/include/linux/i8253.h b/include/linux/i8253.h
> index 0770fc5..e6c032f 100644
> --- a/include/linux/i8253.h
> +++ b/include/linux/i8253.h
> @@ -22,6 +22,10 @@
>
> extern raw_spinlock_t i8253_lock;
>
> +extern struct clock_event_device i8253_clockevent;
> +
> extern void setup_pit_timer(void);
>
> +extern void clockevent_i8253_init(bool oneshot);
> +
> #endif /* __LINUX_I8253_H */
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] i8253: Create common clockevent implementation
2011-06-09 13:08 ` [patch 1/5] i8253: Create common clockevent implementation Thomas Gleixner
2011-06-24 14:28 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
2011-06-25 20:03 ` [patch 1/5] " Stijn Devriendt
@ 2011-07-01 8:40 ` tip-bot for Thomas Gleixner
2 siblings, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-07-01 8:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: e6220bdc9485c5ea972f9e0e6d062a05934bb74b
Gitweb: http://git.kernel.org/tip/e6220bdc9485c5ea972f9e0e6d062a05934bb74b
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:25 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
i8253: Create common clockevent implementation
arm, mips and x86 implement i8253 based clockevents. All the same code
copied. Create a common implementation in drivers/clocksource/i8253.c.
About time to rename drivers/clocksource/ to something else.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130621.921710458@linutronix.de
---
drivers/clocksource/Kconfig | 5 ++-
drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++++++++++---
include/linux/i8253.h | 2 +
3 files changed, 100 insertions(+), 8 deletions(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 330343b..d8d3e02 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -1,11 +1,14 @@
config CLKSRC_I8253
bool
+config CLKEVT_I8253
+ bool
+
config I8253_LOCK
bool
config CLKBLD_I8253
- def_bool y if CLKSRC_I8253 || I8253_LOCK
+ def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK
config CLKSRC_MMIO
bool
diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c
index e594f52..27c49e6 100644
--- a/drivers/clocksource/i8253.c
+++ b/drivers/clocksource/i8253.c
@@ -1,13 +1,14 @@
/*
* i8253 PIT clocksource
*/
-#include <linux/clocksource.h>
+#include <linux/clockchips.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
#include <linux/module.h>
#include <linux/i8253.h>
+#include <linux/smp.h>
/*
* Protects access to I/O ports
@@ -47,15 +48,15 @@ static cycle_t i8253_read(struct clocksource *cs)
* count), it cannot be newer.
*/
jifs = jiffies;
- outb_pit(0x00, PIT_MODE); /* latch the count ASAP */
- count = inb_pit(PIT_CH0); /* read the latched count */
- count |= inb_pit(PIT_CH0) << 8;
+ outb_p(0x00, PIT_MODE); /* latch the count ASAP */
+ count = inb_p(PIT_CH0); /* read the latched count */
+ count |= inb_p(PIT_CH0) << 8;
/* VIA686a test code... reset the latch if count > max + 1 */
if (count > LATCH) {
- outb_pit(0x34, PIT_MODE);
- outb_pit(PIT_LATCH & 0xff, PIT_CH0);
- outb_pit(PIT_LATCH >> 8, PIT_CH0);
+ outb_p(0x34, PIT_MODE);
+ outb_p(PIT_LATCH & 0xff, PIT_CH0);
+ outb_p(PIT_LATCH >> 8, PIT_CH0);
count = PIT_LATCH - 1;
}
@@ -97,3 +98,89 @@ int __init clocksource_i8253_init(void)
return clocksource_register_hz(&i8253_cs, PIT_TICK_RATE);
}
#endif
+
+#ifdef CONFIG_CLKEVT_I8253
+/*
+ * Initialize the PIT timer.
+ *
+ * This is also called after resume to bring the PIT into operation again.
+ */
+static void init_pit_timer(enum clock_event_mode mode,
+ struct clock_event_device *evt)
+{
+ raw_spin_lock(&i8253_lock);
+
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ /* binary, mode 2, LSB/MSB, ch 0 */
+ outb_p(0x34, PIT_MODE);
+ outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
+ outb_p(LATCH >> 8 , PIT_CH0); /* MSB */
+ break;
+
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ case CLOCK_EVT_MODE_UNUSED:
+ if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
+ evt->mode == CLOCK_EVT_MODE_ONESHOT) {
+ outb_p(0x30, PIT_MODE);
+ outb_p(0, PIT_CH0);
+ outb_p(0, PIT_CH0);
+ }
+ break;
+
+ case CLOCK_EVT_MODE_ONESHOT:
+ /* One shot setup */
+ outb_p(0x38, PIT_MODE);
+ break;
+
+ case CLOCK_EVT_MODE_RESUME:
+ /* Nothing to do here */
+ break;
+ }
+ raw_spin_unlock(&i8253_lock);
+}
+
+/*
+ * Program the next event in oneshot mode
+ *
+ * Delta is given in PIT ticks
+ */
+static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
+{
+ raw_spin_lock(&i8253_lock);
+ outb_p(delta & 0xff , PIT_CH0); /* LSB */
+ outb_p(delta >> 8 , PIT_CH0); /* MSB */
+ raw_spin_unlock(&i8253_lock);
+
+ return 0;
+}
+
+/*
+ * On UP the PIT can serve all of the possible timer functions. On SMP systems
+ * it can be solely used for the global tick.
+ */
+struct clock_event_device i8253_clockevent = {
+ .name = "pit",
+ .features = CLOCK_EVT_FEAT_PERIODIC,
+ .set_mode = init_pit_timer,
+ .set_next_event = pit_next_event,
+};
+
+/*
+ * Initialize the conversion factor and the min/max deltas of the clock event
+ * structure and register the clock event source with the framework.
+ */
+void __init clockevent_i8253_init(bool oneshot)
+{
+ if (oneshot)
+ i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
+ /*
+ * Start pit with the boot cpu mask. x86 might make it global
+ * when it is used as broadcast device later.
+ */
+ i8253_clockevent.cpumask = cpumask_of(smp_processor_id());
+
+ clockevents_config_and_register(&i8253_clockevent, PIT_TICK_RATE,
+ 0xF, 0x7FFF);
+}
+#endif
diff --git a/include/linux/i8253.h b/include/linux/i8253.h
index 76039c8..487d50c 100644
--- a/include/linux/i8253.h
+++ b/include/linux/i8253.h
@@ -24,6 +24,8 @@
#define outb_pit outb_p
extern raw_spinlock_t i8253_lock;
+extern struct clock_event_device i8253_clockevent;
+extern void clockevent_i8253_init(bool oneshot);
extern void setup_pit_timer(void);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [patch 2/5] x86: Use common i8253 clockevent
2011-06-09 13:08 [patch 0/5] i8253: common clockevent Thomas Gleixner
2011-06-09 13:08 ` [patch 1/5] i8253: Create common clockevent implementation Thomas Gleixner
@ 2011-06-09 13:08 ` Thomas Gleixner
2011-06-24 14:30 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
2011-07-01 8:40 ` tip-bot for Thomas Gleixner
2011-06-09 13:08 ` [patch 3/5] mips: " Thomas Gleixner
` (2 subsequent siblings)
4 siblings, 2 replies; 20+ messages in thread
From: Thomas Gleixner @ 2011-06-09 13:08 UTC (permalink / raw)
To: LKML; +Cc: Russell King, Ralf Baechle, Ingo Molnar, John Stultz
[-- Attachment #1: x86-use-common-i8253-ce.patch --]
[-- Type: text/plain, Size: 4022 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/Kconfig | 2 -
arch/x86/kernel/i8253.c | 93 +-----------------------------------------------
2 files changed, 4 insertions(+), 91 deletions(-)
Index: linux-2.6-tip/arch/x86/Kconfig
===================================================================
--- linux-2.6-tip.orig/arch/x86/Kconfig
+++ linux-2.6-tip/arch/x86/Kconfig
@@ -71,7 +71,7 @@ config X86
select IRQ_FORCED_THREADING
select USE_GENERIC_SMP_HELPERS if SMP
select HAVE_BPF_JIT if (X86_64 && NET)
- select I8253_LOCK
+ select CLKEVT_I8253
config INSTRUCTION_DECODER
def_bool (KPROBES || PERF_EVENTS)
Index: linux-2.6-tip/arch/x86/kernel/i8253.c
===================================================================
--- linux-2.6-tip.orig/arch/x86/kernel/i8253.c
+++ linux-2.6-tip/arch/x86/kernel/i8253.c
@@ -3,15 +3,9 @@
*
*/
#include <linux/clockchips.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/timex.h>
-#include <linux/delay.h>
#include <linux/i8253.h>
-#include <linux/init.h>
-#include <linux/io.h>
#include <asm/hpet.h>
#include <asm/time.h>
@@ -23,91 +17,10 @@
*/
struct clock_event_device *global_clock_event;
-/*
- * Initialize the PIT timer.
- *
- * This is also called after resume to bring the PIT into operation again.
- */
-static void init_pit_timer(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- /* binary, mode 2, LSB/MSB, ch 0 */
- outb_pit(0x34, PIT_MODE);
- outb_pit(LATCH & 0xff , PIT_CH0); /* LSB */
- outb_pit(LATCH >> 8 , PIT_CH0); /* MSB */
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
- evt->mode == CLOCK_EVT_MODE_ONESHOT) {
- outb_pit(0x30, PIT_MODE);
- outb_pit(0, PIT_CH0);
- outb_pit(0, PIT_CH0);
- }
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- /* One shot setup */
- outb_pit(0x38, PIT_MODE);
- break;
-
- case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
- break;
- }
- raw_spin_unlock(&i8253_lock);
-}
-
-/*
- * Program the next event in oneshot mode
- *
- * Delta is given in PIT ticks
- */
-static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
- outb_pit(delta & 0xff , PIT_CH0); /* LSB */
- outb_pit(delta >> 8 , PIT_CH0); /* MSB */
- raw_spin_unlock(&i8253_lock);
-
- return 0;
-}
-
-/*
- * On UP the PIT can serve all of the possible timer functions. On SMP systems
- * it can be solely used for the global tick.
- *
- * The profiling and update capabilities are switched off once the local apic is
- * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
- * !using_apic_timer decisions in do_timer_interrupt_hook()
- */
-static struct clock_event_device pit_ce = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
- .set_mode = init_pit_timer,
- .set_next_event = pit_next_event,
- .irq = 0,
-};
-
-/*
- * Initialize the conversion factor and the min/max deltas of the clock event
- * structure and register the clock event source with the framework.
- */
void __init setup_pit_timer(void)
{
- /*
- * Start pit with the boot cpu mask and make it global after the
- * IO_APIC has been initialized.
- */
- pit_ce.cpumask = cpumask_of(smp_processor_id());
-
- clockevents_config_and_register(&pit_ce, CLOCK_TICK_RATE, 0xF, 0x7FFF);
- global_clock_event = &pit_ce;
+ clockevent_i8253_init(true);
+ global_clock_event = &i8253_clockevent;
}
#ifndef CONFIG_X86_64
@@ -121,7 +34,7 @@ static int __init init_pit_clocksource(v
* - when local APIC timer is active (PIT is switched off)
*/
if (num_possible_cpus() > 1 || is_hpet_enabled() ||
- pit_ce.mode != CLOCK_EVT_MODE_PERIODIC)
+ i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC)
return 0;
return clocksource_i8253_init();
^ permalink raw reply [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] x86: Use common i8253 clockevent
2011-06-09 13:08 ` [patch 2/5] x86: Use common i8253 clockevent Thomas Gleixner
@ 2011-06-24 14:30 ` tip-bot for Thomas Gleixner
2011-07-01 8:40 ` tip-bot for Thomas Gleixner
1 sibling, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-06-24 14:30 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 2739ce151665a72acdc19ed9dc6b9f6a235b7c30
Gitweb: http://git.kernel.org/tip/2739ce151665a72acdc19ed9dc6b9f6a235b7c30
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:26 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 24 Jun 2011 16:22:54 +0200
x86: Use common i8253 clockevent
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.026152527@linutronix.de
---
arch/x86/Kconfig | 2 +-
arch/x86/kernel/i8253.c | 93 ++---------------------------------------------
2 files changed, 4 insertions(+), 91 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 2dd95b5..26a14b4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -71,7 +71,7 @@ config X86
select IRQ_FORCED_THREADING
select USE_GENERIC_SMP_HELPERS if SMP
select HAVE_BPF_JIT if (X86_64 && NET)
- select I8253_LOCK
+ select CLKEVT_I8253
config INSTRUCTION_DECODER
def_bool (KPROBES || PERF_EVENTS)
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
index 5783e6d..f2b96de 100644
--- a/arch/x86/kernel/i8253.c
+++ b/arch/x86/kernel/i8253.c
@@ -3,15 +3,9 @@
*
*/
#include <linux/clockchips.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/timex.h>
-#include <linux/delay.h>
#include <linux/i8253.h>
-#include <linux/init.h>
-#include <linux/io.h>
#include <asm/hpet.h>
#include <asm/time.h>
@@ -23,91 +17,10 @@
*/
struct clock_event_device *global_clock_event;
-/*
- * Initialize the PIT timer.
- *
- * This is also called after resume to bring the PIT into operation again.
- */
-static void init_pit_timer(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- /* binary, mode 2, LSB/MSB, ch 0 */
- outb_pit(0x34, PIT_MODE);
- outb_pit(LATCH & 0xff , PIT_CH0); /* LSB */
- outb_pit(LATCH >> 8 , PIT_CH0); /* MSB */
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
- evt->mode == CLOCK_EVT_MODE_ONESHOT) {
- outb_pit(0x30, PIT_MODE);
- outb_pit(0, PIT_CH0);
- outb_pit(0, PIT_CH0);
- }
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- /* One shot setup */
- outb_pit(0x38, PIT_MODE);
- break;
-
- case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
- break;
- }
- raw_spin_unlock(&i8253_lock);
-}
-
-/*
- * Program the next event in oneshot mode
- *
- * Delta is given in PIT ticks
- */
-static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
- outb_pit(delta & 0xff , PIT_CH0); /* LSB */
- outb_pit(delta >> 8 , PIT_CH0); /* MSB */
- raw_spin_unlock(&i8253_lock);
-
- return 0;
-}
-
-/*
- * On UP the PIT can serve all of the possible timer functions. On SMP systems
- * it can be solely used for the global tick.
- *
- * The profiling and update capabilities are switched off once the local apic is
- * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
- * !using_apic_timer decisions in do_timer_interrupt_hook()
- */
-static struct clock_event_device pit_ce = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
- .set_mode = init_pit_timer,
- .set_next_event = pit_next_event,
- .irq = 0,
-};
-
-/*
- * Initialize the conversion factor and the min/max deltas of the clock event
- * structure and register the clock event source with the framework.
- */
void __init setup_pit_timer(void)
{
- /*
- * Start pit with the boot cpu mask and make it global after the
- * IO_APIC has been initialized.
- */
- pit_ce.cpumask = cpumask_of(smp_processor_id());
-
- clockevents_config_and_register(&pit_ce, CLOCK_TICK_RATE, 0xF, 0x7FFF);
- global_clock_event = &pit_ce;
+ clockevent_i8253_init(true);
+ global_clock_event = &i8253_clockevent;
}
#ifndef CONFIG_X86_64
@@ -121,7 +34,7 @@ static int __init init_pit_clocksource(void)
* - when local APIC timer is active (PIT is switched off)
*/
if (num_possible_cpus() > 1 || is_hpet_enabled() ||
- pit_ce.mode != CLOCK_EVT_MODE_PERIODIC)
+ i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC)
return 0;
return clocksource_i8253_init();
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] x86: Use common i8253 clockevent
2011-06-09 13:08 ` [patch 2/5] x86: Use common i8253 clockevent Thomas Gleixner
2011-06-24 14:30 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
@ 2011-07-01 8:40 ` tip-bot for Thomas Gleixner
1 sibling, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-07-01 8:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 0a779c571314b7951ff12edac80aa0cbe7c12b6e
Gitweb: http://git.kernel.org/tip/0a779c571314b7951ff12edac80aa0cbe7c12b6e
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:26 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
x86: Use common i8253 clockevent
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.026152527@linutronix.de
---
arch/x86/Kconfig | 2 +-
arch/x86/kernel/i8253.c | 93 ++---------------------------------------------
2 files changed, 4 insertions(+), 91 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 2dd95b5..26a14b4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -71,7 +71,7 @@ config X86
select IRQ_FORCED_THREADING
select USE_GENERIC_SMP_HELPERS if SMP
select HAVE_BPF_JIT if (X86_64 && NET)
- select I8253_LOCK
+ select CLKEVT_I8253
config INSTRUCTION_DECODER
def_bool (KPROBES || PERF_EVENTS)
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
index 5783e6d..f2b96de 100644
--- a/arch/x86/kernel/i8253.c
+++ b/arch/x86/kernel/i8253.c
@@ -3,15 +3,9 @@
*
*/
#include <linux/clockchips.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/timex.h>
-#include <linux/delay.h>
#include <linux/i8253.h>
-#include <linux/init.h>
-#include <linux/io.h>
#include <asm/hpet.h>
#include <asm/time.h>
@@ -23,91 +17,10 @@
*/
struct clock_event_device *global_clock_event;
-/*
- * Initialize the PIT timer.
- *
- * This is also called after resume to bring the PIT into operation again.
- */
-static void init_pit_timer(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- /* binary, mode 2, LSB/MSB, ch 0 */
- outb_pit(0x34, PIT_MODE);
- outb_pit(LATCH & 0xff , PIT_CH0); /* LSB */
- outb_pit(LATCH >> 8 , PIT_CH0); /* MSB */
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
- evt->mode == CLOCK_EVT_MODE_ONESHOT) {
- outb_pit(0x30, PIT_MODE);
- outb_pit(0, PIT_CH0);
- outb_pit(0, PIT_CH0);
- }
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- /* One shot setup */
- outb_pit(0x38, PIT_MODE);
- break;
-
- case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
- break;
- }
- raw_spin_unlock(&i8253_lock);
-}
-
-/*
- * Program the next event in oneshot mode
- *
- * Delta is given in PIT ticks
- */
-static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
- outb_pit(delta & 0xff , PIT_CH0); /* LSB */
- outb_pit(delta >> 8 , PIT_CH0); /* MSB */
- raw_spin_unlock(&i8253_lock);
-
- return 0;
-}
-
-/*
- * On UP the PIT can serve all of the possible timer functions. On SMP systems
- * it can be solely used for the global tick.
- *
- * The profiling and update capabilities are switched off once the local apic is
- * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
- * !using_apic_timer decisions in do_timer_interrupt_hook()
- */
-static struct clock_event_device pit_ce = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
- .set_mode = init_pit_timer,
- .set_next_event = pit_next_event,
- .irq = 0,
-};
-
-/*
- * Initialize the conversion factor and the min/max deltas of the clock event
- * structure and register the clock event source with the framework.
- */
void __init setup_pit_timer(void)
{
- /*
- * Start pit with the boot cpu mask and make it global after the
- * IO_APIC has been initialized.
- */
- pit_ce.cpumask = cpumask_of(smp_processor_id());
-
- clockevents_config_and_register(&pit_ce, CLOCK_TICK_RATE, 0xF, 0x7FFF);
- global_clock_event = &pit_ce;
+ clockevent_i8253_init(true);
+ global_clock_event = &i8253_clockevent;
}
#ifndef CONFIG_X86_64
@@ -121,7 +34,7 @@ static int __init init_pit_clocksource(void)
* - when local APIC timer is active (PIT is switched off)
*/
if (num_possible_cpus() > 1 || is_hpet_enabled() ||
- pit_ce.mode != CLOCK_EVT_MODE_PERIODIC)
+ i8253_clockevent.mode != CLOCK_EVT_MODE_PERIODIC)
return 0;
return clocksource_i8253_init();
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [patch 3/5] mips: Use common i8253 clockevent
2011-06-09 13:08 [patch 0/5] i8253: common clockevent Thomas Gleixner
2011-06-09 13:08 ` [patch 1/5] i8253: Create common clockevent implementation Thomas Gleixner
2011-06-09 13:08 ` [patch 2/5] x86: Use common i8253 clockevent Thomas Gleixner
@ 2011-06-09 13:08 ` Thomas Gleixner
2011-06-24 14:31 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
2011-07-01 8:40 ` tip-bot for Thomas Gleixner
2011-06-09 13:08 ` [patch 4/5] arm: footbridge: " Thomas Gleixner
2011-06-09 13:08 ` [patch 5/5] i8253: Cleanup outb/inb magic Thomas Gleixner
4 siblings, 2 replies; 20+ messages in thread
From: Thomas Gleixner @ 2011-06-09 13:08 UTC (permalink / raw)
To: LKML; +Cc: Russell King, Ralf Baechle, Ingo Molnar, John Stultz
[-- Attachment #1: mips-use-common-i8253-ce.patch --]
[-- Type: text/plain, Size: 3913 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
arch/mips/Kconfig | 1
arch/mips/kernel/i8253.c | 97 -----------------------------------------------
2 files changed, 3 insertions(+), 95 deletions(-)
Index: linux-2.6-tip/arch/mips/Kconfig
===================================================================
--- linux-2.6-tip.orig/arch/mips/Kconfig
+++ linux-2.6-tip/arch/mips/Kconfig
@@ -2391,6 +2391,7 @@ config MMU
config I8253
bool
select CLKSRC_I8253
+ select CLKEVT_I8253
select MIPS_EXTERNAL_TIMER
config ZONE_DMA32
Index: linux-2.6-tip/arch/mips/kernel/i8253.c
===================================================================
--- linux-2.6-tip.orig/arch/mips/kernel/i8253.c
+++ linux-2.6-tip/arch/mips/kernel/i8253.c
@@ -4,92 +4,15 @@
*/
#include <linux/clockchips.h>
#include <linux/i8253.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/smp.h>
-#include <linux/spinlock.h>
#include <linux/irq.h>
-#include <asm/delay.h>
-#include <asm/io.h>
#include <asm/time.h>
-/*
- * Initialize the PIT timer.
- *
- * This is also called after resume to bring the PIT into operation again.
- */
-static void init_pit_timer(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
-
- switch(mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- /* binary, mode 2, LSB/MSB, ch 0 */
- outb_p(0x34, PIT_MODE);
- outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
- outb(LATCH >> 8 , PIT_CH0); /* MSB */
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
- evt->mode == CLOCK_EVT_MODE_ONESHOT) {
- outb_p(0x30, PIT_MODE);
- outb_p(0, PIT_CH0);
- outb_p(0, PIT_CH0);
- }
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- /* One shot setup */
- outb_p(0x38, PIT_MODE);
- break;
-
- case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
- break;
- }
- raw_spin_unlock(&i8253_lock);
-}
-
-/*
- * Program the next event in oneshot mode
- *
- * Delta is given in PIT ticks
- */
-static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
- outb_p(delta & 0xff , PIT_CH0); /* LSB */
- outb(delta >> 8 , PIT_CH0); /* MSB */
- raw_spin_unlock(&i8253_lock);
-
- return 0;
-}
-
-/*
- * On UP the PIT can serve all of the possible timer functions. On SMP systems
- * it can be solely used for the global tick.
- *
- * The profiling and update capabilites are switched off once the local apic is
- * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
- * !using_apic_timer decisions in do_timer_interrupt_hook()
- */
-static struct clock_event_device pit_clockevent = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
- .set_mode = init_pit_timer,
- .set_next_event = pit_next_event,
- .irq = 0,
-};
-
static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
- pit_clockevent.event_handler(&pit_clockevent);
+ i8253_clockevent.event_handler(&pit_clockevent);
return IRQ_HANDLED;
}
@@ -100,25 +23,9 @@ static struct irqaction irq0 = {
.name = "timer"
};
-/*
- * Initialize the conversion factor and the min/max deltas of the clock event
- * structure and register the clock event source with the framework.
- */
void __init setup_pit_timer(void)
{
- struct clock_event_device *cd = &pit_clockevent;
- unsigned int cpu = smp_processor_id();
-
- /*
- * Start pit with the boot cpu mask and make it global after the
- * IO_APIC has been initialized.
- */
- cd->cpumask = cpumask_of(cpu);
- clockevent_set_clock(cd, CLOCK_TICK_RATE);
- cd->max_delta_ns = clockevent_delta2ns(0x7FFF, cd);
- cd->min_delta_ns = clockevent_delta2ns(0xF, cd);
- clockevents_register_device(cd);
-
+ clockevent_i8253_init(true);
setup_irq(0, &irq0);
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] mips: Use common i8253 clockevent
2011-06-09 13:08 ` [patch 3/5] mips: " Thomas Gleixner
@ 2011-06-24 14:31 ` tip-bot for Thomas Gleixner
2011-07-01 8:40 ` tip-bot for Thomas Gleixner
1 sibling, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-06-24 14:31 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 594fa4ac22954c9cb8d65040c5c3676778b08e1d
Gitweb: http://git.kernel.org/tip/594fa4ac22954c9cb8d65040c5c3676778b08e1d
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:27 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 24 Jun 2011 16:22:55 +0200
mips: Use common i8253 clockevent
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.133068765@linutronix.de
---
arch/mips/Kconfig | 1 +
arch/mips/kernel/i8253.c | 97 +---------------------------------------------
2 files changed, 3 insertions(+), 95 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 45f7aac..6cb60ad 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2391,6 +2391,7 @@ config MMU
config I8253
bool
select CLKSRC_I8253
+ select CLKEVT_I8253
select MIPS_EXTERNAL_TIMER
config ZONE_DMA32
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 3d2ff57..8d95fe4f 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -4,92 +4,15 @@
*/
#include <linux/clockchips.h>
#include <linux/i8253.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/smp.h>
-#include <linux/spinlock.h>
#include <linux/irq.h>
-#include <asm/delay.h>
-#include <asm/io.h>
#include <asm/time.h>
-/*
- * Initialize the PIT timer.
- *
- * This is also called after resume to bring the PIT into operation again.
- */
-static void init_pit_timer(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
-
- switch(mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- /* binary, mode 2, LSB/MSB, ch 0 */
- outb_p(0x34, PIT_MODE);
- outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
- outb(LATCH >> 8 , PIT_CH0); /* MSB */
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
- evt->mode == CLOCK_EVT_MODE_ONESHOT) {
- outb_p(0x30, PIT_MODE);
- outb_p(0, PIT_CH0);
- outb_p(0, PIT_CH0);
- }
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- /* One shot setup */
- outb_p(0x38, PIT_MODE);
- break;
-
- case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
- break;
- }
- raw_spin_unlock(&i8253_lock);
-}
-
-/*
- * Program the next event in oneshot mode
- *
- * Delta is given in PIT ticks
- */
-static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
- outb_p(delta & 0xff , PIT_CH0); /* LSB */
- outb(delta >> 8 , PIT_CH0); /* MSB */
- raw_spin_unlock(&i8253_lock);
-
- return 0;
-}
-
-/*
- * On UP the PIT can serve all of the possible timer functions. On SMP systems
- * it can be solely used for the global tick.
- *
- * The profiling and update capabilites are switched off once the local apic is
- * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
- * !using_apic_timer decisions in do_timer_interrupt_hook()
- */
-static struct clock_event_device pit_clockevent = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
- .set_mode = init_pit_timer,
- .set_next_event = pit_next_event,
- .irq = 0,
-};
-
static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
- pit_clockevent.event_handler(&pit_clockevent);
+ i8253_clockevent.event_handler(&pit_clockevent);
return IRQ_HANDLED;
}
@@ -100,25 +23,9 @@ static struct irqaction irq0 = {
.name = "timer"
};
-/*
- * Initialize the conversion factor and the min/max deltas of the clock event
- * structure and register the clock event source with the framework.
- */
void __init setup_pit_timer(void)
{
- struct clock_event_device *cd = &pit_clockevent;
- unsigned int cpu = smp_processor_id();
-
- /*
- * Start pit with the boot cpu mask and make it global after the
- * IO_APIC has been initialized.
- */
- cd->cpumask = cpumask_of(cpu);
- clockevent_set_clock(cd, CLOCK_TICK_RATE);
- cd->max_delta_ns = clockevent_delta2ns(0x7FFF, cd);
- cd->min_delta_ns = clockevent_delta2ns(0xF, cd);
- clockevents_register_device(cd);
-
+ clockevent_i8253_init(true);
setup_irq(0, &irq0);
}
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] mips: Use common i8253 clockevent
2011-06-09 13:08 ` [patch 3/5] mips: " Thomas Gleixner
2011-06-24 14:31 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
@ 2011-07-01 8:40 ` tip-bot for Thomas Gleixner
1 sibling, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-07-01 8:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 2d02612f61cc15b2025c90e32ed4a43eaa6753cd
Gitweb: http://git.kernel.org/tip/2d02612f61cc15b2025c90e32ed4a43eaa6753cd
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:27 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
mips: Use common i8253 clockevent
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.133068765@linutronix.de
---
arch/mips/Kconfig | 1 +
arch/mips/kernel/i8253.c | 97 +---------------------------------------------
2 files changed, 3 insertions(+), 95 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 45f7aac..6cb60ad 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2391,6 +2391,7 @@ config MMU
config I8253
bool
select CLKSRC_I8253
+ select CLKEVT_I8253
select MIPS_EXTERNAL_TIMER
config ZONE_DMA32
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 3d2ff57..8d95fe4f 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -4,92 +4,15 @@
*/
#include <linux/clockchips.h>
#include <linux/i8253.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/smp.h>
-#include <linux/spinlock.h>
#include <linux/irq.h>
-#include <asm/delay.h>
-#include <asm/io.h>
#include <asm/time.h>
-/*
- * Initialize the PIT timer.
- *
- * This is also called after resume to bring the PIT into operation again.
- */
-static void init_pit_timer(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
-
- switch(mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- /* binary, mode 2, LSB/MSB, ch 0 */
- outb_p(0x34, PIT_MODE);
- outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
- outb(LATCH >> 8 , PIT_CH0); /* MSB */
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
- evt->mode == CLOCK_EVT_MODE_ONESHOT) {
- outb_p(0x30, PIT_MODE);
- outb_p(0, PIT_CH0);
- outb_p(0, PIT_CH0);
- }
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- /* One shot setup */
- outb_p(0x38, PIT_MODE);
- break;
-
- case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
- break;
- }
- raw_spin_unlock(&i8253_lock);
-}
-
-/*
- * Program the next event in oneshot mode
- *
- * Delta is given in PIT ticks
- */
-static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
-{
- raw_spin_lock(&i8253_lock);
- outb_p(delta & 0xff , PIT_CH0); /* LSB */
- outb(delta >> 8 , PIT_CH0); /* MSB */
- raw_spin_unlock(&i8253_lock);
-
- return 0;
-}
-
-/*
- * On UP the PIT can serve all of the possible timer functions. On SMP systems
- * it can be solely used for the global tick.
- *
- * The profiling and update capabilites are switched off once the local apic is
- * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
- * !using_apic_timer decisions in do_timer_interrupt_hook()
- */
-static struct clock_event_device pit_clockevent = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
- .set_mode = init_pit_timer,
- .set_next_event = pit_next_event,
- .irq = 0,
-};
-
static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
- pit_clockevent.event_handler(&pit_clockevent);
+ i8253_clockevent.event_handler(&pit_clockevent);
return IRQ_HANDLED;
}
@@ -100,25 +23,9 @@ static struct irqaction irq0 = {
.name = "timer"
};
-/*
- * Initialize the conversion factor and the min/max deltas of the clock event
- * structure and register the clock event source with the framework.
- */
void __init setup_pit_timer(void)
{
- struct clock_event_device *cd = &pit_clockevent;
- unsigned int cpu = smp_processor_id();
-
- /*
- * Start pit with the boot cpu mask and make it global after the
- * IO_APIC has been initialized.
- */
- cd->cpumask = cpumask_of(cpu);
- clockevent_set_clock(cd, CLOCK_TICK_RATE);
- cd->max_delta_ns = clockevent_delta2ns(0x7FFF, cd);
- cd->min_delta_ns = clockevent_delta2ns(0xF, cd);
- clockevents_register_device(cd);
-
+ clockevent_i8253_init(true);
setup_irq(0, &irq0);
}
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [patch 4/5] arm: footbridge: Use common i8253 clockevent
2011-06-09 13:08 [patch 0/5] i8253: common clockevent Thomas Gleixner
` (2 preceding siblings ...)
2011-06-09 13:08 ` [patch 3/5] mips: " Thomas Gleixner
@ 2011-06-09 13:08 ` Thomas Gleixner
2011-06-24 14:33 ` [tip:timers/cleanup] arm: Footbridge: " tip-bot for Thomas Gleixner
2011-07-01 8:41 ` tip-bot for Thomas Gleixner
2011-06-09 13:08 ` [patch 5/5] i8253: Cleanup outb/inb magic Thomas Gleixner
4 siblings, 2 replies; 20+ messages in thread
From: Thomas Gleixner @ 2011-06-09 13:08 UTC (permalink / raw)
To: LKML; +Cc: Russell King, Ralf Baechle, Ingo Molnar, John Stultz
[-- Attachment #1: arm-use-common-i8253-ce.patch --]
[-- Type: text/plain, Size: 2786 bytes --]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
---
| 1
| 51 -----------------------------------
2 files changed, 2 insertions(+), 50 deletions(-)
Index: linux-2.6-tip/arch/arm/mach-footbridge/Kconfig
===================================================================
--- linux-2.6-tip.orig/arch/arm/mach-footbridge/Kconfig
+++ linux-2.6-tip/arch/arm/mach-footbridge/Kconfig
@@ -5,6 +5,7 @@ menu "Footbridge Implementations"
config ARCH_CATS
bool "CATS"
select CLKSRC_I8253
+ select CLKEVT_I8253
select FOOTBRIDGE_HOST
select ISA
select ISA_DMA
Index: linux-2.6-tip/arch/arm/mach-footbridge/isa-timer.c
===================================================================
--- linux-2.6-tip.orig/arch/arm/mach-footbridge/isa-timer.c
+++ linux-2.6-tip/arch/arm/mach-footbridge/isa-timer.c
@@ -5,12 +5,10 @@
* Copyright (C) 1998 Phil Blundell
*/
#include <linux/clockchips.h>
-#include <linux/clocksource.h>
#include <linux/i8253.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
-#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
@@ -19,48 +17,6 @@
#include "common.h"
-static void pit_set_mode(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- unsigned long flags;
-
- raw_local_irq_save(flags);
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- outb_p(0x34, PIT_MODE);
- outb_p(PIT_LATCH & 0xff, PIT_CH0);
- outb_p(PIT_LATCH >> 8, PIT_CH0);
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- outb_p(0x30, PIT_MODE);
- outb_p(0, PIT_CH0);
- outb_p(0, PIT_CH0);
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- case CLOCK_EVT_MODE_RESUME:
- break;
- }
- local_irq_restore(flags);
-}
-
-static int pit_set_next_event(unsigned long delta,
- struct clock_event_device *evt)
-{
- return 0;
-}
-
-static struct clock_event_device pit_ce = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC,
- .set_mode = pit_set_mode,
- .set_next_event = pit_set_next_event,
- .shift = 32,
-};
-
static irqreturn_t pit_timer_interrupt(int irq, void *dev_id)
{
struct clock_event_device *ce = dev_id;
@@ -77,15 +33,10 @@ static struct irqaction pit_timer_irq =
static void __init isa_timer_init(void)
{
- pit_ce.cpumask = cpumask_of(smp_processor_id());
- pit_ce.mult = div_sc(PIT_TICK_RATE, NSEC_PER_SEC, pit_ce.shift);
- pit_ce.max_delta_ns = clockevent_delta2ns(0x7fff, &pit_ce);
- pit_ce.min_delta_ns = clockevent_delta2ns(0x000f, &pit_ce);
-
clocksource_i8253_init();
setup_irq(pit_ce.irq, &pit_timer_irq);
- clockevents_register_device(&pit_ce);
+ clockevents_i8253_init(false);
}
struct sys_timer isa_timer = {
^ permalink raw reply [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] arm: Footbridge: Use common i8253 clockevent
2011-06-09 13:08 ` [patch 4/5] arm: footbridge: " Thomas Gleixner
@ 2011-06-24 14:33 ` tip-bot for Thomas Gleixner
2011-07-01 8:41 ` tip-bot for Thomas Gleixner
1 sibling, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-06-24 14:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: cfb5e3d96a8ef12a2aafce2c1cf2ebb849267b16
Gitweb: http://git.kernel.org/tip/cfb5e3d96a8ef12a2aafce2c1cf2ebb849267b16
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:28 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 24 Jun 2011 16:22:55 +0200
arm: Footbridge: Use common i8253 clockevent
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.241312122@linutronix.de
---
| 1 +
| 51 +---------------------------------
2 files changed, 2 insertions(+), 50 deletions(-)
--git a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig
index 46adca0..dc26fff 100644
--- a/arch/arm/mach-footbridge/Kconfig
+++ b/arch/arm/mach-footbridge/Kconfig
@@ -5,6 +5,7 @@ menu "Footbridge Implementations"
config ARCH_CATS
bool "CATS"
select CLKSRC_I8253
+ select CLKEVT_I8253
select FOOTBRIDGE_HOST
select ISA
select ISA_DMA
--git a/arch/arm/mach-footbridge/isa-timer.c b/arch/arm/mach-footbridge/isa-timer.c
index 71fd96d..136eb4b 100644
--- a/arch/arm/mach-footbridge/isa-timer.c
+++ b/arch/arm/mach-footbridge/isa-timer.c
@@ -5,12 +5,10 @@
* Copyright (C) 1998 Phil Blundell
*/
#include <linux/clockchips.h>
-#include <linux/clocksource.h>
#include <linux/i8253.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
-#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
@@ -19,48 +17,6 @@
#include "common.h"
-static void pit_set_mode(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- unsigned long flags;
-
- raw_local_irq_save(flags);
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- outb_p(0x34, PIT_MODE);
- outb_p(PIT_LATCH & 0xff, PIT_CH0);
- outb_p(PIT_LATCH >> 8, PIT_CH0);
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- outb_p(0x30, PIT_MODE);
- outb_p(0, PIT_CH0);
- outb_p(0, PIT_CH0);
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- case CLOCK_EVT_MODE_RESUME:
- break;
- }
- local_irq_restore(flags);
-}
-
-static int pit_set_next_event(unsigned long delta,
- struct clock_event_device *evt)
-{
- return 0;
-}
-
-static struct clock_event_device pit_ce = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC,
- .set_mode = pit_set_mode,
- .set_next_event = pit_set_next_event,
- .shift = 32,
-};
-
static irqreturn_t pit_timer_interrupt(int irq, void *dev_id)
{
struct clock_event_device *ce = dev_id;
@@ -77,15 +33,10 @@ static struct irqaction pit_timer_irq = {
static void __init isa_timer_init(void)
{
- pit_ce.cpumask = cpumask_of(smp_processor_id());
- pit_ce.mult = div_sc(PIT_TICK_RATE, NSEC_PER_SEC, pit_ce.shift);
- pit_ce.max_delta_ns = clockevent_delta2ns(0x7fff, &pit_ce);
- pit_ce.min_delta_ns = clockevent_delta2ns(0x000f, &pit_ce);
-
clocksource_i8253_init();
setup_irq(pit_ce.irq, &pit_timer_irq);
- clockevents_register_device(&pit_ce);
+ clockevents_i8253_init(false);
}
struct sys_timer isa_timer = {
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] arm: Footbridge: Use common i8253 clockevent
2011-06-09 13:08 ` [patch 4/5] arm: footbridge: " Thomas Gleixner
2011-06-24 14:33 ` [tip:timers/cleanup] arm: Footbridge: " tip-bot for Thomas Gleixner
@ 2011-07-01 8:41 ` tip-bot for Thomas Gleixner
1 sibling, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-07-01 8:41 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 8560a6cfc9818edde1fd8677961714b264ffa03d
Gitweb: http://git.kernel.org/tip/8560a6cfc9818edde1fd8677961714b264ffa03d
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:28 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
arm: Footbridge: Use common i8253 clockevent
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.241312122@linutronix.de
---
| 1 +
| 55 ++--------------------------------
2 files changed, 4 insertions(+), 52 deletions(-)
--git a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig
index 46adca0..dc26fff 100644
--- a/arch/arm/mach-footbridge/Kconfig
+++ b/arch/arm/mach-footbridge/Kconfig
@@ -5,6 +5,7 @@ menu "Footbridge Implementations"
config ARCH_CATS
bool "CATS"
select CLKSRC_I8253
+ select CLKEVT_I8253
select FOOTBRIDGE_HOST
select ISA
select ISA_DMA
--git a/arch/arm/mach-footbridge/isa-timer.c b/arch/arm/mach-footbridge/isa-timer.c
index 71fd96d..c40bb41 100644
--- a/arch/arm/mach-footbridge/isa-timer.c
+++ b/arch/arm/mach-footbridge/isa-timer.c
@@ -5,12 +5,10 @@
* Copyright (C) 1998 Phil Blundell
*/
#include <linux/clockchips.h>
-#include <linux/clocksource.h>
#include <linux/i8253.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
-#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
@@ -19,48 +17,6 @@
#include "common.h"
-static void pit_set_mode(enum clock_event_mode mode,
- struct clock_event_device *evt)
-{
- unsigned long flags;
-
- raw_local_irq_save(flags);
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- outb_p(0x34, PIT_MODE);
- outb_p(PIT_LATCH & 0xff, PIT_CH0);
- outb_p(PIT_LATCH >> 8, PIT_CH0);
- break;
-
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
- outb_p(0x30, PIT_MODE);
- outb_p(0, PIT_CH0);
- outb_p(0, PIT_CH0);
- break;
-
- case CLOCK_EVT_MODE_ONESHOT:
- case CLOCK_EVT_MODE_RESUME:
- break;
- }
- local_irq_restore(flags);
-}
-
-static int pit_set_next_event(unsigned long delta,
- struct clock_event_device *evt)
-{
- return 0;
-}
-
-static struct clock_event_device pit_ce = {
- .name = "pit",
- .features = CLOCK_EVT_FEAT_PERIODIC,
- .set_mode = pit_set_mode,
- .set_next_event = pit_set_next_event,
- .shift = 32,
-};
-
static irqreturn_t pit_timer_interrupt(int irq, void *dev_id)
{
struct clock_event_device *ce = dev_id;
@@ -72,20 +28,15 @@ static struct irqaction pit_timer_irq = {
.name = "pit",
.handler = pit_timer_interrupt,
.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
- .dev_id = &pit_ce,
+ .dev_id = &i8253_clockevent,
};
static void __init isa_timer_init(void)
{
- pit_ce.cpumask = cpumask_of(smp_processor_id());
- pit_ce.mult = div_sc(PIT_TICK_RATE, NSEC_PER_SEC, pit_ce.shift);
- pit_ce.max_delta_ns = clockevent_delta2ns(0x7fff, &pit_ce);
- pit_ce.min_delta_ns = clockevent_delta2ns(0x000f, &pit_ce);
-
clocksource_i8253_init();
- setup_irq(pit_ce.irq, &pit_timer_irq);
- clockevents_register_device(&pit_ce);
+ setup_irq(i8253_clockevent.irq, &pit_timer_irq);
+ clockevent_i8253_init(false);
}
struct sys_timer isa_timer = {
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [patch 5/5] i8253: Cleanup outb/inb magic
2011-06-09 13:08 [patch 0/5] i8253: common clockevent Thomas Gleixner
` (3 preceding siblings ...)
2011-06-09 13:08 ` [patch 4/5] arm: footbridge: " Thomas Gleixner
@ 2011-06-09 13:08 ` Thomas Gleixner
2011-06-09 13:34 ` Ralf Baechle
` (2 more replies)
4 siblings, 3 replies; 20+ messages in thread
From: Thomas Gleixner @ 2011-06-09 13:08 UTC (permalink / raw)
To: LKML; +Cc: Russell King, Ralf Baechle, Ingo Molnar, John Stultz
[-- Attachment #1: i8253-cleanup-outb-inb-magic.patch --]
[-- Type: text/plain, Size: 1485 bytes --]
Remove the hysterical outb/inb_pit defines and use outb_p/inb_p in the
code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@arm.linux.org.uk>
---
arch/x86/kernel/apm_32.c | 6 +++---
include/linux/i8253.h | 3 ---
2 files changed, 3 insertions(+), 6 deletions(-)
Index: linux-2.6-tip/arch/x86/kernel/apm_32.c
===================================================================
--- linux-2.6-tip.orig/arch/x86/kernel/apm_32.c
+++ linux-2.6-tip/arch/x86/kernel/apm_32.c
@@ -1220,11 +1220,11 @@ static void reinit_timer(void)
raw_spin_lock_irqsave(&i8253_lock, flags);
/* set the clock to HZ */
- outb_pit(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
+ outb_p(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
udelay(10);
- outb_pit(LATCH & 0xff, PIT_CH0); /* LSB */
+ outb_p(LATCH & 0xff, PIT_CH0); /* LSB */
udelay(10);
- outb_pit(LATCH >> 8, PIT_CH0); /* MSB */
+ outb_p(LATCH >> 8, PIT_CH0); /* MSB */
udelay(10);
raw_spin_unlock_irqrestore(&i8253_lock, flags);
#endif
Index: linux-2.6-tip/include/linux/i8253.h
===================================================================
--- linux-2.6-tip.orig/include/linux/i8253.h
+++ linux-2.6-tip/include/linux/i8253.h
@@ -20,9 +20,6 @@
#define PIT_LATCH ((PIT_TICK_RATE + HZ/2) / HZ)
-#define inb_pit inb_p
-#define outb_pit outb_p
-
extern raw_spinlock_t i8253_lock;
extern void setup_pit_timer(void);
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch 5/5] i8253: Cleanup outb/inb magic
2011-06-09 13:08 ` [patch 5/5] i8253: Cleanup outb/inb magic Thomas Gleixner
@ 2011-06-09 13:34 ` Ralf Baechle
2011-06-09 14:41 ` H. Peter Anvin
2011-06-24 14:35 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
2011-07-01 8:41 ` tip-bot for Thomas Gleixner
2 siblings, 1 reply; 20+ messages in thread
From: Ralf Baechle @ 2011-06-09 13:34 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Russell King, Ingo Molnar, John Stultz, H. Peter Anvin
On Thu, Jun 09, 2011 at 01:08:30PM -0000, Thomas Gleixner wrote:
> Remove the hysterical outb/inb_pit defines and use outb_p/inb_p in the
> code.
FWIW, I've traced the use of inb_p and outb_p to access the PIT timer
all the way back to Linux 0.10
I wonder if any of the systems affected actually has enough memory to boot
a modern kernel or if the _p versions have become useless bagagge that
should be dropped - cleanup which would then also allow more code to the
iomap() API.
I'm interested because quite a few MIPS systems have been built based on
Intel, OPTi and other chipsets which may or may not have been affected.
Ralf
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch 5/5] i8253: Cleanup outb/inb magic
2011-06-09 13:34 ` Ralf Baechle
@ 2011-06-09 14:41 ` H. Peter Anvin
0 siblings, 0 replies; 20+ messages in thread
From: H. Peter Anvin @ 2011-06-09 14:41 UTC (permalink / raw)
To: Ralf Baechle
Cc: Thomas Gleixner, LKML, Russell King, Ingo Molnar, John Stultz
On 06/09/2011 06:34 AM, Ralf Baechle wrote:
> On Thu, Jun 09, 2011 at 01:08:30PM -0000, Thomas Gleixner wrote:
>
>> Remove the hysterical outb/inb_pit defines and use outb_p/inb_p in the
>> code.
>
> FWIW, I've traced the use of inb_p and outb_p to access the PIT timer
> all the way back to Linux 0.10
>
> I wonder if any of the systems affected actually has enough memory to boot
> a modern kernel or if the _p versions have become useless bagagge that
> should be dropped - cleanup which would then also allow more code to the
> iomap() API.
>
> I'm interested because quite a few MIPS systems have been built based on
> Intel, OPTi and other chipsets which may or may not have been affected.
>
On the x86 side, we already have configurability of the delay in
inb_p/outb_p... one option could be null delay.
-hpa
^ permalink raw reply [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] i8253: Cleanup outb/inb magic
2011-06-09 13:08 ` [patch 5/5] i8253: Cleanup outb/inb magic Thomas Gleixner
2011-06-09 13:34 ` Ralf Baechle
@ 2011-06-24 14:35 ` tip-bot for Thomas Gleixner
2011-07-01 8:41 ` tip-bot for Thomas Gleixner
2 siblings, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-06-24 14:35 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 51928d12a6e07a1bd7b38d8b151a50cb24175dd3
Gitweb: http://git.kernel.org/tip/51928d12a6e07a1bd7b38d8b151a50cb24175dd3
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:30 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 24 Jun 2011 16:22:55 +0200
i8253: Cleanup outb/inb magic
Remove the hysterical outb/inb_pit defines and use outb_p/inb_p in the
code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.348437125@linutronix.de
---
arch/x86/kernel/apm_32.c | 6 +++---
include/linux/i8253.h | 3 ---
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index a30740e..0371c48 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1220,11 +1220,11 @@ static void reinit_timer(void)
raw_spin_lock_irqsave(&i8253_lock, flags);
/* set the clock to HZ */
- outb_pit(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
+ outb_p(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
udelay(10);
- outb_pit(LATCH & 0xff, PIT_CH0); /* LSB */
+ outb_p(LATCH & 0xff, PIT_CH0); /* LSB */
udelay(10);
- outb_pit(LATCH >> 8, PIT_CH0); /* MSB */
+ outb_p(LATCH >> 8, PIT_CH0); /* MSB */
udelay(10);
raw_spin_unlock_irqrestore(&i8253_lock, flags);
#endif
diff --git a/include/linux/i8253.h b/include/linux/i8253.h
index 76039c8..0770fc5 100644
--- a/include/linux/i8253.h
+++ b/include/linux/i8253.h
@@ -20,9 +20,6 @@
#define PIT_LATCH ((PIT_TICK_RATE + HZ/2) / HZ)
-#define inb_pit inb_p
-#define outb_pit outb_p
-
extern raw_spinlock_t i8253_lock;
extern void setup_pit_timer(void);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [tip:timers/cleanup] i8253: Cleanup outb/inb magic
2011-06-09 13:08 ` [patch 5/5] i8253: Cleanup outb/inb magic Thomas Gleixner
2011-06-09 13:34 ` Ralf Baechle
2011-06-24 14:35 ` [tip:timers/cleanup] " tip-bot for Thomas Gleixner
@ 2011-07-01 8:41 ` tip-bot for Thomas Gleixner
2 siblings, 0 replies; 20+ messages in thread
From: tip-bot for Thomas Gleixner @ 2011-07-01 8:41 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, john.stultz, hpa, mingo, ralf, linux, tglx
Commit-ID: 01898e3e29ea8242d81923da11ce88ba71290a48
Gitweb: http://git.kernel.org/tip/01898e3e29ea8242d81923da11ce88ba71290a48
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 9 Jun 2011 13:08:30 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 1 Jul 2011 10:37:15 +0200
i8253: Cleanup outb/inb magic
Remove the hysterical outb/inb_pit defines and use outb_p/inb_p in the
code.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20110609130622.348437125@linutronix.de
---
arch/x86/kernel/apm_32.c | 6 +++---
include/linux/i8253.h | 3 ---
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index a30740e..0371c48 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1220,11 +1220,11 @@ static void reinit_timer(void)
raw_spin_lock_irqsave(&i8253_lock, flags);
/* set the clock to HZ */
- outb_pit(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
+ outb_p(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */
udelay(10);
- outb_pit(LATCH & 0xff, PIT_CH0); /* LSB */
+ outb_p(LATCH & 0xff, PIT_CH0); /* LSB */
udelay(10);
- outb_pit(LATCH >> 8, PIT_CH0); /* MSB */
+ outb_p(LATCH >> 8, PIT_CH0); /* MSB */
udelay(10);
raw_spin_unlock_irqrestore(&i8253_lock, flags);
#endif
diff --git a/include/linux/i8253.h b/include/linux/i8253.h
index 487d50c..e6bb36a 100644
--- a/include/linux/i8253.h
+++ b/include/linux/i8253.h
@@ -20,9 +20,6 @@
#define PIT_LATCH ((PIT_TICK_RATE + HZ/2) / HZ)
-#define inb_pit inb_p
-#define outb_pit outb_p
-
extern raw_spinlock_t i8253_lock;
extern struct clock_event_device i8253_clockevent;
extern void clockevent_i8253_init(bool oneshot);
^ permalink raw reply related [flat|nested] 20+ messages in thread