[PATCH v2 1/3] PCI/PM: Honor PCI_DEV_FLAGS_NO_D3 in pci_bridge_d3_possible()
From: Aviv Bakal
Date: Mon Nov 16 2026 - 11:51:49 EST
pci_set_power_state() does not put a device with PCI_DEV_FLAGS_NO_D3
into D3, but pci_bridge_d3_possible() ignores the flag.
pcie_portdrv_probe() therefore enables runtime PM on such a port, and
on runtime suspend pciehp masks the hotplug interrupt while the port
stays in D0.
Return false from pci_bridge_d3_possible() when the flag is set.
pci_bridge_d3_possible() must return the same value for the lifetime
of the device, and FINAL fixups may set the flag after portdrv has
probed, so record the flag in pci_pm_init() and check that copy.
Fixes: d4c79b63d82d ("PCI: Allow D3 for native hotplug-capable Root Ports on non-x86 platforms")
Cc: stable@xxxxxxxxxxxxxxx # 7.3.x
Co-developed-by: Zeev Zilberman <zeev@xxxxxxxxxx>
Signed-off-by: Zeev Zilberman <zeev@xxxxxxxxxx>
Signed-off-by: Aviv Bakal <avivb@xxxxxxxxxx>
---
drivers/pci/pci.c | 10 ++++++++++
include/linux/pci.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..eb7f2f03d9ae 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3055,6 +3055,10 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
if (pci_bridge_d3_disable)
return false;
+ /* The port is known not to work correctly in D3 */
+ if (bridge->no_d3)
+ return false;
+
/*
* Hotplug ports handled by platform firmware may not be put
* into D3 by the OS, e.g. ACPI slots ...
@@ -3227,6 +3231,12 @@ void pci_pm_init(struct pci_dev *dev)
dev->pm_cap = 0;
dev->pme_support = 0;
+ /*
+ * pci_bridge_d3_possible() must not change after this point, so
+ * ignore NO_D3 set by later fixups.
+ */
+ dev->no_d3 = !!(dev->dev_flags & PCI_DEV_FLAGS_NO_D3);
+
/* find PCI PM capability in list */
pm = pci_find_capability(dev, PCI_CAP_ID_PM);
if (!pm)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aa3765a20a96..1238667d643c 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -420,6 +420,7 @@ struct pci_dev {
unsigned int no_d1d2:1; /* D1 and D2 are forbidden */
unsigned int no_d3cold:1; /* D3cold is forbidden */
unsigned int bridge_d3:1; /* Allow D3 for bridge */
+ unsigned int no_d3:1; /* NO_D3 set before PM init */
unsigned int d3cold_allowed:1; /* D3cold is allowed by user */
unsigned int mmio_always_on:1; /* Disallow turning off io/mem
decoding during BAR sizing */
--
2.50.1