From patchwork Fri May 13 11:15:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 9090661 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 51BF0BF29F for ; Fri, 13 May 2016 11:24:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EDF2200D6 for ; Fri, 13 May 2016 11:24:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE1B02022D for ; Fri, 13 May 2016 11:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752596AbcEMLYS (ORCPT ); Fri, 13 May 2016 07:24:18 -0400 Received: from mailout3.hostsharing.net ([176.9.242.54]:43340 "EHLO mailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520AbcEMLYS (ORCPT ); Fri, 13 May 2016 07:24:18 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout3.hostsharing.net (Postfix) with ESMTPS id 5DF6210405D8F; Fri, 13 May 2016 13:24:16 +0200 (CEST) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id EF708603E03D; Fri, 13 May 2016 13:24:14 +0200 (CEST) X-Mailbox-Line: From 9f0713b23baf7c6139a4b476cd9637d96e18cc95 Mon Sep 17 00:00:00 2001 Message-Id: <9f0713b23baf7c6139a4b476cd9637d96e18cc95.1463134232.git.lukas@wunner.de> In-Reply-To: References: From: Lukas Wunner Date: Fri, 13 May 2016 13:15:31 +0200 Subject: [PATCH v2 11/13] PM / sleep: Allow opt-out from runtime resume after direct-complete To: linux-pci@vger.kernel.org, linux-pm@vger.kernel.org Cc: Andreas Noever , "Rafael J. Wysocki" , Alan Stern Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Since commit aae4518b3124 ("PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily"), we no longer wake up devices which are already runtime suspended upon entering system sleep ("direct-complete"). However commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware") changed this to mandatorily runtime resume such devices after the system is woken. The motivation was to ensure that devices do not remain in a reset-power-on state after system resume, potentially preventing deep SoC-wide low-power states from being entered on idle. This is counter-productive for devices of which we know that the mandatory runtime resume is unnecessary. Thunderbolt on the Mac is a case in point: Runtime resume not just powers up the controller, but multiple adjacent chips, including a 15V boost converter, multiplexers and an eeprom. Gratuitously powering this up after every system sleep burns a not insignificant amount of energy and needlessly strains the hardware. Perhaps it would have been better to carry out the mandatory runtime resume only for those devices that actually need it, but at least we should allow an opt-out. Cc: Rafael J. Wysocki Cc: Alan Stern Signed-off-by: Lukas Wunner --- drivers/base/power/generic_ops.c | 3 ++- include/linux/pm.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index 07c3c4a..6e88f55 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c @@ -316,7 +316,8 @@ void pm_complete_with_resume_check(struct device *dev) * the sleep state it is going out of and it has never been resumed till * now, resume it in case the firmware powered it up. */ - if (dev->power.direct_complete && pm_resume_via_firmware()) + if (dev->power.direct_complete && pm_resume_via_firmware() && + !dev->power.direct_complete_noresume) pm_request_resume(dev); } EXPORT_SYMBOL_GPL(pm_complete_with_resume_check); diff --git a/include/linux/pm.h b/include/linux/pm.h index 6a5d654..023de94 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -596,6 +596,7 @@ struct dev_pm_info { unsigned int use_autosuspend:1; unsigned int timer_autosuspends:1; unsigned int memalloc_noio:1; + unsigned int direct_complete_noresume:1; enum rpm_request request; enum rpm_status runtime_status; int runtime_error;