Skip to contentSkip to conversation

PCI/DPC: Decide DPC ownership with host_bridge->native_dpc

PATCH Applied Kuppuswamy Sathyanarayanan 5 participants 23 messages Nov 18 – Nov 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover PCI/DPC: Decide DPC ownership with host_bridge->native_dpc

This series makes host_bridge->native_dpc the single decider for whether Linux uses DPC, as Bjorn asked during the review of "Simplify PCIe native ownership".

https://lore.kernel.org/r/20261001221408.GA2731929@bhelgaas

Today the DPC service binds on host_bridge->native_aer, AER availability and "pcie_ports=dpc-native". host_bridge->native_dpc is only consulted by pci_dpc_recovered(). After this series, native_dpc is the end result of everything that decides DPC ownership, and portdrv binds the DPC service on it.

Patches 1-2 are the two DPC patches from v2 of Lukas's "Error reporting for AER-incapable devices", which are included here directly.

https://lore.kernel.org/r/34c9ee153876bac953135b4518035194b7c07c6c.1794997749.git.lukas@wunner.de
https://lore.kernel.org/r/58d8a99cc6c2ecba6dadc450ecb4501d47816732.1794997749.git.lukas@wunner.de

Patch 1 keeps the DPC driver from accessing a non-existent AER capability.

Patch 2 drops the AER ownership check from dpc_probe(), so DPC also works on ports without an AER capability.

Patch 3 builds EDR whenever DPC is enabled on ACPI, so CONFIG_PCIE_EDR is no longer a separate knob in deciding whether to request DPC control.

Patch 4 stops requiring pci_aer_available() to bind the DPC service, since the DPC driver does not depend on MSI or on the AER driver.

Patch 5 requests DPC control only together with AER control, as PCI Firmware r3.3, sec 4.5.2.4, requires.

Patch 6 binds the DPC service on host_bridge->native_dpc and logs a message when the OS assumes DPC control that _OSC did not grant.

Changes since v2:

- Pick up v2 of Lukas's two DPC patches. Patch 1 now uses the AER capability to find the error severity when the port has one.

- Keep CONFIG_PCIE_EDR as a hidden option instead of removing it, and remove the pci_dpc_recovered() check that becomes dead (Yazen).

- Fold the PCI Firmware spec reference into the existing comment in calculate_control() (Yazen).

- Shorten the comment in acpi_pci_root_create() (Yazen).

- Rebase on v7.4-rc1 and add Reviewed-by and Acked-by tags.

v2: https://lore.kernel.org/r/20261020181924.3003553-1-sathyanarayanan.kuppuswamy@linux.intel.com
v1: https://lore.kernel.org/r/20261007165840.1604136-1-sathyanarayanan.kuppuswamy@linux.intel.com

Kuppuswamy Sathyanarayanan (4):
PCI/EDR: Build EDR whenever DPC is enabled on ACPI PCI/portdrv: Don't require AER to bind DPC service PCI/ACPI: Request DPC control only together with AER control PCI/portdrv: Bind DPC service based on host_bridge->native_dpc

Lukas Wunner (2):
PCI/DPC: Avoid access to non-existent AER capability PCI/DPC: Reinstate support for AER-incapable ports

 drivers/acpi/pci_root.c    | 19 +++++++++++--
 drivers/pci/pcie/Kconfig   |  8 +-----
 drivers/pci/pcie/dpc.c     | 58 +++++++++++++++++++++-----------------
 drivers/pci/pcie/portdrv.c |  7 +----
 4 files changed, 51 insertions(+), 41 deletions(-)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/6 PCI/DPC: Avoid access to non-existent AER capability

From: Lukas Wunner <[email protected]>

Downstream Port Containment does not mandate presence of an Advanced Error Reporting capability, so a Downstream Port may support DPC, but not AER (PCIe r7.1 sec 6.2.11.2).

In February 2019, commit 9f08a5d896ce ("PCI/DPC: Fix print AER status in DPC event handling") amended the DPC driver to access the AER capability without checking for its presence.

This did not cause actual problems because in March 2018, commit 4e5fad429bd1 ("PCI/DPC: Do not enable DPC if AER control is not allowed by the BIOS") had seemingly inadvertently prevented instantiation of a DPC port service on AER-incapable ports.

However in October 2019, commit 35a0b2378c19 ("PCI/DPC: Add "pcie_ports=dpc-native" to allow DPC without AER control") made it possible to override this: The DPC driver may access a non-existent AER capability if "pcie_ports=dpc-native" is passed on the command line.

Fix it by making the DPC driver cope with AER-unsupporting Downstream Ports.

There are two places where the AER capability is accessed:

- dpc_get_aer_uncorrect_severity() uses it to discern whether a Fatal or Non-Fatal Error triggered DPC. Access the Device Status Register instead, in accordance with PCIe r7.1 sec 6.2.5.

- dpc_is_surprise_removal() uses it to detect whether a Surprise Down Error triggered DPC. Return false on AER-unsupporting devices. The function works around an AMD-specific quirk and it seems reasonable to assume that all affected products are AER-supporting. In any case the detection is not possible without AER capability.

Insert a temporary check for an AER capability after the call to aer_get_device_error_info() because the function currently returns false for AER-unsupporting devices. The check will become obsolete and will be removed with the imminent baseline capability error reporting.

Fixes 35a0b2378c19 ("PCI/DPC: Add "pcie_ports=dpc-native" to allow DPC without AER control")
---
 drivers/pci/pcie/dpc.c | 45 ++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 13 deletions(-)
