From patchwork Tue Nov 17 16:42:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 56822 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2048917lbb; Tue, 17 Nov 2015 08:42:52 -0800 (PST) X-Received: by 10.25.148.202 with SMTP id w193mr214302lfd.130.1447778572409; Tue, 17 Nov 2015 08:42:52 -0800 (PST) Return-Path: Received: from mail-lb0-x232.google.com (mail-lb0-x232.google.com. [2a00:1450:4010:c04::232]) by mx.google.com with ESMTPS id j78si31274054lfi.123.2015.11.17.08.42.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 08:42:52 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::232 as permitted sender) client-ip=2a00:1450:4010:c04::232; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::232 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by lbblt2 with SMTP id lt2so9098948lbb.3 for ; Tue, 17 Nov 2015 08:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=dUvOTDuxpFERsv2ge1LoCBBnu/NP/dkBTuNVkaoMy6A=; b=d2lucb1JfgBMBAQ8ZZFb7o0pit0SMLYCJ5IRYuFWmXNFPTeQxSFs2zp1KP0ivW/nHp GIy6oXJ+ObruzQUpzPHOshTcyG895ferjXU7kp48QrEl9cTlfdQXjQEMfSYB3YtCeVox hYzQlxzbuagTXFPuXjR/GXY3/+ftBrLRkLYvZGb0yDfheDud29rrgKBfgfe8Z++Bg7yM zuVuxNWpQlN2RK+0kd7wwJnNbCATnROxIGGAChar4HCbJmKA8ylbMTTKBB/bB2OuA7OX bcwI7tNiTuQZ9aybab4RUL/nDXGvjeSxO2iaebny5HremIcGnwF6cK/Eb6kTBb1BhONF qXTQ== 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; bh=dUvOTDuxpFERsv2ge1LoCBBnu/NP/dkBTuNVkaoMy6A=; b=Xc8KieCwyMqLw4kva3Qc+FuY3d8+igz0eW5Dspd+6VWyo0qg2d9Y44E3SRl7wUXC+J 1t8IujMF6TgB386DPnZJDcNX4r1GJQmoQ5nAX/Hr4yx8sK6mXMr9sMV7oY829cofAQMm fEYWOz7Rns4K6Tqjs+IQ6CdA/LKa7oAkWQX3lolfz+8WF62N0V8eNa/gPk3BNKxQlc4b 9l3kf0sy5/VwvJCOXmLon2BWWM7aZ7mdJO6HPyG+uGtTUF+bbnmKmSvrxpjnKQiJ4hnd ZvtQfzvwY6zwQ8U018+AWBKPrqtMGsZUMW0UXEFkzGLEShCpAG1FHj6fAAw46feZbHH5 k9ZQ== X-Gm-Message-State: ALoCoQk+cg25Jg5yxK77qdv9p2lHCVx/8Ilz5SlBPGdoh21L+d/xULkdJNiBY7KwukHDmV7VeIUs X-Received: by 10.112.135.136 with SMTP id ps8mr20282069lbb.38.1447778572069; Tue, 17 Nov 2015 08:42:52 -0800 (PST) Return-Path: Received: from localhost.localdomain (c-83-233-167-104.cust.bredband2.com. [83.233.167.104]) by smtp.gmail.com with ESMTPSA id q197sm6577904lfd.36.2015.11.17.08.42.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 08:42:51 -0800 (PST) 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 , Cao Minh Hiep , Harunaga Subject: [PATCH] PM / Domains: Allow runtime PM callbacks to be re-used during system PM Date: Tue, 17 Nov 2015 17:42:41 +0100 Message-Id: <1447778561-9767-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 Runtime PM centric subsystems/drivers may re-use their runtime PM callbacks for system PM. Typically that's done via using the runtime PM helpers, pm_runtime_force_suspend|resume(). To genpd, this means its runtime PM callbacks may be invoked even when runtime PM has been disabled for the device. By checking this condition, it allows genpd to skip latency validation and measurement in the system PM path. That's needed to enable drivers/subsystems to re-use the runtime PM callbacks for system PM. Fixes: ba2bbfbf6307 ("PM / Domains: Remove intermediate states from the power off sequence") Reported-by: Cao Minh Hiep Reported-by: Harunaga Signed-off-by: Ulf Hansson --- This patch has only been quick tested on ux500, so further tests are welcome and needed. It was reported [1] to point out a certain commit causing the regression, but further analyze actually tells that the problem been there longer. So, I decided to point the fixes tag to a commit from where it actually becomes quite simple to address the problem. Earlier than that, is just not worth the effort. [1] https://lkml.org/lkml/2015/11/16/748 --- drivers/base/power/domain.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e03b1ad..8f0c2a3 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -390,6 +390,7 @@ static int pm_genpd_runtime_suspend(struct device *dev) struct generic_pm_domain *genpd; bool (*stop_ok)(struct device *__dev); struct gpd_timing_data *td = &dev_gpd_data(dev)->td; + bool system_pm = !pm_runtime_enabled(dev); ktime_t time_start; s64 elapsed_ns; int ret; @@ -400,12 +401,18 @@ static int pm_genpd_runtime_suspend(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; + /* + * A runtime PM centric subsystem/driver may re-use the runtime PM + * callbacks for system PM. In these cases, don't validate or measure + * latencies. + */ stop_ok = genpd->gov ? genpd->gov->stop_ok : NULL; - if (stop_ok && !stop_ok(dev)) + if (!system_pm && stop_ok && !stop_ok(dev)) return -EBUSY; /* Measure suspend latency. */ - time_start = ktime_get(); + if (!system_pm) + time_start = ktime_get(); ret = genpd_save_dev(genpd, dev); if (ret) @@ -417,6 +424,10 @@ static int pm_genpd_runtime_suspend(struct device *dev) return ret; } + /* Don't try poweroff in system PM as it's prevented anyway. */ + if (system_pm) + return 0; + /* Update suspend latency value if the measured time exceeds it. */ elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); if (elapsed_ns > td->suspend_latency_ns) { @@ -453,6 +464,7 @@ static int pm_genpd_runtime_resume(struct device *dev) { struct generic_pm_domain *genpd; struct gpd_timing_data *td = &dev_gpd_data(dev)->td; + bool system_pm = !pm_runtime_enabled(dev); ktime_t time_start; s64 elapsed_ns; int ret; @@ -464,8 +476,8 @@ static int pm_genpd_runtime_resume(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - /* If power.irq_safe, the PM domain is never powered off. */ - if (dev->power.irq_safe) { + /* If power.irq_safe or system PM, the PM domain remains powered. */ + if (dev->power.irq_safe || system_pm) { timed = false; goto out; }