Re: PROBLEM: Kernel BUG in mfgpt_tick (cs5535-clockevt.c) on ALIX 2c3 - null call

From: Thomas Gleixner
Date: Mon Oct 16 2017 - 05:30:56 EST


On Thu, 12 Oct 2017, David Kozub wrote:
> On Thu, 12 Oct 2017, Thomas Gleixner wrote:
> > On Thu, 12 Oct 2017, Daniel Lezcano wrote:
> > The real question is why
> >
> > /* Set the clock scale and enable the event mode for CMP2 */
> > val = MFGPT_SCALE | (3 << 8);
> >
> > cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val);
> >
> > is in the setup code at all.
> >
> > The obvious place for this is in mfgpt_set_periodic() which gets called
> > when the clock event and the handler is set up in the core code. Up to that
> > point the interrupt handler is protected against shared interrupts via the
> > is_shutdown() check.
>
> It is, but only after clockevents_config_and_register. But mfgpt_tick is
> called before that (just after setup_irq).

Right, but the protection against the spurious interrupt there is not
sufficient. See patch below.

Thanks,

tglx

8<-------------------

--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -117,7 +117,8 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id)
/* Turn off the clock (and clear the event) */
disable_timer(cs5535_event_clock);

- if (clockevent_state_shutdown(&cs5535_clockevent))
+ if (clockevent_state_detached(&cs5535_clockevent) ||
+ clockevent_state_shutdown(&cs5535_clockevent))
return IRQ_HANDLED;

/* Clear the counter */