From patchwork Tue May 17 11:41:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 67940 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2022178qge; Tue, 17 May 2016 04:42:00 -0700 (PDT) X-Received: by 10.25.152.133 with SMTP id a127mr360858lfe.36.1463485312617; Tue, 17 May 2016 04:41:52 -0700 (PDT) Return-Path: Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id u13si2168743lff.99.2016.05.17.04.41.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 May 2016 04:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; 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::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x229.google.com with SMTP id u64so5564276lff.3 for ; Tue, 17 May 2016 04:41:52 -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=/VftiJPsUiD20d4o0Rl7g8mbj+E2DgN3GThjGVLRzyM=; b=LiR8FLPfT/L4Yri6y6+xqk/Tfsy0pfkvG1CKHrDQXU+uVu7jVxWm5mRRHEN79Yok1G OKwa70HAZ1308s7Wb3TH+TeT+YqghuVKnOX6J4A+AFj3iQUc41cHuHQqeWWwZX57/dE+ ntHcJLF4qJhJMNEcYbkhD5Du5mlGpGXklweqM= 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=/VftiJPsUiD20d4o0Rl7g8mbj+E2DgN3GThjGVLRzyM=; b=GkgU7pf/Lm16IZkZKeo49sbS/Lc597tSIrRxCs8Wz6QKzxuhfVi05fZzOwHUm2ly6P mexHGosv3kqGxnfcZ76/umnmSNVYXVGj+EEjFxqDgWSdktWft89iSYjdkOHZgFnTyqGY ShLzbFckkv6/fsBin54K0gGU50W9DXdPk6nwqMEkUsBkyIKdru/xDuLBv7+zHfu6wtjr Vd2sRr3TL0cEJuXEJx/j2yQyztvm+US0wrT4SmpS7eTw/Kb16w2ldGQTU6mzJ+NWa+Mx fPxT4AbOG5ODdo0hEHSbC0q5NmbCeHddKAQClcMwmdYZLsdJuv6QiIbQec9nj+QM9h11 ibeg== X-Gm-Message-State: AOPr4FUDkj4I5KbqhuNimoRdPRSzcV6x1ke4OH0yZA+fXHNfTjlLGrrtjn4QbvVG12MFCR4b0iw= X-Received: by 10.25.160.77 with SMTP id j74mr323136lfe.72.1463485312321; Tue, 17 May 2016 04:41:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id e187sm448752lfg.10.2016.05.17.04.41.50 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2016 04:41:50 -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 4/4] PM / Runtime: Defer resuming of the device in pm_runtime_force_resume() Date: Tue, 17 May 2016 13:41:36 +0200 Message-Id: <1463485296-22742-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463485296-22742-1-git-send-email-ulf.hansson@linaro.org> References: <1463485296-22742-1-git-send-email-ulf.hansson@linaro.org> When the pm_runtime_force_suspend|resume() helpers were invented, we still had CONFIG_PM_RUNTIME and CONFIG_PM_SLEEP as separate Kconfig options. To make sure these helpers worked for all combinations and without introducing too much of complexity, the device was always resumed in pm_runtime_force_resume(). More precisely, when CONFIG_PM_SLEEP was set and CONFIG_PM_RUNTIME was unset, we needed to resume the device as the subsystem/driver couldn't rely on using runtime PM to do it. As the CONFIG_PM_RUNTIME option was merged into CONFIG_PM a while ago, it removed this combination, of using CONFIG_PM_SLEEP without the earlier CONFIG_PM_RUNTIME. For this reason we can now rely on the subsystem/driver to use runtime PM to resume the device, instead of forcing that to be done in all cases. In other words, let's defer this to a later point when it's actually needed. Signed-off-by: Ulf Hansson --- drivers/base/power/runtime.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 1.9.1 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 09e4eb1..1db7b46 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1509,6 +1509,17 @@ int pm_runtime_force_resume(struct device *dev) if (!pm_runtime_status_suspended(dev)) goto out; + /* + * The PM core increases the runtime PM usage count in the system PM + * prepare phase. If the count is greather than 1 at this point, someone + * else has also increased it. In that case, invoke the runtime resume + * callback for the device as that is likely what is expected. In other + * case we trust the subsystem/driver to runtime resume the device when + * it's actually needed. + */ + if (atomic_read(&dev->power.usage_count) < 2) + goto out; + ret = pm_runtime_set_active(dev); if (ret) goto out;