drivers/pci/pcie/dpc.c +32 -13
index 2b779bd1d861..d02cbbbe3143 100644
@@ -238,19 +238,35 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
 {
 	int pos = dev->aer_cap;
 	u32 status, mask, sev;
+	u16 devsta;
 
-	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
-	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
-	status &= ~mask;
-	if (!status)
-		return 0;
-
-	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
-	status &= sev;
-	if (status)
-		info->severity = AER_FATAL;
-	else
-		info->severity = AER_NONFATAL;
+	/*
+	 * Infer severity from AER Extended Capability if present, else from
+	 * Device Status register.  The latter cannot be used on AER-capable
+	 * ports because it also logs masked errors (PCIe r7.1 sec 7.5.3.5).
+	 */
+	if (pos) {
+		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
+		status &= ~mask;
+		if (!status)
+			return 0;
+
+		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
+		status &= sev;
+		if (status)
+			info->severity = AER_FATAL;
+		else
+			info->severity = AER_NONFATAL;
+	} else {
+		pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &devsta);
+		if (devsta & PCI_EXP_DEVSTA_FED)
+			info->severity = AER_FATAL;
+		else if (devsta & PCI_EXP_DEVSTA_NFED)
+			info->severity = AER_NONFATAL;
+		else
+			return 0;
+	}
 
 	info->level = KERN_ERR;
 
@@ -275,7 +291,7 @@ void dpc_process_error(struct pci_dev *pdev)
 		pci_warn(pdev, "containment event, status:%#06x: unmasked uncorrectable error detected\n",
 			 status);
 		if (dpc_get_aer_uncorrect_severity(pdev, &info) &&
-		    aer_get_device_error_info(&info, 0)) {
+		    (aer_get_device_error_info(&info, 0) || !pdev->aer_cap)) {
 			aer_print_error(&info, 0);
 			pci_aer_clear_nonfatal_status(pdev);
 			pci_aer_clear_fatal_status(pdev);
@@ -353,6 +369,9 @@ static bool dpc_is_surprise_removal(struct pci_dev *pdev)
 	if (!pdev->is_hotplug_bridge)
 		return false;
 
+	if (!pdev->aer_cap)
+		return false;
+
 	if (pci_read_config_word(pdev, pdev->aer_cap + PCI_ERR_UNCOR_STATUS,
 				 &status))
 		return false;
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v3 1/6] PCI/DPC: Avoid access to non-existent AER capability

Sashiko has reviewed this patch and found no issues.
Quoted 15 lines

From: Lukas Wunner <[email protected]>

Downstream Port Containment does not mandate presence of an Advanced Error Reporting capability, so a Downstream Port may support DPC, but not AER (PCIe r7.1 sec 6.2.11.2).

In February 2019, commit 9f08a5d896ce ("PCI/DPC: Fix print AER status in DPC event handling") amended the DPC driver to access the AER capability without checking for its presence.

This did not cause actual problems because in March 2018, commit 4e5fad429bd1 ("PCI/DPC: Do not enable DPC if AER control is not allowed by the BIOS") had seemingly inadvertently prevented instantiation of a DPC port service on AER-incapable ports.

Quoted 6 lines

[ ... ]
for AER-unsupporting devices. The check will become obsolete and will be removed with the imminent baseline capability error reporting.

Fixes 35a0b2378c19 ("PCI/DPC: Add "pcie_ports=dpc-native" to allow DPC without AER control")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com?part=1
#3 lore raw

PATCH v3 2/6 PCI/DPC: Reinstate support for AER-incapable ports

In reply to Kuppuswamy Sathyanarayanan

From: Lukas Wunner <[email protected]>

Downstream Port Containment does not mandate presence of an Advanced Error Reporting capability, so a Downstream Port may support DPC, but not AER (PCIe r7.1 sec 6.2.11.2).

Commit 708b20003624 ("PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER ownership") seemingly inadvertently constrained DPC to AER-supporting Downstream Ports by inserting a call to pcie_aer_is_native() in dpc_probe(), which implicitly checks for presence of an AER capability.

Drop the call. It is superfluous because it duplicates the conditions applied by the PCIe port service driver when it decides whether to instantiate a DPC port service (see get_port_device_capability()). If the conditions are not met, no port service is instantiated and dpc_probe() isn't executed.

The only difference between the conditions in dpc_probe() and the ones in get_port_device_capability() is the check for the AER capability, so by removing the checks from dpc_probe(), DPC is supported on AER-incapable Downstream Ports again.

Fixes 708b20003624 ("PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER ownership")
---
 drivers/pci/pcie/dpc.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/pci/pcie/dpc.c +0 -3
index d02cbbbe3143..a0880e3cd68c 100644
@@ -496,9 +496,6 @@ static int dpc_probe(struct pcie_device *dev)
 	int status;
 	u16 cap;
 
-	if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
-		return -ENOTSUPP;
-
 	status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
 					   dpc_handler, IRQF_SHARED,
 					   "pcie-dpc", pdev);
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH v3 2/6] PCI/DPC: Reinstate support for AER-incapable ports

Sashiko has reviewed this patch and found no issues.
Quoted 17 lines

From: Lukas Wunner <[email protected]>

Downstream Port Containment does not mandate presence of an Advanced Error Reporting capability, so a Downstream Port may support DPC, but not AER (PCIe r7.1 sec 6.2.11.2).

