From patchwork Thu Jul 7 23:54:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 9219933 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 9DF966048B for ; Thu, 7 Jul 2016 23:54:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DC6E1FF15 for ; Thu, 7 Jul 2016 23:54:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FE77212DA; Thu, 7 Jul 2016 23:54:58 +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 64A3D1FF15 for ; Thu, 7 Jul 2016 23:54:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753488AbcGGXy4 (ORCPT ); Thu, 7 Jul 2016 19:54:56 -0400 Received: from lekensteyn.nl ([178.21.112.251]:46527 "EHLO lekensteyn.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753028AbcGGXy4 (ORCPT ); Thu, 7 Jul 2016 19:54:56 -0400 X-Greylist: delayed 951 seconds by postgrey-1.27 at vger.kernel.org; Thu, 07 Jul 2016 19:54:55 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lekensteyn.nl; s=s2048-2015-q1; h=Message-Id:Date:Subject:Cc:To:From; bh=Yceepe33/QQASZ2F3hiQRbtOnXu2tfmGV9a9i9546Yg=; b=gNxXmHzXuVPCzlwqLZh57RMPyiP8fKJpGkYbVEJ5adxwJzsRx4uLeuU2bDCSjh+EhHp9zzg02owsI3FGFW4Yd3r7TW4e8OyaqkcX6qu+PH+mjKUc1dBeIIu8gxW2DDl16QCWFtazkkfD6v9+5jOXUKnaH7QMi9j90GIDeaZDbLxYAqtspukUp7weQ/tQT0V9tV6EEkMqwxVqoNclWZbkBqTC/FOcb0UeYRNGd2h7Mw2VP0VQKW3xUBrehEwGg7EvFAZdihN/YpXFrRZ87yYhwCrVHFcoDsF6m/sljB6IHBfqPWa3K2kJZyBklp4l8ioJi0ZkmvPadMOV43EyRVef/g==; Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bLJ89-0002aN-5R; Fri, 08 Jul 2016 01:54:53 +0200 From: Peter Wu To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Mika Westerberg Subject: [PATCH] PCI: export pci_bridge_d3_possible Date: Fri, 8 Jul 2016 01:54:48 +0200 Message-Id: <20160707235448.2622-1-peter@lekensteyn.nl> X-Mailer: git-send-email 2.9.0 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 Allow the nouveau driver to find out whether the bridge can put itself in the D3cold state or whether it should use a specific DSM method to achieve the same result. Cc: Mika Westerberg Signed-off-by: Peter Wu --- Since it is not yet merged in Linus tree, maybe the patch in pci/pm can be amended? This is the follow-up patch I had in mind for nouveau: --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c @@ -223,6 +223,9 @@ static bool nouveau_pr3_present(struct pci_dev *pdev) if (!parent_pdev) return false; + if (!pci_bridge_d3_possible(parent_pdev)) + return false; + parent_adev = ACPI_COMPANION(&parent_pdev->dev); if (!parent_adev) return false; Related nouveau patches were sent a few minutes ago, titled "[PATCH v2 0/4] nouveau RPM fixes for Optimus". --- drivers/pci/pci.c | 3 ++- include/linux/pci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 9ff7183..714701b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2178,7 +2178,7 @@ void pci_config_pm_runtime_put(struct pci_dev *pdev) * This function checks if it is possible to move the bridge to D3. * Currently we only allow D3 for recent enough PCIe ports. */ -static bool pci_bridge_d3_possible(struct pci_dev *bridge) +bool pci_bridge_d3_possible(struct pci_dev *bridge) { unsigned int year; @@ -2207,6 +2207,7 @@ static bool pci_bridge_d3_possible(struct pci_dev *bridge) return false; } +EXPORT_SYMBOL_GPL(pci_bridge_d3_possible); static int pci_dev_check_d3cold(struct pci_dev *dev, void *data) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 0a1a9e3..f19761d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1088,6 +1088,7 @@ int pci_back_from_sleep(struct pci_dev *dev); bool pci_dev_run_wake(struct pci_dev *dev); bool pci_check_pme_status(struct pci_dev *dev); void pci_pme_wakeup_bus(struct pci_bus *bus); +bool pci_bridge_d3_possible(struct pci_dev *bridge); void pci_d3cold_enable(struct pci_dev *dev); void pci_d3cold_disable(struct pci_dev *dev);