i8253: common clockevent
Subsystems (7)
cover i8253: common clockevent
Replace all the copies of i8253 clockevents code with a single common implementation.
Thanks,
tglx
--- arch/arm/mach-footbridge/Kconfig | 1 arch/arm/mach-footbridge/isa-timer.c | 51 ----------------- arch/mips/Kconfig | 1 arch/mips/kernel/i8253.c | 97 --------------------------------- arch/x86/Kconfig | 2 arch/x86/kernel/i8253.c | 93 +------------------------------- drivers/clocksource/Kconfig | 5 + drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++--- 8 files changed, 107 insertions(+), 244 deletions(-)
PATCH 1/5 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.
--- drivers/clocksource/Kconfig | 5 +- drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 98 insertions(+), 8 deletions(-)
drivers/clocksource/Kconfig +4 -1
@@ -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
drivers/clocksource/i8253.c +94 -7
125 lines not on this page · raw message
[tip:timers/cleanup] i8253: Create common clockevent implementation
Commit-ID: 9f9119424bbc4e1c4c8690ea418fa6129dc9fa04 Gitweb: http://git.kernel.org/tip/9f9119424bbc4e1c4c8690ea418fa6129dc9fa04 Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:25 +0000 Committer: Thomas Gleixner <[email protected]> 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.
--- drivers/clocksource/Kconfig | 5 ++- drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 98 insertions(+), 8 deletions(-)
drivers/clocksource/Kconfig +4 -1
@@ -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
drivers/clocksource/i8253.c +94 -7
125 lines not on this page · raw message
Re: [patch 1/5] i8253: Create common clockevent implementation
In reply to Thomas GleixnerQuoted 9 lines
(quoted diff) +8
-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 clockevent_i8253_init(bool oneshot) +{ + if (oneshot) + i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;
Review
Quoted 10 lines
(quoted diff) +10
-0+ /* + * 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 ofgit://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 <[email protected]> Date: Sat Jun 25 22:04:53 2011 +0200
Fix missing declarations of i8253.
include/linux/i8253.h +4 -0
@@ -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 */
Re: [patch 1/5] i8253: Create common clockevent implementation
Quoted 22 lines · Stijn Devriendt
Quoted 9 lines
(quoted diff) +8
-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 clockevent_i8253_init(bool oneshot) +{ + if (oneshot) + i8253_clockevent.features |= CLOCK_EVT_FEAT_ONESHOT;Review
Quoted 10 lines
(quoted diff) +10
-0+ /* + * 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); +} +#endifBoth this function and the
i8253_clockeventdeclaration seem to be missing frominclude/linux/i8253.hcausing compile failures for at least x86.
Quoted 2 lines
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.
Quoted 1 line
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,
Quoted 24 lines
commit
0c24072a8d580acd5b4fc57009b72b217c0f23d9Author: Stijn Devriendt <[email protected]> Date: Sat Jun 25 22:04:53 2011 +0200Fix missing declarations of i8253.
Signed-off-by Stijn Devriendt <[email protected]>include/linux/i8253.h +4
-0@@ -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 */
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
[tip:timers/cleanup] i8253: Create common clockevent implementation
In reply to Thomas GleixnerCommit-ID: e6220bdc9485c5ea972f9e0e6d062a05934bb74b Gitweb: http://git.kernel.org/tip/e6220bdc9485c5ea972f9e0e6d062a05934bb74b Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:25 +0000 Committer: Thomas Gleixner <[email protected]> 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.
--- drivers/clocksource/Kconfig | 5 ++- drivers/clocksource/i8253.c | 101 ++++++++++++++++++++++++++++++++++++++++--- include/linux/i8253.h | 2 + 3 files changed, 100 insertions(+), 8 deletions(-)
drivers/clocksource/Kconfig +4 -1
@@ -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
drivers/clocksource/i8253.c +94 -7
125 lines not on this page · raw message
include/linux/i8253.h +2 -0
@@ -24,6 +24,8 @@#define outb_pit outb_pextern 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 );
PATCH 2/5 x86: Use common i8253 clockevent
In reply to Thomas Gleixner--- arch/x86/Kconfig | 2 - arch/x86/kernel/i8253.c | 93 +----------------------------------------------- 2 files changed, 4 insertions(+), 91 deletions(-)
arch/x86/Kconfig +1 -1
@@ -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)
arch/x86/kernel/i8253.c +3 -90
116 lines not on this page · raw message
[tip:timers/cleanup] x86: Use common i8253 clockevent
Commit-ID: 2739ce151665a72acdc19ed9dc6b9f6a235b7c30 Gitweb: http://git.kernel.org/tip/2739ce151665a72acdc19ed9dc6b9f6a235b7c30 Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:26 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 24 Jun 2011 16:22:54 +0200
x86: Use common i8253 clockevent
--- arch/x86/Kconfig | 2 +- arch/x86/kernel/i8253.c | 93 ++--------------------------------------------- 2 files changed, 4 insertions(+), 91 deletions(-)
arch/x86/Kconfig +1 -1
@@ -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)
arch/x86/kernel/i8253.c +3 -90
116 lines not on this page · raw message
[tip:timers/cleanup] x86: Use common i8253 clockevent
In reply to Thomas GleixnerCommit-ID: 0a779c571314b7951ff12edac80aa0cbe7c12b6e Gitweb: http://git.kernel.org/tip/0a779c571314b7951ff12edac80aa0cbe7c12b6e Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:26 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
x86: Use common i8253 clockevent
--- arch/x86/Kconfig | 2 +- arch/x86/kernel/i8253.c | 93 ++--------------------------------------------- 2 files changed, 4 insertions(+), 91 deletions(-)
arch/x86/Kconfig +1 -1
@@ -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)
arch/x86/kernel/i8253.c +3 -90
116 lines not on this page · raw message
PATCH 3/5 mips: Use common i8253 clockevent
In reply to Thomas Gleixner--- arch/mips/Kconfig | 1 arch/mips/kernel/i8253.c | 97 ----------------------------------------------- 2 files changed, 3 insertions(+), 95 deletions(-)
arch/mips/Kconfig +1 -0
@@ -2391,6 +2391,7 @@ config MMU config I8253 bool select CLKSRC_I8253 + select CLKEVT_I8253 select MIPS_EXTERNAL_TIMER config ZONE_DMA32
arch/mips/kernel/i8253.c +2 -95
119 lines not on this page · raw message
[tip:timers/cleanup] mips: Use common i8253 clockevent
Commit-ID: 594fa4ac22954c9cb8d65040c5c3676778b08e1d Gitweb: http://git.kernel.org/tip/594fa4ac22954c9cb8d65040c5c3676778b08e1d Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:27 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 24 Jun 2011 16:22:55 +0200
mips: Use common i8253 clockevent
--- arch/mips/Kconfig | 1 + arch/mips/kernel/i8253.c | 97 +--------------------------------------------- 2 files changed, 3 insertions(+), 95 deletions(-)
arch/mips/Kconfig +1 -0
@@ -2391,6 +2391,7 @@ config MMU config I8253 bool select CLKSRC_I8253 + select CLKEVT_I8253 select MIPS_EXTERNAL_TIMER config ZONE_DMA32
arch/mips/kernel/i8253.c +2 -95
119 lines not on this page · raw message
[tip:timers/cleanup] mips: Use common i8253 clockevent
In reply to Thomas GleixnerCommit-ID: 2d02612f61cc15b2025c90e32ed4a43eaa6753cd Gitweb: http://git.kernel.org/tip/2d02612f61cc15b2025c90e32ed4a43eaa6753cd Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:27 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
mips: Use common i8253 clockevent
--- arch/mips/Kconfig | 1 + arch/mips/kernel/i8253.c | 97 +--------------------------------------------- 2 files changed, 3 insertions(+), 95 deletions(-)
arch/mips/Kconfig +1 -0
@@ -2391,6 +2391,7 @@ config MMU config I8253 bool select CLKSRC_I8253 + select CLKEVT_I8253 select MIPS_EXTERNAL_TIMER config ZONE_DMA32
arch/mips/kernel/i8253.c +2 -95
119 lines not on this page · raw message
PATCH 4/5 arm: footbridge: Use common i8253 clockevent
In reply to Thomas Gleixner--- arch/arm/mach-footbridge/Kconfig | 1 arch/arm/mach-footbridge/isa-timer.c | 51 ----------------------------------- 2 files changed, 2 insertions(+), 50 deletions(-)
arch/arm/mach-footbridge/Kconfig +1 -0
@@ -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
arch/arm/mach-footbridge/isa-timer.c +1 -50
76 lines not on this page · raw message
[tip:timers/cleanup] arm: Footbridge: Use common i8253 clockevent
Commit-ID: cfb5e3d96a8ef12a2aafce2c1cf2ebb849267b16 Gitweb: http://git.kernel.org/tip/cfb5e3d96a8ef12a2aafce2c1cf2ebb849267b16 Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:28 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 24 Jun 2011 16:22:55 +0200
arm: Footbridge: Use common i8253 clockevent
--- arch/arm/mach-footbridge/Kconfig | 1 + arch/arm/mach-footbridge/isa-timer.c | 51 +--------------------------------- 2 files changed, 2 insertions(+), 50 deletions(-)
arch/arm/mach-footbridge/Kconfig +1 -0
@@ -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
arch/arm/mach-footbridge/isa-timer.c +1 -50
76 lines not on this page · raw message
[tip:timers/cleanup] arm: Footbridge: Use common i8253 clockevent
In reply to Thomas GleixnerCommit-ID: 8560a6cfc9818edde1fd8677961714b264ffa03d Gitweb: http://git.kernel.org/tip/8560a6cfc9818edde1fd8677961714b264ffa03d Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:28 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 1 Jul 2011 10:37:14 +0200
arm: Footbridge: Use common i8253 clockevent
--- arch/arm/mach-footbridge/Kconfig | 1 + arch/arm/mach-footbridge/isa-timer.c | 55 ++-------------------------------- 2 files changed, 4 insertions(+), 52 deletions(-)
arch/arm/mach-footbridge/Kconfig +1 -0
@@ -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
arch/arm/mach-footbridge/isa-timer.c +3 -52
83 lines not on this page · raw message
PATCH 5/5 i8253: Cleanup outb/inb magic
In reply to Thomas GleixnerRemove the hysterical outb/inb_pit defines and use outb_p/inb_p in the code.
--- arch/x86/kernel/apm_32.c | 6 +++--- include/linux/i8253.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/apm_32.c +3 -3
@@ -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
include/linux/i8253.h +0 -3
@@ -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 );
Re: [patch 5/5] i8253: Cleanup outb/inb magic
Quoted 2 lines · Thomas Gleixner
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
H. Peter Anvin
reviewerRe: [patch 5/5] i8253: Cleanup outb/inb magic
Quoted 8 lines · Ralf Baechle
Quoted 2 lines · Thomas Gleixner
Remove the hysterical outb/inb_pit defines and use outb_p/inb_p in the code.
FWIW, I've traced the use of
inb_pandoutb_pto access the PIT timer all the way back to Linux 0.10
Quoted 8 lines
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
[tip:timers/cleanup] i8253: Cleanup outb/inb magic
In reply to Thomas GleixnerCommit-ID: 51928d12a6e07a1bd7b38d8b151a50cb24175dd3 Gitweb: http://git.kernel.org/tip/51928d12a6e07a1bd7b38d8b151a50cb24175dd3 Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:30 +0000 Committer: Thomas Gleixner <[email protected]> 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.
--- arch/x86/kernel/apm_32.c | 6 +++--- include/linux/i8253.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/apm_32.c +3 -3
@@ -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
include/linux/i8253.h +0 -3
@@ -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 );
[tip:timers/cleanup] i8253: Cleanup outb/inb magic
In reply to Thomas GleixnerCommit-ID: 01898e3e29ea8242d81923da11ce88ba71290a48 Gitweb: http://git.kernel.org/tip/01898e3e29ea8242d81923da11ce88ba71290a48 Author: Thomas Gleixner <[email protected]> AuthorDate: Thu, 9 Jun 2011 13:08:30 +0000 Committer: Thomas Gleixner <[email protected]> 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.
--- arch/x86/kernel/apm_32.c | 6 +++--- include/linux/i8253.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/apm_32.c +3 -3
@@ -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
include/linux/i8253.h +0 -3
@@ -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);