Permit reuse of APB timers on other platforms
Subsystems (2)
v2 cover Permit reuse of APB timers on other platforms
This patch series splits out the DesignWare APB timer handling into clocksource and clockevent drivers then allows different platforms to reuse them. The Synopsys timers can be found in x86, ARM and potentially other architectures.
Here's the updated patch series which Jacob has had running on his x86 platform and I have working on a currently out-of-tree ARM platform.
Many thanks to Jacob for the testing (and fixing) to get this running on x86.
Jamie Iles (2):
x86, mrst: share APB timer code with other platforms
clocksource: platform driver for APB timers
arch/x86/Kconfig | 1 + arch/x86/include/asm/apb_timer.h | 22 +-- arch/x86/kernel/apb_timer.c | 421 +++++---------------------- drivers/Kconfig | 2 + drivers/clocksource/Kconfig | 11 + drivers/clocksource/Makefile | 2 + drivers/clocksource/dw_apb_timer.c | 322 ++++++++++++++++++++ drivers/clocksource/dw_apb_timer_platform.c | 173 +++++++++++ include/linux/dw_apb_timer.h | 129 ++++++++ 9 files changed, 714 insertions(+), 369 deletions(-) create mode 100644 drivers/clocksource/Kconfig create mode 100644 drivers/clocksource/dw_apb_timer.c create mode 100644 drivers/clocksource/dw_apb_timer_platform.c create mode 100644 include/linux/dw_apb_timer.h
Signature · 1 line
1.7.4.2
PATCH v2 1/2 x86, mrst: share APB timer code with other platforms
The APB timers are an IP block from Synopsys (DesignWare APB timers) and are also found in other systems including ARM SoC's. This patch adds functions for creating clock_event_devices and clocksources from APB timers but does not do the resource allocation. This is handled in a higher layer to allow the timers to be created from multiple methods such as platform_devices.
Changes since v1:
- Use the correct timer for clocksource on x86
- Select the correct timer rating for x86
- Restore freerunning timer behaviour for oneshot event devices
- Reenable event irq correctly for hotplug
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/apb_timer.h | 22 +-- arch/x86/kernel/apb_timer.c | 421 ++++++------------------------------ drivers/Kconfig | 2 + drivers/clocksource/Kconfig | 6 + drivers/clocksource/Makefile | 1 + drivers/clocksource/dw_apb_timer.c | 322 +++++++++++++++++++++++++++ include/linux/dw_apb_timer.h | 129 +++++++++++ 8 files changed, 535 insertions(+), 369 deletions(-) create mode 100644 drivers/clocksource/Kconfig create mode 100644 drivers/clocksource/dw_apb_timer.c create mode 100644 include/linux/dw_apb_timer.h
arch/x86/Kconfig +1 -0
@@ -623,6 +623,7 @@ config HPET_EMULATE_RTC config APB_TIMER def_bool y if MRST prompt "Langwell APB Timer Support" if X86_MRST + select DW_APB_TIMER help APB timer is the replacement for 8254, HPET on X86 MID platforms. The APBT provides a stable time base on SMP
arch/x86/include/asm/apb_timer.h +2 -20
@@ -18,24 +18,6 @@#ifdef CONFIG_APB_TIMER -/* Langwell DW APB timer registers */ -#define APBTMR_N_LOAD_COUNT 0x00 -#define APBTMR_N_CURRENT_VALUE 0x04 -#define APBTMR_N_CONTROL 0x08 -#define APBTMR_N_EOI 0x0c -#define APBTMR_N_INT_STATUS 0x10 - -#define APBTMRS_INT_STATUS 0xa0 -#define APBTMRS_EOI 0xa4 -#define APBTMRS_RAW_INT_STATUS 0xa8 -#define APBTMRS_COMP_VERSION 0xac -#define APBTMRS_REG_SIZE 0x14 - -/* register bits */ -#define APBTMR_CONTROL_ENABLE (1<<0) -#define APBTMR_CONTROL_MODE_PERIODIC (1<<1)/*1: periodic 0:free running */ -#define APBTMR_CONTROL_INT (1<<2) -/* default memory mapped register base */ #define LNW_SCU_ADDR 0xFF100000#define LNW_EXT_TIMER_OFFSET 0x1B800
@@ -43,8 +25,8 @@#define LNW_EXT_TIMER_PGOFFSET 0x800/* APBT clock speed range from PCLK to fabric base, 25-100MHz */ -#define APBT_MAX_FREQ 50 -#define APBT_MIN_FREQ 1 +#define APBT_MAX_FREQ 50000000 +#define APBT_MIN_FREQ 1000000#define APBT_MMAP_SIZE 1024#define APBT_DEV_USED 1
arch/x86/kernel/apb_timer.c +72 -349
627 lines not on this page · raw message
drivers/Kconfig +2 -0
@@ -119,4 +119,6 @@ source "drivers/platform/Kconfig" source "drivers/clk/Kconfig" source "drivers/hwspinlock/Kconfig" + +source "drivers/clocksource/Kconfig" endmenu
drivers/clocksource/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +# +# Clocksource configuration +# + +config DW_APB_TIMER + bool
drivers/clocksource/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o +obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o
drivers/clocksource/dw_apb_timer.c new file +322 -0
322 lines not on this page · raw message
include/linux/dw_apb_timer.h new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
1.7.4.2
Re: [PATCHv2 1/2] x86, mrst: share APB timer code with other platforms
Quoted 46 lines · On Fri, 8 Apr 2011 15:33:37 +0100 Jamie Iles <[email protected]> wrote:
The APB timers are an IP block from Synopsys (DesignWare APB timers) and are also found in other systems including ARM SoC's. This patch adds functions for creating
clock_event_devicesand clocksources from APB timers but does not do the resource allocation. This is handled in a higher layer to allow the timers to be created from multiple methods such asplatform_devices.Changes since v1:
- Use the correct timer for clocksource on x86
- Select the correct timer rating for x86
- Restore freerunning timer behaviour for oneshot event
devices
- Reenable event irq correctly for hotplugCc John Stultz <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Jacob Pan <[email protected]>Signed-off-by Jamie Iles <[email protected]>--- arch/x86/Kconfig | 1 + arch/x86/include/asm/apb_timer.h | 22 +-- arch/x86/kernel/apb_timer.c | 421 ++++++------------------------------ drivers/Kconfig | 2 + drivers/clocksource/Kconfig | 6 + drivers/clocksource/Makefile | 1 + drivers/clocksource/dw_apb_timer.c | 322 +++++++++++++++++++++++++++ include/linux/dw_apb_timer.h | 129 +++++++++++ 8 fileschanged, 535 insertions(+), 369 deletions(-) create mode 100644
drivers/clocksource/Kconfigcreate mode 100644drivers/clocksource/dw_apb_timer.ccreate mode 100644include/linux/dw_apb_timer.hdrivers/clocksource/dw_apb_timer.c new file +9
-0+static void apbt_eoi (struct dw_apb_timer *timer) +{ +apbt_readl (timer,APBTMR_N_EOI ); +} + +static irqreturn_t dw_apb_clockevent_irq (int irq,void *data) +{ +struct clock_event_device *evt = data; + struct dw_apb_clock_event_device *dw_ced =
ced_to_dw_apb_ced(evt); +
drivers/clocksource/dw_apb_timer.c line 92
Quoted 6 lines
drivers/clocksource/dw_apb_timer.c new file +6
-0+if (!evt->event_handler) { +pr_info ("Spurious APBT timer interrupt %d" , irq); +return IRQ_NONE ; + } + + dw_ced->eoi (&dw_ced->timer);
I know I proposed this to deal with the fact that X86_MRST does not need eoi. I was hoping gcc to generate nops but it doesn't, especially with FRAME_POINTER turned on in our build.
Since this is in the performance critical path and across ARM and X86 architectures, can we use #define to skip eoi() for CONFIG_X86_MRST?
Thanks,
Jacob
Re: [PATCHv2 1/2] x86, mrst: share APB timer code with other platforms
Hi Jacob,
Quoted 59 lines · jacob pan
Quoted 46 lines · On Fri, 8 Apr 2011 15:33:37 +0100 Jamie Iles <[email protected]> wrote:
The APB timers are an IP block from Synopsys (DesignWare APB timers) and are also found in other systems including ARM SoC's. This patch adds functions for creating
clock_event_devicesand clocksources from APB timers but does not do the resource allocation. This is handled in a higher layer to allow the timers to be created from multiple methods such asplatform_devices.Changes since v1:
- Use the correct timer for clocksource on x86
- Select the correct timer rating for x86
- Restore freerunning timer behaviour for oneshot event
devices
- Reenable event irq correctly for hotplugCc John Stultz <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Jacob Pan <[email protected]>Signed-off-by Jamie Iles <[email protected]>--- arch/x86/Kconfig | 1 + arch/x86/include/asm/apb_timer.h | 22 +-- arch/x86/kernel/apb_timer.c | 421 ++++++------------------------------ drivers/Kconfig | 2 + drivers/clocksource/Kconfig | 6 + drivers/clocksource/Makefile | 1 + drivers/clocksource/dw_apb_timer.c | 322 +++++++++++++++++++++++++++ include/linux/dw_apb_timer.h | 129 +++++++++++ 8 fileschanged, 535 insertions(+), 369 deletions(-) create mode 100644
drivers/clocksource/Kconfigcreate mode 100644drivers/clocksource/dw_apb_timer.ccreate mode 100644include/linux/dw_apb_timer.hdrivers/clocksource/dw_apb_timer.c new file +9
-0+static void apbt_eoi (struct dw_apb_timer *timer) +{ +apbt_readl (timer,APBTMR_N_EOI ); +} + +static irqreturn_t dw_apb_clockevent_irq (int irq,void *data) +{ +struct clock_event_device *evt = data; + struct dw_apb_clock_event_device *dw_ced =
ced_to_dw_apb_ced(evt); +drivers/clocksource/dw_apb_timer.c line 92
Quoted 6 lines
drivers/clocksource/dw_apb_timer.c new file +6
-0+if (!evt->event_handler) { +pr_info ("Spurious APBT timer interrupt %d" , irq); +return IRQ_NONE ; + } + + dw_ced->eoi (&dw_ced->timer);I know I proposed this to deal with the fact that
X86_MRSTdoes not need eoi. I was hoping gcc to generate nops but it doesn't, especially withFRAME_POINTERturned on in our build.
Quoted 2 lines
Since this is in the performance critical path and across ARM and X86 architectures, can we use #define to skip
eoi()forCONFIG_X86_MRST?
How about testing if dw_apb_timer::eoi is defined first before calling and not defining it for x86? It's not zero overhead but it's less than what there is now. The call would still be there for ARM but I don't have a good feel for how much this overhead is in relation to the rest of the IRQ and clock events handling. I would guess that it isn't too significant.
Jamie
Re: [PATCHv2 1/2] x86, mrst: share APB timer code with other platforms
Quoted 67 lines · On Fri, 8 Apr 2011 23:55:30 +0100 Jamie Iles <[email protected]> wrote:
Hi Jacob,
Quoted 60 lines · jacob pan
Quoted 47 lines · On Fri, 8 Apr 2011 15:33:37 +0100 Jamie Iles <[email protected]> wrote:
The APB timers are an IP block from Synopsys (DesignWare APB timers) and are also found in other systems including ARM SoC's. This patch adds functions for creating
clock_event_devicesand clocksources from APB timers but does not do the resource allocation. This is handled in a higher layer to allow the timers to be created from multiple methods such asplatform_devices.Changes since v1:
- Use the correct timer for clocksource on x86
- Select the correct timer rating for x86
- Restore freerunning timer behaviour for oneshot event
devices
- Reenable event irq correctly for hotplugCc John Stultz <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Jacob Pan <[email protected]>Signed-off-by Jamie Iles <[email protected]>--- arch/x86/Kconfig | 1 + arch/x86/include/asm/apb_timer.h | 22 +-- arch/x86/kernel/apb_timer.c | 421 ++++++------------------------------ drivers/Kconfig | 2 + drivers/clocksource/Kconfig | 6 + drivers/clocksource/Makefile | 1 + drivers/clocksource/dw_apb_timer.c | 322+++++++++++++++++++++++++++
include/linux/dw_apb_timer.h|
129 +++++++++++ 8 files changed, 535 insertions(+), 369 deletions(-) create mode 100644drivers/clocksource/Kconfigcreate mode 100644drivers/clocksource/dw_apb_timer.ccreate mode 100644include/linux/dw_apb_timer.hdrivers/clocksource/dw_apb_timer.c new file +9
-0+static void apbt_eoi (struct dw_apb_timer *timer) +{ +apbt_readl (timer,APBTMR_N_EOI ); +} + +static irqreturn_t dw_apb_clockevent_irq (int irq,void *data) +{ +struct clock_event_device *evt = data; + struct dw_apb_clock_event_device *dw_ced =
ced_to_dw_apb_ced(evt); +drivers/clocksource/dw_apb_timer.c line 92
Quoted 6 lines
drivers/clocksource/dw_apb_timer.c new file +6
-0+if (!evt->event_handler) { +pr_info ("Spurious APBT timer interrupt %d" , irq); +return IRQ_NONE ; + } + + dw_ced->eoi (&dw_ced->timer);I know I proposed this to deal with the fact that
X86_MRSTdoes not need eoi. I was hoping gcc to generate nops but it doesn't, especially withFRAME_POINTERturned on in our build.Quoted 3 lines
Since this is in the performance critical path and across ARM and X86 architectures, can we use #define to skip
eoi()forCONFIG_X86_MRST?
Quoted 6 lines
How about testing if
dw_apb_timer::eoiis defined first before calling and not defining it for x86? It's not zero overhead but it's less than what there is now. The call would still be there for ARM but I don't have a good feel for how much this overhead is in relation to the rest of the IRQ and clock events handling. I would guess that it isn't too significant.
sounds good to me, I agree the check costs less than a function call. My original concern for check was that since they are in timer interrupt so the branch prediction may not work well (no history). But a failed branch prediction should not cost too much for either ATOM or ARM since both should have shorter pipeline. It would cost a lot more on P4 :).
Signature · 4 lines
Thanks Jacob (from Linux laptop)
PATCH v2 2/2 clocksource: platform driver for APB timers
In reply to Jamie IlesAdd a platform driver for the APB timers that can be used for embedded systems such as ARM SoC. This uses early_platform so that the timers can be used early in the boot sequence.
--- drivers/clocksource/Kconfig | 5 + drivers/clocksource/Makefile | 1 + drivers/clocksource/dw_apb_timer_platform.c | 173 +++++++++++++++++++++++++++ 3 files changed, 179 insertions(+), 0 deletions(-) create mode 100644 drivers/clocksource/dw_apb_timer_platform.c
drivers/clocksource/Kconfig +5 -0
@@ -4,3 +4,8 @@ config DW_APB_TIMER bool + +config DW_APB_TIMER_PLATFORM + depends on HAVE_CLK + select DW_APB_TIMER + bool
drivers/clocksource/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o +obj-$(CONFIG_DW_APB_TIMER_PLATFORM) += dw_apb_timer_platform.o
drivers/clocksource/dw_apb_timer_platform.c new file +173 -0
173 lines not on this page · raw message
Signature · 1 line
1.7.4.2
Quoted 23 lines · On Fri, 8 Apr 2011 15:33:36 +0100 Jamie Iles <[email protected]> wrote:
This patch series splits out the DesignWare APB timer handling into clocksource and clockevent drivers then allows different platforms to reuse them. The Synopsys timers can be found in x86, ARM and potentially other architectures.
Here's the updated patch series which Jacob has had running on his x86 platform and I have working on a currently out-of-tree ARM platform.
Many thanks to Jacob for the testing (and fixing) to get this running on x86.
Jamie Iles (2):
x86, mrst: share APB timer code with other platforms
clocksource: platform driver for APB timersarch/x86/Kconfig | 1 + arch/x86/include/asm/apb_timer.h | 22 +-- arch/x86/kernel/apb_timer.c | 421 +++++---------------------- drivers/Kconfig | 2 + drivers/clocksource/Kconfig | 11 + drivers/clocksource/Makefile | 2 + drivers/clocksource/dw_apb_timer.c | 322
Quoted 8 lines
++++++++++++++++++++
drivers/clocksource/dw_apb_timer_platform.c|
173 +++++++++++include/linux/dw_apb_timer.h| 129
++++++++ 9 files changed, 714 insertions(+), 369 deletions(-) create mode 100644drivers/clocksource/Kconfigcreate mode 100644drivers/clocksource/dw_apb_timer.ccreate mode 100644drivers/clocksource/dw_apb_timer_platform.ccreate mode 100644include/linux/dw_apb_timer.h
Hi Jamie,
Which tree are your patches based on? I failed to apply them on both mainline and tip tree.
There has been some recent changes in arch/x86/kernel/apb_timer.c I have resolved conflict and sending you updated patch separately.
Please check,
Signature · 4 lines
Thanks Jacob (from Linux laptop)