From patchwork Wed Aug 31 06:15:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 9306389 X-Patchwork-Delegate: bhelgaas@google.com 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 CF28260865 for ; Wed, 31 Aug 2016 06:16:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1BC6283F4 for ; Wed, 31 Aug 2016 06:16:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B698B28D99; Wed, 31 Aug 2016 06:16:44 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 66F8928B24 for ; Wed, 31 Aug 2016 06:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756255AbcHaGQk (ORCPT ); Wed, 31 Aug 2016 02:16:40 -0400 Received: from mailout1.hostsharing.net ([83.223.95.204]:50833 "EHLO mailout1.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756082AbcHaGQi (ORCPT ); Wed, 31 Aug 2016 02:16:38 -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 mailout1.hostsharing.net (Postfix) with ESMTPS id DC16E101BB5F2; Wed, 31 Aug 2016 08:16:36 +0200 (CEST) Received: from localhost (4-38-90-81.adsl.cmo.de [81.90.38.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id DC862600C2BB; Wed, 31 Aug 2016 08:16:35 +0200 (CEST) X-Mailbox-Line: From 9f9152c11c6178bbac53fd3d0ef0d38173ad4b0b Mon Sep 17 00:00:00 2001 Message-Id: <9f9152c11c6178bbac53fd3d0ef0d38173ad4b0b.1472554278.git.lukas@wunner.de> In-Reply-To: References: From: Lukas Wunner Date: Wed, 31 Aug 2016 08:15:18 +0200 Subject: [PATCH 4/4] PCI: Avoid unnecessary resume on shutdown To: linux-pci@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, "Rafael J. Wysocki" , Peter Wu , Andreas Noever Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We currently perform a mandatory runtime resume of all PCI devices on ->shutdown. However it is pointless to wake devices only to immediately power them down afterwards. (Or have the firmware reset them, in case of a reboot.) It seems there are only two cases when a runtime resume is actually necessary: If the driver has declared a ->shutdown callback or if kexec is in progress. Constrain resume of a device to these cases and let it slumber otherwise, thereby conserving energy and speeding up shutdown. Cc: Rafael J. Wysocki Signed-off-by: Lukas Wunner --- drivers/pci/pci-driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index fd4b9c4..09a4e56 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -459,6 +459,11 @@ static void pci_device_shutdown(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_driver *drv = pci_dev->driver; + /* Fast path for suspended devices */ + if (pm_runtime_suspended(dev) && (!drv || !drv->shutdown) && + !kexec_in_progress) + return; + pm_runtime_resume(dev); if (drv && drv->shutdown)