From patchwork Fri Dec 29 11:37:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 122927 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4574599qgn; Fri, 29 Dec 2017 03:37:21 -0800 (PST) X-Received: by 10.25.202.83 with SMTP id h19mr8380007lfj.97.1514547440953; Fri, 29 Dec 2017 03:37:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514547440; cv=none; d=google.com; s=arc-20160816; b=PuWpgj+Cn4mKOYzNUkEqHyPWEvvOlvuqIV33F3VijP13nwKNxF97uZtjerYIaI+oE2 62mgBs5r7uFN7CcCh4GQ94LUQLR9I0XBtl/DJZZrspDUleAuWElFS6KeQAejDT7ciKRf d5zQ+Uv1leyK2brbCSDZd0KonVkcPQjRRi0Pq2JQZmcbY86cQjA5otAXiQPOnrLianIQ Hu8R9MMrutVo1XNQZsxLP0U7E4GFioWat2oZkFxTJvKR5lckCdCcRwRnN6I2QxOZPJhp pgA5awA51ctCvvyQvBYCcQzf7AAFKNvqlm6YY+7bFII+uTRgFaKSiJ99anydHkfiOmgb jTZw== 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=OXVTbBVyb8As8Yrqn/1KiYPJKsdq9JJvs6Uwj5w0K14=; b=l3/TvQJRuFaEBO8TQ3kiVkWRrZdF8wB7aJV19bDMVRBGF7fnJCKqJrC4JsSnZmdmfl gJqn5XvBxzl8gSOEPq2QTCxWVJToC2Wgp3RsfFZqPrNZbR8hW3yMim9ZVxGif2PnHeb6 9BkmWqqLc4vxGZWSDGF0UulvzJfwOeVhDFs0Bk5MeofCy+/J9XMPMxIGN4MePCmudlNh s2YSyXvbR8el1n4NHGDJwsMcMOL83T6ycpu4bDl9nCP+ynYvrlhIFPerhY/eWVBmsgof oTYS/vf7WhtRGjOfUpTH4ayhfd7dfMJmTTwupzpaE88v8iBRKpgvn0LZ9QW4bEmMlVWb wzCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dV9ShgD5; 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 s192sor2366927lfe.81.2017.12.29.03.37.20 for (Google Transport Security); Fri, 29 Dec 2017 03:37:20 -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=dV9ShgD5; 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=OXVTbBVyb8As8Yrqn/1KiYPJKsdq9JJvs6Uwj5w0K14=; b=dV9ShgD5RBjp0kCSM+rTXROtkQVMXnC48KQ1+tHCitNoiey7JQ0stDqc9rUAMl8yhu Olxmw9B8RgYrEqnXbcW6Sg6fBRBExP6+YP7E5TyHUMf8qhVaDJ8U5iB+sbZYoBXI6IuK +qNusFI6n8EJ1xYSfgGTWI3zP57ygjXQhQoGo= 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=Ags5KqwoAfEBJBeXd8rX/al7zDLcLKgvlzNAyRJbdi9QcT6BdEaZbeJPj8kPWki59j NdQSLacWXD+b7ZZbgIYXVznuRAmvGy4J7K+HrzOozMcvJKwR+EGXUJRGC1uvaFjzwPnE 8bYnLDrjwgdbkrAanA4Sod2lTJ1CZlaiu0UZzEWNC3HgAkj10pq1tXJrOMNE5/eCSEzV FxxjmkjXE3t/JQlKJU0JTeOXUQbIZKGgjLStwzbqMGJJzxSxHqh+o891WJeMudZPSe9I Y3W/s/9IA0JmXvnArmiHPykrCr3Yxj5cVfGkrEAad2Le5OlKZmQfJJLQoeB3xZtgQVvk vJNA== X-Gm-Message-State: AKGB3mJEfXw4dhdN7+iKdBuhV6GhBKsZgG2tU1ug1ho4CB2TbX8qkeTP DwnzzmA+mwzdoEWwwcfgySNHUTdW X-Google-Smtp-Source: ACJfBotyyN5lvD3ODk1SvoD9nyvhhsCOMQHndcGxWWVP/sjtHpfBgfCFQn6dEXrD1qE29BKrFTiLXg== X-Received: by 10.25.147.193 with SMTP id w62mr14760083lfk.72.1514547440156; Fri, 29 Dec 2017 03:37:20 -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 r74sm7280469ljb.28.2017.12.29.03.37.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 03:37:19 -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 v2 2/4] PM / core: Add WAKEUP_PATH driver flag Date: Fri, 29 Dec 2017 12:37:01 +0100 Message-Id: <1514547423-18965-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514547423-18965-1-git-send-email-ulf.hansson@linaro.org> References: <1514547423-18965-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 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(-) -- 2.7.4 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;