On Mon, Jan 8, 2018 at 12:13 PM, Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote: > On 6 January 2018 at 00:57, Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote: >> On Tue, Jan 2, 2018 at 5:08 PM, Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote: >>> In general, wakeup settings are not supposed to be changed during any of >>> the system wide PM phases. The reason is simply that it would break >>> guarantees provided by the PM core, to properly act on active wakeup >>> sources. >>> >>> However, there are exceptions to when, in particular, disabling a device as >>> wakeup source makes sense. For example, in cases when a driver realizes >>> that its device is dead during system suspend. For these scenarios, we >>> don't need to care about acting on the wakeup source correctly, because a >>> dead device shouldn't deliver wakeup signals. >>> >>> To this reasoning and to help users to properly manage wakeup settings, >>> let's print a warning in cases someone calls device_wakeup_enable() during >>> system sleep. >>> >>> Suggested-by: Rafael J. Wysocki <rafael@xxxxxxxxxx> >>> Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx> >>> --- >>> drivers/base/power/wakeup.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c >>> index b7b8b2f..272c44b 100644 >>> --- a/drivers/base/power/wakeup.c >>> +++ b/drivers/base/power/wakeup.c >>> @@ -268,6 +268,9 @@ int device_wakeup_enable(struct device *dev) >>> if (!dev || !dev->power.can_wakeup) >>> return -EINVAL; >>> >>> + if (pm_suspend_target_state != PM_SUSPEND_ON) >>> + dev_warn(dev, "don't enable as wakup source during sleep!\n"); >>> + >>> ws = wakeup_source_register(dev_name(dev)); >>> if (!ws) >>> return -ENOMEM; >>> -- >> >> It looks like we need to defer this until we fix a couple of issues ... > > Yes. > > Or, perhaps changing from dev_warn() to dev_dbg(), as it could provide > us with some more detailed information, compared to a "git grep" > research? That would work too. Thanks, Rafael