From patchwork Wed Aug 23 14:42:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9917565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE54E602CB for ; Wed, 23 Aug 2017 14:55:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFB8028900 for ; Wed, 23 Aug 2017 14:55:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D456E288A1; Wed, 23 Aug 2017 14:55:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C8B4E289A5 for ; Wed, 23 Aug 2017 14:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VsrEPFdfe3wUxCBfBZT0AgVcwMFXuzQ4p84S2VIvGwQ=; b=M1mkwEHbVuNylh00UYs2w5/kGT n3l9zT7mr+/ToY7a2ekUhhXcP4g0lExh2jITw++6H7xz0VV5D2pGJpipDit3I/d8e+HvdsJUMBmV8 DCRhSKOq03tHgtybTT0ANxPkz4eYw0O6GLXYdgh9DCxvR6IROf094fDvl9XM4bxcWpdV4pa4eiHgZ nxHc8zfGVhehBI3KuINTzQjCheKXaWggjOOMZPfcHc9BWv6TT9zCa/w5jpQT5biNnuieEjZspx8KY d0bZSnezIRAETk8iwyQwzzMBw6rTzZWKFMnAbv3FdmDjMPKZqpM22zIwVNZQHAZkOewNogs7+v/LL dKvcpg+Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dkX41-0003lo-Ni; Wed, 23 Aug 2017 14:55:25 +0000 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkWrn-0001f4-DG for linux-arm-kernel@lists.infradead.org; Wed, 23 Aug 2017 14:43:05 +0000 Received: by mail-lf0-x22d.google.com with SMTP id d17so1565967lfe.0 for ; Wed, 23 Aug 2017 07:42:28 -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=cFtN7cmkVNQ4DEF3pHQhfXJjO7HTQgcgUFCs5qRmUEo=; b=Lj9VfaJ+xVEZHBDO4liUKOc2w96M80xH+qe9KbFA9TK173dHh6lFbDZXHMRFLAwGl1 Je2I3HUOai/jfX3qOGa3TSk51y2oRMfOIYy62NlCDWTnogRpOukA0FSq81U0+tYXba35 F6/w/F1XyUp68VtYFVkweY+u4xtHZpLsziTwk= 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=cFtN7cmkVNQ4DEF3pHQhfXJjO7HTQgcgUFCs5qRmUEo=; b=d4W1wcXTLIYKJQhUxOBo8V/mhRbzZAud/CXrhTTPQFcFgy6LH+BZG3btO4oqEoju8E nF2E1VGxbiBIDsKblRae5S6EOphVB3wIKwVCZdz/HbScdNwru8lKCiNsJOGeeKiRoDIC VzrfOVZnKa7JMLHdcV/RGlb7lUJ4h9yg2MVnZTC6SgyyMXIfAaJjeJjC2NPisbuQ9Yxm jEF2xwC1M5TLjHepG5udQpnp7qlQoG11sJRoTds1OvAH/xIqEKjK7tJmf7+zFdmmdVxm 0ZDJyZ+eGR8eMmx6YUV+LP3f8QkUVuD0YL4IJ5tDKiLLiVRDUwokvhdbzUkrkDu1K9FE cOCQ== X-Gm-Message-State: AHYfb5hOiBhD9cl7848TZzrErXohClchrcnrp7iCr5LGAJpt4EZadots 8dkfebv93TSajZtN X-Received: by 10.46.69.213 with SMTP id s204mr1196849lja.176.1503499346939; Wed, 23 Aug 2017 07:42:26 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id c89sm287593lfb.78.2017.08.23.07.42.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 07:42:26 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 7/9] PM / ACPI: Avoid runtime resuming device in acpi_subsys_suspend|freeze() Date: Wed, 23 Aug 2017 16:42:07 +0200 Message-Id: <1503499329-28834-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170823_074248_108986_7ABEF90E X-CRM114-Status: GOOD ( 15.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jisheng Zhang , Ulf Hansson , Guodong Xu , Kevin Hilman , Jarkko Nikula , Haojian Zhuang , John Stultz , Andy Shevchenko , Mika Westerberg , Sumit Semwal , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 means we can decrease the time needed for the device to enter its system sleep state, but also that we can avoid to waste power. More precisely, calling acpi_dev_needs_resume() from the acpi_subsys_suspend|freeze() in cases when the no_direct_complete flag has been set for the device, tells us if a runtime resume of the device is needed. Thus it may allow us to avoid it. Signed-off-by: Ulf Hansson --- Changes in v2: - Clarified changelog. - Improved comments is code. - Rebased. - Improved change to avoid open-coding. --- drivers/acpi/device_pm.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index b595968..5dd23de 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1117,11 +1117,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) { - pm_runtime_resume(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + + if (!adev->power.no_direct_complete || acpi_dev_needs_resume(dev, adev)) + pm_runtime_resume(dev); + return pm_generic_suspend(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_suspend); @@ -1178,13 +1186,20 @@ 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. In case the no_direct_complete is set, try to avoid it. */ - pm_runtime_resume(dev); + if (!adev->power.no_direct_complete || acpi_dev_needs_resume(dev, adev)) + pm_runtime_resume(dev); + return pm_generic_freeze(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_freeze);