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: 123867 Delivered-To: patches@linaro.org Received: by 10.80.140.226 with SMTP id r31csp303383edr; Tue, 9 Jan 2018 02:54:21 -0800 (PST) X-Received: by 10.46.97.1 with SMTP id v1mr8790227ljb.84.1515495261779; Tue, 09 Jan 2018 02:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515495261; cv=none; d=google.com; s=arc-20160816; b=vQ3qhUUFp4MW/Rpv+T3m3HfQ5MDW230cQrW4Tzm9i/aJNBHuJUm24xJj3WRLMEvInJ Ln2G0GW9jRPj8OkXwNUgDamddtcKFX9oNGEmpEu3KkrMjqA466vpGG2LCOtCwyGGzxWV 5vLtgAvxKyjp7JrxitMmS3E1/3SoJRteczY6m/eI+fIXq63X0/ylIiMYnA7iyCKq0//P Tavt74NNtHJrA9SFLq+mnGzuuDbJhXUK8CnB99YkspPvVmVXcGGyQ5P85jVd97Xr5F5J Za6B/awCdd+fP4HDfLYcUyX/kj6UDD3pdcxSUOgugNAri+yOYVvrfU3fUPOkOyzJaChp d0gA== 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=y0svNXhCXMZx6p8nvvXCRzYY5DxwAqYF7ULjkLTHv0A=; b=yyQ+Jk4vD4eY6XcbJRWBtOxwbUKeIpCbDtHibgJ6d3TAp/C4b8Rt2dci1TcnMnYgP3 JIZ3D+FIxNUFjGaqx9SqUr+LyeN9Y5/z6BReHqFStYuVyWgKJnF/00z2JVb2EBNX+cH3 UFCUDkDyyYKYCZNruG/a/2KJdXL77jdrIZJm5s+O4lzNcgPNZfweQ0VlDEqgihXnzjlQ V2Y2ZcZSIVq3xstEZDC5FpLXNcTx5lY/oYwOP4xBVDbFk4GXeNuoGostCwKKkRZyOp5X Ws0dJ8Fzraeqfu+EHJpETb/PCKsBsDmL1A49n+ku4iZKjcDFKDWnfO5sUj87HFvlmB+4 JeIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MgKbx83A; 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 b62sor1940016lfe.15.2018.01.09.02.54.21 for (Google Transport Security); Tue, 09 Jan 2018 02:54:21 -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=MgKbx83A; 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=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=F4U5I6VkPB+nOUjwoXcZMLdwR7gn9Lhm8g3kbRkkLRvhU+YwiTY8FmwwrIkuXewgd8 RCrTH6XpzNk72Mkz5wKxMVN9TYH51uZGWzJDH1bvQcyr/e75bsUTn2Z64D0Br7rAiX0T Rti5pRV9+tziCQLsc+ERh4h81MUsANcdTcjaZUXG4xLuhWGrWsm3ZnbdnpSis2UYKFi1 HWvPw359Fbd5k7dvDv5odPhA09NImzIU1BN+HyL4l+TL+0w8ZaQ0mhdXZL44v0gxdfxa WnAQDjPYgfRMsi5+kKIYqji926DPgLMjawGTnRVhZYl8Phk546MZK5ruIJ+xOv7AAgOP 2LvA== X-Gm-Message-State: AKwxytdooPTwnwwBxmDjlmHaA4iqW0OT6yXE020lqfIJbpfER7N+Xs7R KB7tW5D4ogIHH7jq2LDJDDJstDIE 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) 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 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 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(-) -- 2.7.4 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) {}