Commit 708b20003624 ("PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER ownership") seemingly inadvertently constrained DPC to AER-supporting Downstream Ports by inserting a call to pcie_aer_is_native() in dpc_probe(), which implicitly checks for presence of an AER capability.

Drop the call. It is superfluous because it duplicates the conditions applied by the PCIe port service driver when it decides whether to instantiate a DPC port service (see get_port_device_capability()). If the conditions are not met, no port service is instantiated and dpc_probe() isn't executed.

Quoted 7 lines

The only difference between the conditions in dpc_probe() and the ones in get_port_device_capability() is the check for the AER capability, so by removing the checks from dpc_probe(), DPC is supported on AER-incapable Downstream Ports again.

Fixes 708b20003624 ("PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER ownership")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com?part=2
#5 lore raw

PATCH v3 3/6 PCI/EDR: Build EDR whenever DPC is enabled on ACPI

In reply to Kuppuswamy Sathyanarayanan

Error Disconnect Recover (EDR) is the ACPI half of the hybrid DPC model, where firmware owns DPC and notifies the OS of containment events.

CONFIG_PCIE_EDR made EDR optional on top of CONFIG_PCIE_DPC. This adds another knob to the decision to request DPC control in _OSC. The OS requests DPC control only if it also supports EDR, so with CONFIG_PCIE_EDR=n it never requests DPC control. There is little reason to build DPC without EDR on ACPI systems.

Make CONFIG_PCIE_EDR a hidden option that is enabled whenever CONFIG_PCIE_DPC and CONFIG_ACPI are both enabled, like CONFIG_PCIE_PME.

pci_dpc_recovered() gave up if firmware owned DPC and EDR was not enabled. EDR is now always enabled with DPC on ACPI, and native_dpc is only cleared by the _OSC negotiation, so remove that check.

---
Changes since v2:
- Keep CONFIG_PCIE_EDR as a hidden option instead of removing it (Yazen)
- Remove the pci_dpc_recovered() check that becomes dead (Yazen)
- New subject, was "PCI/EDR: Remove CONFIG_PCIE_EDR"

 drivers/pci/pcie/Kconfig |  8 +-------
 drivers/pci/pcie/dpc.c   | 10 ----------
 2 files changed, 1 insertion(+), 17 deletions(-)
drivers/pci/pcie/Kconfig +1 -7
index 207c2deae35f..4d097c53f140 100644
@@ -138,11 +138,5 @@ config PCIE_PTM
 	  is safe to enable even if you don't.
 
 config PCIE_EDR
-	bool "PCI Express Error Disconnect Recover support"
+	def_bool y
 	depends on PCIE_DPC && ACPI
-	help
-	  This option adds Error Disconnect Recover support as specified
-	  in the Downstream Port Containment Related Enhancements ECN to
-	  the PCI Firmware Specification r3.2.  Enable this if you want to
-	  support hybrid DPC model which uses both firmware and OS to
-	  implement DPC.
drivers/pci/pcie/dpc.c +0 -10
index a0880e3cd68c..1e917febcbf3 100644
@@ -102,19 +102,9 @@ static bool dpc_completed(struct pci_dev *pdev)
  */
 bool pci_dpc_recovered(struct pci_dev *pdev)
 {
-	struct pci_host_bridge *host;
-
 	if (!pdev->dpc_cap)
 		return false;
 
-	/*
-	 * Synchronization between hotplug and DPC is not supported
-	 * if DPC is owned by firmware and EDR is not enabled.
-	 */
-	host = pci_find_host_bridge(pdev->bus);
-	if (!host->native_dpc && !IS_ENABLED(CONFIG_PCIE_EDR))
-		return false;
-
 	/*
 	 * Need a timeout in case DPC never completes due to failure of
 	 * dpc_wait_rp_inactive().  The spec doesn't mandate a time limit,
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH v3 3/6] PCI/EDR: Build EDR whenever DPC is enabled on ACPI

Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

Error Disconnect Recover (EDR) is the ACPI half of the hybrid DPC model, where firmware owns DPC and notifies the OS of containment events.

CONFIG_PCIE_EDR made EDR optional on top of CONFIG_PCIE_DPC. This adds another knob to the decision to request DPC control in _OSC. The OS requests DPC control only if it also supports EDR, so with CONFIG_PCIE_EDR=n it never requests DPC control. There is little reason to build DPC without EDR on ACPI systems.

Quoted 8 lines

Make CONFIG_PCIE_EDR a hidden option that is enabled whenever CONFIG_PCIE_DPC and CONFIG_ACPI are both enabled, like CONFIG_PCIE_PME.

pci_dpc_recovered() gave up if firmware owned DPC and EDR was not enabled. EDR is now always enabled with DPC on ACPI, and native_dpc is only cleared by the _OSC negotiation, so remove that check.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com?part=3
#7 lore raw

PATCH v3 4/6 PCI/portdrv: Don't require AER to bind DPC service

In reply to Kuppuswamy Sathyanarayanan

get_port_device_capability() binds the DPC service only if pci_aer_available() is true. pci_aer_available() is false with "pci=noaer" or when MSI is disabled.

The DPC driver does not need either of these. pci_aer_available() depends on MSI only because the AER driver does not work with INTx (commit 3e77a3f7895e ("PCI: Disable AER with pci=nomsi")). The DPC driver does not depend on MSI or on the AER driver, and it works on ports without an AER capability.

PCIe r7.0 sec 6.2.11 recommends that the OS link control of DPC to control of AER. PCI Firmware r3.3, sec 4.5.2.4, requires the same for _OSC. Both are about ownership, not about using the AER driver. host->native_aer and the _OSC negotiation already cover ownership.

Drop the pci_aer_available() check.

The changes in behavior are:

- ACPI systems booted with "pci=noaer" or with MSI disabled, and with "pcie_ports=native" or "pcie_ports=dpc-native". The OS now uses DPC there, which is what those options ask for. Without them nothing changes, because the OS does not request AER control in _OSC, so host->native_aer is not set.

- Non-ACPI systems booted with "pci=noaer" or with MSI disabled. host->native_aer is set there, so the OS now uses DPC. An uncorrectable error that used to be ignored with "pci=noaer" now triggers DPC, which takes the link down and resets the devices below the port.

---
Changes since v2:
- Add Reviewed-by from Yazen

 drivers/pci/pcie/portdrv.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pci/pcie/portdrv.c +0 -1
index 32fc623dd410..b77680fd3b75 100644
@@ -263,7 +263,6 @@ static int get_port_device_capability(struct pci_dev *dev)
 	 * permission to use AER.
 	 */
 	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;
 
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH v3 4/6] PCI/portdrv: Don't require AER to bind DPC service

