From patchwork Fri Dec 29 11:37:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 122926 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4574567qgn; Fri, 29 Dec 2017 03:37:19 -0800 (PST) X-Received: by 10.25.233.25 with SMTP id g25mr19123020lfh.101.1514547439246; Fri, 29 Dec 2017 03:37:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514547439; cv=none; d=google.com; s=arc-20160816; b=UtwVvTWc+nEWScPlOfu4bPNm/2eDJLFZZleizaSggGAeanO4ThYUkIm8Gj2iaUeb3Z UGWmk7RRFTDriegtTo4a8KtyeoQuKFfSWBFgl5kPScmHwzmDYQO1iVLBnOk0ZF8w9s7k tglscWACWE1lmpCaObCNrp6gCz2+o8j0n1bo1TrHhbhQGv7erxk7Xim5uxAVRhoG/YBB NW8ukCTBjIU76zNwEwdugUXRMvpnrzLbivWeNd81pXmVBswyWh/NIn5ukKZR5v+3pomy hu6y2uSOPvSflZB9X3g+dYObKAyl12xh+z+J3TdjVZ/THv/PWbuUKWwV10n5OitSZlxB j6XQ== 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=oW3rET3KLR2qx3Z+Qyo47ErWsC0L9XLCU7bkqm0PBv0=; b=OubaaRuvMjUKIWRrEy3sP85PFF1BDdia2Cyk6EU/8bOA8OSviXlyFBzmg/jFDhEFT8 rgHGV44MxkrjI5hYKp6kkZ4X6ulF2vXpnheVEavq3bKRwqiJvSMzK4zO/+aKrWj1HH3B OT296ZxXL0r6H+tQyjd324q/ti+Jc6Or5NBzDEfc1nq40zlZNBsKi+rxIJP7c3NJPEYF PamWo6YFnc5qgIBto2Ku3iLa87J34miSl8JijrvAf1ZalA3wuTMYaQu02SYEsIMDNQ0i 2CtiKqeWQQluFjtCf5DgAgArgFvrolmuj0p475HXoP/75tcSaN4Nul4B1wKz2+A+v3l7 P3qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EBJk72+i; 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 r24sor6273441ljr.59.2017.12.29.03.37.19 for (Google Transport Security); Fri, 29 Dec 2017 03:37:19 -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=EBJk72+i; 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=oW3rET3KLR2qx3Z+Qyo47ErWsC0L9XLCU7bkqm0PBv0=; b=EBJk72+ipL/Z/EOn/tiROsKxaFJwmuojXo+hQ+vtLcftA6T9CAplI3IzrwPfvToRt9 uB2MFbgei73ZPlC6uuhMdmHgM8QE0gsCk8Cj6NP2zCRkvomc+wfHo45LfaEPpkdJQM8I 7QW6bzSolV/1gphQWAuIw07G2calo8q3FnoLY= 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=oW3rET3KLR2qx3Z+Qyo47ErWsC0L9XLCU7bkqm0PBv0=; b=swoyQKc2bZrPXRxcK9092Ad3oQP0AqYcRXEbGDCuHjyYxO2Ha57SuUgjUYbjb1ewry MF79dDdxFhMsiH2lJEOXwANzrMm7Sk276ILwcD060yMngECYpamyqrbgJSYlbZeRFyhV CrdeR+MXNLSewTVu7RiecVKF8gPvI89XwFIE9pCjpLRevgecvI2fivyVVklqoZ4kyTyL n7hkuoBNmQy24OK1cWkTl/43Pe8IESIjuVKjvEeoeLvA5l9G2JIYDgTy3QojemUP2Ry2 +eJBTVXXiPUk4oc6tFEqmUk/W9oQHp5+Am4Unppe9TORJxPbv1+gvNaQLhujzjyergA5 8Q2g== X-Gm-Message-State: AKGB3mIon38wSma4T6douvpdC7GlbegN6gUWkKrtzRsd/klPRojvn93u mKSaBEfYSrsfSyAaHHvcHrZzCgty X-Google-Smtp-Source: ACJfBos8XqndgB6w6r0c3xPQ+z0z52+qRe4uRK50XcM5HaeCuolDo2YjEX4DYZP8rfHFZQCoBlRUJQ== X-Received: by 10.46.21.87 with SMTP id 23mr19867373ljv.107.1514547438860; Fri, 29 Dec 2017 03:37:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 03:37:18 -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 1/4] PM / core: Assign the wakeup_path status flag in __device_prepare() Date: Fri, 29 Dec 2017 12:37:00 +0100 Message-Id: <1514547423-18965-2-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> The PM core in the device_prepare() phase, resets the wakeup_path status flag to the value of device_may_wakeup(). This means if a ->prepare() or a ->suspend() callback for the device would update the device's wakeup setting, this doesn't become reflected in the wakeup_path status flag. In general this isn't a problem, because wakeup settings are not supposed to be changed (via for example calling device_set_wakeup_enable()) during any system wide suspend/resume phase. Nevertheless there are some users, which can be considered as legacy, that don't conform to this behaviour. These legacy cases should be corrected, however until that is done, let's address the issue from the PM core, by moving the assignment of the wakeup_path status flag to the __device_suspend() phase and after the ->suspend() callback has been invoked. Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 6e8cc5d..810e5fb 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1620,6 +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)) + dev->power.wakeup_path = true; dpm_propagate_to_parent(dev); dpm_clear_suppliers_direct_complete(dev); } @@ -1744,7 +1746,7 @@ static int device_prepare(struct device *dev, pm_message_t state) device_lock(dev); - dev->power.wakeup_path = device_may_wakeup(dev); + dev->power.wakeup_path = false; if (dev->power.no_pm_callbacks) { ret = 1; /* Let device go direct_complete */ 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; From patchwork Fri Dec 29 11:37:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 122928 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4574612qgn; Fri, 29 Dec 2017 03:37:21 -0800 (PST) X-Received: by 10.46.66.140 with SMTP id h12mr21737563ljf.140.1514547441812; Fri, 29 Dec 2017 03:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514547441; cv=none; d=google.com; s=arc-20160816; b=LVM9xWe3mtqP6GXn7n7f+Baz/aM4euOdxYO9R9XhiCA/rwmHo1BlQIGMPjsqNKyk+j Zh8yNEI9aTmQr6QiUv11JTSE5hMVLIE0W/qkUyUOdej31pdc2Y443Dz9oGYqE/ysgtqL re/iUnF+Xih4DgN5dW3X/G1iOHtES6o8SE8iWw2WFzjTFOCYT5VNZa9HidVGb2qdNrex qUuYsl6rIlHkbIxScMCwuGqzAbjWEbxNUHnaW7YQnTpCbrE5JxoQm1oWwqBA+69vwVn/ +JVMqje83yk0ruBLH/28/dheYeO1OHexwlyKtfoa5SojOlk6qGslXQJOEBGl55bUdSrl 8X5w== 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=rdpOgODAN4wA1DRykNoVcAfIYjCPQk13D5XDO5F/Qcs=; b=tv04i0APMHaTkGbqpnSlcTZVCjDkjU70F3XbGX33sXWyIXsY532o0/ZAXstrQHpMJe ZBo1Imo6Qo+VvAWL5ufhJsptuxMIrfghdf5ap00cXn9X0avb4weIAO/hipVaMA6xpD6a +dwygL1rOeSHOf/HcME4Uoz87sqCQUw4uCunwoKL65jEDuzUgyTIOB0KuS4Jc4SqOZXU 7KI8Nms8EOaLbdvac0jeOCxjeuYD0xWb/GHIMbznMe5Zc3YX6JGElW8HvPzGKQN2iT4H JFqiTT8zvSfAFm9a91nj2oCbj/3wwyM+BLn1aEN/d/2piw8lmAVfi9q0Oh0sll/U9fXS Xo0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GjjonOkh; 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 i62sor4261901lfk.93.2017.12.29.03.37.21 for (Google Transport Security); Fri, 29 Dec 2017 03:37: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=GjjonOkh; 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=rdpOgODAN4wA1DRykNoVcAfIYjCPQk13D5XDO5F/Qcs=; b=GjjonOkhCzeFqCaq3Hr0pnoyVJbtknwQFhuNTFXHuaRdrOmqbV5dgAkLfvKE4DlrsW gd67bAM6udGD3wMD45xt92Y/vn1StjWPsP1mYwOPNHBgLKbxXqaVIgKP73Wy1VWl+0ff om3E3zaztKDIZqLLDQbOrMO2TWZQfG+/QzDHw= 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=rdpOgODAN4wA1DRykNoVcAfIYjCPQk13D5XDO5F/Qcs=; b=GwECNjoqri5Lhg6d9nGFJ5tye6dgg7ji3EjxvU5As37tkqnuPwYaZdgPhUNI1/smO6 cBG8+8PWQV3X8L5rudcqShaCu9DYAx55RceMgzQ0FNcU+wzMLlo2yqwpGThKiTwdJomQ y85xvwZEoCaXTR4qGTKMd1507DO0UoZs/0Fjci4KHn0JUb0594s4gW0VMAEUpRAMl8BE zb+0Qq/A905kxinFjqWXetr783XFN6nd/CfoYfoUpydjqD5aKesaKtGPlg6rj/d1NqD+ ddUXWyDHtkB5kg3Fk53xHRG18bSKtYAHWfhx36A7IgDB7gRNzlqRSVDbQBpdEq91Adzi JvQw== X-Gm-Message-State: AKGB3mLNJxkruSrSw7ehfnom9YS9CwxarMi3eqbTkrLzjHp1mLAh4wuG fYCj2+teWLsPHJhtfCIGTBoZMY6q X-Google-Smtp-Source: ACJfBoucv+YqSnRWvDymTGhy0JBn+jblyL5WEECEXULta+vq2/wO9Js4RHx0SgGIvbKef7as/yFSww== X-Received: by 10.25.21.101 with SMTP id l98mr20294871lfi.134.1514547441464; Fri, 29 Dec 2017 03:37: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 r74sm7280469ljb.28.2017.12.29.03.37.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 03:37:20 -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 3/4] PM / Domains: Take WAKEUP_PATH driver flag into account in genpd Date: Fri, 29 Dec 2017 12:37:02 +0100 Message-Id: <1514547423-18965-4-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> In case the WAKEUP_PATH flag has been set in a later phase than from the ->suspend() callback, the PM core don't set the ->power.wakeup_path status flag for the device. Therefore, let's be safe and check it explicitly. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index f9dcc98..32b4ba7 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1038,7 +1038,9 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) if (IS_ERR(genpd)) return -EINVAL; - if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd)) + if ((dev->power.wakeup_path || + dev_pm_test_driver_flags(dev, DPM_FLAG_WAKEUP_PATH)) && + genpd_is_active_wakeup(genpd)) return 0; if (poweroff) @@ -1093,7 +1095,9 @@ static int genpd_resume_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd)) + if ((dev->power.wakeup_path || + dev_pm_test_driver_flags(dev, DPM_FLAG_WAKEUP_PATH)) && + genpd_is_active_wakeup(genpd)) return 0; genpd_lock(genpd); From patchwork Fri Dec 29 11:37:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 122929 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4574642qgn; Fri, 29 Dec 2017 03:37:23 -0800 (PST) X-Received: by 10.46.23.20 with SMTP id l20mr23423758lje.25.1514547443025; Fri, 29 Dec 2017 03:37:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514547443; cv=none; d=google.com; s=arc-20160816; b=qIaUpqq0WETnHD8xDisfbkvDl4yUjm2AYgLlTebaceMVd+VcrbpNm2fs3CIpX3571h K+CH/kA+8mzddRT10Amq7b0cV18Pm5YHbSFSQsJQXtOQrRa292yz6OrUuDIM1ri/WR7e uByYJJaIX1KEdSCHbwSDxb+xszy1drrIpFKo7keLRegSjXmurnnJyiydrWq8HUpnzYI/ ejr1uU5Nin/acWzzCpOW3RyveG7TyKblvZ69waTsj+aMt9XxVl5EbWBcdwz/SfQZ2Zed CXJdJIHnf9E1k+i2Mv+dyTTNLIhZqirQabL4Ac6Zp/Hop9UTTGLtWam/w4FqrnwQa6G4 isyg== 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=jeSqjtzB2DBp2xANqlxHzuTbpbqPELPc77QlkQt6RsU=; b=MsgTBaYmvwhvDDE8UciBaFTK0y/Vogv+KXn0iUy6h9Kb6iCQHXA5Sz+3GfQIe2kwC6 n/m8Au4+NZVAeUrzxfrf4v6y9TunoJaf+pcw0Nl2wC4GW4NkVlAL/WbToAlXkC242i+k enCULRHnY1h50oBOFD86tNicuFxj1HRemmu42N3eKcF7RmGoSxsq+byT64/ingJQhopE eS2wstnbn/oKuHs9sCwkzteLO8KdQLoIjXCrCGoRYJ2RSbq9Vhr6PSLAeefoLw48pSEf 4fndcEzWVhjTWmFFenrnWEXFgb4RpQsM8W72+/XCZxKFoNUSUpqa7k/3zFt6cdZbjE21 IWmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EluEPxjw; 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 f79sor3808430lfi.39.2017.12.29.03.37.22 for (Google Transport Security); Fri, 29 Dec 2017 03:37:23 -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=EluEPxjw; 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=jeSqjtzB2DBp2xANqlxHzuTbpbqPELPc77QlkQt6RsU=; b=EluEPxjwD8gsHte8MkyuIsRRpQ1mfsDQfG5fPBV9bHGpR5W7wloO0Z/MSROFeb3tmG yuFbc66RkpPycp+Kix4aFyVvCuuCiF0Qc70QhDYBglFe7Uw1O79RKHI4yAy8dn5uAR9i lB47NAyTXjCGOelzcRXmUtEwNzlUghSvUeyko= 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=jeSqjtzB2DBp2xANqlxHzuTbpbqPELPc77QlkQt6RsU=; b=LD12La2GSJ7hjQu+EsbtiWO0jm4y5vpMt1adaDZbAHwUjTNzjqBDILO57kAu1KpQ9F K26eyqUmBT9M+8mFg7LViphko+t1y7FjQ7M+2ROsZ29Cw0Y7SCeNPnqR2HnTjbYZHZxL U7jBx8x4hb4Hy9P4ahaVs0RaIn6r/avMM56obMMdSUfgwg/y2RKjftAnoFgt27IFDI1v p7pVgnXLO04YRQD725ODrlnQT5/oBeVk5Ra8lLIO7jlydnna+04m8khcreYFAU90zK5P Zao8SrdmJkLVpbZPggjA3tybVjYuxlbMcWxgUB9aKCKKSFdDtrp4pfYtJkI9mb4YU21O E0mA== X-Gm-Message-State: AKGB3mKW6P9VF2EpDba02gXzvZxn1QEYAOXmPWepbJU3pijzcn+nbR74 U0Ryr8PDdR2RQJsrFYjjCUeaXaiX X-Google-Smtp-Source: ACJfBovEQwxpeJHuLLimKgAque7caoR3bHXOHQNLYavbHuq+hz82ImfcJD3npBSCXcDBfzQAoyDv3g== X-Received: by 10.25.150.137 with SMTP id y131mr19534724lfd.91.1514547442641; Fri, 29 Dec 2017 03:37:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 03:37:22 -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 4/4] PM / core: Print warn if device gets enabled as wakeup source during sleep Date: Fri, 29 Dec 2017 12:37:03 +0100 Message-Id: <1514547423-18965-5-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> In general, wakeup settings are not supposed to be changed during any of the system wide PM phases. The reason is simply that it would break guarantees provided by the PM core, to properly act on active wakeup sources. However, there are exceptions to when, in particular, disabling a device as wakeup source makes sense. For example, in cases when a driver realizes that its device is dead during system suspend. For these scenarios, we don't need to care about acting on the wakeup source correctly, because a dead device shouldn't deliver wakeup signals. To this reasoning and to help users to properly manage wakeup settings, let's print a warning in cases someone calls device_wakeup_enable() during system sleep. Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 4 ++++ drivers/base/power/wakeup.c | 4 ++++ include/linux/pm.h | 1 + 3 files changed, 9 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 1327726..6b0d312 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1030,6 +1030,8 @@ static void device_complete(struct device *dev, pm_message_t state) callback(dev); } + dev->power.may_set_wakeup = dev->power.can_wakeup; + device_unlock(dev); pm_runtime_put(dev); @@ -1747,6 +1749,7 @@ static int device_prepare(struct device *dev, pm_message_t state) device_lock(dev); + dev->power.may_set_wakeup = false; dev->power.wakeup_path = false; if (dev->power.no_pm_callbacks) { @@ -1775,6 +1778,7 @@ static int device_prepare(struct device *dev, pm_message_t state) if (ret < 0) { suspend_report_result(callback, ret); pm_runtime_put(dev); + dev->power.may_set_wakeup = dev->power.can_wakeup; return ret; } /* diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index cb72965..5445bea 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -268,6 +268,9 @@ int device_wakeup_enable(struct device *dev) if (!dev || !dev->power.can_wakeup) return -EINVAL; + if (!dev->power.may_set_wakeup) + dev_warn(dev, "don't enable as wakup source during sleep!\n"); + ws = wakeup_source_register(dev_name(dev)); if (!ws) return -ENOMEM; @@ -413,6 +416,7 @@ void device_set_wakeup_capable(struct device *dev, bool capable) return; dev->power.can_wakeup = capable; + dev->power.may_set_wakeup = capable; if (device_is_registered(dev) && !list_empty(&dev->power.entry)) { if (capable) { int ret = wakeup_sysfs_add(dev); diff --git a/include/linux/pm.h b/include/linux/pm.h index ebc6ef8..106fb15 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -606,6 +606,7 @@ struct dev_pm_info { struct list_head entry; struct completion completion; struct wakeup_source *wakeup; + bool may_set_wakeup:1; bool wakeup_path:1; bool syscore:1; bool no_pm_callbacks:1; /* Owned by the PM core */