From patchwork Wed Oct 19 14:07:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 9384777 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 E59C360487 for ; Wed, 19 Oct 2016 16:20:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7DB029903 for ; Wed, 19 Oct 2016 16:20:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCAE629935; Wed, 19 Oct 2016 16:20:15 +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 7EF1229903 for ; Wed, 19 Oct 2016 16:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938783AbcJSQUL (ORCPT ); Wed, 19 Oct 2016 12:20:11 -0400 Received: from mailout3.hostsharing.net ([176.9.242.54]:44325 "EHLO mailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938895AbcJSORa (ORCPT ); Wed, 19 Oct 2016 10:17:30 -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 03575101EE85D; Wed, 19 Oct 2016 16:09:33 +0200 (CEST) Received: from localhost (3-38-90-81.adsl.cmo.de [81.90.38.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id B86D76001E52; Wed, 19 Oct 2016 16:09:31 +0200 (CEST) X-Mailbox-Line: From ba2f9f322b4aeea1aeb01f98a2eda8efe055494f Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Lukas Wunner Date: Wed, 19 Oct 2016 16:07:13 +0200 Subject: [PATCH 6/9] PCI: Unfold conditions to block runtime PM on PCIe ports To: linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bjorn Helgaas Cc: Mika Westerberg , "Rafael J. Wysocki" , Andreas Noever , Keith Busch 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 The conditions to block D3 on parent ports are currently condensed into a single expression in pci_dev_check_d3cold(). Upcoming commits will add further conditions for hotplug ports, making this expression fairly large and impenetrable. Unfold the conditions to maintain readability when they are amended. No functional change intended. Cc: Mika Westerberg Cc: Rafael J. Wysocki Signed-off-by: Lukas Wunner --- drivers/pci/pci.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a19056e..f1ddb6b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2270,19 +2270,20 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) static int pci_dev_check_d3cold(struct pci_dev *dev, void *data) { bool *d3cold_ok = data; - bool no_d3cold; - /* - * The device needs to be allowed to go D3cold and if it is wake - * capable to do so from D3cold. - */ - no_d3cold = dev->no_d3cold || !dev->d3cold_allowed || - (device_may_wakeup(&dev->dev) && !pci_pme_capable(dev, PCI_D3cold)) || - !pci_power_manageable(dev); + /* The device needs to be allowed to go D3cold. */ + if (dev->no_d3cold || !dev->d3cold_allowed) + *d3cold_ok = false; + + /* If it is wakeup capable it must be able to do so from D3cold. */ + if (device_may_wakeup(&dev->dev) && !pci_pme_capable(dev, PCI_D3cold)) + *d3cold_ok = false; - *d3cold_ok = !no_d3cold; + /* If it is a bridge it must be allowed to go to D3. */ + if (!pci_power_manageable(dev)) + *d3cold_ok = false; - return no_d3cold; + return !*d3cold_ok; } /*