From patchwork Thu Aug 24 00:13:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9918755 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 AFF3D602A0 for ; Thu, 24 Aug 2017 00:23:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1BFE28AB3 for ; Thu, 24 Aug 2017 00:23:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 967AF28AB6; Thu, 24 Aug 2017 00:23:33 +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 C64E728AB3 for ; Thu, 24 Aug 2017 00:23:31 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=SlSitgL3INa9rKqXl2urrQ2Fa3cg1sYO2wDNfuGdLCw=; b=CAs8IRmkyksQJt M7wQpD33OVNb+JgmfTazEqCjM4Le/avHiAWE9qLkK4Rygc7y0nrtlUpflTYm4fxH4RxsXk9dIvQ8x eAtLm3DKsfEW6e2DaOga3p2muA2xbNMRNh/FH/b/ppoRP9/zYGwjd9zsidqE5//INqndEVBoTfOqy mdMHgIDdkXA0F5zRAS1SIjXFmtdBQqZzwjNXhD7j292jVIG6HnIlbYyzmDcXXk1Znied3FSYRNCsN ATahUwm1/95uSLRCSYZHA8hZhpd27bV2AbLOm/Q+8oDMCbSTVKSa4ITqn6zqZU5DAzA0GpzDg5+Gc nzncFCcBtfspNSaZ3VmQ==; 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 1dkfvG-0001Mw-Jy; Thu, 24 Aug 2017 00:22:58 +0000 Received: from cloudserver094114.home.net.pl ([79.96.170.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkfvD-0001Lj-1m for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2017 00:22:57 +0000 Received: from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.82) id 2ef34f9d4752a592; Thu, 24 Aug 2017 02:22:28 +0200 From: "Rafael J. Wysocki" To: Ulf Hansson Subject: Re: [PATCH v2 5/9] PM / ACPI: Provide option to disable direct_complete for ACPI devices Date: Thu, 24 Aug 2017 02:13:55 +0200 Message-ID: <3774251.HUIR40xRhc@aspire.rjw.lan> In-Reply-To: References: <1503499329-28834-1-git-send-email-ulf.hansson@linaro.org> <1503499329-28834-6-git-send-email-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170823_172255_286183_B2A8398D X-CRM114-Status: GOOD ( 24.65 ) 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 , Guodong Xu , Linux PM , Mika Westerberg , Wolfram Sang , linux-i2c , ACPI Devel Maling List , Jarkko Nikula , Haojian Zhuang , "Rafael J. Wysocki" , John Stultz , Andy Shevchenko , Kevin Hilman , Sumit Semwal , "linux-arm-kernel@lists.infradead.org" , Len Brown 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 On Thursday, August 24, 2017 1:39:44 AM CEST Rafael J. Wysocki wrote: > On Wed, Aug 23, 2017 at 4:42 PM, Ulf Hansson wrote: > > In some cases a driver for an ACPI device needs to be able to prevent the > > ACPI PM domain from using the direct_complete path during system sleep. > > > > One typical case is when the driver for the device needs its device to stay > > runtime enabled, during the __device_suspend phase. This isn't the case > > when the direct_complete path is being executed by the PM core, as it then > > disables runtime PM for the device in __device_suspend(). Any following > > attempts to runtime resume the device after that point, just fails. > > OK, that is a problem. > > > A workaround to this problem is to let the driver runtime resume its device > > from its ->prepare() callback, as that would prevent the direct_complete > > path from being executed. However, that may often be a waste, especially if > > it turned out that no one really needed the device. > > > > For this reason, invent acpi_dev_disable|enable_direct_complete(), to allow > > drivers to inform the ACPI PM domain to change its default behaviour during > > system sleep, and thus control whether it may use the direct_complete path > > or not. > > But I'm not sure this is the right place to address it as it very well > may affect a PCI device too. > > Also, this is about the device and not about its ACPI companion > object, so putting the flag in there is somewhat unclean, so to speak. > > It looks like we need a flag in dev_pm_info saying something along the > lines of "my system suspend callback can deal with runtime PM" that > will cause the direct_complete update to occur in > __device_suspend_late() instead of __device_suspend(). IOW, something like the patch below. It actually should work with the ACPI PM domain code as is except that it will cause the device to be runtime resumed every time during suspend. But acpi_subsys_suspend() can be changed to avoid resuming the device if power.force_suspend is set. --- drivers/base/power/main.c | 11 +++++++++-- include/linux/pm.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) Index: linux-pm/drivers/base/power/main.c =================================================================== --- linux-pm.orig/drivers/base/power/main.c +++ linux-pm/drivers/base/power/main.c @@ -1271,9 +1271,16 @@ static int __device_suspend_late(struct goto Complete; } - if (dev->power.syscore || dev->power.direct_complete) + if (dev->power.syscore) goto Complete; + if (dev->power.direct_complete) { + if (pm_runtime_status_suspended(dev)) + goto Complete; + + dev->power.direct_complete = false; + } + if (dev->pm_domain) { info = "late power domain "; callback = pm_late_early_op(&dev->pm_domain->ops, state); @@ -1482,7 +1489,7 @@ static int __device_suspend(struct devic if (dev->power.syscore) goto Complete; - if (dev->power.direct_complete) { + if (dev->power.direct_complete && !dev->power.force_suspend) { if (pm_runtime_status_suspended(dev)) { pm_runtime_disable(dev); if (pm_runtime_status_suspended(dev)) Index: linux-pm/include/linux/pm.h =================================================================== --- linux-pm.orig/include/linux/pm.h +++ linux-pm/include/linux/pm.h @@ -554,6 +554,7 @@ struct dev_pm_info { pm_message_t power_state; unsigned int can_wakeup:1; unsigned int async_suspend:1; + unsigned int force_suspend:1; bool in_dpm_list:1; /* Owned by the PM core */ bool is_prepared:1; /* Owned by the PM core */ bool is_suspended:1; /* Ditto */