Sashiko has reviewed this patch and found no issues.
Quoted 15 lines

get_port_device_capability() binds the DPC service only if pci_aer_available() is true. pci_aer_available() is false with "pci=noaer" or when MSI is disabled.

The DPC driver does not need either of these. pci_aer_available() depends on MSI only because the AER driver does not work with INTx (commit 3e77a3f7895e ("PCI: Disable AER with pci=nomsi")). The DPC driver does not depend on MSI or on the AER driver, and it works on ports without an AER capability.

PCIe r7.0 sec 6.2.11 recommends that the OS link control of DPC to control of AER. PCI Firmware r3.3, sec 4.5.2.4, requires the same for _OSC. Both are about ownership, not about using the AER driver. host->native_aer and the _OSC negotiation already cover ownership.

Quoted 6 lines

[ ... ]
uncorrectable error that used to be ignored with "pci=noaer" now triggers DPC, which takes the link down and resets the devices below the port.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com?part=4
#9 lore raw

PATCH v3 5/6 PCI/ACPI: Request DPC control only together with AER control

In reply to Kuppuswamy Sathyanarayanan

PCI Firmware r3.3, sec 4.5.2.4, requires the OS to request AER control when it requests DPC control. calculate_control() requests DPC control whenever CONFIG_PCIE_DPC and CONFIG_PCIE_EDR are enabled, even if it does not request AER control, e.g., with "pci=noaer" or when MSI is disabled.

Request DPC control only if AER control is also requested.

---
Changes since v2:
- Fold the PCI Firmware spec reference into the existing comment (Yazen)
- Keep the CONFIG_PCIE_EDR test and mention it in the commit log
- Add Reviewed-by from Yazen

 drivers/acpi/pci_root.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/pci_root.c +4 -2
index a1a9c06012f8..510943649b41 100644
@@ -515,9 +515,11 @@ static u32 calculate_control(void)
 	 * Per the Downstream Port Containment Related Enhancements ECN to
 	 * the PCI Firmware Spec, r3.2, sec 4.5.1, table 4-5,
 	 * OSC_PCI_EXPRESS_DPC_CONTROL indicates the OS supports both DPC
-	 * and EDR.
+	 * and EDR.  PCI Firmware r3.3, sec 4.5.2.4, also requires the OS to
+	 * request AER control along with DPC control.
 	 */
-	if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR))
+	if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR) &&
+	    (control & OSC_PCI_EXPRESS_AER_CONTROL))
 		control |= OSC_PCI_EXPRESS_DPC_CONTROL;
 
 	return control;
Signature · 1 line
2.43.0
#10 lore raw

Re: [PATCH v3 5/6] PCI/ACPI: Request DPC control only together with AER control

Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

PCI Firmware r3.3, sec 4.5.2.4, requires the OS to request AER control when it requests DPC control. calculate_control() requests DPC control whenever CONFIG_PCIE_DPC and CONFIG_PCIE_EDR are enabled, even if it does not request AER control, e.g., with "pci=noaer" or when MSI is disabled.

Request DPC control only if AER control is also requested.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com?part=5
#11 lore raw

PATCH v3 6/6 PCI/portdrv: Bind DPC service based on host_bridge->native_dpc

In reply to Kuppuswamy Sathyanarayanan

get_port_device_capability() binds the DPC service if the port has a DPC capability and either "pcie_ports=dpc-native" was given or the OS controls AER. This repeats decisions that are already made elsewhere. It also ignores host_bridge->native_dpc, which is meant to say whether the OS owns DPC.

Make host_bridge->native_dpc the single decider:

- In acpi_pci_root_create(), assume DPC control whenever _OSC grants AER control. PCI Firmware r3.3, sec 4.5.2.4, requires platforms to retain AER if they retain DPC. Put the other way, firmware that grants AER does not keep DPC. PCIe r7.0 sec 6.2.11 recommends that the OS link control of DPC to control of AER. Commit 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER") relied on this link. Keeping it means DPC still works with firmware that predates the _OSC DPC control bit. Such firmware grants AER but masks DPC. The OS cannot tell such firmware from firmware that retains DPC on purpose, so log a message when it assumes DPC control that _OSC did not grant. Only do this if the OS requested DPC control, i.e., if CONFIG_PCIE_DPC is enabled.

