From patchwork Thu Jan 11 08:18:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10157457 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2F1E601A1 for ; Thu, 11 Jan 2018 08:19:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E25F5286A4 for ; Thu, 11 Jan 2018 08:19:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0E8B286F4; Thu, 11 Jan 2018 08:19:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 442FB286A4 for ; Thu, 11 Jan 2018 08:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753660AbeAKITJ (ORCPT ); Thu, 11 Jan 2018 03:19:09 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33751 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747AbeAKITI (ORCPT ); Thu, 11 Jan 2018 03:19:08 -0500 Received: by mail-lf0-f67.google.com with SMTP id j143so1776958lfg.0 for ; Thu, 11 Jan 2018 00:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ISr/ZlGciKx+MMnHPVY2yh+um78pY3IQutM5jfldZKM=; b=F/AFot6WVXf/iXEhqPmlZa5t7UnPBQKka2aGtcGlcpVZ9ASNpchqWfyc/4Un0aL2ue CDuzQEcPxG1hxJdrMgwODxIpAgvEzcRONLrhRUoCFfY8B5Z1rbI6vmaFBBjLkKQubw60 enUL3wdcF+nk2p15vC5bXV/tRtK1JpqZ5PIYg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ISr/ZlGciKx+MMnHPVY2yh+um78pY3IQutM5jfldZKM=; b=I+GkNr3NNThNeuLft/hfzXMYbM+TnkW8aa0MQK5vDeY05ls0n2rKp0ABOB1gr2l2RZ Uu1W1krHF++rRgbPNSbAWEgjqD7pdK28dMWoE62Aq9EGg1M8Tjqa9Wj15siVmGcK+/Wz rq2xXRBe60KhtuEI9GZ7qLALFIgyeZwsdTuuiU6ub0ir1zlWdywt54go5zxkQ6rsp5Vt xPhzLiOp91T3teRpeCHpd5Vk8tKhUxJghtR4+fh3Z1vHrYpGaLqSqwHlA6YLb4qN+aP8 Rk/WqalcUhYpgnTtMlYm4aH5s9FM1ZwVSXzyi1wnDtIXHXaJOxy6bMzxKEzSJXrPGJk2 /dfQ== X-Gm-Message-State: AKGB3mKx4h2xwQRuibjOeuvTEbgG7H1qN+e+/X9inavaFfiK6pZBeDc3 Q8+OvP0TL4W0fKCNj5PSmzPQP1qnU3s= X-Google-Smtp-Source: ACJfBoug8rrMK8vKTHrJRs7ucTdjSr4NlP45izsQFniogtVqzAMa0igpcjdDTnglRefE/C/MQ3oHMQ== X-Received: by 10.46.21.68 with SMTP id 4mr13896604ljv.95.1515658747046; Thu, 11 Jan 2018 00:19:07 -0800 (PST) Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r5sm1941752lfi.14.2018.01.11.00.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jan 2018 00:19:06 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Ulf Hansson Subject: [PATCH v5] PM / wakeup: Print warn if device gets enabled as wakeup source during sleep Date: Thu, 11 Jan 2018 09:18:59 +0100 Message-Id: <1515658739-24833-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Ulf Hansson --- Changes in v5: - Fix build error when CONFIG_SUSPEND is unset and CONFIG_PM_SLEEP is set. Changes in v4: - Send this as a separate change. - Changed from dev_warn() to dev_dbg(). --- drivers/base/power/wakeup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index e73a081..c9dc468 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -19,6 +19,11 @@ #include "power.h" +#ifndef CONFIG_SUSPEND +suspend_state_t pm_suspend_target_state; +#define pm_suspend_target_state (PM_SUSPEND_ON) +#endif + /* * If set, the suspend/hibernate code will abort transitions to a sleep state * if wakeup events are registered during or immediately before the transition. @@ -268,6 +273,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_dbg(dev, "don't enable as wakup source during sleep!\n"); + ws = wakeup_source_register(dev_name(dev)); if (!ws) return -ENOMEM;