Linux-PCI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] PCI: Make pcie_find_root_port() work for PCIe root ports as well
@ 2020-06-22 16:12 Mika Westerberg
  2020-06-30 22:01 ` Bjorn Helgaas
  0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2020-06-22 16:12 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Kalle Valo, Yicong Yang, Mika Westerberg, linux-pci

Commit 6ae72bfa656e ("PCI: Unify pcie_find_root_port() and
pci_find_pcie_root_port()") unified the root port finding functionality
into a single function but missed the fact that the passed in device may
already be a root port. This causes the kernel to block power management
of PCIe hierarchies in recent systems because ->bridge_d3 started to
return false for such ports after the commit in question.

Fixes: 6ae72bfa656e ("PCI: Unify pcie_find_root_port() and pci_find_pcie_root_port()")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: stable@vger.kernel.org
---
 include/linux/pci.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index c79d83304e52..c17c24f5eeed 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2169,8 +2169,13 @@ static inline int pci_pcie_type(const struct pci_dev *dev)
  */
 static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
 {
-	struct pci_dev *bridge = pci_upstream_bridge(dev);
+	struct pci_dev *bridge;
 
+	/* If dev is already root port */
+	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
+		return dev;
+
+	bridge = pci_upstream_bridge(dev);
 	while (bridge) {
 		if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT)
 			return bridge;
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 16:12 [PATCH] PCI: Make pcie_find_root_port() work for PCIe root ports as well Mika Westerberg
2020-06-30 22:01 ` Bjorn Helgaas
2020-07-01  1:53   ` Yicong Yang
2020-07-01 10:15     ` Mika Westerberg
2020-07-01 12:47       ` Yicong Yang
2020-07-01 10:14   ` Mika Westerberg

Linux-PCI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pci/0 linux-pci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pci linux-pci/ https://lore.kernel.org/linux-pci \
		linux-pci@vger.kernel.org
	public-inbox-index linux-pci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git