From patchwork Wed Jun 21 19:21:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106122 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092685qgd; Wed, 21 Jun 2017 12:21:58 -0700 (PDT) X-Received: by 10.25.199.13 with SMTP id x13mr11997997lff.52.1498072918426; Wed, 21 Jun 2017 12:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072918; cv=none; d=google.com; s=arc-20160816; b=Mjh+3F0dI7dh2xibnNDuo7uswP1ykqT50yucyUF9KH9FZOD9IJo6rBARD3labBCCQT 18uDKv4wMjokjqBl0mI7Vtg9SGIGUFDO7jIewfxBJXAd6C7PCOAel9M+IBxPm+Pux6q5 aGfcK69/a7ZesAGYL8My4W8zeuORs/8vJhvcNJebdnmluhcdPqvtls6ht1iNIawJ2MM9 OhRFBibFrA4qVuwulO/rpCDNztdciRybkmugOBV4HJUggzSt5q1aFXw6o5YJevKScvaA I5cPJB7MZL0VVxHOaiL8oGMdhW+oCWujqYSGSkOUeONE1YQhrpfP8OTuAV3mfYiXFrpn gIhg== 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=CAI7eMLczbKxpADKYBOT9FpeOYlOScekjsamv5c1doA=; b=zMUtzaXTvNf1eZoXRO6rHPWy21mGVELI9O9NsHJmlMjyaP1OzGYxtoMaLD6PNy2b/i CXUHsEhGJ9j5AEuwYwNhJK7yyfXrh01g2OI3HIhZJepZCl7GAyRHaknUDgUAHsuxlbdK S5/xdZtGBpwRTvBs4059wT4sQRRS7e8TToAbk059JHUFIn1ts5jLljs2ApCijqbidvGh pP92RsmrwVf0gS0Cpc/gxtJ75Fvm1xuPuviIN61Jumav9XAJsYxlWPpBkNFT1yg+H0vH 6eTdXb2+O1NNbdJFZwqzB/zGGJb2/5/vyO41wO1UQfLVBsSGZXXEogDkj8ULVxsi+Ht4 wKYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=HIJlqKgS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b 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-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id n68si9551905lfi.330.2017.06.21.12.21.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=HIJlqKgS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22b.google.com with SMTP id m77so102862430lfe.0 for ; Wed, 21 Jun 2017 12:21:58 -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=CAI7eMLczbKxpADKYBOT9FpeOYlOScekjsamv5c1doA=; b=HIJlqKgSphwFvwGdoMRyLKo2/2TdIaXn7JeT1O+7xHuC0MvINd1DLgMIaLWvvl5Ouk QAheBFiu+YXi2f+jVFGtBLBRY1h0F1Y7N8SV9AOGqNX1HqJ2x7DSS4X9psl6/K2Y0csS HTQtXmAgsCYuzh8rLYnWuX1uh3zvdHdgNVJgk= 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=CAI7eMLczbKxpADKYBOT9FpeOYlOScekjsamv5c1doA=; b=tz62uJn4Lk8z6CKWt+F+w+BTodLvvpMOHlrh37xqzn9nsHDoHPVDw07QdOA0OsTYsp yrou9s/w85SLbC8i3SIF1QXf7XnxVis4Ab5W+vghZC+vuxOtl5PR2fHQuOJGevxTq1is hbRWfB6WzVzs45LxIrki7E8sbQW7sX35FOioLF7tECzduXdWKA1rnVZMTpHs48e0J9xh PzDwzhiPlFCq/UMEcvKK07LqpJb28v/kM3VKva5A1trpm3oJUVaIVwvD3FXLI2zlmz6R BZJ4cSOGAb+rt1hoHsIltQv4ISftfrY5Xc3bBxOavVwFxtcGk/W9dtAX1VKcJKvi5eCi A3rA== X-Gm-Message-State: AKS2vOwnnKb/f+7lFFuUxfZHfXJ/NqKbURQr9DXIK0JQmxpxy1X2nA12 vsplJuV9r3LkCMWb+ZA= X-Received: by 10.46.82.68 with SMTP id g65mr1552089ljb.123.1498072918074; Wed, 21 Jun 2017 12:21:58 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id t24sm3920047ljd.1.2017.06.21.12.21.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:57 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 8/9] PM / ACPI: Avoid runtime resuming device in acpi_subsys_suspend|freeze() Date: Wed, 21 Jun 2017 21:21:27 +0200 Message-Id: <1498072888-14782-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> In the case when the no_direct_complete flag is set for the ACPI device, we can under some conditions during system sleep, avoid runtime resuming the device in acpi_subsys_suspend|freeze(). This will of course improve the time it takes for the system to suspend, but also avoid wasting power. More precisely, from acpi_subsys_suspend|freeze(), let's call acpi_dev_needs_resume() when the no_direct_complete flag is set, as it tells us when runtime resume of the device is needed, thus let's avoid it if possible. Signed-off-by: Ulf Hansson --- drivers/acpi/device_pm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index e0324ab..f3061f9 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1056,10 +1056,19 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete); * @dev: Device to handle. * * Follow PCI and resume devices suspended at run time before running their - * system suspend callbacks. + * system suspend callbacks. However, try to avoid it when no_direct_complete + * is set. */ int acpi_subsys_suspend(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + + if (adev->no_direct_complete && !acpi_dev_needs_resume(dev, adev)) + return pm_generic_suspend(dev); + pm_runtime_resume(dev); return pm_generic_suspend(dev); } @@ -1117,12 +1126,22 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); */ int acpi_subsys_freeze(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + /* * This used to be done in acpi_subsys_prepare() for all devices and * some drivers may depend on it, so do it here. Ideally, however, * runtime-suspended devices should not be touched during freeze/thaw - * transitions. + * transitions. At least when no_direct_complete is set, let's try to + * avoid it. */ + + if (adev->no_direct_complete && !acpi_dev_needs_resume(dev, adev)) + return pm_generic_freeze(dev); + pm_runtime_resume(dev); return pm_generic_freeze(dev); }