From patchwork Tue Jan 2 16:08:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123153 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9132219qgn; Tue, 2 Jan 2018 08:09:00 -0800 (PST) X-Received: by 10.46.95.28 with SMTP id t28mr25064745ljb.110.1514909340498; Tue, 02 Jan 2018 08:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514909340; cv=none; d=google.com; s=arc-20160816; b=BqYgabxMa6l57knqJU2QEHal4hhVTVyWvS81JpeEZvlXPN1CUql/Bk60ocZgQwhyeE nTZ9s2jwZ/4OSng1BlQsomS3MqvyWWpxbiTCFLzMF+Yb3/VpgEZtB3NvP1lZcBhtItpu q6MNj1LUi5GN92+0qttHMFGDsT7QPmHxbd0RWbQZkTDZnNIcoXrOL41ROlyqLAsc7WVR m6p3jisLdsawSt0tmCTjsvm/6MQJMRSkw9tr3uDeTo02MMbQK2ZcpYff9xPAG0yOdBu9 yeO9HsDlN/g0Iw7/fofuWQQ9oHPfCncNM4k10SSIO0XAXBKhpSRZqZ3FubL0L91hg7kQ H9MQ== 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=2TkJwObSBzzfwZ33Q+ifKvh0/A+ZHvasaCfRCMgstgI=; b=zVcSI81dOaoz34sCIU9Ic4+7g5kHa3tgWST5FEoU1QmG4+Wg0ya/hVROzj9uYdMaXo Gpd5RW63pDtOyzIV2AlIuzugI9ZEsM6unnf85CCQddOTeMcM5zGsABV/UuWU95R4ozyM hikJvFmY6mJjdU5WjwW+2sQuU8Hhu31eamp+4nduXFWEtxq7tCXVDLpsT1JAr8yZn+On Pz9PUyDXaAFtgqAdT+yS/ctKfyxNSCZlDAYRKXLXnqW3lE5lPhparZFuBXH/ykerAcUG Djh0J7Lvwqzsd/MHBW013dSbZD1iz2t6LILKK6p8TeUv/g8K2g6BqLS8HwpSMeucqcpX jdFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D1HuTXIe; 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 u72sor4812691lfi.86.2018.01.02.08.09.00 for (Google Transport Security); Tue, 02 Jan 2018 08:09:00 -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=D1HuTXIe; 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=2TkJwObSBzzfwZ33Q+ifKvh0/A+ZHvasaCfRCMgstgI=; b=D1HuTXIeI1elawHYSa1o09S06AUZHZY3lWSLwcIvcqNv3HpEdrKBMuLLRo3ZPjFpRF CRGOiOq443Fym8O28L5ICrRQui9ROYQY+WP++u4hbpjtiCauNDAejE5EDRY2rpUQWURS uTYfJcAVZhr8WQz3DETqOsyTxR29FUDM4yjhg= 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=2TkJwObSBzzfwZ33Q+ifKvh0/A+ZHvasaCfRCMgstgI=; b=CxUmZjn5oTxUJcGPGzXnKp8iz9fx2PVi+5q/hrQm3kEHJU9wur8ZrNOz6XCOu4tjQp W0eAberuxcZIr9/S+D+YedAwIggtp5hrvQnCkzNN1DVCGzdMFAvcRb2c/hGwNN7SLgHG 7uUejO2RMMf0gvuvfVbr47PwIQEETyu7gx0NjE75q+uYaVKqgrv1NzUOmG7evKuGntf2 A5dEipKbBY5UdhZ9K8ctxI7ciktp/YUL3gy+6/UYCt+RnhAlFeFMsKbOYn5p43JNyjMo w5uQmw6ffHKIF+L59Z0fnDpMeIF4jRwditLocZOjpOKFkYLIwdXOnbM99bYvltWF4hyN fopA== X-Gm-Message-State: AKGB3mLoY8mEWMx8I67k1eMqjO4UFnennO/a/UcYNk8AwzD9tLQraN7b VfA2HA6uJLRUYB1s+7tIrgRtXGjKmAbqyg== X-Google-Smtp-Source: ACJfBouYDUz0IS3colNOO+fknCZg/6Hf51TMsINg4FQVagwWJAgGO0i9F1xu22WhMV58k9bK0jQauQ== X-Received: by 10.25.150.8 with SMTP id y8mr2074435lfd.49.1514909340125; Tue, 02 Jan 2018 08:09:00 -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.08.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:08:59 -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 1/4] PM / core: Assign the wakeup_path status flag in __device_prepare() Date: Tue, 2 Jan 2018 17:08:50 +0100 Message-Id: <1514909333-4450-2-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> 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 70398e7..7aeb91d 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1788,6 +1788,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); } @@ -1912,7 +1914,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 Tue Jan 2 16:08:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123154 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9132239qgn; Tue, 2 Jan 2018 08:09:01 -0800 (PST) X-Received: by 10.46.95.206 with SMTP id x75mr28594185lje.111.1514909341768; Tue, 02 Jan 2018 08:09:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514909341; cv=none; d=google.com; s=arc-20160816; b=lnVbGQo42PIwd0ku8xEsTd8VZAzPgfePXyVyhfOWnNVa/S4xRitEhP0Scd8xgSGaXf 25LPLzC7EyPsrzUaYAvtFHnSzQvHrklX7ahesKkxl/vLqNLrYs8jV+Uj83btrfNIdW2x mXMdFfVM5czzw92JoI9FfJOSrvdUWZ4ZP83jNTqPKU3m6Jxesaz/QFskZE5Herr4gVIk isdd0X6K2SM16A++wzM8coTDwNVE5HtIhxHbIX+q1ik8okrfkm8yxFoE7PBUGS+CR6Vn QYsQEBIMH/yUC47euj3o/w4bFZEXGrNw2mEWq2jLr8QhuRX2Pw4zUNGatxXcmtsbW+sz NAHw== 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=JCerMTek20UlHIiT5CohPKjIQW87drp5DugK/MATYGI=; b=G5QrW3jaXSGrIq3v51Ik28NDOk0Y5mCyd4PYqoBUfiK2tAn6M/9ORVkwlWo+lLeZD9 Jpy85/z23Zd8zxonA1gASR/ab6p7L16GbT1krjKKj6689GQsxoOBKUv0XFKNj4hpntiN KVuEw9vVNwT1aB+RleFSdtMjHGtRqTHyAC8u/YRHKHHGqK9F5xcDKufkLcKaRVF1fMbL t3vcPpK/MAGNU4jnbjigFYvS3IpyE3HlZVTcMqfEtihwO4g720O7SlGnt+X3OyTaT/Zt civlZ3zxQDYEU93vGAAmoaEWNDC8OltpOAbK41i3f4NUOzTyq8P6RxnSC4bni76odZoJ 1YGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V1R2on9/; 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 102sor4946756lfw.11.2018.01.02.08.09.01 for (Google Transport Security); Tue, 02 Jan 2018 08:09:01 -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=V1R2on9/; 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=JCerMTek20UlHIiT5CohPKjIQW87drp5DugK/MATYGI=; b=V1R2on9/TplKDFSANCTTPZXp+zC95735TOKKi/OfG4ZjNrUmcLaaadGCUmhG9lCnOS +OydSB3xzIvBXd3TOSwV2IVSzzzggqhcXHescvp10hRGrH38lJjM/36ycxiclcyfu8B+ XMEGsWqz4L8BZlfOapjGpuPHbaWAK2ddOjRPU= 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=JCerMTek20UlHIiT5CohPKjIQW87drp5DugK/MATYGI=; b=DGAkP26XB72NihZutvyoa8z9VayOgeSdsCpo74o+3D1FnuIz/Zoi+04m7zmvL0ZJaN E5c8PQi2rKJ0g2J4XdhQLxfVkGn8tOtcWPMMfox+MM0GmQwI4ZFcqRUe1MX6LK90uvD3 whNLs67jhD6IkPxq8xc5S89LI0LOhnPuU0D91+eKASYxJv4zt8Ksb1RlxDEWx9VxQiXB kfO9fyG0brQExWTWibX97dhAI/G1uEAbFJ/nG3T5q8Z9BmqqL7UjbugxAbbTQtS2+QQZ DJT4LVrtijdLSEoeTUFnVMrUGipwvXFmIPrzTXX56cwh/k2wXjn6DcAZ+OEJTMZj+Jfz 9lHQ== X-Gm-Message-State: AKGB3mJvMbAqLO73naWKBSJmXMG4ncmyB+EzKau5+3IxTUFVIJV/coo7 9GhLPkiuyoJdSNhROrsSIWlttq95 X-Google-Smtp-Source: ACJfBovMQvMoKxtukzbJz9tD0mabMvAaNX6UKnuscxzP3OAIES7JOQkvcWYL3f/QDzy4E3Ovze2/0w== X-Received: by 10.25.196.212 with SMTP id u203mr22200658lff.126.1514909341401; Tue, 02 Jan 2018 08:09:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:09:00 -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 2/4] PM / core: Propagate wakeup_path status flag in __device_suspend_late() Date: Tue, 2 Jan 2018 17:08:51 +0100 Message-Id: <1514909333-4450-3-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> Currently the wakeup_path status flag becomes propagated from a child device to its parent device at __device_suspend(). This allows a driver dealing with a parent device to act on the flag from its ->suspend() callback. However, in situations when the wakeup_path status flag needs to be set from a ->suspend_late() callback, its value doesn't get propagated to the parent by the PM core. Let's address this limitation, by also propagating the flag at __device_suspend_late(). Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 7aeb91d..612bf1b 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1476,6 +1476,22 @@ static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev, return callback; } +static void dpm_propagate_to_parent(struct device *dev) +{ + struct device *parent = dev->parent; + + if (!parent) + return; + + spin_lock_irq(&parent->power.lock); + + parent->power.direct_complete = false; + if (dev->power.wakeup_path && !parent->power.ignore_children) + parent->power.wakeup_path = true; + + spin_unlock_irq(&parent->power.lock); +} + /** * __device_suspend_late - Execute a "late suspend" callback for given device. * @dev: Device to handle. @@ -1528,6 +1544,7 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as goto Complete; } + dpm_propagate_to_parent(dev); Skip: dev->power.is_late_suspended = true; @@ -1660,22 +1677,6 @@ static int legacy_suspend(struct device *dev, pm_message_t state, return error; } -static void dpm_propagate_to_parent(struct device *dev) -{ - struct device *parent = dev->parent; - - if (!parent) - return; - - spin_lock_irq(&parent->power.lock); - - parent->power.direct_complete = false; - if (dev->power.wakeup_path && !parent->power.ignore_children) - parent->power.wakeup_path = true; - - spin_unlock_irq(&parent->power.lock); -} - static void dpm_clear_suppliers_direct_complete(struct device *dev) { struct device_link *link; 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) {} From patchwork Tue Jan 2 16:08:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123156 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9132312qgn; Tue, 2 Jan 2018 08:09:04 -0800 (PST) X-Received: by 10.25.208.73 with SMTP id h70mr7125920lfg.27.1514909344856; Tue, 02 Jan 2018 08:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514909344; cv=none; d=google.com; s=arc-20160816; b=DMsMLscsGSSPTanDc9NRXvPP9ROgu62LgyTzQSt+vOn42D1X3mSGff9QDRHpYPIOAi cryEyhbJQZzY4ndPQW/Ww0GNllgCjQLBSTBiaCfd7L2Kh1XIRXQtzoGedzUmoaKKeCYr qKTW/Ok8mTBvjjV6pHAJPCQsO80wm3TyKNNCd3ju/npvi1pOW6hZaNHoJjCLvtoRYWxa GCFiCWaXF3P4v2vWFS3WmJRVKcFojh6PkGEzOPYWw1Dge2IPQfaozWDX1XeLs8PHEyWR MCiJJdlowLLdck0drjrRKcyT5JUAhHLUpsyniyPAVwKGDgHuckv1/w7Ees9eDc5LsLXh Z5qQ== 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=qzgVlJAaUoxZcV1T0FZ1W7uGyIHi5+2gErHUg+31Tqg=; b=MewfCd7X2Q/F9QNtQDXxvPw+TCXLyyUYr5XlaBEckOZYD9cQSFavIFKQmBmxiQSC6t YmPWu4EZLuZunQLMGCqNd72N8OvBSKaZsm743x8lZvnVzcZguMhexZw3J06v0ojGFFjc ocVC0n/x7HvIAoBZaPmy12usLgaY8nsMYSKiYCrEbq6JPQ/JBdP60Jxud5O2sSR8jfno anaIVTREHNLxt9Kv0GIDYeRPLGopMB2Unt6n/8qJ2HBmE2zrTUNvlcDQKW0ACm8UgFyM c/I6Si8MZkFOphXF9dyS0bH1GbY1rfQ62AM+YJWLAsyRYfQGkwuG+aj6l/AVFJzPnt1o nbuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M48fErZT; 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 g78sor3188017lfh.47.2018.01.02.08.09.04 for (Google Transport Security); Tue, 02 Jan 2018 08:09:04 -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=M48fErZT; 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=qzgVlJAaUoxZcV1T0FZ1W7uGyIHi5+2gErHUg+31Tqg=; b=M48fErZTjgCJYTmBEk6/n5f0ge/yt0xBAYguU9ePHFTEVfZf7nUpU0FWWu1gL9gkHY z5IDN69uicL1uFbMV8vxe7ceOSjMroapFCHq3a3JA3vcdk5c6zobFDSm4Q1QSkwgDcPS hQwXKwIS1egUI61NbYJV5vyTX1yLFXruupnQA= 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=qzgVlJAaUoxZcV1T0FZ1W7uGyIHi5+2gErHUg+31Tqg=; b=YywBy77FDjpP92ksxbKB8ruxh74gGbFmg26+6GHYT18PUD/ST30Ax7yctjP3fa2cAm 8lTk1yVmtJ4YPByhaq5Pj5rUN1PeNbxvvzISvcEiNmtfX3m/34/pAE/Lx3/HKf9yP8lr LiOAhbPse8a0zOhyNVpzVOfzymQuuDZbuG6gTv+rOK3xhaQWeplG9r6W7/RIzoTdG3iv hCi0/Z1P4z46ARUFk2JK2EGesqgYnCN46pE77H7fLEUYgHNjZGp7btwZ9/D4tbDegJoA 3TKF9szRBE40gMKBXtW3AO2BqWr4mfk3wm7tHkEyC2PO22Jb+P6+YX/KorUZmPc5M4VV /GiA== X-Gm-Message-State: AKGB3mKRkVq+UlFyAybf0Vogl3uaSiHDpo2SZ+mIlFsvZaQ3S8cAGLtU ZM4m3LB3CR7VSBAlv4RRizLTZjgcyfMWwQ== X-Google-Smtp-Source: ACJfBot3p1SS6/ZEjF7NB4yvB8l/SwxoqueLuY5pN/w31TVP4uaCEAl9n6+3FQVmMpBNSLE8kli7zg== X-Received: by 10.25.145.85 with SMTP id y21mr15749894lfj.123.1514909344492; Tue, 02 Jan 2018 08:09:04 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:09:03 -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 4/4] PM / wakeup: Print warn if device gets enabled as wakeup source during sleep Date: Tue, 2 Jan 2018 17:08:53 +0100 Message-Id: <1514909333-4450-5-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> 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. Suggested-by: Rafael J. Wysocki Signed-off-by: Ulf Hansson --- drivers/base/power/wakeup.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index b7b8b2f..272c44b 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 (pm_suspend_target_state != PM_SUSPEND_ON) + dev_warn(dev, "don't enable as wakup source during sleep!\n"); + ws = wakeup_source_register(dev_name(dev)); if (!ws) return -ENOMEM;