From patchwork Tue Jan 9 10:54:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10151659 X-Patchwork-Delegate: geert@linux-m68k.org 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 0D89460223 for ; Tue, 9 Jan 2018 10:54:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09714209CC for ; Tue, 9 Jan 2018 10:54:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F260628173; Tue, 9 Jan 2018 10:54:25 +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 61193209CC for ; Tue, 9 Jan 2018 10:54:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751927AbeAIKyY (ORCPT ); Tue, 9 Jan 2018 05:54:24 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38299 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbeAIKyX (ORCPT ); Tue, 9 Jan 2018 05:54:23 -0500 Received: by mail-lf0-f67.google.com with SMTP id d19so7135758lfj.5 for ; Tue, 09 Jan 2018 02:54:22 -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=y0svNXhCXMZx6p8nvvXCRzYY5DxwAqYF7ULjkLTHv0A=; b=MgKbx83AMM8XKhHJ6nI43yO0DNuwIrQgbXw090d3tYXN5UoOElAVpH8kAMLZCZjbEH QsoDGefWsZi88TU78uqQVzJ+arIY5L+YxBjJrP6ppspagIen3ivM6mCfIj4NTGNReWE6 yxq2TMJc4Zzi4UcYeMYX3KyDBU9jKZMBXFOLo= 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=y0svNXhCXMZx6p8nvvXCRzYY5DxwAqYF7ULjkLTHv0A=; b=h0w1pWkY264ZNYsZoi8z1Y+Jugz8c7nfJukdLVGHENFROTzBskaEoiwrlCFKAIsXnU 2FEqjWo2NUYdTk4RHguRsV5IxI6ghQt85ovEltCc8PMYAoH6BBRpXmmluDfokNkOibO4 g8//bRinwq2C5Gifb8Jbx8grNM25k7VUjsv3zrqka56tdnMHPeqoq09Nd5VVS/Brfrhu 9aeCcawTpyjsgRdgN4eUiUXNN8Bag9gQ1uKN/u971tbI/bBbQc/O24ltG5P74eiV391C OsVtCgpYhDMrD5sH0zUHo6Hj1K/zg1c4gjvORpsnY3nSt5uo86CBYRn2LMUnJf0en6id tohA== X-Gm-Message-State: AKwxytcAeuSXG9dTuli3R0eJAwX1XulFJvGT29An6mN2fXjvj2kuHN4W Op3TNVgoAIMhWDaj8ecGovnshg== X-Google-Smtp-Source: ACJfBov4+YSMxYnw29uhXOn+9iXM5u6FEgv7F5fRlRp9au2+zniv40fa37Z66O+vO0GVQe2iXA6V8g== X-Received: by 10.25.93.86 with SMTP id p22mr7499614lfj.16.1515495261182; Tue, 09 Jan 2018 02:54:21 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id d1sm2815272ljf.66.2018.01.09.02.54.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 02:54:20 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Adrian Hunter , Kevin Hilman , Viresh Kumar , Geert Uytterhoeven , Simon Horman , Niklas Soderlund , Vincent Guittot , linux-renesas-soc@vger.kernel.org, linux-mmc@vger.kernel.org, Ulf Hansson Subject: [PATCH] PM / wakeup: Enable option to specify wakeup as a non in-band wakeup Date: Tue, 9 Jan 2018 11:54:11 +0100 Message-Id: <1515495251-22906-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases, a driver may not require its device to be powered on to be able to deliver wakeup signals during system suspend. Likely the most common scenario when this is the case, is a driver routing the wakeup signal through a GPIO IRQ, instead of using the regular in-band IRQ logic, via the device itself. Obviously the driver may put its device into a low power state during system suspend in cases like this. For example it may gate clocks, put pinctrls into sleep state, etc. However, for middle-layers and PM domains (like genpd), which checks the return value from device_may_wakeup() and/or the ->dev.power.wakeup_path status flag, there is information missing about scenarios like these. In the case of genpd, when it finds the ->dev.power.wakeup_path status flag being set for a device during system suspend, it leaves the device in powered on state including its PM domain. In other words, wasting power. To address this issue, add a new ->dev.power.no_inband_wakeup flag for the device, which drivers may set/clear to inform the PM core, in case device_may_wakeup() returns true, whether that shall make the ->dev.power.wakeup_path status flag to be set or not for the device. The PM core checks the ->dev.power.no_inband_wakeup flag in the __device_suspend() phase, after invoking the ->suspend() callback for the device. At that point, the driver is responsible that it has set a correct value to the flag. Let's also introduce a helper function, device_set_no_inband_wakeup(), which drivers shall use to set/clear the ->dev.power.no_inband_wakeup flag. Signed-off-by: Ulf Hansson --- To get some additional background, one may look at earlier discussions from various threads. The most recent is in and RFD [1] from Rafael and from an mmc series by Adrian [2]. Kind regards Uffe [1] https://marc.info/?l=linux-pm&m=151541229425689&w=2 [2] https://www.spinics.net/lists/linux-mmc/msg47549.html --- drivers/base/power/main.c | 2 +- include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 02a497e..376c275 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1794,7 +1794,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) End: if (!error) { dev->power.is_suspended = true; - if (device_may_wakeup(dev)) + if (device_may_wakeup(dev) && !dev->power.no_inband_wakeup) dev->power.wakeup_path = true; dpm_propagate_wakeup_to_parent(dev); diff --git a/include/linux/pm.h b/include/linux/pm.h index e723b78..d131834 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -600,6 +600,7 @@ struct dev_pm_info { struct completion completion; struct wakeup_source *wakeup; bool wakeup_path:1; + bool no_inband_wakeup:1; bool syscore:1; bool no_pm_callbacks:1; /* Owned by the PM core */ unsigned int must_resume:1; /* Owned by the PM core */ diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h index 4238dde..5d40887 100644 --- a/include/linux/pm_wakeup.h +++ b/include/linux/pm_wakeup.h @@ -93,6 +93,11 @@ static inline void device_set_wakeup_path(struct device *dev) dev->power.wakeup_path = true; } +static inline void device_set_no_inband_wakeup(struct device *dev, bool wakeup) +{ + dev->power.no_inband_wakeup = wakeup; +} + /* drivers/base/power/wakeup.c */ extern void wakeup_source_prepare(struct wakeup_source *ws, const char *name); extern struct wakeup_source *wakeup_source_create(const char *name); @@ -181,6 +186,9 @@ static inline bool device_may_wakeup(struct device *dev) static inline void device_set_wakeup_path(struct device *dev) {} +static inline void device_set_no_inband_wakeup(struct device *dev, + bool wakeup) {} + static inline void __pm_stay_awake(struct wakeup_source *ws) {} static inline void pm_stay_awake(struct device *dev) {}