Re: Understanding the use cases for calling pm_wakeup_event()
From: Rajat Jain
Date: Thu Oct 12 2017 - 20:19:01 EST
[+lkml]
On Thu, Oct 12, 2017 at 5:13 PM, Rajat Jain <rajatja@xxxxxxxxxx> wrote:
> Hi,
>
> I'm trying to understand when a driver is supposed to call the
> pm_wakeup_event(). It appears that the purpose of this call is to
>
> (1) In the suspend patch, halt the suspend if the driver believes it
> just got an appropriate wake event from the device while the system is
> trying to suspend.
>
> (2) If driver detects the event in the resume path, identify the
> device as (one of the) wake sources that fired.
>
> I understand good use cases of this call will be when a driver knows
> that its device has woken up the system, e.g:
>
> * When a driver handles dedicated "wakeup irq", and sees the interrupt fired.
> * If a driver detect operator events such as lid opened, power button
> pressed, switched to tablet mode etc etc.
>
> But what should a driver do, when it handles an event (in the resume
> path) that potentially was a wake up source but the driver is not
> sure? Is it appropriate to call
>
> if (device_may_wakeup(dev))
> pm_wakeup_event(dev, 0);
>
> in that case, because I do see some drivers seem to call it when they
> think that their device *may* have been the reason the system woke up,
> but not necessarily *is* the reason for wake up. E.g.:
>
> drivers/input/mouse/cyapa.c:
> drivers/input/serio/hyperv-keyboard.c
> drivers/input/serio/olpc_apsp.c
>
> Thanks,
>
> Rajat