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: 10140975 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 30A0B60594 for ; Tue, 2 Jan 2018 16:09:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 177E728433 for ; Tue, 2 Jan 2018 16:09:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C3C728BE8; Tue, 2 Jan 2018 16:09:08 +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 8E27F28B7B for ; Tue, 2 Jan 2018 16:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751083AbeABQJF (ORCPT ); Tue, 2 Jan 2018 11:09:05 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35281 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbeABQJE (ORCPT ); Tue, 2 Jan 2018 11:09:04 -0500 Received: by mail-lf0-f68.google.com with SMTP id h5so12499720lfj.2 for ; Tue, 02 Jan 2018 08:09:04 -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: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=DwGyBwxLTIU3HiJs3xTM9JCx5vjIceX1I8ZHrdqR2U9XXtwmPAIx3A54f51wIOAsJt hIwrnorUK56GO/C2r0Wyrgk9LeZAbEYCsiTaboVcoQDTh2VUKTf8bd+utwJRU4+9bfn4 k+n7VNqtbHBPL0kFskP5fuQAPmjiU1/+HxVWmYCOmqhszZlZPg3xDirzCmkrO7JlQnIY VGxJ0DB1a13nB31GZ2I+q9n1CJq7AIDa9lnhA1zxjLn/9PtlqclHTsQfByiDAwmilpBc UVVkgDHhVw58ClAty1ekZUF7aWx5CGUCGJuzRA8REtG07PBrbXVs/WmhLUJGBaHkZ2eO 9ZUg== X-Gm-Message-State: AKGB3mKXreRedtfO1Nm5iI4sPrgm5rc9rhwGswA4byMtBdLkhiEi2N0X ao7K23wlU9j6wYiC32xfD8/JAA== 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) 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> 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 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(+) 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) {}