- "pcie_ports=native" and "pcie_ports=dpc-native" are already folded into the _OSC control mask, so they are reflected in native_dpc.

Then bind the DPC service if the port has a DPC capability and host_bridge->native_dpc is set.

The only change in behavior is for firmware that grants DPC control but retains AER control. PCI Firmware r3.3, sec 4.5.2.4, does not forbid this. The OS now uses DPC there because firmware granted it. Since "PCI/DPC: Reinstate support for AER-incapable ports", dpc_probe() no longer requires AER control.

---
Changes since v2:
- Shorten the comment in acpi_pci_root_create() (Yazen)
- Add Reviewed-by from Yazen

 drivers/acpi/pci_root.c    | 13 +++++++++++++
 drivers/pci/pcie/portdrv.c |  6 +-----
 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/acpi/pci_root.c +13 -0
index 510943649b41..b08261b6372f 100644
@@ -1054,6 +1054,19 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
 	ctrl = root->osc_control_set;
 	ext_ctrl = root->osc_ext_control_set;
 
+	/*
+	 * Firmware that predates the _OSC DPC control bit grants AER but
+	 * masks DPC.  Link DPC control to AER control, as PCIe r7.0 sec
+	 * 6.2.11 recommends.
+	 */
+	if (IS_ENABLED(CONFIG_PCIE_DPC) &&
+	    (ctrl & OSC_PCI_EXPRESS_AER_CONTROL) &&
+	    !(ctrl & OSC_PCI_EXPRESS_DPC_CONTROL)) {
+		decode_osc_control(root, "OS assuming control (AER granted) of",
+				   OSC_PCI_EXPRESS_DPC_CONTROL);
+		ctrl |= OSC_PCI_EXPRESS_DPC_CONTROL;
+	}
+
 	/*
 	 * If the user specified "pcie_ports=native", use the PCIe port
 	 * services regardless of what _OSC says, i.e., proceed as though the
drivers/pci/pcie/portdrv.c +1 -5
index b77680fd3b75..f1beb440a3dc 100644
@@ -258,12 +258,8 @@ static int get_port_device_capability(struct pci_dev *dev)
 		pcie_pme_interrupt_enable(dev, false);
 	}
 
-	/*
-	 * With dpc-native, allow Linux to use DPC even if it doesn't have
-	 * permission to use AER.
-	 */
 	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
-	    (pcie_ports_dpc_native || host->native_aer))
+	    host->native_dpc)
 		services |= PCIE_PORT_SERVICE_DPC;
 
 	/* Enable bandwidth control if more than one speed is supported. */
Signature · 1 line
2.43.0
#12 lore raw

Re: [PATCH v3 6/6] PCI/portdrv: Bind DPC service based on host_bridge->native_dpc

Sashiko has reviewed this patch and found no issues.
Quoted 20 lines

get_port_device_capability() binds the DPC service if the port has a DPC capability and either "pcie_ports=dpc-native" was given or the OS controls AER. This repeats decisions that are already made elsewhere. It also ignores host_bridge->native_dpc, which is meant to say whether the OS owns DPC.

Make host_bridge->native_dpc the single decider:

- In acpi_pci_root_create(), assume DPC control whenever _OSC grants AER control. PCI Firmware r3.3, sec 4.5.2.4, requires platforms to retain AER if they retain DPC. Put the other way, firmware that grants AER does not keep DPC. PCIe r7.0 sec 6.2.11 recommends that the OS link control of DPC to control of AER. Commit 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER") relied on this link. Keeping it means DPC still works with firmware
[ ... ]
this. The OS now uses DPC there because firmware granted it. Since "PCI/DPC: Reinstate support for AER-incapable ports", dpc_probe() no longer requires AER control.

Quoted 1 line

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com?part=6
#13 lore raw
In reply to Kuppuswamy Sathyanarayanan
Quoted 64 lines · Kuppuswamy Sathyanarayanan

This series makes host_bridge->native_dpc the single decider for whether Linux uses DPC, as Bjorn asked during the review of "Simplify PCIe native ownership".

https://lore.kernel.org/r/20261001221408.GA2731929@bhelgaas

Today the DPC service binds on host_bridge->native_aer, AER availability and "pcie_ports=dpc-native". host_bridge->native_dpc is only consulted by pci_dpc_recovered(). After this series, native_dpc is the end result of everything that decides DPC ownership, and portdrv binds the DPC service on it.

Patches 1-2 are the two DPC patches from v2 of Lukas's "Error reporting for AER-incapable devices", which are included here directly.

https://lore.kernel.org/r/34c9ee153876bac953135b4518035194b7c07c6c.1794997749.git.lukas@wunner.de
https://lore.kernel.org/r/58d8a99cc6c2ecba6dadc450ecb4501d47816732.1794997749.git.lukas@wunner.de

Patch 1 keeps the DPC driver from accessing a non-existent AER capability.

Patch 2 drops the AER ownership check from dpc_probe(), so DPC also works on ports without an AER capability.

Patch 3 builds EDR whenever DPC is enabled on ACPI, so CONFIG_PCIE_EDR is no longer a separate knob in deciding whether to request DPC control.

Patch 4 stops requiring pci_aer_available() to bind the DPC service, since the DPC driver does not depend on MSI or on the AER driver.

Patch 5 requests DPC control only together with AER control, as PCI Firmware r3.3, sec 4.5.2.4, requires.

Patch 6 binds the DPC service on host_bridge->native_dpc and logs a message when the OS assumes DPC control that _OSC did not grant.

Changes since v2:

- Pick up v2 of Lukas's two DPC patches. Patch 1 now uses the AER capability to find the error severity when the port has one.

- Keep CONFIG_PCIE_EDR as a hidden option instead of removing it, and remove the pci_dpc_recovered() check that becomes dead (Yazen).

- Fold the PCI Firmware spec reference into the existing comment in calculate_control() (Yazen).

- Shorten the comment in acpi_pci_root_create() (Yazen).

- Rebase on v7.4-rc1 and add Reviewed-by and Acked-by tags.

v2: https://lore.kernel.org/r/20261020181924.3003553-1-sathyanarayanan.kuppuswamy@linux.intel.com
v1: https://lore.kernel.org/r/20261007165840.1604136-1-sathyanarayanan.kuppuswamy@linux.intel.com

Kuppuswamy Sathyanarayanan (4):
PCI/EDR: Build EDR whenever DPC is enabled on ACPI PCI/portdrv: Don't require AER to bind DPC service PCI/ACPI: Request DPC control only together with AER control PCI/portdrv: Bind DPC service based on host_bridge->native_dpc

Lukas Wunner (2):
PCI/DPC: Avoid access to non-existent AER capability PCI/DPC: Reinstate support for AER-incapable ports

Quoted 5 lines
 drivers/acpi/pci_root.c    | 19 +++++++++++--
 drivers/pci/pcie/Kconfig   |  8 +-----
 drivers/pci/pcie/dpc.c     | 58 +++++++++++++++++++++-----------------
 drivers/pci/pcie/portdrv.c |  7 +----
 4 files changed, 51 insertions(+), 41 deletions(-)

Applied to pci/aer for v7.5, thank you!

B4 seems to collect historical things, e.g., Yazen's reviewed-by and another Fixes: tag on "PCI/DPC: Reinstate support for AER-incapable ports". I *guess* that's all great, but I didn't dig out where they originally came from. I don't see them in the v3 thread on lore
(https://lore.kernel.org/all/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com/),
so they must be from a previous posting.

#14 lore raw
Quoted 4 lines · Bjorn Helgaas
Quoted 3 lines · Kuppuswamy Sathyanarayanan

This series makes host_bridge->native_dpc the single decider for whether Linux uses DPC, as Bjorn asked during the review of "Simplify PCIe native ownership".

[...]

Quoted 7 lines
Quoted 5 lines

Patches 1-2 are the two DPC patches from v2 of Lukas's "Error reporting for AER-incapable devices", which are included here directly.

https://lore.kernel.org/r/34c9ee153876bac953135b4518035194b7c07c6c.1794997749.git.lukas@wunner.de
https://lore.kernel.org/r/58d8a99cc6c2ecba6dadc450ecb4501d47816732.1794997749.git.lukas@wunner.de

Applied to pci/aer for v7.5, thank you!

Hm, it looks like you applied to pci/portdrv instead of pci/aer.

Note that the first two patches in Sathya's series are identical to the first two patches of this other pending series...

https://lore.kernel.org/r/[email protected]

...and so if/when that other series gets applied to pci/aer, the two patches will have to be applied once more as otherwise the last (7th) patch in that series doesn't apply cleanly.

If on the other hand you move the patches from pci/portdrv to pci/aer, the first two patches in my series need not (and should not) be applied.

Quoted 6 lines

B4 seems to collect historical things, e.g., Yazen's reviewed-by and another Fixes: tag on "PCI/DPC: Reinstate support for AER-incapable ports". I *guess* that's all great, but I didn't dig out where they originally came from. I don't see them in the v3 thread on lore
(https://lore.kernel.org/all/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com/),
so they must be from a previous posting.

Right, Yazen's Reviewed-by was sent in reply to v2 of Sathya's series:

https://lore.kernel.org/r/[email protected]

And the additional Fixes tag was from Sathya in reply to v1 of my series:

https://lore.kernel.org/r/[email protected]

But I think both extra tags are fine.

Thanks,

Lukas

#15 lore raw
Quoted 19 lines · Lukas Wunner
Quoted 4 lines · Bjorn Helgaas
Quoted 3 lines · Kuppuswamy Sathyanarayanan

This series makes host_bridge->native_dpc the single decider for whether Linux uses DPC, as Bjorn asked during the review of "Simplify PCIe native ownership".

[...]

Quoted 7 lines
Quoted 5 lines

Patches 1-2 are the two DPC patches from v2 of Lukas's "Error reporting for AER-incapable devices", which are included here directly.

https://lore.kernel.org/r/34c9ee153876bac953135b4518035194b7c07c6c.1794997749.git.lukas@wunner.de
https://lore.kernel.org/r/58d8a99cc6c2ecba6dadc450ecb4501d47816732.1794997749.git.lukas@wunner.de

Applied to pci/aer for v7.5, thank you!

Hm, it looks like you applied to pci/portdrv instead of pci/aer.

Note that the first two patches in Sathya's series are identical to the first two patches of this other pending series...

Quoted 8 lines

https://lore.kernel.org/r/[email protected]

...and so if/when that other series gets applied to pci/aer, the two patches will have to be applied once more as otherwise the last (7th) patch in that series doesn't apply cleanly.

If on the other hand you move the patches from pci/portdrv to pci/aer, the first two patches in my series need not (and should not) be applied.

Thanks, I did move all these to pci/aer to avoid this complication.

There were minor conflicts with Yazen's patches in sysfs-bus-pci-devices-aer but nothing serious, and if we rework the negative value handling in the ratelimiting parameters they would mostly disappear.

#16 lore raw
Quoted 7 lines · Bjorn Helgaas
Quoted 1 line · Lukas Wunner

https://lore.kernel.org/r/[email protected]

There were minor conflicts with Yazen's patches in sysfs-bus-pci-devices-aer but nothing serious, and if we rework the negative value handling in the ratelimiting parameters they would mostly disappear.

I've reviewed the changes to sysfs-bus-pci-devices-aer on pci/aer and they LGTM. I will review again if/when updates of Yazen's patches happen.

One more thing: sashiko flagged two valid issues in patch [7/7] of my above-linked-series (which is now the top-most commit on pci/aer). I've provided a fixup patch for both findings at the bottom of my reply to sashiko:

https://lore.kernel.org/r/[email protected]/

Could you fold this into the commit? Alternatively, I'd be happy to submit these as two separate patches if that is preferred, with a proper commit message to explain each change.

Thanks,

Lukas

#17 lore raw
Quoted 3 lines · Lukas Wunner
Quoted 2 lines · Bjorn Helgaas
Quoted 1 line · Lukas Wunner

https://lore.kernel.org/r/[email protected]

[...]

Quoted 10 lines

One more thing: sashiko flagged two valid issues in patch [7/7] of my above-linked-series (which is now the top-most commit on pci/aer). I've provided a fixup patch for both findings at the bottom of my reply to sashiko:

https://lore.kernel.org/r/[email protected]/

Could you fold this into the commit? Alternatively, I'd be happy to submit these as two separate patches if that is preferred, with a proper commit message to explain each change.

Actually... come to think of it, you had this question about whether ratelimiting knobs should be exposed at all if there is no AER-capable Root Port or RCEC. I think this could be implemented simply by not allocating aer_info in pci_aer_init() and jumping directly to the "enable" label. (Because I think we still want to continue enabling Error Messages in case the user or the platform sets the System Error bits in the Root Control register.)

That would implicitly hide all statistics and ratelimiting files and may be a cleaner approach to overcome sashiko's objection that Root Port statistics are exposed on AER-incapable Root Ports with patch [7/7] of my series. It would also save a little bit of memory if we don't unnecessarily allocate aer_info.

Do you agree? If so I can prepare a patch.

Thanks,

Lukas

#18 lore raw
Quoted 24 lines · Lukas Wunner
Quoted 3 lines · Lukas Wunner
Quoted 2 lines · Bjorn Helgaas
Quoted 1 line · Lukas Wunner

https://lore.kernel.org/r/[email protected]

[...]

Quoted 10 lines

One more thing: sashiko flagged two valid issues in patch [7/7] of my above-linked-series (which is now the top-most commit on pci/aer). I've provided a fixup patch for both findings at the bottom of my reply to sashiko:

https://lore.kernel.org/r/[email protected]/

Could you fold this into the commit? Alternatively, I'd be happy to submit these as two separate patches if that is preferred, with a proper commit message to explain each change.

Actually... come to think of it, you had this question about whether ratelimiting knobs should be exposed at all if there is no AER-capable Root Port or RCEC. I think this could be implemented simply by not allocating aer_info in pci_aer_init() and jumping directly to the "enable" label. (Because I think we still want to continue enabling Error Messages in case the user or the platform sets the System Error bits in the Root Control register.)

Quoted 7 lines

That would implicitly hide all statistics and ratelimiting files and may be a cleaner approach to overcome sashiko's objection that Root Port statistics are exposed on AER-incapable Root Ports with patch [7/7] of my series. It would also save a little bit of memory if we don't unnecessarily allocate aer_info.

Do you agree? If so I can prepare a patch.

I folded in the fix above for now, but will be happy to replace with the approach you propose.

#19 lore raw
Quoted 15 lines · Bjorn Helgaas
Quoted 14 lines · Lukas Wunner

Actually... come to think of it, you had this question about whether ratelimiting knobs should be exposed at all if there is no AER-capable Root Port or RCEC. I think this could be implemented simply by not allocating aer_info in pci_aer_init() and jumping directly to the "enable" label. (Because I think we still want to continue enabling Error Messages in case the user or the platform sets the System Error bits in the Root Control register.)

That would implicitly hide all statistics and ratelimiting files and may be a cleaner approach to overcome sashiko's objection that Root Port statistics are exposed on AER-incapable Root Ports with patch [7/7] of my series. It would also save a little bit of memory if we don't unnecessarily allocate aer_info.

Quoted 4 lines
Quoted 1 line

Do you agree? If so I can prepare a patch.

I folded in the fix above for now, but will be happy to replace with the approach you propose.

Hm, I thought about this some more and realized that at least on x86, the kernel may receive PCI System Errors through pci_serr_error() in arch/86/kernel/nmi.c.

A quick web search finds numerous recent reports of messages such as:

NMI: PCI system error (SERR) for reason a0 on CPU 0. Dazed and confused, but trying to continue

It would be possible to add plumbing such that pci_serr_error() funnels such errors to the AER driver, which would search for the error-reporting device and emit more useful messages. The NMI message causes a lot of head-scratching among users.

With such plumbing added, the ratelimiting knobs and statistics in sysfs would actually be useful despite lack of an AER-capable Root Port or RCEC, which suggests that hiding them may be the wrong thing to do. So maybe we should leave it as it is for now?

The "reason" in the NMI message is sometimes a1 or b1 in reports found on the web. It's unclear to me if the "reason" and "CPU" provide a clue where the error-reporting device is located.

Support for this type of NMI was added in 2011 by commit 1c7b74d46fed ("x86, NMI: Add NMI symbol constants and rename memory parity to PCI SERR").

Thanks,

Lukas

#20 lore raw
Quoted 16 lines · Lukas Wunner
Quoted 15 lines · Bjorn Helgaas
Quoted 14 lines · Lukas Wunner

Actually... come to think of it, you had this question about whether ratelimiting knobs should be exposed at all if there is no AER-capable Root Port or RCEC. I think this could be implemented simply by not allocating aer_info in pci_aer_init() and jumping directly to the "enable" label. (Because I think we still want to continue enabling Error Messages in case the user or the platform sets the System Error bits in the Root Control register.)

That would implicitly hide all statistics and ratelimiting files and may be a cleaner approach to overcome sashiko's objection that Root Port statistics are exposed on AER-incapable Root Ports with patch [7/7] of my series. It would also save a little bit of memory if we don't unnecessarily allocate aer_info.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Do you agree? If so I can prepare a patch.

I folded in the fix above for now, but will be happy to replace with the approach you propose.

Hm, I thought about this some more and realized that at least on x86, the kernel may receive PCI System Errors through pci_serr_error() in arch/86/kernel/nmi.c.

Do modern systems still do this?

The nature of x86 is that the hardware still holds legacy/deprecated features for the sake of backwards-compatibility. But they aren't expected to be used in a modern context.

I have an old patch to that effect.
fdce765a1338 ("EDAC/amd64: Don't set up EDAC PCI control on Family 17h+")

Tony, what do you think?

Quoted 15 lines

A quick web search finds numerous recent reports of messages such as:

NMI: PCI system error (SERR) for reason a0 on CPU 0. Dazed and confused, but trying to continue

It would be possible to add plumbing such that pci_serr_error() funnels such errors to the AER driver, which would search for the error-reporting device and emit more useful messages. The NMI message causes a lot of head-scratching among users.

With such plumbing added, the ratelimiting knobs and statistics in sysfs would actually be useful despite lack of an AER-capable Root Port or RCEC, which suggests that hiding them may be the wrong thing to do. So maybe we should leave it as it is for now?

Quoted 8 lines

The "reason" in the NMI message is sometimes a1 or b1 in reports found on the web. It's unclear to me if the "reason" and "CPU" provide a clue where the error-reporting device is located.

Support for this type of NMI was added in 2011 by commit 1c7b74d46fed ("x86, NMI: Add NMI symbol constants and rename memory parity to PCI SERR").

I don't think the reason and CPU give any explicit indicator for the error-reporting device.

I expect there would need to be a platform-specific handler. Or do you think a brute force search across all PCI devices would be okay?

There's also overlap with EDAC modules. I assume the EDAC PCI handling was a solution before AER came about.

Maybe this is a tangent, should the PCI error handling be removed from EDAC and folded into the PCI subsystem?

Thanks,
Yazen

#21 lore raw
Quoted 7 lines · Yazen Ghannam
Quoted 4 lines · Lukas Wunner

Hm, I thought about this some more and realized that at least on x86, the kernel may receive PCI System Errors through pci_serr_error() in arch/86/kernel/nmi.c.

Do modern systems still do this?

The reports I found are for systems sold in the early 2010s, e.g.:

HP Proliant ML330 G6 (2010)
HP Proliant DL380 G6 (2010)
Intel Server Board S2600CP (2012)

However the reports are as recent as 2024 because people continue using the hardware despite its age.

Quoted 5 lines

I don't think the reason and CPU give any explicit indicator for the error-reporting device.

I expect there would need to be a platform-specific handler. Or do you think a brute force search across all PCI devices would be okay?

The PCI topology of these systems seems to be fairly small, so a brute force search would seem okay.

However my point is that there are platforms which do signal System Errors in a way that may benefit from the statistics and ratelimiting knobs exposed for AER.

Thanks,

Lukas

#22 lore raw
Quoted 9 lines · Lukas Wunner
Quoted 7 lines · Yazen Ghannam
Quoted 4 lines · Lukas Wunner

Hm, I thought about this some more and realized that at least on x86, the kernel may receive PCI System Errors through pci_serr_error() in arch/86/kernel/nmi.c.

Do modern systems still do this?

Quoted 9 lines

The reports I found are for systems sold in the early 2010s, e.g.:

HP Proliant ML330 G6 (2010)
HP Proliant DL380 G6 (2010)
Intel Server Board S2600CP (2012)

However the reports are as recent as 2024 because people continue using the hardware despite its age.

Yes, that's fair.

Quoted 6 lines
Quoted 5 lines

I don't think the reason and CPU give any explicit indicator for the error-reporting device.

I expect there would need to be a platform-specific handler. Or do you think a brute force search across all PCI devices would be okay?

Quoted 7 lines

The PCI topology of these systems seems to be fairly small, so a brute force search would seem okay.

However my point is that there are platforms which do signal System Errors in a way that may benefit from the statistics and ratelimiting knobs exposed for AER.

Right, so basically the EDAC behavior but folded into PCI subsystem.

EDAC scan: edac_pci_do_parity_check()

Not sure if there is anything worth moving. Or just do something fresh and deprecate the old code. What do you think?

Thanks,
Yazen