From patchwork Fri Dec 15 15:56:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10115439 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 9FCFC60231 for ; Fri, 15 Dec 2017 15:56:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9AD29E60 for ; Fri, 15 Dec 2017 15:56:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8365029EBB; Fri, 15 Dec 2017 15:56:51 +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=unavailable 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 2E06429E60 for ; Fri, 15 Dec 2017 15:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932523AbdLOP4u (ORCPT ); Fri, 15 Dec 2017 10:56:50 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:38726 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932419AbdLOP4s (ORCPT ); Fri, 15 Dec 2017 10:56:48 -0500 Received: by mail-lf0-f68.google.com with SMTP id u127so6894673lff.5 for ; Fri, 15 Dec 2017 07:56:47 -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=OXVTbBVyb8As8Yrqn/1KiYPJKsdq9JJvs6Uwj5w0K14=; b=VS04eRJBW0tF2J2SQvw2Et8mZE7AswIJ2eqcS5Ot5PU+3VdzkLXjFgn9yTqfgqiuz/ HTzXbLgROL7FP7kKA0U+jEl6UGhjezOXHf+wGb7HXlqoF7zC0SeqcszIFVcd/W7BtgH5 8L/KYd6knfg/EoiU1FshE5av0FfeAP8v4yeVg= 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=OXVTbBVyb8As8Yrqn/1KiYPJKsdq9JJvs6Uwj5w0K14=; b=Io67JhBiNaPU+m1z9741wr1vi822PXjEBeBUP5xlawUmElJbHuiLqI/CRSy4n9P3kT CHmyf6QYXyKdWMwJMbFrXIFzpxqVca5KN500tnR+pdkmDibdYeGvJSysqMjJJ81oiqR2 XJXe+a/yLTjh7+C2676FcpSRaZi5vh1JLY62W3noguiSYwqTpV0FmiSJcWkhdbanT3b3 l3kU62tRxei/UXetD888c524YF0J8EWxcUjWlarRkQZbwGr4lBPpTXo9vv97ih3uU5Tl iZF9aTsuJswfud46sZ6qseLspF1GVKj+yAW5gg4YI6nmkGTQi4pjHhM5oNoANemZkzwa uogw== X-Gm-Message-State: AKGB3mI8S0DMVMuIMxTlTo2GuqD20DqhUseNNDqkHNj0qxV53xjZQzHj ggVKaEydQ6Dm1f6l4Knpre2VvA== X-Google-Smtp-Source: ACJfBovBOC6OCdFGXSMMNM2M6wQ+vV2sVSA3KK4lo+esHlHbP2lfzL64+5pAkKEHZkQderNBOrkufg== X-Received: by 10.46.34.196 with SMTP id i187mr6727659lji.106.1513353406285; Fri, 15 Dec 2017 07:56:46 -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 y15sm1294216lje.10.2017.12.15.07.56.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 07:56:45 -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 2/3] PM / core: Add WAKEUP_PATH driver flag Date: Fri, 15 Dec 2017 16:56:30 +0100 Message-Id: <1513353391-30806-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513353391-30806-1-git-send-email-ulf.hansson@linaro.org> References: <1513353391-30806-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 information about the wakeup path for resources, is currently not available to a PM domain (unless it has some HW-logic that knows this), which means that it may decide to power off a device and its PM domain. In other words, it may prevent the wakeup signal from being delivered. For this reason, let's introduce a new WAKEUP_PATH driver flag, to allow a driver to indicate that it controls a resource needed in the wakeup path. Make the PM core to check the WAKEUP_PATH flag immediately after the ->suspend() callback has been invoked and set the wakeup_path status flag accordingly. In this way the wakeup_path flag also becomes propagated to the parent device, which may be useful for some cases. For a PM domain that needs the information about the wakeup path, it should check the wakeup_path status flag for its attached devices in a later suspend phase, but perhaps also the WAKEUP_PATH driver flag explicitly, in case it has been set after the ->suspend() callback has been invoked for the device. Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 3 ++- include/linux/pm.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 810e5fb..1327726 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1620,7 +1620,8 @@ 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_pm_test_driver_flags(dev, DPM_FLAG_WAKEUP_PATH)) dev->power.wakeup_path = true; dpm_propagate_to_parent(dev); dpm_clear_suppliers_direct_complete(dev); diff --git a/include/linux/pm.h b/include/linux/pm.h index e723b78..ebc6ef8 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -560,6 +560,7 @@ struct pm_subsys_data { * SMART_PREPARE: Check the return value of the driver's ->prepare callback. * SMART_SUSPEND: No need to resume the device from runtime suspend. * LEAVE_SUSPENDED: Avoid resuming the device during system resume if possible. + * WAKEUP_PATH: The device is used in the wakeup path from system suspend. * * Setting SMART_PREPARE instructs bus types and PM domains which may want * system suspend/resume callbacks to be skipped for the device to return 0 from @@ -576,11 +577,17 @@ struct pm_subsys_data { * * Setting LEAVE_SUSPENDED informs the PM core and middle-layer code that the * driver prefers the device to be left in suspend after system resume. + * + * Setting WAKEUP_PATH informs the PM core and the PM domain, that the device is + * a part of the wakeup path at system suspend. The PM core detects this flag + * and sets the wakeup_path status flag immeditaley after the ->suspend() + * callback has been invoked for the the device. */ #define DPM_FLAG_NEVER_SKIP BIT(0) #define DPM_FLAG_SMART_PREPARE BIT(1) #define DPM_FLAG_SMART_SUSPEND BIT(2) #define DPM_FLAG_LEAVE_SUSPENDED BIT(3) +#define DPM_FLAG_WAKEUP_PATH BIT(4) struct dev_pm_info { pm_message_t power_state;