Subject: [PATCH 0/2] clocksource: exynos_mct: Clear timer interrupt when shutting down
Subsystems (2)
cover Subject: [PATCH 0/2] clocksource: exynos_mct: Clear timer interrupt when shutting down
When debugging suspend problems on Exynos 5260, I had a large number of debugging prints going to the serial port after interrupts had been disabled but before the timer interrupt was shutdown. This was long enough for a timer tick to occur, but as interrupts were disabled the ISR didn't run, and so the interrupt wasn't cleared. Later when the timer was shutdown the interrupt was left asserted and so the wfi at the heart of the suspend code didn't wait, causing the suspend to fail.
Currently the code which stops the timer when it is on one-shot mode and the interrupt occurs is in exynos4_mct_tick_clear(), meaning if we called this from the shutdown code exynos4_mct_tick_stop() could be called twice. So first restructure the existing code, so the check for one-shot mode and stopping the timer is moved to the ISR, leaving exynos4_mct_tick_clear() just clearing the interrupt flag.
Once this has been done simply call exynos4_mct_tick_clear() from set_state_shutdown().
Stuart Menefy (2):
clocksource: exynos_mct: Move one-shot check from tick clear to ISR
clocksource: exynos_mct: Clear timer interrupt when shutdown
drivers/clocksource/exynos_mct.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
Signature · 1 line
2.13.6
PATCH 1/2 clocksource: exynos_mct: Move one-shot check from tick clear to ISR
When a timer tick occurs and the clock is in one-shot mode, the timer needs to be stopped to prevent it triggering subsequent interrupts. Currently this code is in exynos4_mct_tick_clear(), but as it is only needed when an ISR occurs move it into exynos4_mct_tick_isr(), leaving exynos4_mct_tick_clear() just doing what its name suggests it should.
--- drivers/clocksource/exynos_mct.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/clocksource/exynos_mct.c +11 -11
@@ -388,6 +388,13 @@ static void exynos4_mct_tick_start(unsigned long cycles,exynos4_mct_write (tmp, mevt->base +MCT_L_TCON_OFFSET ); } +static void exynos4_mct_tick_clear (struct mct_clock_event_device *mevt) +{ +/* Clear the MCT tick interrupt */ +if (readl_relaxed (reg_base + mevt->base +MCT_L_INT_CSTAT_OFFSET ) &1 ) +exynos4_mct_write (0x1 , mevt->base +MCT_L_INT_CSTAT_OFFSET ); +} +static int exynos4_tick_set_next_event (unsigned long cycles,struct clock_event_device *evt) {
@@ -420,8 +427,11 @@ static int set_state_periodic(struct clock_event_device *evt)return 0 ; } -static void exynos4_mct_tick_clear (struct mct_clock_event_device *mevt) +static irqreturn_t exynos4_mct_tick_isr (int irq,void *dev_id) { +struct mct_clock_event_device *mevt = dev_id; +struct clock_event_device *evt = &mevt->evt; +/* * This is for supporting oneshot mode. * Mct would generate interrupt periodically
@@ -430,16 +440,6 @@ static void exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)if (!clockevent_state_periodic (&mevt->evt))exynos4_mct_tick_stop (mevt); -/* Clear the MCT tick interrupt */ -if (readl_relaxed (reg_base + mevt->base +MCT_L_INT_CSTAT_OFFSET ) &1 ) -exynos4_mct_write (0x1 , mevt->base +MCT_L_INT_CSTAT_OFFSET ); -} - -static irqreturn_t exynos4_mct_tick_isr (int irq,void *dev_id) -{ -struct mct_clock_event_device *mevt = dev_id; -struct clock_event_device *evt = &mevt->evt; -exynos4_mct_tick_clear (mevt); evt->event_handler (evt);
Signature · 1 line
2.13.6
Re: [PATCH 1/2] clocksource: exynos_mct: Move one-shot check from tick clear to ISR
Quoted 8 lines · Stuart Menefy
When a timer tick occurs and the clock is in one-shot mode, the timer needs to be stopped to prevent it triggering subsequent interrupts. Currently this code is in
exynos4_mct_tick_clear(), but as it is only needed when an ISR occurs move it intoexynos4_mct_tick_isr(), leavingexynos4_mct_tick_clear()just doing what its name suggests it should.
Quoted 4 lines
Signed-off-by Stuart Menefy <[email protected]>--- drivers/clocksource/exynos_mct.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
Best regards,
Krzysztof
PATCH 2/2 clocksource: exynos_mct: Clear timer interrupt when shutdown
In reply to Stuart MenefyWhen shutting down the timer, ensure that after we have stopped the timer any pending interrupts are cleared. This fixes a problem when suspending, as interrupts are disabled before the timer is stopped, so the timer interrupt may still be asserted, preventing the system entering a low power state when the wfi is executed.
--- drivers/clocksource/exynos_mct.c | 1 + 1 file changed, 1 insertion(+)
drivers/clocksource/exynos_mct.c +1 -0
@@ -411,6 +411,7 @@ static int set_state_shutdown(struct clock_event_device *evt) mevt = container_of(evt, struct mct_clock_event_device, evt);exynos4_mct_tick_stop (mevt); +exynos4_mct_tick_clear (mevt);return 0 ; }
Signature · 1 line
2.13.6
Re: [PATCH 2/2] clocksource: exynos_mct: Clear timer interrupt when shutdown
Quoted 11 lines · Stuart Menefy
When shutting down the timer, ensure that after we have stopped the timer any pending interrupts are cleared. This fixes a problem when suspending, as interrupts are disabled before the timer is stopped, so the timer interrupt may still be asserted, preventing the system entering a low power state when the wfi is executed.
Signed-off-by Stuart Menefy <[email protected]>--- drivers/clocksource/exynos_mct.c | 1 + 1 file changed, 1 insertion(+)
Best regards,
Krzysztof
Hi Stuart
Quoted 16 lines · Stuart Menefy
When debugging suspend problems on Exynos 5260, I had a large number of debugging prints going to the serial port after interrupts had been disabled but before the timer interrupt was shutdown. This was long enough for a timer tick to occur, but as interrupts were disabled the ISR didn't run, and so the interrupt wasn't cleared. Later when the timer was shutdown the interrupt was left asserted and so the wfi at the heart of the suspend code didn't wait, causing the suspend to fail.
Currently the code which stops the timer when it is on one-shot mode and the interrupt occurs is in
exynos4_mct_tick_clear(), meaning if we called this from the shutdown codeexynos4_mct_tick_stop()could be called twice. So first restructure the existing code, so the check for one-shot mode and stopping the timer is moved to the ISR, leavingexynos4_mct_tick_clear()just clearing the interrupt flag.
Quoted 2 lines
Once this has been done simply call
exynos4_mct_tick_clear()fromset_state_shutdown().
This also fixes mysterious suspend failures on Odroid XU3/XU4/HC1 :)
Quoted 7 lines
Stuart Menefy (2):
clocksource:exynos_mct: Move one-shot check from tick clear to ISR
clocksource:exynos_mct: Clear timer interrupt when shutdowndrivers/clocksource/exynos_mct.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Quoted 19 lines · Marek Szyprowski
Hi Stuart
Quoted 16 lines · Stuart Menefy
When debugging suspend problems on Exynos 5260, I had a large number of debugging prints going to the serial port after interrupts had been disabled but before the timer interrupt was shutdown. This was long enough for a timer tick to occur, but as interrupts were disabled the ISR didn't run, and so the interrupt wasn't cleared. Later when the timer was shutdown the interrupt was left asserted and so the wfi at the heart of the suspend code didn't wait, causing the suspend to fail.
Currently the code which stops the timer when it is on one-shot mode and the interrupt occurs is in
exynos4_mct_tick_clear(), meaning if we called this from the shutdown codeexynos4_mct_tick_stop()could be called twice. So first restructure the existing code, so the check for one-shot mode and stopping the timer is moved to the ISR, leavingexynos4_mct_tick_clear()just clearing the interrupt flag.
Quoted 6 lines
Quoted 2 lines
Once this has been done simply call
exynos4_mct_tick_clear()fromset_state_shutdown().This also fixes mysterious suspend failures on Odroid XU3/XU4/HC1 :)
Tested-by Marek Szyprowski <[email protected]>
Applied. Shall I add the stable@ tag?
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
Krzysztof Kozlowski
maintainerQuoted 21 lines · Daniel Lezcano
Quoted 19 lines · Marek Szyprowski
Hi Stuart
Quoted 16 lines · Stuart Menefy
When debugging suspend problems on Exynos 5260, I had a large number of debugging prints going to the serial port after interrupts had been disabled but before the timer interrupt was shutdown. This was long enough for a timer tick to occur, but as interrupts were disabled the ISR didn't run, and so the interrupt wasn't cleared. Later when the timer was shutdown the interrupt was left asserted and so the wfi at the heart of the suspend code didn't wait, causing the suspend to fail.
Currently the code which stops the timer when it is on one-shot mode and the interrupt occurs is in
exynos4_mct_tick_clear(), meaning if we called this from the shutdown codeexynos4_mct_tick_stop()could be called twice. So first restructure the existing code, so the check for one-shot mode and stopping the timer is moved to the ISR, leavingexynos4_mct_tick_clear()just clearing the interrupt flag.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Once this has been done simply call
exynos4_mct_tick_clear()fromset_state_shutdown().This also fixes mysterious suspend failures on Odroid XU3/XU4/HC1 :)
Tested-by Marek Szyprowski <[email protected]>Applied. Shall I add the stable@ tag?
Makes sense - for the second patch, although first is a prerequisite. It should be backported up to v4.3 (the code differ a lot on older versions).
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerQuoted 17 lines · Stuart Menefy
When debugging suspend problems on Exynos 5260, I had a large number of debugging prints going to the serial port after interrupts had been disabled but before the timer interrupt was shutdown. This was long enough for a timer tick to occur, but as interrupts were disabled the ISR didn't run, and so the interrupt wasn't cleared. Later when the timer was shutdown the interrupt was left asserted and so the wfi at the heart of the suspend code didn't wait, causing the suspend to fail.
Currently the code which stops the timer when it is on one-shot mode and the interrupt occurs is in
exynos4_mct_tick_clear(), meaning if we called this from the shutdown codeexynos4_mct_tick_stop()could be called twice. So first restructure the existing code, so the check for one-shot mode and stopping the timer is moved to the ISR, leavingexynos4_mct_tick_clear()just clearing the interrupt flag.
Quoted 2 lines
Once this has been done simply call
exynos4_mct_tick_clear()fromset_state_shutdown().
For sending the corrected version. This is second revision of the patchset so please remember to add v2 to the title and changelog in cover letter. v2 can be easily added with format-patch (-v2).
Best regards,
Krzysztof