add GPT timer support for mt8173
Subsystems (5)
cover add GPT timer support for mt8173
This series add GPT timer support for mt8173. This is based on v4.2-rc1 and Matthias' next branch (for dts parts).
The first 2 patches comes from 'Add SMP bringup support for mt65xx socs' series [1]. I decide to move these 2 patches to this series, since it is more relevent here. They are changed based on Matthias' and Daniel's comments.
[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000714.html
Daniel Kurtz (1):
arm64: dts: mt8173: add timer node
Yingjoe Chen (4):
clocksource: mediatek: do not enable GPT_CLK_EVT when setup
clocksource: mediatek: Use GPT as sched clock source
arm64: mediatek: enable MTK_TIMER
clk: mediatek: add 13mhz clock for MT8173
arch/arm64/Kconfig | 1 + arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ drivers/clk/mediatek/clk-mt8173.c | 5 +++++ drivers/clocksource/mtk_timer.c | 26 ++++++++++++++++++++------ include/dt-bindings/clock/mt8173-clk.h | 3 ++- 5 files changed, 37 insertions(+), 7 deletions(-)
PATCH 1/5 clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enable GPT_CLK_SRC at mtk_timer_init.
--- drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/clocksource/mtk_timer.c +10 -6
@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer, +u8 option,bool enable) { +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));
@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer)); }static void mtk_timer_enable_irq (struct mtk_clock_event_device *evt,u8 timer)
@@ -235,12 +239,12 @@ static void __init mtk_timer_init(struct device_node *node) evt->ticks_per_jiffy =DIV_ROUND_UP (rate,HZ );/* Configure clock source */ -mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN ); +mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN , true);clocksource_mmio_init (evt->gpt_base +TIMER_CNT_REG (GPT_CLK_SRC ), node->name, rate,300 ,32 , clocksource_mmio_readl_up);/* Configure clock event */ -mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT ); +mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT , false);clockevents_config_and_register (&evt->dev, rate,0x3 ,0xffffffff );
Signature · 1 line
1.8.1.1.dirty
Re: [PATCH 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Hi Yingjoe,
Quoted 16 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enableGPT_CLK_SRCatmtk_timer_init.Signed-off-by Yingjoe Chen <[email protected]>--- drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/clocksource/mtk_timer.c +0
-0
drivers/clocksource/mtk_timer.c static void mtk_timer_global_reset(struct mtk_clock_event_device *evt) · line 160
Quoted 7 lines
drivers/clocksource/mtk_timer.c +2
-2@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer, +u8 option,bool enable)
This function can be: __init
Other than this tiny nit, and the small potential conflict in patch 4, this whole series is:
(I do think it is a bit strange that the mediatek,mt6577-timer binding does not use "clock-names", but that is independent of this patch set).
Thanks!
Quoted 37 lines
drivers/clocksource/mtk_timer.c +8
-5{ +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer)); }static void mtk_timer_enable_irq (struct mtk_clock_event_device *evt,u8 timer)@@ -235,12 +239,12 @@ static void __init mtk_timer_init(struct device_node *node) evt->ticks_per_jiffy =DIV_ROUND_UP (rate,HZ );/* Configure clock source */ -mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN ); +mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN , true);clocksource_mmio_init (evt->gpt_base +TIMER_CNT_REG (GPT_CLK_SRC ), node->name, rate,300 ,32 , clocksource_mmio_readl_up);/* Configure clock event */ -mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT ); +mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT , false);clockevents_config_and_register (&evt->dev, rate,0x3 ,0xffffffff ); --1.8.1.1.dirty
PATCH v2 1/5 clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enable GPT_CLK_SRC at mtk_timer_init.
---
Update to my patch [1], added __init as Daniel suggest. This is the only patch that need to change in that series, so I only sent this one.
http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001545.html
drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/clocksource/mtk_timer.c +10 -6
@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void __init mtk_timer_setup (struct mtk_clock_event_device *evt, +u8 timer,u8 option,bool enable) { +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));
@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer)); }static void mtk_timer_enable_irq (struct mtk_clock_event_device *evt,u8 timer)
@@ -235,12 +239,12 @@ static void __init mtk_timer_init(struct device_node *node) evt->ticks_per_jiffy =DIV_ROUND_UP (rate,HZ );/* Configure clock source */ -mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN ); +mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN , true);clocksource_mmio_init (evt->gpt_base +TIMER_CNT_REG (GPT_CLK_SRC ), node->name, rate,300 ,32 , clocksource_mmio_readl_up);/* Configure clock event */ -mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT ); +mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT , false);clockevents_config_and_register (&evt->dev, rate,0x3 ,0xffffffff );
Signature · 1 line
1.8.1.1.dirty
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Quoted 6 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enableGPT_CLK_SRCatmtk_timer_init.
Quoted 8 lines
Acked-by Matthias Brugger <[email protected]>Reviewed-by Daniel Kurtz <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>---
Update to my patch [1], added__initas Daniel suggest. This is the only patch that need to change in that series, so I only sent this one.http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001545.html
Hi Daniel, Thomas,
Any suggestions for mtk_timer fixes in this series? Should I resend and add tags from the reviewers?
Joe.C
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
In reply to Yingjoe ChenQuoted 38 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enableGPT_CLK_SRCatmtk_timer_init.Acked-by Matthias Brugger <[email protected]>Reviewed-by Daniel Kurtz <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>---
Update to my patch [1], added
__initas Daniel suggest. This is the only patch that need to change in that series, so I only sent this one.http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001545.html
drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/clocksource/mtk_timer.c +4
-2@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void __init mtk_timer_setup (struct mtk_clock_event_device *evt, +u8 timer,u8 option,bool enable) { +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));
drivers/clocksource/mtk_timer.c mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option) · line 175
Quoted 9 lines
drivers/clocksource/mtk_timer.c +4
-2@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer));
Instead of the 'enable' new option, I prefer a test with 'timer' with a comment:
/* * the timer hw is broken in that way ... bla bla, so we only * enable the clocksource ... */ if (timer == GPT_CLK_SRC) val |= TIMER_CTRL_ENABLE;
That said, can you have a look at commit 1096be08 ? "clockevents: sun5i: Fix setup_irq init sequence"
first and check if moving the interrupt request after the clockevents_config_and_register could fix your issue.
Quoted 17 lines
drivers/clocksource/mtk_timer.c +2
-2}static void mtk_timer_enable_irq (struct mtk_clock_event_device *evt,u8 timer)@@ -235,12 +239,12 @@ static void __init mtk_timer_init(struct device_node *node) evt->ticks_per_jiffy =DIV_ROUND_UP (rate,HZ );/* Configure clock source */ -mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN ); +mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN , true);clocksource_mmio_init (evt->gpt_base +TIMER_CNT_REG (GPT_CLK_SRC ), node->name, rate,300 ,32 , clocksource_mmio_readl_up);/* Configure clock event */ -mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT ); +mtk_timer_setup (evt,GPT_CLK_EVT ,TIMER_CTRL_OP_REPEAT , false);clockevents_config_and_register (&evt->dev, rate,0x3 ,0xffffffff );
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
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Quoted 52 lines · Daniel Lezcano
Quoted 38 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enableGPT_CLK_SRCatmtk_timer_init.Acked-by Matthias Brugger <[email protected]>Reviewed-by Daniel Kurtz <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>---
Update to my patch [1], added
__initas Daniel suggest. This is the only patch that need to change in that series, so I only sent this one.http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001545.html
drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/clocksource/mtk_timer.c +4
-2@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void __init mtk_timer_setup (struct mtk_clock_event_device *evt, +u8 timer,u8 option,bool enable) { +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));drivers/clocksource/mtk_timer.c mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option) · line 175
Quoted 9 lines
drivers/clocksource/mtk_timer.c +4
-2@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer));Instead of the 'enable' new option, I prefer a test with 'timer' with a comment:
Quoted 6 lines
/* * the timer hw is broken in that way ... bla bla, so we only * enable the clocksource ... */ if (timer == GPT_CLK_SRC) val |= TIMER_CTRL_ENABLE;
Hi Daniel,
Thanks for your review.
Since this bug happens to anyone using interrupt, I'm not sure checking timer and only enable it for GPT_CLK_SRC is easier to read. Anyway, I'll change to this in next version.
Quoted 5 lines
That said, can you have a look at commit
1096be08? "clockevents: sun5i: Fixsetup_irqinit sequence"first and check if moving the interrupt request after the
clockevents_config_and_registercould fix your issue.
I've tested this before, see:
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000539.html
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000551.html
Joe.C
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Quoted 5 lines · Yingjoe Chen
Quoted 4 lines · Daniel Lezcano
Quoted 3 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled.
It "seems" ?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
When irq is enabled afterward, we see
spurious interrupt.
Doesn't have the firmware something to do with that ?
I have a mtk 8173 board I can use next week. How do you reproduce the issue ?
Quoted 54 lines
Quoted 47 lines
Quoted 34 lines
Change init flow to only enable
GPT_CLK_SRCatmtk_timer_init.Acked-by Matthias Brugger <[email protected]>Reviewed-by Daniel Kurtz <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>---
Update to my patch [1], added
__initas Daniel suggest. This is the only patch that need to change in that series, so I only sent this one.http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001545.html
drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/clocksource/mtk_timer.c +4
-2@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void __init mtk_timer_setup (struct mtk_clock_event_device *evt, +u8 timer,u8 option,bool enable) { +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));drivers/clocksource/mtk_timer.c mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option) · line 175
Quoted 9 lines
drivers/clocksource/mtk_timer.c +4
-2@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer));Instead of the 'enable' new option, I prefer a test with 'timer' with a comment:
Quoted 6 lines
/* * the timer hw is broken in that way ... bla bla, so we only * enable the clocksource ... */ if (timer == GPT_CLK_SRC) val |= TIMER_CTRL_ENABLE;
Quoted 4 lines
Hi Daniel,
Thanks for your review.
Since this bug happens to anyone using interrupt,
Can you elaborate ? I don't get the point.
Quoted 6 lines
I'm not sure checking
timer and only enable it forGPT_CLK_SRCis easier to read. Anyway, I'll change to this in next version.Quoted 3 lines
That said, can you have a look at commit
1096be08? "clockevents: sun5i: Fixsetup_irqinit sequence"
Quoted 7 lines
Quoted 2 lines
first and check if moving the interrupt request after the
clockevents_config_and_registercould fix your issue.I've tested this before, see:
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000539.html
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000551.html
I could take or ack this patch trusting it fixes the issue but there are some points that need clarifications.
- Does the spurious interrupt occurs *every* time ? at each boot ?
The previous patches were supposed to fix the issue but they actually didn't. So how is tested the patch ?
Regarding the different fixes for this problem, it sounds like you are proceeding by trial and error.
Please give a more detailed analysis of the problem and especially check the timer is not altered by the firmware leaving it in a transient state or whatever.
-- Daniel
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
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Quoted 8 lines · Daniel Lezcano
Quoted 5 lines · Yingjoe Chen
Quoted 4 lines · Daniel Lezcano
Quoted 3 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled.
It "seems" ?
Hi,
Datasheet doesn't mention detail. So I did some experiments, playing around with registers. Based on my observation, I think this is what happens:
For each GPT timer, it has ENABLE, IRQ_EN, IRQ status, IRQ_ACK, counter & compare.
When mtk_timer_init calls mtk_timer_setup to setup GPT_CLK_EVT, it enable the timer but didn't set counter or compare. Both counter & compare is zero on reset, so GPT immediately raise IRQ status. IRQ_EN is still disabled now, so it didn't trigger interrupt right away.
At end of mtk_timer_init, it calls mtk_timer_enable_irq to enable irq. Since IRQ status is 1 now, GPT trigger interrupt immediately. The interrupt is serviced by mtk_timer_interrupt. Since this is not an expected event, evt->dev.event_handler will be NULL and system crashed in the handler.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
When irq is enabled afterward, we see
spurious interrupt.Doesn't have the firmware something to do with that ?
We have 6 GPT on mt8173, mtk timer use 2 of them. The spurious interrupt only happens on GPT_CLK_EVT (GPT1). Our firmware didn't touch that one, so it is in reset default when mtk timer driver try to enable it.
Quoted 75 lines
I have a mtk 8173 board I can use next week. How do you reproduce the issue ?
Quoted 54 lines
Quoted 47 lines
Quoted 34 lines
Change init flow to only enable
GPT_CLK_SRCatmtk_timer_init.Acked-by Matthias Brugger <[email protected]>Reviewed-by Daniel Kurtz <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>---
Update to my patch [1], added
__initas Daniel suggest. This is the only patch that need to change in that series, so I only sent this one.http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001545.html
drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/clocksource/mtk_timer.c +4
-2@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void __init mtk_timer_setup (struct mtk_clock_event_device *evt, +u8 timer,u8 option,bool enable) { +u32 val; +writel (TIMER_CTRL_CLEAR |TIMER_CTRL_DISABLE , evt->gpt_base +TIMER_CTRL_REG (timer));drivers/clocksource/mtk_timer.c mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option) · line 175
Quoted 9 lines
drivers/clocksource/mtk_timer.c +4
-2@@ -167,8 +169,10 @@ mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)writel (0x0 , evt->gpt_base +TIMER_CMP_REG (timer)); -writel (TIMER_CTRL_OP (option) |TIMER_CTRL_ENABLE , - evt->gpt_base +TIMER_CTRL_REG (timer)); + val =TIMER_CTRL_OP (option); +if (enable) + val |=TIMER_CTRL_ENABLE ; +writel (val, evt->gpt_base +TIMER_CTRL_REG (timer));Instead of the 'enable' new option, I prefer a test with 'timer' with a comment:
Quoted 6 lines
/* * the timer hw is broken in that way ... bla bla, so we only * enable the clocksource ... */ if (timer == GPT_CLK_SRC) val |= TIMER_CTRL_ENABLE;Quoted 4 lines
Hi Daniel,
Thanks for your review.
Since this bug happens to anyone using interrupt,Can you elaborate ? I don't get the point.
Quoted 11 lines
I'm not sure checking
timer and only enable it forGPT_CLK_SRCis easier to read. Anyway, I'll change to this in next version.Quoted 5 lines
That said, can you have a look at commit
1096be08? "clockevents: sun5i: Fixsetup_irqinit sequence"first and check if moving the interrupt request after the
clockevents_config_and_registercould fix your issue.I've tested this before, see:
Quoted 7 lines
Quoted 2 lines
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000539.html
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000551.htmlI could take or ack this patch trusting it fixes the issue but there are some points that need clarifications.
- Does the spurious interrupt occurs *every* time ? at each boot ?
Yes. If you applied this series to enable mtk timer without this fix on mt8173 or mt8135 you can reproduce it. It occurs for every boot.
It crash before uart driver is ready, so you'll have to use earlycon to see the crash log.
Quoted 2 lines
The previous patches were supposed to fix the issue but they actually didn't. So how is tested the patch ?
I'm not sure. I believe Matthias test that one on mt6589, maybe it have different behavior, or different timing.
Quoted 6 lines
Regarding the different fixes for this problem, it sounds like you are proceeding by trial and error.
Please give a more detailed analysis of the problem and especially check the timer is not altered by the firmware leaving it in a transient state or whatever.
See above for my analysis.
Thanks.
Joe.C
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
On 08/21/2015 04:39 PM, Yingjoe Chen wrote:
[ ... ]
Quoted 7 lines
Quoted 1 line
- Does the spurious interrupt occurs *every* time ? at each boot ?
Yes. If you applied this series to enable mtk timer without this fix on mt8173 or mt8135 you can reproduce it. It occurs for every boot.
It crash before uart driver is ready, so you'll have to use earlycon to see the crash log.
Can you give me the earlycon params ?
Thanks.
-- Daniel
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
Re: [PATCH v2 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
Quoted 6 lines · Daniel Lezcano
On 08/21/2015 04:39 PM, Yingjoe Chen wrote:
[ ... ]
Quoted 2 lines
Quoted 1 line
- Does the spurious interrupt occurs *every* time ? at each boot ?
Quoted 7 lines
Quoted 5 lines
Yes. If you applied this series to enable mtk timer without this fix on mt8173 or mt8135 you can reproduce it. It occurs for every boot.
It crash before uart driver is ready, so you'll have to use earlycon to see the crash log.
Can you give me the earlycon params ?
Hi Daniel,
You probably already figure this out. anyway I'm using this to enable earlycon:
Add 'earlycon' in bootargs, and in device tree chosen part, add "linux,stdout-path=&uart0;"
Joe.C
PATCH 1/1 clockevents/drivers/mtk: Fix spurious interrupt leading to crash
In reply to Yingjoe ChenAfter 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 | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/clocksource/mtk_timer.c +3 -10
@@ -156,14 +156,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) {
@@ -183,6 +175,9 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) {u32 val; +/* 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 );
@@ -232,8 +227,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
Re: [PATCH] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 7 lines · Daniel Lezcano
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]>
Hi Daniel,
Thanks for your patch, this can fix the boot issue.
Quoted 24 lines
--- drivers/clocksource/mtk_timer.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/clocksource/mtk_timer.c +0
-8@@ -156,14 +156,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) {
drivers/clocksource/mtk_timer.c static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) · line 179
Quoted 5 lines
drivers/clocksource/mtk_timer.c +2
-0@@ -183,6 +175,9 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer) {u32 val; +/* Acknowledge all spurious pending interrupts */ +writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG );
This should use tab to indent.
drivers/clocksource/mtk_timer.c static void __init mtk_timer_init(struct device_node *node) · line 236
Quoted 10 lines
drivers/clocksource/mtk_timer.c +1
-2+ val =readl (evt->gpt_base +GPT_IRQ_EN_REG );writel (val |GPT_IRQ_ENABLE (timer), evt->gpt_base +GPT_IRQ_EN_REG );@@ -232,8 +227,6 @@ static void __init mtk_timer_init(struct device_node *node) } rate =clk_get_rate (clk); -mtk_timer_global_reset (evt); -
I think we should keep this one, or at least disable irq first in mtk_timer_enable_irq. MT8173 firmware didn't use this GPT, but I think it is a good ideat to do it just in case firmware in some other platform use it.
Joe.C
PATCH v2 1/1 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
@@ -156,14 +156,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) {
@@ -183,6 +175,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 );
@@ -232,8 +230,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
Re: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 44 lines · Daniel Lezcano
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]>--- drivers/clocksource/mtk_timer.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)drivers/clocksource/mtk_timer.c +6
-8@@ -156,14 +156,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) {@@ -183,6 +175,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 );
drivers/clocksource/mtk_timer.c static void __init mtk_timer_init(struct device_node *node) · line 235
Quoted 8 lines
drivers/clocksource/mtk_timer.c +0
-2@@ -232,8 +230,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);
Hi Daniel,
Thanks for your patch, tested on mt8173
Joe.C
Daniel Lezcano
AppliedRe: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 1 line · Yingjoe Chen
Tested-by Yingjoe Chen<[email protected]>
Applied to my tree for 4.4.
-- Daniel
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
Re: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 7 lines · Daniel Lezcano
Quoted 1 line · Yingjoe Chen
Tested-by Yingjoe Chen<[email protected]>Applied to my tree for 4.4.
-- Daniel
Hi Daniel,
I can't find this patch in
https://git.linaro.org/people/daniel.lezcano/linux.git
Is this tree public now? Where can I see it?
Also, will you take patch[1] "clocksource: mediatek: Use GPT as sched clock source" in your tree?
Joe.C
[1]:
http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001547.html
Re: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 9 lines · Yingjoe Chen
Quoted 7 lines · Daniel Lezcano
Quoted 1 line · Yingjoe Chen
Tested-by Yingjoe Chen<[email protected]>Applied to my tree for 4.4.
-- Daniel
Quoted 8 lines
Hi Daniel,
I can't find this patch in
https://git.linaro.org/people/daniel.lezcano/linux.git
Is this tree public now? Where can I see it?Also, will you take patch[1] "clocksource: mediatek: Use GPT as sched clock source" in your tree?
Yep. I did not push my branch. Done.
Note it will be also available for linux-next.
Thanks for the head up.
-- Daniel
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
Matthias Brugger
maintainerRe: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
In reply to Daniel LezcanoHi Daniel,
Quoted 7 lines · Daniel Lezcano
Quoted 1 line · Yingjoe Chen
Tested-by Yingjoe Chen<[email protected]>Applied to my tree for 4.4.
-- Daniel
Kevin found a regression in v4.3 which will need this patch to fix it [1]. Can you apply it to your clockevents/4.3-fixes branch please.
Thanks,
Matthias
Re: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 11 lines · Matthias Brugger
Hi Daniel,
Quoted 7 lines · Daniel Lezcano
Quoted 1 line · Yingjoe Chen
Tested-by Yingjoe Chen<[email protected]>Applied to my tree for 4.4.
-- Daniel
Quoted 7 lines
Kevin found a regression in v4.3 which will need this patch to fix it [1]. Can you apply it to your clockevents/4.3-fixes branch please.
Thanks,
Matthias
Hmm, I thought it wasn't impacting 4.3, so it went to 4.4.
Let me look how to backport this fix without introducing a conflict when tip/timers/urgent will be merged to tip/timers/core.
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
Re: [PATCH V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash
Quoted 18 lines · Daniel Lezcano
Quoted 17 lines · Matthias Brugger
Hi Daniel,
Quoted 7 lines · Daniel Lezcano
Quoted 1 line · Yingjoe Chen
Tested-by Yingjoe Chen<[email protected]>Applied to my tree for 4.4.
-- Daniel
Kevin found a regression in v4.3 which will need this patch to fix it [1]. Can you apply it to your clockevents/4.3-fixes branch please.
Thanks,
Matthias
Quoted 6 lines
Quoted 1 line
Hmm, I thought it wasn't impacting 4.3, so it went to 4.4.
Let me look how to backport this fix without introducing a conflict when tip/timers/urgent will be merged to tip/timers/core.
Thomas,
do you think I can cherry-pick from tip/timers/core or clockevents/4.4 directly the fix to be pulled into clockevents/4.3-fixes ? That will certainly raise a conflict when tip/timers/urgent will be merged to tip/timers/core (a trivial conflict actually).
-- Daniel
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
Re: [PATCH 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
In reply to Daniel KurtzQuoted 29 lines · Daniel Kurtz
Hi Yingjoe,
Quoted 16 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enableGPT_CLK_SRCatmtk_timer_init.Signed-off-by Yingjoe Chen <[email protected]>--- drivers/clocksource/mtk_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/clocksource/mtk_timer.c +0
-0drivers/clocksource/mtk_timer.c static void mtk_timer_global_reset(struct mtk_clock_event_device *evt) · line 160
Quoted 7 lines
drivers/clocksource/mtk_timer.c +2
-2@@ -156,9 +156,11 @@ static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)writel (0x3f , evt->gpt_base +GPT_IRQ_ACK_REG ); } -static void -mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer,u8 option) +static void mtk_timer_setup (struct mtk_clock_event_device *evt,u8 timer, +u8 option,bool enable)This function can be:
__init
Quoted 9 lines
Other than this tiny nit, and the small potential conflict in patch 4, this whole series is:
Reviewed-by Daniel Kurtz <[email protected]>(I do think it is a bit strange that the mediatek,mt6577-timer binding does not use "clock-names", but that is independent of this patch set).
Hi Daniel,
Thanks for your review.
I added __init as you suggested, and Pi-Cheng already sent an updated version of his patch to resolve the conflict[1].
Joe.C
[1]
http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001592.html
Re: [PATCH 1/5] clocksource: mediatek: do not enable GPT_CLK_EVT when setup
In reply to Yingjoe ChenQuoted 8 lines · Yingjoe Chen
Spurious mtk timer interrupt is noticed at boot and cause kernel crash. It seems if GPT is enabled, it will latch irq status even when its IRQ is disabled. When irq is enabled afterward, we see spurious interrupt.
Change init flow to only enableGPT_CLK_SRCatmtk_timer_init.Signed-off-by Yingjoe Chen <[email protected]>---
PATCH 2/5 clocksource: mediatek: Use GPT as sched clock source
In reply to Yingjoe ChenWhen 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) {
@@ -242,6 +250,8 @@ static void __init mtk_timer_init(struct device_node *node)mtk_timer_setup (evt,GPT_CLK_SRC ,TIMER_CTRL_OP_FREERUN , true);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 , false);
Signature · 1 line
1.8.1.1.dirty
Re: [PATCH 2/5] clocksource: mediatek: Use GPT as sched clock source
Quoted 5 lines · Yingjoe Chen
When cpu is in deep idle, arch timer will stop counting. Setup GPT as sched clock source so it can keep counting in idle.
Signed-off-by Yingjoe Chen <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/5] clocksource: mediatek: Use GPT as sched clock source
In reply to Yingjoe ChenQuoted 5 lines · Yingjoe Chen
When cpu is in deep idle, arch timer will stop counting. Setup GPT as sched clock source so it can keep counting in idle.
Signed-off-by Yingjoe Chen <[email protected]>---
PATCH 3/5 arm64: mediatek: enable MTK_TIMER
In reply to Yingjoe ChenEnable MTK_TIMER for MediaTek plaform, which will be used as schedule clock.
--- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -193,6 +193,7 @@ config ARCH_MEDIATEK bool "Mediatek MT65xx & MT81xx ARMv8 SoC" select ARM_GIC select PINCTRL + select MTK_TIMER help Support for Mediatek MT65xx & MT81xx ARMv8 SoCs
Signature · 1 line
1.8.1.1.dirty
Re: [PATCH 3/5] arm64: mediatek: enable MTK_TIMER
Quoted 5 lines · Yingjoe Chen
Enable
MTK_TIMERfor MediaTek plaform, which will be used as schedule clock.Signed-off-by Yingjoe Chen <[email protected]>---
Applied, thanks.
Re: [PATCH 3/5] arm64: mediatek: enable MTK_TIMER
Quoted 8 lines · Matthias Brugger
Quoted 5 lines · Yingjoe Chen
Enable
MTK_TIMERfor MediaTek plaform, which will be used as schedule clock.Signed-off-by Yingjoe Chen <[email protected]>---
Applied, thanks.
So you enable the current code w/o the modifications required for this to work?
Thanks,
tglx
Matthias Brugger
maintainerRe: [PATCH 3/5] arm64: mediatek: enable MTK_TIMER
Quoted 5 lines · Thomas Gleixner
Quoted 4 lines · Matthias Brugger
Quoted 3 lines · Yingjoe Chen
Enable
MTK_TIMERfor MediaTek plaform, which will be used as schedule clock.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Yingjoe Chen <[email protected]>---
Applied, thanks.
So you enable the current code w/o the modifications required for this to work?
Well as the timer is not defined in dts it should not break the board... But yes you are right, I will drop this commit for now.
Thanks,
Matthias
PATCH 4/5 clk: mediatek: add 13mhz clock for MT8173
In reply to Yingjoe ChenAdd 13mhz clock used by GPT timer in infracfg.
--- drivers/clk/mediatek/clk-mt8173.c | 5 +++++ include/dt-bindings/clock/mt8173-clk.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mt8173.c +5 -0
@@ -618,6 +618,10 @@ static const struct mtk_gate infra_clks[] __initconst = { GATE_ICG(CLK_INFRA_PMICWRAP, "infra_pmicwrap", "axi_sel", 23), }; +static const struct mtk_fixed_factor infra_divs[]__initconst = { +FACTOR (CLK_INFRA_CLK_13M ,"clk13m" ,"clk26m" ,1 ,2 ), +}; +static const struct mtk_gate_regs peri0_cg_regs = { .set_ofs =0x0008 , .clr_ofs =0x0010 ,
@@ -737,6 +741,7 @@ static void __init mtk_infrasys_init(struct device_node *node)mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data); +mtk_clk_register_factors (infra_divs,ARRAY_SIZE (infra_divs), clk_data); r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r)
include/dt-bindings/clock/mt8173-clk.h +2 -1
@@ -187,7 +187,8 @@#define CLK_INFRA_CEC 9#define CLK_INFRA_PMICSPI 10#define CLK_INFRA_PMICWRAP 11 -#define CLK_INFRA_NR_CLK 12 +#define CLK_INFRA_CLK_13M 12 +#define CLK_INFRA_NR_CLK 13/* PERI_SYS */
Signature · 1 line
1.8.1.1.dirty
Re: [PATCH 4/5] clk: mediatek: add 13mhz clock for MT8173
Quoted 4 lines · Yingjoe Chen
Add 13mhz clock used by GPT timer in infracfg.
Signed-off-by Yingjoe Chen <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 4/5] clk: mediatek: add 13mhz clock for MT8173
In reply to Yingjoe ChenQuoted 36 lines · Yingjoe Chen
Add 13mhz clock used by GPT timer in infracfg.
Signed-off-by Yingjoe Chen <[email protected]>--- drivers/clk/mediatek/clk-mt8173.c | 5 +++++ include/dt-bindings/clock/mt8173-clk.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)drivers/clk/mediatek/clk-mt8173.c +5
-0@@ -618,6 +618,10 @@ static const struct mtk_gate infra_clks[] __initconst = { GATE_ICG(CLK_INFRA_PMICWRAP, "infra_pmicwrap", "axi_sel", 23), }; +static const struct mtk_fixed_factor infra_divs[]__initconst = { +FACTOR (CLK_INFRA_CLK_13M ,"clk13m" ,"clk26m" ,1 ,2 ), +}; +static const struct mtk_gate_regs peri0_cg_regs = { .set_ofs =0x0008 , .clr_ofs =0x0010 ,@@ -737,6 +741,7 @@ static void __init mtk_infrasys_init(struct device_node *node)mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data); +mtk_clk_register_factors (infra_divs,ARRAY_SIZE (infra_divs), clk_data); r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);if (r)include/dt-bindings/clock/mt8173-clk.h +0
-0
include/dt-bindings/clock/mt8173-clk.h line 191
Quoted 6 lines
include/dt-bindings/clock/mt8173-clk.h +2
-1@@ -187,7 +187,8 @@#define CLK_INFRA_CEC 9#define CLK_INFRA_PMICSPI 10#define CLK_INFRA_PMICWRAP 11 -#define CLK_INFRA_NR_CLK 12 +#define CLK_INFRA_CLK_13M 12 +#define CLK_INFRA_NR_CLK 13
Note: this one conflicts slightly with pi-cheng's patch that adds CPU mux clocks for cpufreq driver, since they both add more INFRA clocks:
https://patchwork.kernel.org/patch/6721511/
Quoted 6 lines
include/dt-bindings/clock/mt8173-clk.h +0
-1/* PERI_SYS */ --1.8.1.1.dirty
PATCH 5/5 arm64: dts: mt8173: add timer node
In reply to Yingjoe ChenFrom: Daniel Kurtz <[email protected]>
Add device node to enable GPT timer. This timer will be used as sched clock source.
--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +9 -0
@@ -219,6 +219,15 @@ reg = <0 0x10007000 0 0x100>; }; + timer: timer at 10008000 { + compatible = "mediatek,mt8173-timer", + "mediatek,mt6577-timer"; + reg = <0 0x10008000 0 0x1000>; + interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_CLK_13M>, + <&topckgen CLK_TOP_RTC_SEL>; + }; + pwrap: pwrap at 1000d000 { compatible = "mediatek,mt8173-pwrap"; reg = <0 0x1000d000 0 0x1000>;
Signature · 1 line
1.8.1.1.dirty
Re: [PATCH 5/5] arm64: dts: mt8173: add timer node
Quoted 8 lines · Yingjoe Chen
From: Daniel Kurtz <[email protected]>
Add device node to enable GPT timer. This timer will be used as sched clock source.
Signed-off-by Daniel Kurtz <[email protected]>Signed-off-by Eddie Huang <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>
This binding needs documentation.
Quoted 9 lines
--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/boot/dts/mediatek/mt8173.dtsi +0
-0
arch/arm64/boot/dts/mediatek/mt8173.dtsi line 228
Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +7
-0@@ -219,6 +219,15 @@ reg = <0 0x10007000 0 0x100>; }; + timer: timer at 10008000 { + compatible = "mediatek,mt8173-timer", + "mediatek,mt6577-timer"; + reg = <0 0x10008000 0 0x1000>; + interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_CLK_13M>, + <&topckgen CLK_TOP_RTC_SEL>;
Why two clocks? The driver only uses one.
Please use a clock-names property.
Thanks,
-Dan
Quoted 8 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +2
-1+ }; + pwrap: pwrap at 1000d000 { compatible = "mediatek,mt8173-pwrap"; reg = <0 0x1000d000 0 0x1000>; --1.8.1.1.dirty
Re: [PATCH 5/5] arm64: dts: mt8173: add timer node
Quoted 11 lines · Daniel Kurtz
Quoted 8 lines · Yingjoe Chen
From: Daniel Kurtz <[email protected]>
Add device node to enable GPT timer. This timer will be used as sched clock source.
Signed-off-by Daniel Kurtz <[email protected]>Signed-off-by Eddie Huang <[email protected]>Signed-off-by Yingjoe Chen <[email protected]>This binding needs documentation.
Whoops. I just found it at:Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
Quoted 35 lines
Quoted 10 lines
--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/boot/dts/mediatek/mt8173.dtsi +0
-0arch/arm64/boot/dts/mediatek/mt8173.dtsi line 228
Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +7
-0@@ -219,6 +219,15 @@ reg = <0 0x10007000 0 0x100>; }; + timer: timer at 10008000 { + compatible = "mediatek,mt8173-timer", + "mediatek,mt6577-timer"; + reg = <0 0x10008000 0 0x1000>; + interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_CLK_13M>, + <&topckgen CLK_TOP_RTC_SEL>;Why two clocks? The driver only uses one.
Please use a clock-names property.Thanks,
-DanQuoted 8 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +2
-1+ }; + pwrap: pwrap at 1000d000 { compatible = "mediatek,mt8173-pwrap"; reg = <0 0x1000d000 0 0x1000>; --1.8.1.1.dirty
Quoted 10 lines · Yingjoe Chen
This series add GPT timer support for mt8173. This is based on v4.2-rc1 and Matthias' next branch (for dts parts).
The first 2 patches comes from 'Add SMP bringup support for mt65xx socs' series [1]. I decide to move these 2 patches to this series, since it is more relevent here. They are changed based on Matthias' and Daniel's comments.
[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000714.html
Quoted 8 lines
Daniel Kurtz (1):
arm64: dts: mt8173: add timer nodeYingjoe Chen (4):
clocksource: mediatek: do not enableGPT_CLK_EVTwhen setup
clocksource: mediatek: Use GPT as sched clock source
arm64: mediatek: enableMTK_TIMER
clk: mediatek: add 13mhz clock for MT8173
Was this mediatek clocksource patch set get forgotten again? All 5 patches have have been reviewed, and I think the ones that need it have been Ack'ed by Matthias and/or Stephen.
What is the plan for merging them?
Thanks,
-Dan
Quoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ drivers/clk/mediatek/clk-mt8173.c | 5 +++++ drivers/clocksource/mtk_timer.c | 26 ++++++++++++++++++++------ include/dt-bindings/clock/mt8173-clk.h | 3 ++- 5 files changed, 37 insertions(+), 7 deletions(-)
Quoted 14 lines · Daniel Kurtz
Quoted 13 lines · Yingjoe Chen
This series add GPT timer support for mt8173. This is based on v4.2-rc1 and Matthias' next branch (for dts parts).
The first 2 patches comes from 'Add SMP bringup support for mt65xx socs' series [1]. I decide to move these 2 patches to this series, since it is more relevent here. They are changed based on Matthias' and Daniel's comments.
[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000714.html
Daniel Kurtz (1):
arm64: dts: mt8173: add timer node
Quoted 7 lines
Quoted 5 lines
Yingjoe Chen (4):
clocksource: mediatek: do not enableGPT_CLK_EVTwhen setup
clocksource: mediatek: Use GPT as sched clock source
arm64: mediatek: enableMTK_TIMER
clk: mediatek: add 13mhz clock for MT8173Was this mediatek clocksource patch set get forgotten again?
Yep. Sounds like it felt at the wrong moment.
Quoted 3 lines
All 5 patches have have been reviewed, and I think the ones that need it have been Ack'ed by Matthias and/or Stephen.
What is the plan for merging them?
So if I am not wrong we have two patches I can take in my tree as a couple of fixes (1 and 2), right ?
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
Quoted 31 lines · Daniel Lezcano
Quoted 18 lines · Daniel Kurtz
Quoted 15 lines · Yingjoe Chen
This series add GPT timer support for mt8173. This is based on v4.2-rc1 and Matthias' next branch (for dts parts).
The first 2 patches comes from 'Add SMP bringup support for mt65xx socs' series [1]. I decide to move these 2 patches to this series, since it is more relevent here. They are changed based on Matthias' and Daniel's comments.
[1]
http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000714.htmlDaniel Kurtz (1):
arm64: dts: mt8173: add timer nodeQuoted 8 lines
Quoted 5 lines
Yingjoe Chen (4):
clocksource: mediatek: do not enableGPT_CLK_EVTwhen setup
clocksource: mediatek: Use GPT as sched clock source
arm64: mediatek: enableMTK_TIMER
clk: mediatek: add 13mhz clock for MT8173Was this mediatek clocksource patch set get forgotten again?
Yep. Sounds like it felt at the wrong moment.
Quoted 7 lines
Quoted 3 lines
All 5 patches have have been reviewed, and I think the ones that need it have been Ack'ed by Matthias and/or Stephen.
What is the plan for merging them?So if I am not wrong we have two patches I can take in my tree as a couple of fixes (1 and 2), right ?
Yes.
Patches 3 & 5 are for Matthias, and patch 4 is Ack'ed by Stephen Boyd, so I assume Matthias can pick that one up too.
Matthias, is that correct?
Or does Patch 4 need to go in via a clock maintainer's tree?
-Dan
Quoted 19 lines · Yingjoe Chen
This series add GPT timer support for mt8173. This is based on v4.2-rc1 and Matthias' next branch (for dts parts).
The first 2 patches comes from 'Add SMP bringup support for mt65xx socs' series [1]. I decide to move these 2 patches to this series, since it is more relevent here. They are changed based on Matthias' and Daniel's comments.
[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000714.html
Daniel Kurtz (1):
arm64: dts: mt8173: add timer nodeYingjoe Chen (4):
clocksource: mediatek: do not enableGPT_CLK_EVTwhen setup
clocksource: mediatek: Use GPT as sched clock source
arm64: mediatek: enableMTK_TIMER
clk: mediatek: add 13mhz clock for MT8173
Quoted 6 lines
arch/arm64/Kconfig | 1 + arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ drivers/clk/mediatek/clk-mt8173.c | 5 +++++ drivers/clocksource/mtk_timer.c | 26 ++++++++++++++++++++------ include/dt-bindings/clock/mt8173-clk.h | 3 ++- 5 files changed, 37 insertions(+), 7 deletions(-)
Who will take this patchset ? I can take the patch 2 if needed.
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
Quoted 20 lines · Daniel Lezcano
Quoted 19 lines · Yingjoe Chen
This series add GPT timer support for mt8173. This is based on v4.2-rc1 and Matthias' next branch (for dts parts).
The first 2 patches comes from 'Add SMP bringup support for mt65xx socs' series [1]. I decide to move these 2 patches to this series, since it is more relevent here. They are changed based on Matthias' and Daniel's comments.
[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-May/000714.html
Daniel Kurtz (1):
arm64: dts: mt8173: add timer nodeYingjoe Chen (4):
clocksource: mediatek: do not enableGPT_CLK_EVTwhen setup
clocksource: mediatek: Use GPT as sched clock source
arm64: mediatek: enableMTK_TIMER
clk: mediatek: add 13mhz clock for MT8173
Quoted 10 lines
Quoted 6 lines
arch/arm64/Kconfig | 1 + arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++ drivers/clk/mediatek/clk-mt8173.c | 5 +++++ drivers/clocksource/mtk_timer.c | 26 ++++++++++++++++++++------ include/dt-bindings/clock/mt8173-clk.h | 3 ++- 5 files changed, 37 insertions(+), 7 deletions(-)Who will take this patchset ? I can take the patch 2 if needed.
Hi Daniel,
Please take patch 2 with your fix. Thanks.
I think patch 3(enable MTK_TIMER in Kconfig) and 5 (add timer node) should go through Matthias' tree to arm-soc and patch 4(add 13mhz clock) should go through James' mtk-clk tree to clk maintainer.
Joe.C