From patchwork Tue Jan 2 16:08:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123155 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9132296qgn; Tue, 2 Jan 2018 08:09:04 -0800 (PST) X-Received: by 10.25.211.76 with SMTP id k73mr3362398lfg.128.1514909343894; Tue, 02 Jan 2018 08:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514909343; cv=none; d=google.com; s=arc-20160816; b=yrLjadNYHPlXlxoa8J8Phh8OGg6gto+dRed0HbeUa5bZPJxFIbs3Imkt4I0LsRTnGx hT2skcDjly8DOmmD+3+DradID+wnP5Je+gl9WaGTHNQw7q2ADvmMLaC43vkASLJr3Xl3 IJ57/jBlb3oxm9Ls3XWbNpB3WMWXy0Fz9m3fG6fLjKzbfczyFJSobr3kUtFaGTPr2b8O IQQ28Ay5PqisD6sh5sPVn3XcLSnqyEPrYuMmrbrL8L7XnaUXT/SAiNXLT48dR3t1IfjL LUrUDzRQv86W+Na5oJPpU9j77JZYkUS4SAzFIo4howbP1AeQFpBdN2nMb4LW92kWXDPe CbRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=K4rX+ztVMVEK9X4ZJB7ynrTTeTWZLjPk88bEZXZkogo=; b=VTkoh/xRt3PfZMYx07uVRmGrWzGualUTEZHGlDi6SHEyAgZpZQvpRNZKSPwRRAvDhR nP+lWAIYvJk/E0wQTnr1sK2tZOhl/EQvBZe4rPEpOxi3lgPy4vjD1KH6yLs6ADKqDsxh dJDLoXtl7xwhsFkqg1Yv/KaCdjahogkif6BUyQfCmwx4n7QBIuGOfFWs5+9R4brCJQNB tuwKJYNVnHBrWeNxHbHUyH9XTBSyDf5i0l/G57EMXxh5Cie9oUgu38eaPy2IVCz/c/l0 7wXMwWZP/MpfalVRmqHAB68X8j0Tmu/h8ih9yu+gcyz/ezfxio0UJG3SRa6Im7PQV67F Q1CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jtNJRIof; 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 98sor3813143lfy.56.2018.01.02.08.09.03 for (Google Transport Security); Tue, 02 Jan 2018 08:09:03 -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=jtNJRIof; 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:in-reply-to:references; bh=K4rX+ztVMVEK9X4ZJB7ynrTTeTWZLjPk88bEZXZkogo=; b=jtNJRIofocKPDMYczWPTByLNvS7vLeQel74M87hNnbqtGk6CTsq8Nf77C7+MklULdU eg223D9UqnMPR7u1iWHf66vLueN0wB3fr/p0Hh6l+MW1kWB//sSUaFLDQMGXfLMubFl4 bbaGcb6hrUu2/CF/rurd7yVHLkYJbQlHHPO3s= 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:in-reply-to :references; bh=K4rX+ztVMVEK9X4ZJB7ynrTTeTWZLjPk88bEZXZkogo=; b=BR5JtZpZH+0J2H5xpro+b3ChriWPC6xoHupgMC51TyBCoU/nkDId05Q9LCn/Fe+Ljc ZbPNT8nLRCA5bxPNyyCbL0Du6UNz6S5GwL1vdHvzd29ZFZ+Kyn7VEKsOW2tt0S+AzSG0 rbHXtFXmws/1c10/5UTOkOUh60ASnnqXZodxXJGUCZ4BdtEoaF/ehCg/ZcJXb4Tpfuc+ ciSy+FVGl2EhkkPHVZwTMdsjb+WxZpRmgKNiynfBPxsetYUxgsi9nPJNNPAWHzpNsLdQ 0dHb9fTbdDSIomn+GTJ2kKkag7AXRowDiJjZ7p/w9r+QLSm4wC5ZJcOtayQqAK7uq4FD HuJg== X-Gm-Message-State: AKGB3mIDlu5eaU76ykg0T2Lp70zk70z1UTj5HugUyffuc/+V4l1jPPEH EXzDE0+wbGm19S+BHkPsQkSp3rTZ X-Google-Smtp-Source: ACJfBovqIoVVLGP8HjHGVXH4PUAfzBcPtvZ4Dv4zPVg63x0yJgaygFJqkC/ora6GuIW5nWlvfG8RHw== X-Received: by 10.25.79.3 with SMTP id d3mr14899863lfb.71.1514909343292; Tue, 02 Jan 2018 08:09:03 -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 f4sm1619422lfl.17.2018.01.02.08.09.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:09:01 -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 v3 3/4] PM / wakeup: Add device_set_wakeup_path() helper to control wakeup path Date: Tue, 2 Jan 2018 17:08:52 +0100 Message-Id: <1514909333-4450-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514909333-4450-1-git-send-email-ulf.hansson@linaro.org> References: <1514909333-4450-1-git-send-email-ulf.hansson@linaro.org> During system suspend, a driver may find that the wakeup setting is enabled for its device and therefore configures it to deliver system wakeup signals. Additionally, sometimes the driver and its device, relies on some further consumed resource, like an irqchip or a phy for example, to stay powered on, as to be able to deliver system wakeup signals. In general the driver deals with this, via raising an "enable count" of the consumed resource or via a subsystem specific API, like irq_set_irq_wake() or enable|disable_irq_wake() for an irqchip. However, this may not be sufficient in cases when the resource's device may be attached to a PM domain (genpd for example) or is attached to a non-trivial middle layer (PCI for example). To address cases like these, the existing ->dev.power.wakeup_path status flag is there to help. As a matter of fact, genpd already monitors the flag during system suspend and acts accordingly. However, so far it has not been clear, if anybody else but the PM core is allowed to set the ->dev.power.wakeup_path status flag, which is required to make this work. For this reason, let's introduce a new helper function, device_set_wakeup_path(). Typically a driver that manages a resource needed in the wakeup path, should call device_set_wakeup_path() from its ->suspend() or ->suspend_late() callback. Signed-off-by: Ulf Hansson --- include/linux/pm_wakeup.h | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.7.4 diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h index 4c2cba7..4238dde 100644 --- a/include/linux/pm_wakeup.h +++ b/include/linux/pm_wakeup.h @@ -88,6 +88,11 @@ static inline bool device_may_wakeup(struct device *dev) return dev->power.can_wakeup && !!dev->power.wakeup; } +static inline void device_set_wakeup_path(struct device *dev) +{ + dev->power.wakeup_path = true; +} + /* 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); @@ -174,6 +179,8 @@ static inline bool device_may_wakeup(struct device *dev) return dev->power.can_wakeup && dev->power.should_wakeup; } +static inline void device_set_wakeup_path(struct device *dev) {} + static inline void __pm_stay_awake(struct wakeup_source *ws) {} static inline void pm_stay_awake(struct device *dev) {}