From patchwork Mon Jan 8 11:44:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123691 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2614636qgn; Mon, 8 Jan 2018 03:44:49 -0800 (PST) X-Received: by 10.46.109.17 with SMTP id i17mr7033284ljc.61.1515411889185; Mon, 08 Jan 2018 03:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515411889; cv=none; d=google.com; s=arc-20160816; b=TzYpCSpubB613vsJkf0gubS88gcu5y8lkTDVYJQTaNWCNZJzfWRqYtAg1JOaw+I428 NrGTJCBq4NEjO826IlSXf0mo+Jas/8Brc39quIsYr0uRPLFPIVMjNJZauGsVHyNOsZFP xRPdj0MCcLrgrEPfVu0NkSvaHPYtXftpLeEuVieol0mLET87c01q10NAQjmmqMarwcjx dwz4m86AeFxM6WnPITXa35XECImyqcFioGb9iw53fevhm60BQDRqWsnMTogdPlYt9CO8 r5Zee6Ol7puur8X7R2TNhjPpfGKwRlj24vgTm+Lc5N7m/HIjgwxG+161+e7lKxeODHO6 8liw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=gO5LTI+4vUuhoii3lkp++pg9Sj5CfX8eQLxeK2r/eBo=; b=K88BCD14qg6Ftx0+O6vFfbC6sDUDQvxFSjuAHEcGNmB0VBprTjDK+7+GofD1NeJaxZ xvuiO1lWcCigRptvJHaXIN0aFZ9HUp7on5W1OF7n+bfYdNHayxOPM1jLRRmIs8kiJHCG aIhzWULEKQIIaJ18sWxThFYC5ANdZ7SPquUEkl0F7Dx4+r63zdt4slMqU+lXsGxpNIBh 5Q9aedAzYqxjOvjfGgprhg+1CCnuFpCC+RTXycv2eOc9mhnpqAgnLzq7RsYI3U9PDR7n 1GKWL5VdvrfXchYem/NRro+krm1RxUdO8swUqvM8qPgyDhnXOsDQNAHtNTvcRPYKyaja jI6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c0qhvzoa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y23sor23251ljc.37.2018.01.08.03.44.49 for (Google Transport Security); Mon, 08 Jan 2018 03:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c0qhvzoa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=gO5LTI+4vUuhoii3lkp++pg9Sj5CfX8eQLxeK2r/eBo=; b=c0qhvzoaiLtpumcDCBbOc/yG7leZcNn1w9uxDh/mvWKLfON3xfcTE7u2Nlf3IBGM+P qbFfI8/fbOAQp4hfYnYSv2C6W450+I/3HcLBD1o6qmOPr1DhDt8yX8v5Q/32PuYs8Zxh SAO5HcgphvB285fG9SoKKoIqnigT0vexBfYv0= 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=gO5LTI+4vUuhoii3lkp++pg9Sj5CfX8eQLxeK2r/eBo=; b=r0p+q71zW8eHuAX4QewTCvDW3O49yiKco16MJHfyQhBLlMOFZYLF8qmmrOMvFHaG7U xUS5e23r3cWUAFGjC6vBdNsDWI09XA9OSFS1OnWBbqFSRwSVuxKQALPoVAusoujTX2DO s7AFcDna3YfcJDVKEUc1QhRYWU3Jec3MIc3KtzDWHipwwbXqcwheYdDPWRNQhvIQdPHL U9cWcCtlZnc/Z2kDLHRcr+260M3h1ZxEyKTbqYDNuNqmEkgvW/wA4+wX1j9RFNwF6tWc TqqkPMxmelW1kVdKN5QPAvJNetEGHm2ZcPKZ2HKWRtjvu7RueiPHnX7RDOd4jzmEIi+A 8UvA== X-Gm-Message-State: AKGB3mJekF5UC26zyv5j4cVoA2oLNjRvmvmXfYQEIbSuUZQsal9NDF7Q D9WRf5jY4+8//NhXFu+WL2ndXLdsMR6twQ== X-Google-Smtp-Source: ACJfBotTHI4Q97VHdUApThRKgQ55URLPx/h6Lmp07uNpZ2gkZKjZI34itOmO8U1B/5mKJy/booyABw== X-Received: by 10.46.64.81 with SMTP id n78mr1777442lja.129.1515411888808; Mon, 08 Jan 2018 03:44:48 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id w7sm2281824ljd.95.2018.01.08.03.44.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Jan 2018 03:44:47 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Kevin Hilman , Viresh Kumar , Geert Uytterhoeven , Simon Horman , Niklas Soderlund , Vincent Guittot , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH v4] PM / wakeup: Print warn if device gets enabled as wakeup source during sleep Date: Mon, 8 Jan 2018 12:44:43 +0100 Message-Id: <1515411883-12626-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 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 v4: - Send this as a separate change. - Changed from dev_warn() to dev_dbg(). --- drivers/base/power/wakeup.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index e73a081..f30c233 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_dbg(dev, "don't enable as wakup source during sleep!\n"); + ws = wakeup_source_register(dev_name(dev)); if (!ws) return -ENOMEM;