From patchwork Mon May 30 09:33:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 68833 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1308852qge; Mon, 30 May 2016 02:33:37 -0700 (PDT) X-Received: by 10.25.34.79 with SMTP id i76mr8285604lfi.204.1464600809577; Mon, 30 May 2016 02:33:29 -0700 (PDT) Return-Path: Received: from mail-lf0-x235.google.com (mail-lf0-x235.google.com. [2a00:1450:4010:c07::235]) by mx.google.com with ESMTPS id g26si10947552lji.58.2016.05.30.02.33.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 02:33:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) client-ip=2a00:1450:4010:c07::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x235.google.com with SMTP id b73so47339805lfb.3 for ; Mon, 30 May 2016 02:33:29 -0700 (PDT) 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=mswl0DbSdaOm5jNUFSeYHYtOM3qInj0Du95f6i7TOSg=; b=XeDwdQWHLPyj8iPs3QfUnk9/B9A7ZVE3OcXB+EqdJEsBIkGsiHDYpnu5uJySYY4bqh XZDnXrzhm6iPGCLpgLgJ7qhg2Myla4xN/RpHYf1nFfrHxc15cLbwwTh4hW6W7ucad9QS 5CMy/aU74DHHGR97AqtzZIKXCviqQzDTQL5T4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mswl0DbSdaOm5jNUFSeYHYtOM3qInj0Du95f6i7TOSg=; b=XrEpDDoni3WJ7MOHpNvPJwqLzjCH3vYr0VIcoB2t3eQ7ANEx15xfgDJeCkzXDVreSs 9Q+3bHToOBMtZOtivAzzqbK9Fgarxs+3LsyzxsO5lSTPyLpYdOKpiMawt7FqxuK0tTVZ 3mGacwBcqQYPBB/ioj04hIf6zfXqInMdi5oSm6keYh9p9UdcyOq+AN2GLJ6iMgxmJZYF oxMcJZsQo/VGnOJwR7I1MYqK3H/fKMCbBHI5wgUwmV4tcxQAE9GyI9iYp7JbAT49AmSu 28GTC7kLpf6gVN4knhd6ZC4zqqmaYgnE1yEBq7fygmySgMEFfUwDNPILqBmjNNvE2nrX y6AA== X-Gm-Message-State: ALyK8tJe/sdkrhzk1iW5Bs8+XdVFrtHSHegJlbfTLFSDoOTwpvLTwPIvZwCxXsTGbKzW4PqW+70= X-Received: by 10.25.29.138 with SMTP id d132mr8254149lfd.142.1464600809231; Mon, 30 May 2016 02:33:29 -0700 (PDT) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 75sm4596853lfw.25.2016.05.30.02.33.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 May 2016 02:33:28 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Geert Uytterhoeven , Lina Iyer , Axel Haslam , Marek Szyprowski , Jon Hunter , Andy Gross , Laurent Pinchart Subject: [PATCH v2 4/5] PM / Domains: Stop/start devices during system PM suspend/resume in genpd Date: Mon, 30 May 2016 11:33:14 +0200 Message-Id: <1464600795-26307-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464600795-26307-1-git-send-email-ulf.hansson@linaro.org> References: <1464600795-26307-1-git-send-email-ulf.hansson@linaro.org> Not all subsystems/drivers that manages devices attached to a genpd, makes use of the pm_runtime_force_suspend|resume() helper functions to deal with system PM suspend/resume. In cases like these and when genpd's ->stop|start() callbacks are being used for the device, invoke the pm_runtime_force_suspend|resume() helper functions from genpd's "noirq" system PM callbacks. In this way we make sure to "stop" the device on suspend and to "start" it on resume. Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. Implements the second part of the earlier version of [PATCH 3/4] PM / Domains: Allow runtime PM during system PM phases --- drivers/base/power/domain.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4cb57f3..9193aac 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -761,6 +761,7 @@ static int pm_genpd_prepare(struct device *dev) static int pm_genpd_suspend_noirq(struct device *dev) { struct generic_pm_domain *genpd; + int ret; dev_dbg(dev, "%s()\n", __func__); @@ -771,6 +772,12 @@ static int pm_genpd_suspend_noirq(struct device *dev) if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)) return 0; + if (genpd->dev_ops.stop && genpd->dev_ops.start) { + ret = pm_runtime_force_suspend(dev); + if (ret) + return ret; + } + /* * Since all of the "noirq" callbacks are executed sequentially, it is * guaranteed that this function will never run twice in parallel for @@ -791,6 +798,7 @@ static int pm_genpd_suspend_noirq(struct device *dev) static int pm_genpd_resume_noirq(struct device *dev) { struct generic_pm_domain *genpd; + int ret = 0; dev_dbg(dev, "%s()\n", __func__); @@ -809,7 +817,10 @@ static int pm_genpd_resume_noirq(struct device *dev) pm_genpd_sync_poweron(genpd, true); genpd->suspended_count--; - return 0; + if (genpd->dev_ops.stop && genpd->dev_ops.start) + ret = pm_runtime_force_resume(dev); + + return ret; } /** @@ -824,6 +835,7 @@ static int pm_genpd_resume_noirq(struct device *dev) static int pm_genpd_freeze_noirq(struct device *dev) { struct generic_pm_domain *genpd; + int ret = 0; dev_dbg(dev, "%s()\n", __func__); @@ -831,7 +843,10 @@ static int pm_genpd_freeze_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - return 0; + if (genpd->dev_ops.stop && genpd->dev_ops.start) + ret = pm_runtime_force_suspend(dev); + + return ret; } /** @@ -844,6 +859,7 @@ static int pm_genpd_freeze_noirq(struct device *dev) static int pm_genpd_thaw_noirq(struct device *dev) { struct generic_pm_domain *genpd; + int ret = 0; dev_dbg(dev, "%s()\n", __func__); @@ -851,7 +867,10 @@ static int pm_genpd_thaw_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - return 0; + if (genpd->dev_ops.stop && genpd->dev_ops.start) + ret = pm_runtime_force_resume(dev); + + return ret; } /** @@ -864,6 +883,7 @@ static int pm_genpd_thaw_noirq(struct device *dev) static int pm_genpd_restore_noirq(struct device *dev) { struct generic_pm_domain *genpd; + int ret = 0; dev_dbg(dev, "%s()\n", __func__); @@ -889,7 +909,10 @@ static int pm_genpd_restore_noirq(struct device *dev) pm_genpd_sync_poweron(genpd, true); - return 0; + if (genpd->dev_ops.stop && genpd->dev_ops.start) + ret = pm_runtime_force_resume(dev); + + return ret; } /**