Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5577375ybl; Tue, 27 Aug 2019 06:49:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFaubqk8evq6XZ13SANGhe+AVkyyk1E+9LNoeXLBMFxLv2ikktURcwGbfBlrBkGrUef0Ji X-Received: by 2002:a62:8688:: with SMTP id x130mr13823101pfd.162.1566913760250; Tue, 27 Aug 2019 06:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566913760; cv=none; d=google.com; s=arc-20160816; b=1GSfNbXtBnaojH+iAw2gGcKDZlRVwoN+Cj7jk5R0JPGfX+5VlEKWVmvvUKJq/cFFKC qEzjbVs8dI5sEHCaVxb9CcaC0Y1zYdIGQoI0cpogPe4o6IYaJebAYKo5+igaNOFjRYSw zHQyDz/BFurntQg3SY8hSU9Q8Gu0ai+bq7oBu1WnKelZuXQh/1pvKr86ZaMhuZD/V/AP 72P7FsXq15pn9q/1uMWNe3/d++nHBbIQTrpZWdNvEAK6o2qazmw/A8k3wklolhlWyil4 vXHH99zhcrXCbsflPQPuPOL1vjorKC4MLlYiJ1Orx0KccamDFQKxn1SnnaThsC2uExEY pTiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=0o7hgE0tyl1Uw8Ekd5qb06YhobFx0e9CBmR5uqH4X2g=; b=x1k4JssucghzDHZCkyQsnOXJ1xZtZwwle/FxY4fXN+ogXpQ8BjHrk0Rm8wVEjMuPAL btvE889huJo2pp1jgfeDvCARacBiwbLz4fcJ6rVkfOMHDZ5MkjHjaocKhwC4BWi81M03 tdCoxeoqTC1HIFWV1VgU4TRrJXBkq8sRjWw3DQoAdteJLYeNsLVpoZH9s6GiVqJhYPWL AajY2+DKrkv8JKPvUnJVbFjwH0OucrAOi/PAlcXRjX7ZXGdXg+JlRUTbRaNuYSXyzIhO /vDcyeGHhDRPrJXPmsvRe/HStgpZG+rgU8rxNSGwAmAUl2lPion3b1VXSW8L8SgAy9jf bozw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b96si12737120plb.56.2019.08.27.06.49.05; Tue, 27 Aug 2019 06:49:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729997AbfH0NsH (ORCPT + 99 others); Tue, 27 Aug 2019 09:48:07 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37096 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbfH0NsG (ORCPT ); Tue, 27 Aug 2019 09:48:06 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1i2bpJ-0005sq-Ns; Tue, 27 Aug 2019 13:48:02 +0000 From: Kai-Heng Feng To: bhelgaas@google.com, tiwai@suse.com Cc: linux-pci@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Kai-Heng Feng Subject: [PATCH 1/2] PCI: Add a helper to check Power Resource Requirements _PR3 existence Date: Tue, 27 Aug 2019 21:47:55 +0800 Message-Id: <20190827134756.10807-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A driver may want to know the existence of _PR3, to choose different runtime suspend behavior. A user will be add in next patch. This is mostly the same as nouveau_pr3_present(). Signed-off-by: Kai-Heng Feng --- drivers/pci/pci.c | 20 ++++++++++++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1b27b5af3d55..776af15b92c2 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5856,6 +5856,26 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode, return 0; } +bool pci_pr3_present(struct pci_dev *pdev) +{ + struct pci_dev *parent_pdev = pci_upstream_bridge(pdev); + struct acpi_device *parent_adev; + + if (acpi_disabled) + return false; + + if (!parent_pdev) + return false; + + parent_adev = ACPI_COMPANION(&parent_pdev->dev); + if (!parent_adev) + return false; + + return parent_adev->power.flags.power_resources && + acpi_has_method(parent_adev->handle, "_PR3"); +} +EXPORT_SYMBOL_GPL(pci_pr3_present); + /** * pci_add_dma_alias - Add a DMA devfn alias for a device * @dev: the PCI device for which alias is added diff --git a/include/linux/pci.h b/include/linux/pci.h index 82e4cd1b7ac3..9b6f7b67fac9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2348,9 +2348,11 @@ struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus); void pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *)); +bool pci_pr3_present(struct pci_dev *pdev); #else static inline struct irq_domain * pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; } +static bool pci_pr3_present(struct pci_dev *pdev) { return false; } #endif #ifdef CONFIG_EEH -- 2.17.1