From patchwork Thu Apr 21 10:34:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 8898741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4BF3C9F457 for ; Thu, 21 Apr 2016 10:36:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64372202DD for ; Thu, 21 Apr 2016 10:36:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93C5920165 for ; Thu, 21 Apr 2016 10:36:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1atBwo-0001x7-B3; Thu, 21 Apr 2016 10:34:58 +0000 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atBwk-0001vS-8D for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2016 10:34:55 +0000 Received: by mail-lf0-x22b.google.com with SMTP id e190so57908584lfe.0 for ; Thu, 21 Apr 2016 03:34:33 -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; bh=KWE/Ygav/5h73kfctIGSM0mc2N6EzIOQdr+2cb7bD6w=; b=UmHz1lnZVNoPBe4qg6wirCGf6LLQaybBOeL8B6cC0qSiDiX+ZJpUSlKA1dxOUNLK2X 8IfqpvxCHJOmdVSDLaVSz82dNONG8gRasQSVne42NfW0e4gkaREXlcSNif3ytMec2BQ0 +t9hjwHSNJ18ClrP3PfuaIe38YUsKHZPCSPsY= 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=KWE/Ygav/5h73kfctIGSM0mc2N6EzIOQdr+2cb7bD6w=; b=P+7irus9p8aTUBxeIOoe98VdBsBgqks/m8qcMN/hya4QhnZzmNHMaGbk7BjSU36R4s qHWrNgf97QVjBFydgISO6FqHDAqBS/+f0mLMVSt0llpz+qbybfFToiQHHGAFtVu0R88U yFGp7qPrUvisSaMkkIB0F2zGfhVkYZQvseZN9rLSWecO2ynL2ut/Iko0Jsbk3DsRyx6D +KbZm8AkaWWVrzl9zygbbexqRX266p66qjAT6HIjfH5ol/uBBbCYWZV5WNpdF2G9izWl jv8kPsaVcE20K+Jx6BGO0rcuD0HzHBRS4Ww4iyhbd23mZfQm43/5dit69kW4ow8XIY6k trBA== X-Gm-Message-State: AOPr4FVr4I7HVP8YNwsFPJGIcag3AwoNPAhxT60oRVTHHPevUvcVoXnuS67asnsWhKO6qzVK X-Received: by 10.25.87.19 with SMTP id l19mr5152153lfb.27.1461234872103; Thu, 21 Apr 2016 03:34:32 -0700 (PDT) Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id hw7sm406095lbb.40.2016.04.21.03.34.30 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Apr 2016 03:34:30 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , linux-pm@vger.kernel.org Subject: [PATCH] PM / Runtime: Defer resuming of the device in pm_runtime_force_resume() Date: Thu, 21 Apr 2016 12:34:02 +0200 Message-Id: <1461234842-22820-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160421_033455_058872_3A5E55E3 X-CRM114-Status: GOOD ( 15.60 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Len Brown , Ulf Hansson , Sergei Shtylyov , Kevin Hilman , Linus Walleij , Alan Stern , Laurent Pinchart , Pavel Machek , Andy Gross , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Note, this patch is based upon another not yet queued patch [1]. The reason is simply because that [1] is a more important patch as it fixes a problem. It was posted to linux-pm April 8th and I expect it (or a new revision of it) to be applied before $subject patch. [1] https://patchwork.kernel.org/patch/8782851 --- drivers/base/power/runtime.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index b746904..a190ca0 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1506,6 +1506,17 @@ int pm_runtime_force_resume(struct device *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 such case, let's make sure to runtime + * resume 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;