From patchwork Wed Nov 8 15:15:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 118277 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5413738qgn; Wed, 8 Nov 2017 07:15:45 -0800 (PST) X-Received: by 10.46.15.1 with SMTP id 1mr348247ljp.157.1510154145186; Wed, 08 Nov 2017 07:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510154145; cv=none; d=google.com; s=arc-20160816; b=cl0C7kEeKlU1mf/ZkeS2WLkeMwppxX0V+CyWN4PprQ8dqLCv7v2Il+nGf5kNhqr6Ok 2PAyRF3ej0aA9koyJpJ5XQhwzDrY03lUgCUQ1T1IJXGxtBQkoZNbt08cRJv+AvVT1Abt 0uD7cN4h5PF5lOvPw3AqAxPYg6lYRP67BihkxeMBYk4FA89I5r0dl5kXl5/iQPaI5vvY SBpK6EcZBCIR3N5d8RCWe5UiRolqJkvVm72GFf4Lp9JtUo7l7e0625Rynlpc4AjSCWVk pfmjaA73shwTVXgjuXOLEklHb8DcHfJjC7rhP2Wz8ZqlisHOuTb/Nl9YxuQgH3aP3NR+ eSBg== 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=8jESEoVsoZambVbCBs/N9o/7umIkg3CQS8R4zgHizG4=; b=0Eecv47IwQ73Er6Nb8TtpylkSWLFmnRhsdO4x2Qwqbzj8SYzJsC7RB6ufwjyjFrZfy isibX9waUWWJvYtzitlxjc+G14p5+VqU+BzVlRNyblbLQvVI2gz36tXa4ZoXGKmBlY/5 kHLAMdNQrCQKcLaCmk+zgTU3IJnlTu68Ssd5uTMPbANRsKhzDf5tNumfakYolfYEVXHj khHIf7BBY1H70hsLKhEh8yzl3jmOovgBC2XvMWAyk2xproMOylMOU7n6cZDsdCldagXZ fCnbLveO0elHub9Op3km9iI/FOWSn822qrLvMeEfPSQTX1okHAoAHtL179eKUILF4tq+ V3nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MCM5fhwQ; 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 j7sor742289lfk.70.2017.11.08.07.15.45 for (Google Transport Security); Wed, 08 Nov 2017 07:15:45 -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=MCM5fhwQ; 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=8jESEoVsoZambVbCBs/N9o/7umIkg3CQS8R4zgHizG4=; b=MCM5fhwQi2IxTVP0yGJD0NdKdrfkTeUJwLCg2/yLfxia4j98yuRJusu67LNgI9S7ts PcKyo8imYXRERVI8s6MOO3X7HUzNjzA8ssXNouJJ4N8eh0Bvk8pb3NaR3exIiLcWUd0l 8x0Yt0kWyERxwjgWP4MXA4aqnWrhyrADbMc7c= 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=8jESEoVsoZambVbCBs/N9o/7umIkg3CQS8R4zgHizG4=; b=Sbx48u6ggXpW6FH93UVgPe28lXe5P34mlvGf/RouSvkM0QpfQ4iERJtFu3FqWMprDe tG2UC43zYshyA1uwuh+kw8DUYwt6ztudkcj1r9DiHT8ee6G++TPPQ7Imi9URI2yF5Qaj JCxWdR2fq41GCDJ68uT+dehxiTO9y8W5SfchzoKV/XRJSncrSVu2ycA9QBqNb8NNPdz4 rJHy0GKBfZG9XtBkSzi436GKXv081NwrvkTMh+K/A8Z904G6VQ23q6cTB3oZ021VSFPo KMR7r1N4oP2pikGcSdyX5hDhcT48b1arG1LGN19Bj8+uUlMLZBlxoxiBVBoaFn97UFds YaIA== X-Gm-Message-State: AJaThX4keX5/6y8QIz/NVlB+hQ939WzaYVbKW8IQbbfuewhCs7Lrc2Jz MEdeXXOfT1bA85p4gH+tC0Xdd6rg X-Google-Smtp-Source: AGs4zMb/YGEW0gQjPq6acA9WflRProPqoLWat49xioF13CztpGYf/67dKIeT8U/1EDxs9aiCIfwCLA== X-Received: by 10.25.145.88 with SMTP id y24mr315845lfj.135.1510154144846; Wed, 08 Nov 2017 07:15:44 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n131sm713846lfn.29.2017.11.08.07.15.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 07:15:44 -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 , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH 1/3] PM / core: Re-factor some code dealing with parents in __device_suspend() Date: Wed, 8 Nov 2017 16:15:32 +0100 Message-Id: <1510154134-1248-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> References: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> Let's make the code a bit more readable by moving some of the code, which deals with adjustments for parent devices in __device_suspend(), into its own function. Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Geert Uytterhoeven diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 6c6f1c7..8089e72 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1422,6 +1422,22 @@ 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; @@ -1530,19 +1546,8 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) End: if (!error) { - struct device *parent = dev->parent; - dev->power.is_suspended = true; - if (parent) { - spin_lock_irq(&parent->power.lock); - - dev->parent->power.direct_complete = false; - if (dev->power.wakeup_path - && !dev->parent->power.ignore_children) - dev->parent->power.wakeup_path = true; - - spin_unlock_irq(&parent->power.lock); - } + dpm_propagate_to_parent(dev); dpm_clear_suppliers_direct_complete(dev); } From patchwork Wed Nov 8 15:15:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 118278 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5413765qgn; Wed, 8 Nov 2017 07:15:47 -0800 (PST) X-Received: by 10.25.33.139 with SMTP id h133mr296406lfh.140.1510154146950; Wed, 08 Nov 2017 07:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510154146; cv=none; d=google.com; s=arc-20160816; b=xWRyMca63dCU0JCDM+nQgrucfSFFO/rzNHK9cmwe35jQysZ7cp4NtD5YszNpQOaK9n iUW1LW57UKVepIrCR2A/1c5+uqSVWEeRiRIdJWUv6cVWaxBtiDSrfkwWBpWkKLfvQIjz eG+eSeraroWWAQJK9BlwsgiFu/j1V9AWf9BuB4K2HAln8TvuUp7Rv/EMJrQsr5RrbxJF aRvjA7AuZ4UroLh+uNkQN48GgsJ81okYLJ+V2X9KfrevydQ7rQ1MsSu2Dr8xPnwcFknD F6TLZ23jO+KHMS6YtW1nVK5X8+Vpp3zrAfqbeMedM2SGXUbo/43Sl6QMKFA9Ruw+x7RL eGRg== 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=9ljacTEYl9og7ojvhyeo7+NXfO6vEvQF6PE6xCDw3bQ=; b=065qxHCKKaTs0+lmFPpLq1fco65ew6vDJKP7TUoSKs91QOvfiFAHvl4x45mNEN3CCU WkjN9O9inn8tcvfAPFjadDWZh8j39orgmlNZeUGHhXM370ze2XyUy6nNAnybIngKS6jZ 68cYsqUvAfG4Mxty5bvjiBZA2M69NKx+M+l4yPfpES3Jt+JRq2SbNl+jI3zgD/Pkhpxs 4R+A69kCsoBPeYes4fwKKQ75sbhyHKdErZ4KDQinJPBTSl/WTlMPVXoMjrtf+2xOXObx nMTUS3hzIyJ4ZQ7vtN5Y9oMTTdZ9cIxUcJTXvxpGeyZOYky0Io/lCcy4lrIIkKdK/ioD +Zlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DlbYgrZa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id i62sor719839lji.99.2017.11.08.07.15.46 for (Google Transport Security); Wed, 08 Nov 2017 07:15:46 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DlbYgrZa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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=9ljacTEYl9og7ojvhyeo7+NXfO6vEvQF6PE6xCDw3bQ=; b=DlbYgrZaShsXrB8C/3w37sh7qU26IkjF/rITz2tTI7Ej4jGK0zqBVCIuMyDnSBmW+W wtZxX85MXQkM8zQuAHlfELecHj55C4cFYZbT/ktDWXwK8UB3xLg5I+jDothfNhzdOl9e cAoVfgb4amzZANfA0nmnQTDU6ZMXqKJ0etR7I= 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=9ljacTEYl9og7ojvhyeo7+NXfO6vEvQF6PE6xCDw3bQ=; b=msjXQf/+HmqfLHsfWW013taTtXp2PNN4sOfuqWDbkcRaUU18RDFeT6NNEolYOfn671 azYcEoBxjgcefiVUzJ/zQPsDy+Kg0oBozDihb+k4m6+KpwljGKu6rHkh+qcwUZPvXk1Z XOuWIcqueFUuEd8mEXAD+hFB5WcbOl0ofEBk6Ykp4oIabBhC4+gJMxR86lZPf1pGAwdN h0k41GF6aNIw39Pen5cnQOq0jRAXH5oRcFyHqDGbjYh54VuhaaBpwvWQsLkDrXX2l6r1 yiANaCdPW6qRqUtPRrNVDMvbDfts1guyxffgBF2ESwLZiAJZga6FQafN59JviuW9K8pF xqLQ== X-Gm-Message-State: AJaThX6PZp0bl3ZiNHAZvNbj1+idYbWI4jX91OLeevp5WftRxrix3/eM 1As6e/rcjzw/1Pw6XWhrlt1eEtYb X-Google-Smtp-Source: ABhQp+QWf6AmmkGYWSFBiFL8CMDRQvTfbAddkVsVeMcoDeO+wmiuu+3pS5M6AcNOKLU8G3HHtYvHjw== X-Received: by 10.46.16.155 with SMTP id 27mr346031ljq.169.1510154146548; Wed, 08 Nov 2017 07:15:46 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n131sm713846lfn.29.2017.11.08.07.15.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 07:15: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 , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH 2/3] PM / core: Add WAKEUP_POWERED driver flag Date: Wed, 8 Nov 2017 16:15:33 +0100 Message-Id: <1510154134-1248-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> References: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> For some bus types and PM domains, it's not sufficient to only check the return value from device_may_wakeup(), to fully understand how to treat the device during system suspend. In particular, sometimes the device may need to stay in full power state, to have wakeup signals enabled for it. Therefore, define and document a WAKEUP_POWERED flag, to enable drivers to instruct bus types and PM domains exactly about that. During __device_suspend() in the PM core, let's make sure to also propagate the setting of the flag to the parent device, when wakeup signals are enabled and unless the parent has the "ignore_children" flag set. This makes it also consistent with how the existing "wakeup_path" flag is being assigned. Signed-off-by: Ulf Hansson --- Documentation/driver-api/pm/devices.rst | 12 ++++++++++++ drivers/base/power/main.c | 6 +++++- include/linux/pm.h | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) -- 2.7.4 Reviewed-by: Geert Uytterhoeven diff --git a/Documentation/driver-api/pm/devices.rst b/Documentation/driver-api/pm/devices.rst index 53c1b0b..1ca2d0f 100644 --- a/Documentation/driver-api/pm/devices.rst +++ b/Documentation/driver-api/pm/devices.rst @@ -414,6 +414,18 @@ when the system is in the sleep state. For example, :c:func:`enable_irq_wake()` might identify GPIO signals hooked up to a switch or other external hardware, and :c:func:`pci_enable_wake()` does something similar for the PCI PME signal. +Moreover, in case wakeup signals are enabled for a device, some bus types and +PM domains may manage the device slightly differently during system suspend. For +example, sometimes the device needs to stay in full power state, to have wakeup +signals enabled for it. In cases when the wakeup settings are mostly managed by +the driver, it may not be sufficient for bus types and PM domains to only check +the return value of :c:func:`device_may_wakeup(dev)`, to understand what actions +are needed. Therefore, drivers can set ``DPM_FLAG_WAKEUP_POWERED`` in +:c:member:`power.driver_flags`, by passing the flag to +:c:func:`dev_pm_set_driver_flags` helper. This instructs bus types and PM +domains to leave the device in full power state, when wakeup signals are enabled +for it. + If any of these callbacks returns an error, the system won't enter the desired low-power state. Instead, the PM core will unwind its actions by resuming all the devices that were suspended. diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 8089e72..f64f945 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1432,9 +1432,13 @@ static void dpm_propagate_to_parent(struct device *dev) spin_lock_irq(&parent->power.lock); parent->power.direct_complete = false; - if (dev->power.wakeup_path && !parent->power.ignore_children) + if (dev->power.wakeup_path && !parent->power.ignore_children) { parent->power.wakeup_path = true; + if (dev_pm_test_driver_flags(dev, DPM_FLAG_WAKEUP_POWERED)) + parent->power.driver_flags |= DPM_FLAG_WAKEUP_POWERED; + } + spin_unlock_irq(&parent->power.lock); } diff --git a/include/linux/pm.h b/include/linux/pm.h index 65d3911..34c2404 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -559,6 +559,7 @@ struct pm_subsys_data { * NEVER_SKIP: Do not skip system suspend/resume callbacks for the device. * SMART_PREPARE: Check the return value of the driver's ->prepare callback. * SMART_SUSPEND: No need to resume the device from runtime suspend. + * WAKEUP_POWERED: Keep the device powered if it has wakeup enabled. * * 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 @@ -572,10 +573,14 @@ struct pm_subsys_data { * necessary from the driver's perspective. It also may cause them to skip * invocations of the ->suspend_late and ->suspend_noirq callbacks provided by * the driver if they decide to leave the device in runtime suspend. + * + * Setting WAKEUP_POWERED instructs bus types and PM domains that the device + * needs to remain powered in system suspend, in case wakeup is enabled for it. */ #define DPM_FLAG_NEVER_SKIP BIT(0) #define DPM_FLAG_SMART_PREPARE BIT(1) #define DPM_FLAG_SMART_SUSPEND BIT(2) +#define DPM_FLAG_WAKEUP_POWERED BIT(3) struct dev_pm_info { pm_message_t power_state; From patchwork Wed Nov 8 15:15:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 118279 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5413809qgn; Wed, 8 Nov 2017 07:15:48 -0800 (PST) X-Received: by 10.46.93.91 with SMTP id r88mr407778ljb.110.1510154148336; Wed, 08 Nov 2017 07:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510154148; cv=none; d=google.com; s=arc-20160816; b=fMPZc8Sq+8zeyPopkYgkpTY8YaK3Rfy7AvLvmf5JWJVYFqENsmXbiaEfsBNInQvAha wBM8PZRjzQncsMI+M2k6/BC+NuPjjNArbj66HNUFCOSjTiK5+30dd8Pbe9rjNhH5/+Ux iGYT7WlcVW272YANWwZ4bpmRxHgD97OLTsqceVqxoJZdY7gB9/cKzrGQ0cm81XlIwHJH mYl2JwDs7/GxbS1Tzl0u6Ia7MLw57jYcLJnI88uoRdFJeWDEE1Tsx8t9I4bO9Kmyl+0J qp6MZMMon5MP8++28A0svT0Ju/2aRe1wKPxOy7PoowblDppwaphLoUylaSqYRaKySBLB yQPg== 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=427dG1E8OyYAe5SBttgjYtT7Kl442oezD0lSgIjJdSQ=; b=myOh91ACuh/6t8R52pHqKEuG9bGTVvpuxOJdi/6doFpv56kUAehauiH3qs5hueSFUB Pvvk4eYKW+iLDDbGVi+O5ieKwLctRPKRPKLg9w2KuhDYTk4RvtDamh32j+NgXBXjWhj7 5Ma/Y2zUSFICO81JP7L5yOBXEqfC/sHvc9twh61/Os51an5Ptpn9ojjg8wp9n10cL04i qDPF1Cd11VZYVKe88EqIU/DRKDOCMbQEgzq5EbtGSoHVXC+lCbc/1N0gPR45YZCqGuTy DcvE9LwYr7lJaael4PzX4egYtw/UClc6bHzAWB9DkbdGIf8aepkQ+nkVvbglji/l3gGw AxjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iKEWAvKE; 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 g1sor716171lje.107.2017.11.08.07.15.48 for (Google Transport Security); Wed, 08 Nov 2017 07:15:48 -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=iKEWAvKE; 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=427dG1E8OyYAe5SBttgjYtT7Kl442oezD0lSgIjJdSQ=; b=iKEWAvKEzaITniFVcMnOvoeraDW/Q48M+ULVv8Q23x5nSgGo1UkgIdA00OgmnZcKx1 TlCJJ1Cxv1TGsmE93w26bkwmcyUhcwg/x7AD00FEcZ+mChFr1yGmcH8DH9WodW8Pv38j wunjdREVzus9H8sVdoIKYGPWaNlqqVl6L5wbo= 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=427dG1E8OyYAe5SBttgjYtT7Kl442oezD0lSgIjJdSQ=; b=Bf4PPzPBYwKf0a7IkmFhh2gA1Z+p/syjaR+ZOC4ah32x0QdMZ157Ddl2RpMNU0lkbw PL4JfveQSqxizHIJMEibcePMBP/tDqtvf7OfIbC3BfUY3UWoXsuAOus9tXMSwfxZ4Bcx CQ1sImh8H9HCGp0doFbUk8pQU3aPqiuAK7jYhrjVKUBc/6eIUlmCAZKuNcxV1IN/Q+5Y +MCLpIEWyLGgnyT4q5AkD6Ba2vUPRZ4qChAcURTFWcwIc7azVHwsrDEDOEajvzoJn0NC XV6OZZR81r7KPlVt+KDA5nIWnkfqZrjVxbZpcvNUQCpWLu0llg7yN5m3lJpmUbps4qJ6 Sprg== X-Gm-Message-State: AJaThX4XGIbGX/+BcPE67r9h4YkcVcupc5C+2H1ZjqJ1H0pbAB/nZUpg eD9BkafGR3htdMpANWMQBCYlRbpG X-Google-Smtp-Source: AGs4zMaGa9iLQwPCGpEG5aGou6W6VMNo+Fp49ELMNdKL3MSpXgU2InJ53D5fN7YtArcqre4xX3lVIw== X-Received: by 10.46.64.135 with SMTP id r7mr421383lje.111.1510154147893; Wed, 08 Nov 2017 07:15:47 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n131sm713846lfn.29.2017.11.08.07.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 07:15:47 -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 , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH 3/3] PM / Domains: Take WAKEUP_POWERED driver flag into account Date: Wed, 8 Nov 2017 16:15:34 +0100 Message-Id: <1510154134-1248-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> References: <1510154134-1248-1-git-send-email-ulf.hansson@linaro.org> Make genpd to take the WAKEUP_POWERED driver flag into account during system suspend/resume. More precisely, in case the WAKEUP_POWERED flag is set, let's leave the device in full power state and prevent the PM domain from being powered off. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 Reviewed-by: Geert Uytterhoeven diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 24e39ce..dc18f88 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1037,8 +1037,11 @@ 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)) - return 0; + if (dev->power.wakeup_path) { + if (dev_pm_test_driver_flags(dev, DPM_FLAG_WAKEUP_POWERED) || + genpd_is_active_wakeup(genpd)) + return 0; + } if (poweroff) ret = pm_generic_poweroff_noirq(dev); @@ -1092,8 +1095,11 @@ static int genpd_resume_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd)) - return 0; + if (dev->power.wakeup_path) { + if (dev_pm_test_driver_flags(dev, DPM_FLAG_WAKEUP_POWERED) || + genpd_is_active_wakeup(genpd)) + return 0; + } genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0);