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: 9802747 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 C0FE4601C0 for ; Wed, 21 Jun 2017 19:22:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1B4228396 for ; Wed, 21 Jun 2017 19:22:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B013C285E8; Wed, 21 Jun 2017 19:22:27 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AEC1286B0 for ; Wed, 21 Jun 2017 19:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbdFUTWC (ORCPT ); Wed, 21 Jun 2017 15:22:02 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:36311 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997AbdFUTV7 (ORCPT ); Wed, 21 Jun 2017 15:21:59 -0400 Received: by mail-lf0-f41.google.com with SMTP id h22so23140343lfk.3 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=IL4Cov81JbNLyCSUTPSeePztPSGQu6rVOyr19XSzy8LoUSRCrqmIWhxCGJfc9tYQJG IJWpqaU8YIdNBac/Xx2XS/VoMdgqKsdPJGxokXYV7hbqhFfR/StOygBGbKJUMAdX42q2 Z44F4NgG4dXCAxeo/66JuIW4cxfcVRr+6vgrJ5Y6ANuPoc1OmgdQGeUtsjuXJIfp4xsV wgP5bKZix9+hTlepra3Qaum1iUfM2dByki2m1nHbL5b17MZAGzdsSByUIHbZ1+cxLK2a VbizkF2e9bk3n+ytojeBptrbeBgwrn3VVcxtYVfz7/5mjL8nH9dkoce6VKlmsUNmBmcw DP0g== X-Gm-Message-State: AKS2vOz3JzgxYQMJPcLxG3EHY2NXvitrLm3JGGwNPaK/TJkNKwonAAvg KPVSTHTKEolDjjUu X-Received: by 10.46.82.68 with SMTP id g65mr1552089ljb.123.1498072918074; Wed, 21 Jun 2017 12:21:58 -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 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> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.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 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(-) 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); }