diff mbox

[1/7] clocksource: mediatek: Don't run event_handler if it is NULL

Message ID 1430466210-22963-2-git-send-email-yingjoe.chen@mediatek.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yingjoe Chen May 1, 2015, 7:43 a.m. UTC
Spurious timer interrupt is noticed in mtk timer and cause kernel
crash. In mtk_timer_interrupt(), only run event_handler if it is
not NULL.

Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
---
 drivers/clocksource/mtk_timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel Lezcano May 4, 2015, 8:14 a.m. UTC | #1
On 05/01/2015 09:43 AM, Yingjoe Chen wrote:
> Spurious timer interrupt is noticed in mtk timer and cause kernel
> crash. In mtk_timer_interrupt(), only run event_handler if it is
> not NULL.
>
> Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
> ---
>   drivers/clocksource/mtk_timer.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> index 68ab423..85e0ab5 100644
> --- a/drivers/clocksource/mtk_timer.c
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -143,7 +143,8 @@ static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
>
>   	/* Acknowledge timer0 irq */
>   	writel(GPT_IRQ_ACK(GPT_CLK_EVT), evt->gpt_base + GPT_IRQ_ACK_REG);
> -	evt->dev.event_handler(&evt->dev);
> +	if (evt->dev.event_handler)
> +		evt->dev.event_handler(&evt->dev);
>
>   	return IRQ_HANDLED;
>   }
>

This fix does not look good.

Could you try by requesting the irq *after* 
clockevents_config_and_register in the init sequence [1] ?

Thanks
   -- Daniel

[1] 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=1096be084ac59927158ce80ff1d31c33eed0e565
Matthias Brugger May 4, 2015, 8:34 a.m. UTC | #2
2015-05-04 10:14 GMT+02:00 Daniel Lezcano <daniel.lezcano@linaro.org>:
> On 05/01/2015 09:43 AM, Yingjoe Chen wrote:
>>
>> Spurious timer interrupt is noticed in mtk timer and cause kernel
>> crash. In mtk_timer_interrupt(), only run event_handler if it is
>> not NULL.
>>
>> Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
>> ---
>>   drivers/clocksource/mtk_timer.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clocksource/mtk_timer.c
>> b/drivers/clocksource/mtk_timer.c
>> index 68ab423..85e0ab5 100644
>> --- a/drivers/clocksource/mtk_timer.c
>> +++ b/drivers/clocksource/mtk_timer.c
>> @@ -143,7 +143,8 @@ static irqreturn_t mtk_timer_interrupt(int irq, void
>> *dev_id)
>>
>>         /* Acknowledge timer0 irq */
>>         writel(GPT_IRQ_ACK(GPT_CLK_EVT), evt->gpt_base + GPT_IRQ_ACK_REG);
>> -       evt->dev.event_handler(&evt->dev);
>> +       if (evt->dev.event_handler)
>> +               evt->dev.event_handler(&evt->dev);
>>
>>         return IRQ_HANDLED;
>>   }
>>
>
> This fix does not look good.
>
> Could you try by requesting the irq *after* clockevents_config_and_register
> in the init sequence [1] ?
>

From my understanding [1] should already fix this.

[1] https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/clocksource/mtk_timer.c?id=d4a19eb3b15a4ba98f627182f48d5bc0cffae670

Regards,
Matthias
Daniel Lezcano May 4, 2015, 8:44 a.m. UTC | #3
On 05/04/2015 10:34 AM, Matthias Brugger wrote:
> 2015-05-04 10:14 GMT+02:00 Daniel Lezcano <daniel.lezcano@linaro.org>:
>> On 05/01/2015 09:43 AM, Yingjoe Chen wrote:
>>>
>>> Spurious timer interrupt is noticed in mtk timer and cause kernel
>>> crash. In mtk_timer_interrupt(), only run event_handler if it is
>>> not NULL.
>>>
>>> Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
>>> ---
>>>    drivers/clocksource/mtk_timer.c | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/clocksource/mtk_timer.c
>>> b/drivers/clocksource/mtk_timer.c
>>> index 68ab423..85e0ab5 100644
>>> --- a/drivers/clocksource/mtk_timer.c
>>> +++ b/drivers/clocksource/mtk_timer.c
>>> @@ -143,7 +143,8 @@ static irqreturn_t mtk_timer_interrupt(int irq, void
>>> *dev_id)
>>>
>>>          /* Acknowledge timer0 irq */
>>>          writel(GPT_IRQ_ACK(GPT_CLK_EVT), evt->gpt_base + GPT_IRQ_ACK_REG);
>>> -       evt->dev.event_handler(&evt->dev);
>>> +       if (evt->dev.event_handler)
>>> +               evt->dev.event_handler(&evt->dev);
>>>
>>>          return IRQ_HANDLED;
>>>    }
>>>
>>
>> This fix does not look good.
>>
>> Could you try by requesting the irq *after* clockevents_config_and_register
>> in the init sequence [1] ?
>>
>
>  From my understanding [1] should already fix this.
>
> [1] https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/drivers/clocksource/mtk_timer.c?id=d4a19eb3b15a4ba98f627182f48d5bc0cffae670

Indeed it seems to fix it. But I think request_irq should be done after 
clockevents_config_and_register in any case.

Yingjoe, are the spurious interrupts occurring with the fix Matthias 
mentions ?
diff mbox

Patch

diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
index 68ab423..85e0ab5 100644
--- a/drivers/clocksource/mtk_timer.c
+++ b/drivers/clocksource/mtk_timer.c
@@ -143,7 +143,8 @@  static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
 
 	/* Acknowledge timer0 irq */
 	writel(GPT_IRQ_ACK(GPT_CLK_EVT), evt->gpt_base + GPT_IRQ_ACK_REG);
-	evt->dev.event_handler(&evt->dev);
+	if (evt->dev.event_handler)
+		evt->dev.event_handler(&evt->dev);
 
 	return IRQ_HANDLED;
 }