drivers/pci: Allow attaching AER to non-RP devices that support MSI
Subsystems (2)
PATCH 1/1 drivers/pci: Allow attaching AER to non-RP devices that support MSI
Previously portdrv tried to prevent non-Root Port (RP) and non-Root Complex Event Collector (RCEC) devices from enabling AER capability. This was done because some switches enable AER but do not support MSI. Hence, trying to initialize the AER IRQ for such devices would fail and Linux would fail to claim the switch port entirely.
However, it is possible to have switches upstream of an endpoint that support MSI and AER. Without AER capability being enabled on such a switch, portdrv will refuse to enable the DPC capability as well, preventing a PCIe error on an endpoint from being handled by the switch.
Allow enabling the AER service on non-RP, non-RCEC devices if they still support both AER and MSI. This allows switches upstream of an endpoint to generate and handle DPC events.
--- drivers/pci/pcie/portdrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pcie/portdrv.c +2 -2
@@ -237,8 +237,8 @@ static int get_port_device_capability(struct pci_dev *dev) }#ifdef CONFIG_PCIEAER -if ((pci_pcie_type (dev) ==PCI_EXP_TYPE_ROOT_PORT || -pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC ) && +if ((dev->msi_cap ||pci_pcie_type (dev) ==PCI_EXP_TYPE_ROOT_PORT || +pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC ) && dev->aer_cap &&pci_aer_available () && (pcie_ports_native || host->native_aer)) services |=PCIE_PORT_SERVICE_AER ;
Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christian Schlaeger, Christof Hellmis Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597
Quoted 3 lines · Darshit Shah
Previously portdrv tried to prevent non-Root Port (RP) and non-Root Complex Event Collector (RCEC) devices from enabling AER capability. This was done because some switches enable AER but do not support MSI.
The AER driver only binds to RPs and RCECs, see aer_probe():
if ((pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC) && (pci_pcie_type(port) != PCI_EXP_TYPE_ROOT_PORT)) return -ENODEV;
So there's no point in adding PCIE_PORT_SERVICE_AER to "services" for other port types (as your patch does).
Quoted 4 lines
However, it is possible to have switches upstream of an endpoint that support MSI and AER. Without AER capability being enabled on such a switch, portdrv will refuse to enable the DPC capability as well, preventing a PCIe error on an endpoint from being handled by the switch.
I assume you're referring to this clause in get_port_device_capability():
if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) && pci_aer_available() && (pcie_ports_dpc_native || (services & PCIE_PORT_SERVICE_AER))) services |= PCIE_PORT_SERVICE_DPC;
Presumably on your system, BIOS doesn't grant AER handling to the OS upon _OSC negotiation? Is there a BIOS knob to change that? Alternatively, does passing "pcie_ports=dpc-native" fix the issue? If it does, why do you need the patch instead of using the command line option?
Quoted 3 lines
Allow enabling the AER service on non-RP, non-RCEC devices if they still support both AER and MSI. This allows switches upstream of an endpoint to generate and handle DPC events.
Per PCIe r7.0 sec 7.8.4.9, regarding the Root Error Command Register:
"For Functions other than Root Ports and Root Complex Event Collectors:
when End-End TLP Prefix Supported is Set or Flit Mode Supported is Set, this register is RsvdP, otherwise [...] this register is not required to be implemented."
Hence we can't enable AER handling on anything else than RPs and RCECs.
Thanks,
Lukas
Quoted 5 lines · Lukas Wunner
Quoted 3 lines · Darshit Shah
Previously portdrv tried to prevent non-Root Port (RP) and non-Root Complex Event Collector (RCEC) devices from enabling AER capability. This was done because some switches enable AER but do not support MSI.
Quoted 8 lines
The AER driver only binds to RPs and RCECs, see
aer_probe():if ((pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC) && (pci_pcie_type(port) != PCI_EXP_TYPE_ROOT_PORT)) return -ENODEV;So there's no point in adding
PCIE_PORT_SERVICE_AERto "services" for other port types (as your patch does).
I agree that adding PCIE_PORT_SERVICE_AER to "services" for switches is not useful.
Quoted 8 lines
Quoted 5 lines
However, it is possible to have switches upstream of an endpoint that support MSI and AER. Without AER capability being enabled on such a switch, portdrv will refuse to enable the DPC capability as well, preventing a PCIe error on an endpoint from being handled by the switch.
I assume you're referring to this clause in
get_port_device_capability():
Quoted 7 lines
if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) && pci_aer_available() && (pcie_ports_dpc_native || (services & PCIE_PORT_SERVICE_AER))) services |= PCIE_PORT_SERVICE_DPC;Presumably on your system, BIOS doesn't grant AER handling to the OS upon
_OSCnegotiation? Is there a BIOS knob to change that?
On my system, BIOS does grant AER handling to the OS with _OSC negotiation.
2025-12-06 23:15:40.172000 kern INFO [ 0.590601] acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI HPX-Type3] 2025-12-06 23:15:40.172000 kern INFO [ 0.590607] acpi PNP0A08:00: _OSC: platform does not support [LTR] 2025-12-06 23:15:40.172000 kern INFO [ 0.590610] acpi PNP0A08:00: _OSC: OS now controls [PME AER PCIeCapability]
Quoted 3 lines
Alternatively, does passing "pcie_ports=dpc-native" fix the issue? If it does, why do you need the patch instead of using the command line option?
Given that my firmware correctly negotiates and hands over control of AER to Linux, we should not need to use a quirk to enable DPC support.
What seems to be happening instead is that portdrv has misinterpreted the Implementation Note in PCIe r5.0 6.2.10 that states:
"It is recommended that platform firmware and operating systems always link the control of DPC to the control of Advanced Error Reporting"
This does not mean that AER is working on each PCIe device that wants to enable DPC. Rather that the OS is considered to have control over DPC, if it also has control over AER for the host bridge upstream of the device.
Thus, I claim that the following checks are incorrect:
if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) && pci_aer_available() && (pcie_ports_dpc_native || (services & PCIE_PORT_SERVICE_AER))) services |= PCIE_PORT_SERVICE_DPC;
PCIE_PORT_SERVICE_AER will only ever be enabled on RP and RCEC devices. However, PCIE_PORT_SERVICE_DPC should be allowed on non-RP devices. In fact, that is exactly where it is needed, since the switch upstream of an endpoint device is required to generate the DPC signal. A fixed version of this check would instead look like:
if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) && pci_aer_available() && (pcie_ports_dpc_native || host->native_aer) services |= PCIE_PORT_SERVICE_DPC;
That is, we should allow binding PCIE_PORT_SERVICE_DPC to a device, if:
* The device advertises the DPC capability
* AER has not been disabled for Linux through the command line
* Linux has control of AER (and DPC) for the host bridge above the device
* _OR_ pcie_ports=dpc-native was used on the command line
Coming next is an updated patch based on this.
Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christian Schlaeger, Christof Hellmis Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597
PATCH v2 1/1 drivers/pci: Decouple DPC from AER service
According to [1] it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted [1] to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note in [1] meant to imply. If the firmware hands the OS control of AER via _OSC on the host bridge upstream of the device, then the OS should be allowed to assume control of DPC on that device.
The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
[1]: PCI Express Base Specification Revision 5.0 Version 1.0, Sec. 6.2.10
---
Changes in patch v2:
* Don't touch the PCIE_PORT_SERVICE_AER attachment
* Stop relying on PCIE_PORT_SERVICE_AER for enabling DPC
* Instead test that OS has control of AER at parent host bridge
drivers/pci/pcie/portdrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +1 -1
@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (host->native_aer || pcie_ports_dpc_native)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christian Schlaeger, Christof Hellmis Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597
Re: [PATCH v2 1/1] drivers/pci: Decouple DPC from AER service
[cc += Keith, Olaf; start of thread is here:
https://lore.kernel.org/all/[email protected]/
]
Quoted 1 line · Darshit Shah
According to [1] it is recommended that the Operating System link the
Minor stylistic issue: We generally refer to the latest spec revision, the reference at [1] doesn't mention the title of the Implementation Note and personally I find it easier to read the commit message if references are provided inline, so I'd recommend:
According to PCIe r7.0, sec 6.2.11, "Implementation Note: Determination of DPC Control", it is recommended that ...
drivers/pci/pcie/portdrv.c static int get_port_device_capability(struct pci_dev *dev) · line 270
Quoted 10 lines
+++
b/drivers/pci/pcie/portdrv.cdrivers/pci/pcie/portdrv.c +1
-1@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (host->native_aer || pcie_ports_dpc_native)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Somewhat tangential, I note that the pci_aer_available() check results in DPC not being handled by Linux if pci=nomsi is specified on the command line. However PCIe r7.0 sec 6.2.11.1 explicitly mentions use of INTx for DPC, suggesting that MSI support is not required.
Either case, your change looks reasonable to me, so:
Thanks,
Lukas
PATCH v3 1/1 drivers/pci: Decouple DPC from AER service
According to PCIe r7.0, sec. 6.2.11, "Implementation Note: Determination of DPC Control", it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted the spec to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note meant to imply. If the firmware hands Linux control of AER via _OSC on the host bridge upstream of the device, then Linux should be allowed to assume control of DPC on the device.
The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
---
Changes from v2:
* + [email protected] since moving to v6.2+ breaks DPC on our systems
* Minor stylistic changes to commit message
* NO functional changes
drivers/pci/pcie/portdrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +1 -1
@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (host->native_aer || pcie_ports_dpc_native)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597
Re: [PATCH v3] drivers/pci: Decouple DPC from AER service
Hi Bjorn,
I'd like to follow up on the v3 of the patch submitted earlier and see if we can merge them.
Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Re: [PATCH v3 RESEND] drivers/pci: Decouple DPC from AER service
In reply to Darshit ShahHi Bjorn,
Can you please pick this patch up in the PCI tree for the next version? Anything I can do to help expedite the process?
Quoted 67 lines · Darshit Shah
According to PCIe r7.0, sec. 6.2.11, "Implementation Note: Determination of DPC Control", it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted the spec to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note meant to imply. If the firmware hands Linux control of AER via
_OSCon the host bridge upstream of the device, then Linux should be allowed to assume control of DPC on the device.The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
Signed-off-by Darshit Shah <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Reviewed-by Kuppuswamy Sathyanarayanan <[email protected]>---
Changes from v2:
* + [email protected] since moving to v6.2+ breaks DPC on our systems
* Minor stylistic changes to commit message
* NO functional changesdrivers/pci/pcie/portdrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pcie/portdrv.c +1
-1@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (host->native_aer || pcie_ports_dpc_native)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */ Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597
Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Re: [PATCH v3 RESEND] drivers/pci: Decouple DPC from AER service
Quoted 3 lines · Darshit Shah
Hi Bjorn,
Can you please pick this patch up in the PCI tree for the next version? Anything I can do to help expedite the process?
Sorry, I missed this and I don't want to add new changes right now since we're halfway through the v7.2 merge window. Can you ping again after v7.2-rc1, and we can make it v7.3 material?
Re: [PATCH v3 RESEND] drivers/pci: Decouple DPC from AER service
Hi Bjorn,
Now that v7.2-rc2 has been cut, can we please queue this up for v7.3?
Quoted 8 lines · Bjorn Helgaas
Quoted 3 lines · Darshit Shah
Hi Bjorn,
Can you please pick this patch up in the PCI tree for the next version? Anything I can do to help expedite the process?Sorry, I missed this and I don't want to add new changes right now since we're halfway through the v7.2 merge window. Can you ping again after v7.2-rc1, and we can make it v7.3 material?
Re: [PATCH v3] drivers/pci: Decouple DPC from AER service
In reply to Darshit ShahQuoted 28 lines · Darshit Shah
According to PCIe r7.0, sec. 6.2.11, "Implementation Note: Determination of DPC Control", it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted the spec to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note meant to imply. If the firmware hands Linux control of AER via
_OSCon the host bridge upstream of the device, then Linux should be allowed to assume control of DPC on the device.The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
Quoted 4 lines
Signed-off-by Darshit Shah <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Reviewed-by Kuppuswamy Sathyanarayanan <[email protected]>
Sorry for the delay in picking this up. Thanks for doing this; I think it's the right thing. I think the commit log is not completely accurate in terms on which devices advertise AER and DPC, so I propose the following. I also reordered the || operands to make the patch easier to read. Your thoughts?
commit 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")
Author: Darshit Shah <[email protected]> Date: Thu Dec 11 16:42:53 2025 +0000
PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER
PCIe r7.0, sec 6.2.11, "Implementation Note: Determination of DPC Control", recommends that "... operating systems always link control of DPC to the control of Advanced Error Reporting."
Any PCIe device may advertise AER, but only Root Ports and Root Complex Event Collectors can generate AER interrupts, so the AER driver only binds to RPs and RCECs.
Any Root Port or Switch Downstream Port may advertise Downstream Port Containment (DPC), but previously the DPC driver was limited to devices the AER driver could bind to, i.e., only RPs that advertised AER.
Since any Port with DPC can generate DPC interrupts, allow the DPC driver to bind to such a Port as long as the OS controls AER, regardless of whether the AER driver binds to it.
drivers/pci/pcie/portdrv.c +1 -1
@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (pcie_ports_dpc_native || host->native_aer)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Re: [PATCH v3] drivers/pci: Decouple DPC from AER service
Quoted 34 lines · Bjorn Helgaas
Quoted 28 lines · Darshit Shah
According to PCIe r7.0, sec. 6.2.11, "Implementation Note: Determination of DPC Control", it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted the spec to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note meant to imply. If the firmware hands Linux control of AER via
_OSCon the host bridge upstream of the device, then Linux should be allowed to assume control of DPC on the device.The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
Quoted 4 lines
Signed-off-by Darshit Shah <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Reviewed-by Kuppuswamy Sathyanarayanan <[email protected]>
Quoted 6 lines
Sorry for the delay in picking this up. Thanks for doing this; I think it's the right thing. I think the commit log is not completely accurate in terms on which devices advertise AER and DPC, so I propose the following. I also reordered the || operands to make the patch easier to read. Your thoughts?
Thanks. I think the commit log is more succint and accurate now. I'm okay with it.
Quoted 45 lines
commit
97ca178c899d("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")Author: Darshit Shah <[email protected]> Date: Thu Dec 11 16:42:53 2025 +0000PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER
PCIe r7.0, sec 6.2.11, "Implementation Note: Determination of DPC Control", recommends that "... operating systems always link control of DPC to the control of Advanced Error Reporting."
Any PCIe device may advertise AER, but only Root Ports and Root Complex Event Collectors can generate AER interrupts, so the AER driver only binds to RPs and RCECs.
Any Root Port or Switch Downstream Port may advertise Downstream Port Containment (DPC), but previously the DPC driver was limited to devices the AER driver could bind to, i.e., only RPs that advertised AER.
Since any Port with DPC can generate DPC interrupts, allow the DPC driver to bind to such a Port as long as the OS controls AER, regardless of whether the AER driver binds to it.
Signed-off-by Darshit Shah <[email protected]>[bhelgaas: commit log, reorder || operands to simplify patch]Signed-off-by Bjorn Helgaas <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Reviewed-by Kuppuswamy Sathyanarayanan <[email protected]>drivers/pci/pcie/portdrv.c +1
-1@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (pcie_ports_dpc_native || host->native_aer)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Re: [PATCH v3] drivers/pci: Decouple DPC from AER service
In reply to Bjorn HelgaasQuoted 34 lines · Bjorn Helgaas
Quoted 28 lines · Darshit Shah
According to PCIe r7.0, sec. 6.2.11, "Implementation Note: Determination of DPC Control", it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted the spec to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note meant to imply. If the firmware hands Linux control of AER via
_OSCon the host bridge upstream of the device, then Linux should be allowed to assume control of DPC on the device.The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
Quoted 4 lines
Signed-off-by Darshit Shah <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Reviewed-by Kuppuswamy Sathyanarayanan <[email protected]>
Quoted 5 lines
Sorry for the delay in picking this up. Thanks for doing this; I think it's the right thing. I think the commit log is not completely accurate in terms on which devices advertise AER and DPC, so I propose the following. I also reordered the || operands to make the patch easier to read. Your thoughts?
Path below applied to pci/dpc for v7.3, thanks, Darshit!
I'm actually a little surprised that this wasn't an issue earlier. I guess DPC hasn't really been exercised on switches.
Quoted 44 lines
commit
97ca178c899d("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")Author: Darshit Shah <[email protected]> Date: Thu Dec 11 16:42:53 2025 +0000PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER
PCIe r7.0, sec 6.2.11, "Implementation Note: Determination of DPC Control", recommends that "... operating systems always link control of DPC to the control of Advanced Error Reporting."
Any PCIe device may advertise AER, but only Root Ports and Root Complex Event Collectors can generate AER interrupts, so the AER driver only binds to RPs and RCECs.
Any Root Port or Switch Downstream Port may advertise Downstream Port Containment (DPC), but previously the DPC driver was limited to devices the AER driver could bind to, i.e., only RPs that advertised AER.
Since any Port with DPC can generate DPC interrupts, allow the DPC driver to bind to such a Port as long as the OS controls AER, regardless of whether the AER driver binds to it.
Signed-off-by Darshit Shah <[email protected]>[bhelgaas: commit log, reorder || operands to simplify patch]Signed-off-by Bjorn Helgaas <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Reviewed-by Kuppuswamy Sathyanarayanan <[email protected]>drivers/pci/pcie/portdrv.c +1
-1@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (pcie_ports_dpc_native || host->native_aer)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Re: [PATCH v2 1/1] drivers/pci: Decouple DPC from AER service
In reply to Darshit ShahHi,
Quoted 26 lines · Darshit Shah
According to [1] it is recommended that the Operating System link the enablement of Downstream Port Containment (DPC) to the enablement of Advanced Error Reporting (AER).
However, AER is advertised only on Root Port (RP) or Root Complex Event Collector (RCEC) devices. On the other hand, DPC may be advertised on any PCIe device in the hierarchy. In fact, since the main usecase of DPC is for the switch upstream of an endpoint device to trigger a signal to the host-bridge, it is imperative that it be supported on non-RP, non-RCEC devices.
Previously portdrv has interpreted [1] to mean that the AER service must be available on the same device in order for DPC to be available. This is not what the implementation note in [1] meant to imply. If the firmware hands the OS control of AER via
_OSCon the host bridge upstream of the device, then the OS should be allowed to assume control of DPC on that device.The comment above this check alludes to this, by saying:
Quoted 2 lines
With dpc-native, allow Linux to use DPC even if it doesn't have permission to use AER.
However, permission to use AER is negotiated at the host bridge, not per-device. So we should not link DPC to enabling AER at the device. Instead, DPC should be enabled if the OS has control of AER for the host bridge that is upstream of the device in question, or if dpc-native was set on the command line.
Quoted 4 lines
[1]: PCI Express Base Specification Revision 5.0 Version 1.0, Sec. 6.2.10
Signed-off-by Darshit Shah <[email protected]>---
Looks fine to me.
Quoted 21 lines
Changes in patch v2:
* Don't touch thePCIE_PORT_SERVICE_AERattachment
* Stop relying onPCIE_PORT_SERVICE_AERfor enabling DPC
* Instead test that OS has control of AER at parent host bridgedrivers/pci/pcie/portdrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pcie/portdrv.c +1
-1@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)*/ if (pci_find_ext_capability (dev,PCI_EXT_CAP_ID_DPC ) &&pci_aer_available () && - (pcie_ports_dpc_native || (services &PCIE_PORT_SERVICE_AER ))) + (host->native_aer || pcie_ports_dpc_native)) services |=PCIE_PORT_SERVICE_DPC ;/* Enable bandwidth control if more than one speed is supported. */
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Quoted 5 lines · Darshit Shah
Previously portdrv tried to prevent non-Root Port (RP) and non-Root Complex Event Collector (RCEC) devices from enabling AER capability. This was done because some switches enable AER but do not support MSI. Hence, trying to initialize the AER IRQ for such devices would fail and Linux would fail to claim the switch port entirely.
The d8d2b65a940b commit log could have been clearer.
Some switches advertise an AER capability, but they can't generate AER interrupts, regardless of whether they support MSI. Only RPs and RCECs can generate AER interrupts.
Quoted 43 lines
However, it is possible to have switches upstream of an endpoint that support MSI and AER. Without AER capability being enabled on such a switch, portdrv will refuse to enable the DPC capability as well, preventing a PCIe error on an endpoint from being handled by the switch.
Allow enabling the AER service on non-RP, non-RCEC devices if they still support both AER and MSI. This allows switches upstream of an endpoint to generate and handle DPC events.
Fixes d8d2b65a940b ("PCI/portdrv: Allow AER service only for Root Ports & RCECs")Signed-off-by Darshit Shah <[email protected]>--- drivers/pci/pcie/portdrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/pcie/portdrv.c +2
-2@@ -237,8 +237,8 @@ static int get_port_device_capability(struct pci_dev *dev) }#ifdef CONFIG_PCIEAER -if ((pci_pcie_type (dev) ==PCI_EXP_TYPE_ROOT_PORT || -pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC ) && +if ((dev->msi_cap ||pci_pcie_type (dev) ==PCI_EXP_TYPE_ROOT_PORT || +pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC ) && dev->aer_cap &&pci_aer_available () && (pcie_ports_native || host->native_aer)) services |=PCIE_PORT_SERVICE_AER ;Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christian Schlaeger, Christof Hellmis Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597