* [PATCH v2 1/3] PCI/PM: Honor PCI_DEV_FLAGS_NO_D3 in pci_bridge_d3_possible()
2026-11-16 16:51 [PATCH v2 0/3] PCI/PM: Keep hotplug ports that can't wake from D3hot out of D3 Aviv Bakal
@ 2026-11-16 16:51 ` Aviv Bakal
2026-11-16 17:47 ` Kuppuswamy Sathyanarayanan
2026-11-16 16:51 ` [PATCH v2 2/3] PCI: Avoid runtime D3 on Amazon PCIe switch ports Aviv Bakal
2026-11-16 16:51 ` [PATCH v2 3/3] PCI/PM: Keep hotplug ports out of D3 if they can't signal PME from D3hot Aviv Bakal
2 siblings, 1 reply; 5+ messages in thread
From: Aviv Bakal @ 2026-11-16 16:51 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Manivannan Sadhasivam, Lukas Wunner, Kuppuswamy Sathyanarayanan,
linux-pci, linux-kernel, Zeev Zilberman, stable
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@vger.kernel.org # 7.3.x
Co-developed-by: Zeev Zilberman <zeev@amazon.com>
Signed-off-by: Zeev Zilberman <zeev@amazon.com>
Signed-off-by: Aviv Bakal <avivb@amazon.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 1/3] PCI/PM: Honor PCI_DEV_FLAGS_NO_D3 in pci_bridge_d3_possible()
2026-11-16 16:51 ` [PATCH v2 1/3] PCI/PM: Honor PCI_DEV_FLAGS_NO_D3 in pci_bridge_d3_possible() Aviv Bakal
@ 2026-11-16 17:47 ` Kuppuswamy Sathyanarayanan
0 siblings, 0 replies; 5+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-16 17:47 UTC (permalink / raw)
To: Aviv Bakal, Bjorn Helgaas
Cc: Manivannan Sadhasivam, Lukas Wunner, linux-pci, linux-kernel,
Zeev Zilberman, stable
On 11/16/26 08:51, Aviv Bakal wrote:
> 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@vger.kernel.org # 7.3.x
> Co-developed-by: Zeev Zilberman <zeev@amazon.com>
> Signed-off-by: Zeev Zilberman <zeev@amazon.com>
> Signed-off-by: Aviv Bakal <avivb@amazon.com>
> ---
> 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);
This ignores quirk_plx_pex_no_d3(). It is the only other quirk that
sets NO_D3 on a PCIe port, and it is a FINAL fixup. So
pci_bridge_d3_possible() still returns true for those PLX downstream
ports, and portdrv still enables runtime PM on them.
> +
> /* 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 */
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] PCI: Avoid runtime D3 on Amazon PCIe switch ports
2026-11-16 16:51 [PATCH v2 0/3] PCI/PM: Keep hotplug ports that can't wake from D3hot out of D3 Aviv Bakal
2026-11-16 16:51 ` [PATCH v2 1/3] PCI/PM: Honor PCI_DEV_FLAGS_NO_D3 in pci_bridge_d3_possible() Aviv Bakal
@ 2026-11-16 16:51 ` Aviv Bakal
2026-11-16 16:51 ` [PATCH v2 3/3] PCI/PM: Keep hotplug ports out of D3 if they can't signal PME from D3hot Aviv Bakal
2 siblings, 0 replies; 5+ messages in thread
From: Aviv Bakal @ 2026-11-16 16:51 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Manivannan Sadhasivam, Lukas Wunner, Kuppuswamy Sathyanarayanan,
linux-pci, linux-kernel, Zeev Zilberman, stable
The PCIe switch ports on AWS instances (vendor 0x1d0f) advertise PME
from D3hot but do not send it. Since commit d4c79b63d82d ("PCI: Allow
D3 for native hotplug-capable Root Ports on non-x86 platforms") these
ports runtime suspend to D3hot on non-x86 platforms, and hotplug events
such as an ENI attach are lost.
Mark them PCI_DEV_FLAGS_NO_D3, reusing quirk_no_ata_d3() renamed to
quirk_no_d3().
Fixes: d4c79b63d82d ("PCI: Allow D3 for native hotplug-capable Root Ports on non-x86 platforms")
Cc: stable@vger.kernel.org # 7.3.x
Co-developed-by: Zeev Zilberman <zeev@amazon.com>
Signed-off-by: Zeev Zilberman <zeev@amazon.com>
Signed-off-by: Aviv Bakal <avivb@amazon.com>
---
drivers/pci/quirks.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 7f1f47ea2ee4..338e884126fb 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1458,23 +1458,31 @@ static void quirk_ide_samemode(struct pci_dev *pdev)
}
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode);
-/* Some ATA devices break if put into D3 */
-static void quirk_no_ata_d3(struct pci_dev *pdev)
+/* Some devices break if put into D3 */
+static void quirk_no_d3(struct pci_dev *pdev)
{
pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
}
/* Quirk the legacy ATA devices only. The AHCI ones are ok */
DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID,
- PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3);
+ PCI_CLASS_STORAGE_IDE, 8, quirk_no_d3);
DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
- PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3);
+ PCI_CLASS_STORAGE_IDE, 8, quirk_no_d3);
/* ALi loses some register settings that we cannot then restore */
DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID,
- PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3);
+ PCI_CLASS_STORAGE_IDE, 8, quirk_no_d3);
/* VIA comes back fine but we need to keep it alive or ACPI GTM failures
occur when mode detecting */
DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
- PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3);
+ PCI_CLASS_STORAGE_IDE, 8, quirk_no_d3);
+
+/*
+ * Amazon 1d0f PCIe switch ports (e.g. 1d0f:cec2) on AWS instances
+ * advertise PME# from D3hot but never assert it, so hotplug events on
+ * a port in D3 are lost.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMAZON, PCI_ANY_ID,
+ PCI_CLASS_BRIDGE_PCI, 8, quirk_no_d3);
/*
* This was originally an Alpha-specific thing, but it really fits here.
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 3/3] PCI/PM: Keep hotplug ports out of D3 if they can't signal PME from D3hot
2026-11-16 16:51 [PATCH v2 0/3] PCI/PM: Keep hotplug ports that can't wake from D3hot out of D3 Aviv Bakal
2026-11-16 16:51 ` [PATCH v2 1/3] PCI/PM: Honor PCI_DEV_FLAGS_NO_D3 in pci_bridge_d3_possible() Aviv Bakal
2026-11-16 16:51 ` [PATCH v2 2/3] PCI: Avoid runtime D3 on Amazon PCIe switch ports Aviv Bakal
@ 2026-11-16 16:51 ` Aviv Bakal
2 siblings, 0 replies; 5+ messages in thread
From: Aviv Bakal @ 2026-11-16 16:51 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Manivannan Sadhasivam, Lukas Wunner, Kuppuswamy Sathyanarayanan,
linux-pci, linux-kernel, Zeev Zilberman
On runtime suspend pciehp masks the hotplug interrupt and relies on
PME to resume the port on a slot event. pci_bridge_d3_possible() does
not check whether the port can signal PME from D3hot, so a port that
cannot is not resumed by slot events.
Return false from pci_bridge_d3_possible() for such native hotplug
ports. pci_pm_init() computes bridge_d3 before it reads PME_Support,
so move that assignment after dev->pme_support is set.
Co-developed-by: Zeev Zilberman <zeev@amazon.com>
Signed-off-by: Zeev Zilberman <zeev@amazon.com>
Signed-off-by: Aviv Bakal <avivb@amazon.com>
---
drivers/pci/pci.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index eb7f2f03d9ae..fa37dd3067cf 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3081,6 +3081,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
if (platform_pci_bridge_d3(bridge))
return true;
+ /*
+ * pciehp masks the hotplug interrupt on runtime suspend and
+ * relies on PME to resume the port on a slot event. A port
+ * that cannot signal PME from D3hot is not resumed.
+ */
+ if (bridge->is_pciehp && !pci_pme_capable(bridge, PCI_D3hot))
+ return false;
+
/*
* Hotplug ports handled natively by the OS on x86 platforms
* were not validated by vendors for runtime D3 at least until
@@ -3253,7 +3261,6 @@ void pci_pm_init(struct pci_dev *dev)
dev->pm_cap = pm;
dev->d3hot_delay = PCI_PM_D3HOT_WAIT;
dev->d3cold_delay = PCI_PM_D3COLD_WAIT;
- dev->bridge_d3 = pci_bridge_d3_possible(dev);
dev->d3cold_allowed = true;
dev->d1_support = false;
@@ -3289,6 +3296,9 @@ void pci_pm_init(struct pci_dev *dev)
pci_pme_active(dev, false);
}
+ /* pci_bridge_d3_possible() looks at pme_support */
+ dev->bridge_d3 = pci_bridge_d3_possible(dev);
+
poweron:
pci_update_current_state(dev, PCI_UNKNOWN);
if (dev->current_state == PCI_D0) {
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread