Re: [PATCH] PM / sleep: Fix racing timers

From: SÃren Brinkmann
Date: Tue Aug 26 2014 - 20:35:36 EST


On Wed, 2014-08-27 at 02:32AM +0200, Rafael J. Wysocki wrote:
> Hi,
>
> Sorry for being somewhat slow to respond to this, but I'm not sure if the
> approach here is the right one.
>
> On Wednesday, August 20, 2014 01:55:09 PM Soren Brinkmann wrote:
> > On platforms that do not power off during suspend, successfully entering
> > suspend races with timers.
> >
> > The race happening in a couple of location is:
> >
> > 1. disable IRQs (e.g. arch_suspend_disable_irqs())
> > ...
> > 2. syscore_suspend()
> > -> timekeeping_suspend()
> > -> clockevents_notify(SUSPEND)
> > -> tick_suspend() (timers are turned off here)
> > ...
> > 3. wfi (wait for wake-IRQ here)
> >
> > Between steps 1 and 2 the timers can still generate interrupts that are
> > not handled and stay pending until step 3. That pending IRQ causes an
> > immediate - spurious - wake.
>
> Well, the problem here is that the platform is not supposed to re-enable
> interrupts after syscore_suspend(). Of course, some platforms do that, because
> they don't really support system sleep and try to emulate it with something
> along the lines of suspend-to-idle.

No, IRQs are not enabled after syscore-suspend. But the wait for
interrupt state on ARM is left even with IRQs disabled. It will prevent
the core from taking the exception, but it will "wake" it up. So, my
impressions was that the core is the appropriate location to fix this. I
wouldn't know where else to do it.

It is certainly an issue caused by this probably non-standard suspend
state, but if we accept this implementation as a valid suspend
implementation, I'd say it's a core issue.

Thanks,
SÃren
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/