clocksource/drivers/timer-mediatek: optimize systimer irq clear flow on Mediatek Socs
Subsystems (2)
PATCH 1/1 clocksource/drivers/timer-mediatek: optimize systimer irq clear flow on Mediatek Socs
clocksource/drivers/timer-mediatek: optimize systimer irq clear flow on Mediatek Socs
1)ensure systimer is enabled before clear and disable interrupt, which only
for systimer in Mediatek Socs.
2)clear any pending timer-irq when shutdown to keep suspend flow clean,
when use systimer as tick-broadcast timer
Fengquan Chen (1):
clocksource/drivers/timer-mediatek: optimize systimer irq clear flow
on Mediatek Socs
drivers/clocksource/timer-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)
Signature · 5 lines
1.8.1.1.dirty _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 1/1 clocksource/drivers/timer-mediatek: optimize systimer irq clear flow on Mediatek Socs
1)ensure systimer is enabled before clear and disable interrupt, which only for systimer in Mediatek Socs.
2)clear any pending timer-irq when shutdown to keep suspend flow clean, when use systimer as tick-broadcast timer
--- drivers/clocksource/timer-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clocksource/timer-mediatek.c +4 -0
@@ -75,6 +75,7 @@static void mtk_syst_ack_irq (struct timer_of *to) {/* Clear and disable interrupt */ +writel (SYST_CON_EN ,SYST_CON_REG (to));writel (SYST_CON_IRQ_CLR |SYST_CON_EN ,SYST_CON_REG (to)); }
@@ -111,6 +112,9 @@ static int mtk_syst_clkevt_next_event(unsigned long ticks,static int mtk_syst_clkevt_shutdown (struct clock_event_device *clkevt) { +/* Clear any irq */ +mtk_syst_ack_irq (to_timer_of (clkevt)); +/* Disable timer */ writel (0 ,SYST_CON_REG (to_timer_of (clkevt)));
Signature · 5 lines
1.8.1.1.dirty _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 7 lines · Fengquan Chen
1)ensure systimer is enabled before clear and disable interrupt, which only for systimer in Mediatek Socs.
2)clear any pending timer-irq when shutdown to keep suspend flow clean, when use systimer as tick-broadcast timer
Change-Id: Ia3eda83324af2fdaf5cbb3569a9bf020a11f8009
Remove the above.
Add a Fixes tag.
Quoted 10 lines
Signed-off-by Fengquan Chen <[email protected]>--- drivers/clocksource/timer-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/clocksource/timer-mediatek.c +0
-0
drivers/clocksource/timer-mediatek.c line 78
Quoted 4 lines
drivers/clocksource/timer-mediatek.c +1
-0@@ -75,6 +75,7 @@static void mtk_syst_ack_irq (struct timer_of *to) {/* Clear and disable interrupt */ +writel (SYST_CON_EN ,SYST_CON_REG (to));
SYST_CON_EN is set below, why do you have to do it before?
Is that a hw bug ?
It is confusing what the description of the SYST_CON_EN says:
/*
* SYST_CON_EN: Clock enable. Shall be set to
* - Start timer countdown. * - Allow timeout ticks being updated. * - Allow changing interrupt functions.
What means "interrupt functions" ?
Does writing writel(SYST_CON_EN, SYST_CON_REG(to)) before SYST_CON_IRQ_CLR allows to clear the interrupt flag?
Can you explain how the timer works regarding this part?
It sounds to me a bit strange.
*
* SYST_CON_IRQ_EN: Set to allow interrupt.
*
* SYST_CON_IRQ_CLR: Set to clear interrupt.
*/
Quoted 14 lines
drivers/clocksource/timer-mediatek.c +3
-0writel (SYST_CON_IRQ_CLR |SYST_CON_EN ,SYST_CON_REG (to)); }@@ -111,6 +112,9 @@ static int mtk_syst_clkevt_next_event(unsigned long ticks,static int mtk_syst_clkevt_shutdown (struct clock_event_device *clkevt) { +/* Clear any irq */ +mtk_syst_ack_irq (to_timer_of (clkevt)); +/* Disable timer */ writel (0 ,SYST_CON_REG (to_timer_of (clkevt)));
Signature · 10 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 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 4 lines · Daniel Lezcano
Quoted 3 lines · Fengquan Chen
1)ensure systimer is enabled before clear and disable interrupt, which only for systimer in Mediatek Socs.
Quoted 8 lines
Quoted 4 lines
2)clear any pending timer-irq when shutdown to keep suspend flow clean, when use systimer as tick-broadcast timer
Change-Id: Ia3eda83324af2fdaf5cbb3569a9bf020a11f8009
Remove the above.
Add a Fixes tag.
Thanks for review, has been fixed in V4:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
Quoted 35 lines
Quoted 11 lines
Signed-off-by Fengquan Chen <[email protected]>--- drivers/clocksource/timer-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/clocksource/timer-mediatek.c +0
-0drivers/clocksource/timer-mediatek.c line 78
Quoted 4 lines
drivers/clocksource/timer-mediatek.c +1
-0@@ -75,6 +75,7 @@static void mtk_syst_ack_irq (struct timer_of *to) {/* Clear and disable interrupt */ +writel (SYST_CON_EN ,SYST_CON_REG (to));
SYST_CON_ENis set below, why do you have to do it before?Is that a hw bug ?
It is confusing what the description of the
SYST_CON_ENsays:/*
*SYST_CON_EN: Clock enable. Shall be set to* - Start timer countdown. * - Allow timeout ticks being updated. * - Allow changing interrupt functions.What means "interrupt functions" ?
Does writing
writel(SYST_CON_EN, SYST_CON_REG(to))beforeSYST_CON_IRQ_CLRallows to clear the interrupt flag?Can you explain how the timer works regarding this part?
Quoted 8 lines
It sounds to me a bit strange.
*
*SYST_CON_IRQ_EN: Set to allow interrupt.
*
*SYST_CON_IRQ_CLR: Set to clear interrupt.
*/
Thanks for review, descriptions about SYST_CON_IRQ_CLR/SYST_CON_EN/SYST_CON_IRQ_EN have been updated in v4.
And for systimer, there's a hw limitation that before clearing pending irqs, we must enable timer first. so we added a SYST_CON_EN write before SYST_CON_IRQ_CLR write to ensure irq clear successfully.
Also, we cannot only write SYST_CON_IRQ_CLR without SYST_CON_EN bit, because EN bit is also timer clock enable bit.
this is a hardward design limitation but not a bug.
Quoted 17 lines
Quoted 15 lines
drivers/clocksource/timer-mediatek.c +3
-0writel (SYST_CON_IRQ_CLR |SYST_CON_EN ,SYST_CON_REG (to)); }@@ -111,6 +112,9 @@ static int mtk_syst_clkevt_next_event(unsigned long ticks,static int mtk_syst_clkevt_shutdown (struct clock_event_device *clkevt) { +/* Clear any irq */ +mtk_syst_ack_irq (to_timer_of (clkevt)); +/* Disable timer */ writel (0 ,SYST_CON_REG (to_timer_of (clkevt)));
Quoted 3 lines · Fengquan Chen
1)ensure systimer is enabled before clear and disable interrupt, which only for systimer in Mediatek Socs.
Why does the timer need to be enabled before the interrupt can be disabled? The datasheet I have does not suggest that this is required.
Quoted 15 lines
2)clear any pending timer-irq when shutdown to keep suspend flow clean, when use systimer as tick-broadcast timer
Change-Id Ia3eda83324af2fdaf5cbb3569a9bf020a11f8009Signed-off-by Fengquan Chen <[email protected]>--- drivers/clocksource/timer-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/clocksource/timer-mediatek.c +0
-0
drivers/clocksource/timer-mediatek.c line 75
Quoted 1 line
drivers/clocksource/timer-mediatek.c +0
-0@@ -75,6 +75,7 @@static void mtk_syst_ack_irq (struct timer_of *to)
This function seems to be mis-named. It does more than just ack the irq.
drivers/clocksource/timer-mediatek.c line 78
Quoted 3 lines
drivers/clocksource/timer-mediatek.c +1
-0{/* Clear and disable interrupt */ +writel (SYST_CON_EN ,SYST_CON_REG (to));
This line seems to enable the timer and disable the interrupt.
drivers/clocksource/timer-mediatek.c line 79
Quoted 1 line
drivers/clocksource/timer-mediatek.c +0
-0writel (SYST_CON_IRQ_CLR |SYST_CON_EN ,SYST_CON_REG (to));
This line acks the interrupt and enables the timer and disables the interrupt. Are these lines both necessary?
Maybe this function should just ack the interrupt without changing the other bits.
drivers/clocksource/timer-mediatek.c static int mtk_syst_clkevt_next_event(unsigned long ticks, · line 119
Quoted 11 lines
drivers/clocksource/timer-mediatek.c +3
-0}@@ -111,6 +112,9 @@ static int mtk_syst_clkevt_next_event(unsigned long ticks,static int mtk_syst_clkevt_shutdown (struct clock_event_device *clkevt) { +/* Clear any irq */ +mtk_syst_ack_irq (to_timer_of (clkevt)); +/* Disable timer */ writel (0 ,SYST_CON_REG (to_timer_of (clkevt)));
This is a third write to the same register, I believe all 3 writes can be combined into 1. Is that possible?
Quoted 4 lines
drivers/clocksource/timer-mediatek.c +0
-1--1.8.1.1.dirty
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 9 lines · Evan Benn
Quoted 3 lines · Fengquan Chen
1)ensure systimer is enabled before clear and disable interrupt, which only for systimer in Mediatek Socs.
Why does the timer need to be enabled before the interrupt can be disabled? The datasheet I have does not suggest that this is required.
Thanks for review. For systimer, you must enable timer before clear irq,it's a hw limitation that would be easily neglected.
Quoted 23 lines
Quoted 15 lines
2)clear any pending timer-irq when shutdown to keep suspend flow clean, when use systimer as tick-broadcast timer
Change-Id Ia3eda83324af2fdaf5cbb3569a9bf020a11f8009Signed-off-by Fengquan Chen <[email protected]>--- drivers/clocksource/timer-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/clocksource/timer-mediatek.c +0
-0drivers/clocksource/timer-mediatek.c line 75
Quoted 1 line
drivers/clocksource/timer-mediatek.c +0
-0@@ -75,6 +75,7 @@static void mtk_syst_ack_irq (struct timer_of *to)This function seems to be mis-named. It does more than just ack the irq.
drivers/clocksource/timer-mediatek.c line 78
Quoted 3 lines
drivers/clocksource/timer-mediatek.c +1
-0{/* Clear and disable interrupt */ +writel (SYST_CON_EN ,SYST_CON_REG (to));
Quoted 8 lines
This line seems to enable the timer and disable the interrupt.
drivers/clocksource/timer-mediatek.c line 79
Quoted 1 line
drivers/clocksource/timer-mediatek.c +0
-0writel (SYST_CON_IRQ_CLR |SYST_CON_EN ,SYST_CON_REG (to));This line acks the interrupt and enables the timer and disables the interrupt. Are these lines both necessary?
Maybe this function should just ack the interrupt without changing the other bits.
Thanks for review.
it's necessary.
As described above,we must enable timer before clear irq, so here is just want to ensure irq clear successfully.
We always disable irq here, and will be re-enable in mtk_syst_clkevt_next_event.
Quoted 5 lines
Quoted 5 lines
drivers/clocksource/timer-mediatek.c +0
-0}@@ -111,6 +112,9 @@ static int mtk_syst_clkevt_next_event(unsigned long ticks,
Quoted 10 lines
drivers/clocksource/timer-mediatek.c static int mtk_syst_clkevt_next_event(unsigned long ticks, · line 119
Quoted 7 lines
drivers/clocksource/timer-mediatek.c +3
-0static int mtk_syst_clkevt_shutdown (struct clock_event_device *clkevt) { +/* Clear any irq */ +mtk_syst_ack_irq (to_timer_of (clkevt)); +/* Disable timer */ writel (0 ,SYST_CON_REG (to_timer_of (clkevt)));This is a third write to the same register, I believe all 3 writes can be combined into 1. Is that possible?
Thanks for review.
there's a hw limitation here, we can not clear irq while timer is disabled, and SYST_CON_EN&SYST_CON_IRQ_CLR bit must be write at the same time or can not write SYST_CON_IRQ_CLR bit seperately.
Quoted 5 lines
Quoted 5 lines
drivers/clocksource/timer-mediatek.c +0
-1--1.8.1.1.dirty