: clockevents for 4.4
Subsystems (4)
Hi Thomas,
this pull request has the following contents:
- Removed unneeded memset in em_sti, sh_cmt and h8300 because there
are already zeroed by a kzalloc (Alexey Klimov)
- Optimized code by replacing this_cpu_ptr by container_of on theexynos_mct (Alexey Klimov)
- Got immune from a spurious interrupt when enabling the mtk_timer
(Daniel Lezcano)
- Used the dynamic irq affinity to optimize wakeup and useless IPI
timer on the imx timer (Lucas Stach)
- Added new timer for Tango SoCs (Marc Gonzalez)
- Implemented the timer delay for armada-370-xp (Russell King)
- Used GPT as clock source (Yingjoe Chen)
Thanks !
-- Daniel
The following changes since commit c8d75aa47dd585c9538a8205e9bb9847e12cfb84:
posix_cpu_timer: Reduce unnecessary sighand lock contention
(2015-10-15 11:23:41 +0200)
are available in the git repository at:
http://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.4
for you to fetch changes up to cb0f2538039c65f2bb64a9d427dbe9dd7d0f71a6:
clocksource/drivers/armada-370-xp: Implement ARM delay timer
(2015-10-19 22:42:14 +0200)
----------------------------------------------------------------
Alexey Klimov (4):
clocksource/drivers/em_sti: Remove unneeded memset()s clocksource/drivers/sh_cmt: Remove unneeded memset() insh_cmt_setup()
clocksource/drivers/h8300_*: Remove unneeded memset()s clocksource/drivers/exynos_mct: Use container_of() instead ofthis_cpu_ptr()
Daniel Lezcano (1):
clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Lucas Stach (1):
clocksource/drivers/imx: Allow timer irq affinity change
Marc Gonzalez (1):
clocksource/drivers/tango_xtal: Add new timer for Tango SoCs
Russell King (1):
clocksource/drivers/armada-370-xp: Implement ARM delay timer
Yingjoe Chen (1):
clocksource/drivers/mediatek: Use GPT as sched clock source
drivers/clocksource/Kconfig | 4 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/em_sti.c | 2 - drivers/clocksource/exynos_mct.c | 12 ++++-- drivers/clocksource/h8300_timer16.c | 1 - drivers/clocksource/h8300_timer8.c | 1 - drivers/clocksource/h8300_tpu.c | 1 - drivers/clocksource/mtk_timer.c | 26 ++++++++----- drivers/clocksource/sh_cmt.c | 1 - drivers/clocksource/tango_xtal.c | 66 ++++++++++++++++++++++++++++++++ drivers/clocksource/time-armada-370-xp.c | 14 +++++++ drivers/clocksource/timer-imx-gpt.c | 3 +- 12 files changed, 111 insertions(+), 21 deletions(-) create mode 100644 drivers/clocksource/tango_xtal.c
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 1/9 clockevents/drivers/mtk: Fix spurious interrupt leading to crash
After analysis done by Yingjoe Chen, the timer appears to have a pending interrupt when it is enabled.
Fix this by acknowledging the pending interrupt when enabling the timer interrupt.
--- drivers/clocksource/mtk_timer.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/clocksource/mtk_timer.c +6 -10
@@ -141,14 +141,6 @@ static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } -static void mtk_timer_global_reset (struct mtk_clock_event_device *evt) -{ -/* Disable all interrupts */ -writel (0x0 , evt->gpt_base +GPT_IRQ_EN_REG ); -/* Acknowledge all interrupts */ -writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); -} -static void mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) {
@@ -168,6 +160,12 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) {u32 val; +/* Disable all interrupts */ +writel (0x0 , evt->gpt_base +GPT_IRQ_EN_REG ); + +/* Acknowledge all spurious pending interrupts */ +writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); + val =readl (evt->gpt_base +GPT_IRQ_EN_REG );writel (val |GPT_IRQ_ENABLE (timer), evt->gpt_base +GPT_IRQ_EN_REG );
@@ -220,8 +218,6 @@ static void __init mtk_timer_init(struct device_node *node) } rate =clk_get_rate (clk); -mtk_timer_global_reset (evt); -if (request_irq (evt->dev.irq, mtk_timer_interrupt,IRQF_TIMER |IRQF_IRQPOLL ,"mtk_timer" , evt)) {pr_warn ("failed to setup irq %d\n" , evt->dev.irq);
Signature · 1 line
1.9.1
PATCH 2/9 clocksource/drivers/mediatek: Use GPT as sched clock source
From: Yingjoe Chen <[email protected]>
When cpu is in deep idle, arch timer will stop counting. Setup GPT as sched clock source so it can keep counting in idle.
--- drivers/clocksource/mtk_timer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/clocksource/mtk_timer.c +10 -0
@@ -24,6 +24,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> +#include <linux/sched_clock.h> #include <linux/slab.h> #define GPT_IRQ_EN_REG 0x00
@@ -59,6 +60,13 @@ struct mtk_clock_event_device {struct clock_event_device dev; }; +static void __iomem *gpt_sched_reg__read_mostly ; + +static u64 notrace mtk_read_sched_clock(void) +{ +return readl_relaxed (gpt_sched_reg); +} +static inline struct mtk_clock_event_device *to_mtk_clk (struct clock_event_device *c) {
@@ -230,6 +238,8 @@ static void __init mtk_timer_init(struct device_node *node)mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN );clocksource_mmio_init (evt->gpt_base +TIMER_CNT_REG (GPT_CLK_SRC ), node->name, rate,300 ,32 , clocksource_mmio_readl_up); + gpt_sched_reg = evt->gpt_base +TIMER_CNT_REG (GPT_CLK_SRC ); +sched_clock_register (mtk_read_sched_clock,32 , rate);/* Configure clock event */ mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT );
Signature · 1 line
1.9.1
PATCH 6/9 clocksource/drivers/exynos_mct: Use container_of() instead of this_cpu_ptr()
In reply to Daniel LezcanoFrom: Alexey Klimov <[email protected]>
Since evt structure is embedded in per-CPU mevt structure it's definitely faster to use container_of() to get access to mevt if we have evt (for example as incoming function argument) instead of more expensive approach with this_cpu_ptr(&percpu_mct_tick). this_cpu_ptr() on per-CPU mevt structure leads to access to cp15 to get cpu id and arithmetic operations.Container_of() is cheaper since it's just one asm instruction. This should work if used evt pointer is correct and owned by local mevt structure.
For example, before this patch set_state_shutdown() looks like:
4a4: e92d4010 push {r4, lr}
4a8: e3004000 movw r4, #0
4ac: ebfffffe bl 0 <debug_smp_processor_id>
4b0: e3003000 movw r3, #0
4b4: e3404000 movt r4, #0
4b8: e3403000 movt r3, #0
4bc: e7933100 ldr r3, [r3, r0, lsl #2]
4c0: e0844003 add r4, r4, r3
4c4: e59400c0 ldr r0, [r4, #192] ; 0xc0
4c8: ebffffd4 bl 420 <exynos4_mct_tick_stop.isra.1>
4cc: e3a00000 mov r0, #0
4d0: e8bd8010 pop {r4, pc}
With this patch:
4a4: e92d4010 push {r4, lr}
4a8: e59000c0 ldr r0, [r0, #192] ; 0xc0
4ac: ebffffdb bl 420 <exynos4_mct_tick_stop.isra.1>
4b0: e3a00000 mov r0, #0
4b4: e8bd8010 pop {r4, pc}
Also, for me size of exynos_mct.o decreased from 84588 bytes to 83956.
--- drivers/clocksource/exynos_mct.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/clocksource/exynos_mct.c +8 -4
@@ -382,24 +382,28 @@ static void exynos4_mct_tick_start(unsigned long cycles,static int exynos4_tick_set_next_event (unsigned long cycles,struct clock_event_device *evt) { -struct mct_clock_event_device *mevt =this_cpu_ptr (&percpu_mct_tick); +struct mct_clock_event_device *mevt; + mevt = container_of(evt, struct mct_clock_event_device, evt);exynos4_mct_tick_start (cycles, mevt); -return 0 ; }static int set_state_shutdown (struct clock_event_device *evt) { -exynos4_mct_tick_stop (this_cpu_ptr (&percpu_mct_tick)); +struct mct_clock_event_device *mevt; + + mevt = container_of(evt, struct mct_clock_event_device, evt); +exynos4_mct_tick_stop (mevt);return 0 ; }static int set_state_periodic (struct clock_event_device *evt) { -struct mct_clock_event_device *mevt =this_cpu_ptr (&percpu_mct_tick); +struct mct_clock_event_device *mevt;unsigned long cycles_per_jiffy; + mevt = container_of(evt, struct mct_clock_event_device, evt); cycles_per_jiffy = (((unsigned long long )NSEC_PER_SEC /HZ * evt->mult) >> evt->shift);exynos4_mct_tick_stop (mevt);
Signature · 1 line
1.9.1
PATCH 4/9 clocksource/drivers/sh_cmt: Remove unneeded memset() in sh_cmt_setup()
In reply to Daniel LezcanoFrom: Alexey Klimov <[email protected]>
Memory for cmt struct is allocated by kzalloc() in sh_cmt_setup.
--- drivers/clocksource/sh_cmt.c | 1 - 1 file changed, 1 deletion(-)
drivers/clocksource/sh_cmt.c +0 -1
@@ -962,7 +962,6 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)unsigned int i;int ret; -memset (cmt,0 ,sizeof (*cmt)); cmt->pdev = pdev;raw_spin_lock_init (&cmt->lock);
Signature · 1 line
1.9.1
PATCH 8/9 clocksource/drivers/tango_xtal: Add new timer for Tango SoCs
In reply to Daniel LezcanoFrom: Marc Gonzalez <[email protected]>
Sigma Designs Tango platforms provide a 27 MHz crystal oscillator. Use it for clocksource, sched_clock, and delay_timer.
--- drivers/clocksource/Kconfig | 4 +++ drivers/clocksource/Makefile | 1 + drivers/clocksource/tango_xtal.c | 66 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 drivers/clocksource/tango_xtal.c
drivers/clocksource/Kconfig +4 -0
@@ -279,6 +279,10 @@ config CLKSRC_MIPS_GIC depends on MIPS_GIC select CLKSRC_OF +config CLKSRC_TANGO_XTAL + bool + select CLKSRC_OF + config CLKSRC_PXA def_bool y if ARCH_PXA || ARCH_SA1100 select CLKSRC_OF if OF
drivers/clocksource/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_ARCH_KEYSTONE) += timer-keystone.o obj-$(CONFIG_ARCH_INTEGRATOR_AP) += timer-integrator-ap.o obj-$(CONFIG_CLKSRC_VERSATILE) += versatile.o obj-$(CONFIG_CLKSRC_MIPS_GIC) += mips-gic-timer.o +obj-$(CONFIG_CLKSRC_TANGO_XTAL) += tango_xtal.o obj-$(CONFIG_CLKSRC_IMX_GPT) += timer-imx-gpt.o obj-$(CONFIG_ASM9260_TIMER) += asm9260_timer.o obj-$(CONFIG_H8300) += h8300_timer8.o
drivers/clocksource/tango_xtal.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 9/9 clocksource/drivers/armada-370-xp: Implement ARM delay timer
In reply to Daniel LezcanoFrom: Russell King <[email protected]>
Implement an ARM delay timer to be used for udelay() on Armada 37x platforms. This allows us to skip the delay loop calibration at boot, saving 180ms on the boot time of the kernel (which is around 10%).
It also means that udelay() will be unaffected by CPU frequency changes when cpufreq is enabled on these platforms.
--- drivers/clocksource/time-armada-370-xp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/clocksource/time-armada-370-xp.c +14 -0
@@ -45,6 +45,8 @@#include <linux/percpu.h> #include <linux/syscore_ops.h> +#include <asm/delay.h> +/* * Timer block registers. */
@@ -249,6 +251,15 @@ struct syscore_ops armada_370_xp_timer_syscore_ops = { .resume = armada_370_xp_timer_resume, }; +static unsigned long armada_370_delay_timer_read (void ) +{ +return ~readl (timer_base +TIMER0_VAL_OFF ); +} + +static struct delay_timer armada_370_delay_timer = { + .read_current_timer = armada_370_delay_timer_read, +}; +static void __init armada_370_xp_timer_common_init (struct device_node *np) {u32 clr =0 , set =0 ;
@@ -287,6 +298,9 @@ static void __init armada_370_xp_timer_common_init(struct device_node *np)TIMER0_RELOAD_EN | enable_mask, TIMER0_RELOAD_EN | enable_mask); + armada_370_delay_timer.freq = timer_clk; +register_current_timer_delay (&armada_370_delay_timer); +/* * Set scale and timer for sched_clock. */
Signature · 1 line
1.9.1
PATCH 7/9 clocksource/drivers/imx: Allow timer irq affinity change
In reply to Daniel LezcanoFrom: Lucas Stach <[email protected]>
Allow the timer core to change the smp affinity of the broadcast timer irq by setting CLOCK_EVT_FEAT_DYNIRQ flag. For this to work the timer core needs to be told about the used irq.
This reduces interrupt pressure and wakeups on CPU0 as well as vastly reducing the number of timer broadcast IPIs.
--- drivers/clocksource/timer-imx-gpt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-imx-gpt.c +2 -1
@@ -305,13 +305,14 @@ static int __init mxc_clockevent_init(struct imx_timer *imxtm)struct irqaction *act = &imxtm->act; ced->name ="mxc_timer1" ; - ced->features =CLOCK_EVT_FEAT_ONESHOT ; + ced->features =CLOCK_EVT_FEAT_ONESHOT |CLOCK_EVT_FEAT_DYNIRQ ; ced->set_state_shutdown = mxc_shutdown; ced->set_state_oneshot = mxc_set_oneshot; ced->tick_resume = mxc_shutdown; ced->set_next_event = imxtm->gpt->set_next_event; ced->rating =200 ; ced->cpumask =cpumask_of (0 ); + ced->irq = imxtm->irq;clockevents_config_and_register (ced,clk_get_rate (imxtm->clk_per),0xff ,0xfffffffe );
Signature · 1 line
1.9.1
PATCH 5/9 clocksource/drivers/h8300_*: Remove unneeded memset()s
In reply to Daniel LezcanoFrom: Alexey Klimov <[email protected]>
Memory for timer16_priv, timer8_priv and tpu_priv structs is allocated by devm_kzalloc() in corresponding probe functions of drivers.
No need to zero it one more time.
--- drivers/clocksource/h8300_timer16.c | 1 - drivers/clocksource/h8300_timer8.c | 1 - drivers/clocksource/h8300_tpu.c | 1 - 3 files changed, 3 deletions(-)
drivers/clocksource/h8300_timer16.c +0 -1
@@ -153,7 +153,6 @@ static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev)int ret, irq;unsigned int ch; -memset (p,0 ,sizeof (*p)); p->pdev = pdev; res[REG_CH] = platform_get_resource(p->pdev,
drivers/clocksource/h8300_timer8.c +0 -1
@@ -215,7 +215,6 @@ static int timer8_setup(struct timer8_priv *p,int irq;int ret; -memset (p,0 ,sizeof (*p)); p->pdev = pdev; res =platform_get_resource (p->pdev,IORESOURCE_MEM ,0 );
drivers/clocksource/h8300_tpu.c +0 -1
@@ -123,7 +123,6 @@ static int __init tpu_setup(struct tpu_priv *p, struct platform_device *pdev) {struct resource *res[2 ]; -memset (p,0 ,sizeof (*p)); p->pdev = pdev; res[CH_L ] =platform_get_resource (p->pdev,IORESOURCE_MEM ,CH_L );
Signature · 1 line
1.9.1
PATCH 3/9 clocksource/drivers/em_sti: Remove unneeded memset()s
In reply to Daniel LezcanoFrom: Alexey Klimov <[email protected]>
Memory for cs and ced fields in struct em_sti_priv is allocated by devm_kzalloc() in the beginning of em_sti_probe() so they don't need to be zeroed one more time in em_sti_register_clocksource() and in em_sti_register_clockevent().
--- drivers/clocksource/em_sti.c | 2 -- 1 file changed, 2 deletions(-)
drivers/clocksource/em_sti.c +0 -2
@@ -228,7 +228,6 @@ static int em_sti_register_clocksource(struct em_sti_priv *p) {struct clocksource *cs = &p->cs; -memset (cs,0 ,sizeof (*cs)); cs->name =dev_name (&p->pdev->dev); cs->rating =200 ; cs->read = em_sti_clocksource_read;
@@ -285,7 +284,6 @@ static void em_sti_register_clockevent(struct em_sti_priv *p) {struct clock_event_device *ced = &p->ced; -memset (ced,0 ,sizeof (*ced)); ced->name =dev_name (&p->pdev->dev); ced->features =CLOCK_EVT_FEAT_ONESHOT ; ced->rating =200 ;
Signature · 1 line
1.9.1
Re: [PATCH 5/9] clocksource/drivers/h8300_*: Remove unneeded memset()s
In reply to Daniel LezcanoQuoted 10 lines · Daniel Lezcano
From: Alexey Klimov <[email protected]>
Memory for
timer16_priv,timer8_privandtpu_privstructs is allocated bydevm_kzalloc()in corresponding probe functions of drivers.
No need to zero it one more time.Signed-off-by Alexey Klimov <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>
Quoted 45 lines
--- drivers/clocksource/h8300_timer16.c | 1 - drivers/clocksource/h8300_timer8.c | 1 - drivers/clocksource/h8300_tpu.c | 1 - 3 files changed, 3 deletions(-)drivers/clocksource/h8300_timer16.c +0
-1@@ -153,7 +153,6 @@ static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev)int ret, irq;unsigned int ch; -memset (p,0 ,sizeof (*p)); p->pdev = pdev; res[REG_CH] = platform_get_resource(p->pdev,drivers/clocksource/h8300_timer8.c +0
-1@@ -215,7 +215,6 @@ static int timer8_setup(struct timer8_priv *p,int irq;int ret; -memset (p,0 ,sizeof (*p)); p->pdev = pdev; res =platform_get_resource (p->pdev,IORESOURCE_MEM ,0 );drivers/clocksource/h8300_tpu.c +0
-1@@ -123,7 +123,6 @@ static int __init tpu_setup(struct tpu_priv *p, struct platform_device *pdev) {struct resource *res[2 ]; -memset (p,0 ,sizeof (*p)); p->pdev = pdev; res[CH_L ] =platform_get_resource (p->pdev,IORESOURCE_MEM ,CH_L );Signature · 1 line
1.9.1
Re: [PATCH 1/9] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
In reply to Daniel Lezcano2015-10-19 22:59 GMT+02:00 Daniel Lezcano <[email protected]>:
Quoted 8 lines
After analysis done by Yingjoe Chen, the timer appears to have a pending interrupt when it is enabled.
Fix this by acknowledging the pending interrupt when enabling the timer interrupt.
Signed-off-by Daniel Lezcano <[email protected]>Tested-by Yingjoe Chen <[email protected]>
Quoted 48 lines
--- drivers/clocksource/mtk_timer.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)drivers/clocksource/mtk_timer.c +6
-11@@ -141,14 +141,6 @@ static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } -static void mtk_timer_global_reset (struct mtk_clock_event_device *evt) -{ -/* Disable all interrupts */ -writel (0x0 , evt->gpt_base +GPT_IRQ_EN_REG ); -/* Acknowledge all interrupts */ -writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); -} -static void mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) {@@ -168,6 +160,12 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) {u32 val; +/* Disable all interrupts */ +writel (0x0 , evt->gpt_base +GPT_IRQ_EN_REG ); + +/* Acknowledge all spurious pending interrupts */ +writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); + val =readl (evt->gpt_base +GPT_IRQ_EN_REG );writel (val |GPT_IRQ_ENABLE (timer), evt->gpt_base +GPT_IRQ_EN_REG );@@ -220,8 +218,6 @@ static void __init mtk_timer_init(struct device_node *node) } rate =clk_get_rate (clk); -mtk_timer_global_reset (evt); -if (request_irq (evt->dev.irq, mtk_timer_interrupt,IRQF_TIMER |IRQF_IRQPOLL ,"mtk_timer" , evt)) {pr_warn ("failed to setup irq %d\n" , evt->dev.irq); --1.9.1
Signature · 1 line
motzblog.wordpress.com