Skip to contentSkip to conversation

PCI: Add boot options to disable DPC and AER recovery

PATCH Superseded Yury Murashka 3 participants 6 messages Jul 9

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover PCI: Add boot options to disable DPC and AER recovery

On large modular systems with a complex PCIe tree, the default kernel AER recovery and DPC behavior could cause unexpected side effects. Sometimes it would be nice to have the option to keep the system in an unmodified state and be able to handle PCIe errors from userspace.

This series adds two new PCI kernel boot options:

pci=noaer_recovery - Disable AER error recovery while still logging
AER errors
pci=nodpc - Disable PCI Downstream Port Containment entirely

---
v1 -> v2:
- Patch 1: Move disable check from pcie_do_recovery() in err.c to pci_aer_handle_error()/aer_recover_work_func() in aer.c for proper AER-specific scoping. AER error status bits are now preserved (not cleared) so userspace can inspect the error state
- Patch 2: Also skip DPC port service driver registration in pcie_dpc_init() when disabled
- Rebase onto v7.2-rc2

v1: https://lore.kernel.org/linux-pci/[email protected]/

Yury Murashka (2):
PCI: Add pci=noaer_recovery kernel boot option
PCI: Add pci=nodpc kernel boot option

 .../admin-guide/kernel-parameters.txt         |  9 ++++++
 drivers/pci/pci.c                             |  4 +++
 drivers/pci/pci.h                             |  4 +++
 drivers/pci/pcie/aer.c                        | 30 ++++++++++++-------
 drivers/pci/pcie/dpc.c                        | 19 ++++++++++--
 5 files changed, 53 insertions(+), 13 deletions(-)

base-commit: 0e35b9b6ec0ffcc5e23cbdec09f5c622ad532b53

Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/2 PCI: Add pci=noaer_recovery kernel boot option

AER error recovery is part of the AER error handling subsystem in the Linux kernel. On large modular systems with a complex PCIe tree, AER recovery could cause unexpected behavior and side effects. Sometimes it would be nice to have the option to keep the system in an unmodified state and be able to handle PCIe errors from userspace.

Add pci=noaer_recovery kernel boot option to disable AER error recovery when an uncorrectable error is reported. When this option is set, the error is still logged but no recovery actions are taken. AER error status bits are preserved so userspace can inspect the error state.

---
 .../admin-guide/kernel-parameters.txt         |  6 ++++
 drivers/pci/pci.c                             |  2 ++
 drivers/pci/pci.h                             |  2 ++
 drivers/pci/pcie/aer.c                        | 30 ++++++++++++-------
 4 files changed, 30 insertions(+), 10 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
index b5493a7f8f22..13c6b53bb9ee 100644
@@ -5053,6 +5053,12 @@ Kernel parameters
 		noaer		[PCIE] If the PCIEAER kernel config parameter is
 				enabled, this kernel boot option can be used to
 				disable the use of PCIE advanced error reporting.
+		noaer_recovery	[PCIE] If the PCIEAER kernel config parameter is
+				enabled, this kernel boot option can be used to
+				disable AER error recovery when an uncorrectable
+				error is reported. AER error status bits are
+				preserved so userspace can inspect the error
+				state.
 		nodomains	[PCI] Disable support for multiple PCI
 				root domains (aka PCI segments, in ACPI-speak).
 		nommconf	[X86] Disable use of MMCONFIG for PCI
drivers/pci/pci.c +2 -0
index 77b17b13ee61..a215dd567d5d 100644
@@ -6756,6 +6756,8 @@ static int __init pci_setup(char *str)
 				pcie_ats_disabled = true;
 			} else if (!strcmp(str, "noaer")) {
 				pci_no_aer();
+			} else if (!strcmp(str, "noaer_recovery")) {
+				pci_no_aer_recovery();
 			} else if (!strcmp(str, "earlydump")) {
 				pci_early_dump = true;
 			} else if (!strncmp(str, "realloc=", 8)) {
drivers/pci/pci.h +2 -0
index 4469e1a77f3c..c4a42bbc277b 100644
@@ -1283,6 +1283,7 @@ static inline void of_pci_remove_host_bridge_node(struct pci_host_bridge *bridge
 
 #ifdef CONFIG_PCIEAER
 void pci_no_aer(void);
+void pci_no_aer_recovery(void);
 void pci_aer_init(struct pci_dev *dev);
 void pci_aer_exit(struct pci_dev *dev);
 extern const struct attribute_group aer_stats_attr_group;
@@ -1294,6 +1295,7 @@ void pci_save_aer_state(struct pci_dev *dev);
 void pci_restore_aer_state(struct pci_dev *dev);
 #else
 static inline void pci_no_aer(void) { }
+static inline void pci_no_aer_recovery(void) { }
 static inline void pci_aer_init(struct pci_dev *d) { }
 static inline void pci_aer_exit(struct pci_dev *d) { }
 static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }
drivers/pci/pcie/aer.c +20 -10
index c4fd9c0b2a54..fb79990ce8ff 100644
@@ -128,6 +128,7 @@ struct aer_info {
 					PCI_ERR_ROOT_MULTI_UNCOR_RCV)
 
 static bool pcie_aer_disable;
+static bool pcie_aer_recovery_disable;
 static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
 
 void pci_no_aer(void)
@@ -135,6 +136,11 @@ void pci_no_aer(void)
 	pcie_aer_disable = true;
 }
 
+void pci_no_aer_recovery(void)
+{
+	pcie_aer_recovery_disable = true;
+}
+
 bool pci_aer_available(void)
 {
 	return !pcie_aer_disable && pci_msi_enabled();
@@ -1187,10 +1193,12 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)
 				pdrv->err_handler->cor_error_detected(dev);
 			pcie_clear_device_status(dev);
 		}
-	} else if (info->severity == AER_NONFATAL)
-		pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset);
-	else if (info->severity == AER_FATAL)
-		pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset);
+	} else if (!pcie_aer_recovery_disable) {
+		if (info->severity == AER_NONFATAL)
+			pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset);
+		else if (info->severity == AER_FATAL)
+			pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset);
+	}
 }
 
 static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
@@ -1242,12 +1250,14 @@ static void aer_recover_work_func(struct work_struct *work)
 		ghes_estatus_pool_region_free((unsigned long)entry.regs,
 					    sizeof(struct aer_capability_regs));
 
-		if (entry.severity == AER_NONFATAL)
-			pcie_do_recovery(pdev, pci_channel_io_normal,
-					 aer_root_reset);
-		else if (entry.severity == AER_FATAL)
-			pcie_do_recovery(pdev, pci_channel_io_frozen,
-					 aer_root_reset);
+		if (!pcie_aer_recovery_disable) {
+			if (entry.severity == AER_NONFATAL)
+				pcie_do_recovery(pdev, pci_channel_io_normal,
+						 aer_root_reset);
+			else if (entry.severity == AER_FATAL)
+				pcie_do_recovery(pdev, pci_channel_io_frozen,
+						 aer_root_reset);
+		}
 		pci_dev_put(pdev);
 	}
 }
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v2 1/2] PCI: Add pci=noaer_recovery kernel boot option

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The `pci=noaer_recovery` boot option fails to disable error recovery for CXL RCH internal errors. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The pci=noaer_recovery boot option fails to disable error recovery for CXL RCH internal errors. --

--- Patch [1]: [PATCH v2 1/2] PCI: Add pci=noaer_recovery kernel boot option --- commit 055898e8a2a1640801c835036f570a27cacd734b
Author: Yury Murashka <[email protected]>

PCI: Add pci=noaer_recovery kernel boot option

This patch adds a pci=noaer_recovery kernel boot option to disable AER error recovery when an uncorrectable error is reported. This allows userspace to inspect the unmodified error state without the kernel taking recovery actions.

Quoted 4 lines
drivers/pci/pcie/aer.c +0 -0
index c4fd9c0b2a548..fb79990ce8fff 100644

[ ... ]

Quoted 7 lines
drivers/pci/pcie/aer.c +0 -3
@@ -1187,10 +1193,12 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)
 				pdrv->err_handler->cor_error_detected(dev);
 			pcie_clear_device_status(dev);
 		}
-	} else if (info->severity == AER_NONFATAL)
-		pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset);
-	else if (info->severity == AER_FATAL)

drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1204

Quoted 10 lines
drivers/pci/pcie/aer.c +6 -1
-		pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset);
+	} else if (!pcie_aer_recovery_disable) {
+		if (info->severity == AER_NONFATAL)
+			pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset);
+		else if (info->severity == AER_FATAL)
+			pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset);
+	}
 }
 
 static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)

[Severity: High]
Does this fail to disable error recovery for CXL RCH internal errors?

If a CXL RCH device reports an internal uncorrectable error, handle_error_source() calls cxl_rch_handle_error() before calling pci_aer_handle_error():

drivers/pci/pcie/aer.c:handle_error_source() {
	cxl_rch_handle_error(dev, info);
	pci_aer_handle_error(dev, info);
	pci_dev_put(dev);
}

The CXL error handler unconditionally walks the RCEC and invokes the device driver's error_detected callback, completely bypassing the pcie_aer_recovery_disable check:

drivers/pci/pcie/aer_cxl_rch.c:cxl_rch_handle_error_iter() {
	...
		if (info->severity == AER_NONFATAL)
			err_handler->error_detected(dev, pci_channel_io_normal);
		else if (info->severity == AER_FATAL)
			err_handler->error_detected(dev, pci_channel_io_frozen);
	...
}

Should the recovery disable check also apply to cxl_rch_handle_error() so that unexpected recovery actions aren't executed for CXL devices when pci=noaer_recovery is used?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH v2 2/2 PCI: Add pci=nodpc kernel boot option

In reply to Yury Murashka

PCI DPC (Downstream Port Containment) support can be advertised by PCIe devices, but it might not be fully supported in the firmware. On large modular systems with a complex PCIe tree, enabling DPC could cause unexpected behavior and side effects. Sometimes it would be nice to have the option to keep the system in an unmodified state and be able to handle PCIe errors from userspace.

Add pci=nodpc kernel boot option to disable PCI DPC. When this option is set, DPC initialization, state save/restore, recovery, and driver registration are all skipped.

---
 .../admin-guide/kernel-parameters.txt         |  3 +++
 drivers/pci/pci.c                             |  2 ++
 drivers/pci/pci.h                             |  2 ++
 drivers/pci/pcie/dpc.c                        | 19 ++++++++++++++++---
 4 files changed, 23 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index 13c6b53bb9ee..ccc26849a1ae 100644
@@ -5050,6 +5050,9 @@ Kernel parameters
 				through ports 0xC000-0xCFFF).
 				See http://wiki.osdev.org/PCI for more info
 				on the configuration access mechanisms.
+		nodpc		[PCIE] If the PCIE_DPC kernel config parameter is
+				enabled, this kernel boot option can be used to
+				disable the use of PCIE DPC.
 		noaer		[PCIE] If the PCIEAER kernel config parameter is
 				enabled, this kernel boot option can be used to
 				disable the use of PCIE advanced error reporting.
drivers/pci/pci.c +2 -0
index a215dd567d5d..6cd06a872ba0 100644
@@ -6754,6 +6754,8 @@ static int __init pci_setup(char *str)
 			} else if (!strncmp(str, "noats", 5)) {
 				pr_info("PCIe: ATS is disabled\n");
 				pcie_ats_disabled = true;
+			} else if (!strcmp(str, "nodpc")) {
+				pci_no_dpc();
 			} else if (!strcmp(str, "noaer")) {
 				pci_no_aer();
 			} else if (!strcmp(str, "noaer_recovery")) {
drivers/pci/pci.h +2 -0
index c4a42bbc277b..146cd5df985a 100644
@@ -880,6 +880,7 @@ struct rcec_ea {
 #endif
 
 #ifdef CONFIG_PCIE_DPC
+void pci_no_dpc(void);
 void pci_save_dpc_state(struct pci_dev *dev);
 void pci_restore_dpc_state(struct pci_dev *dev);
 void pci_dpc_init(struct pci_dev *pdev);
@@ -888,6 +889,7 @@ pci_ers_result_t dpc_reset_link(struct pci_dev *pdev);
 bool pci_dpc_recovered(struct pci_dev *pdev);
 unsigned int dpc_tlp_log_len(struct pci_dev *dev);
 #else
+static inline void pci_no_dpc(void) { }
 static inline void pci_save_dpc_state(struct pci_dev *dev) { }
 static inline void pci_restore_dpc_state(struct pci_dev *dev) { }
 static inline void pci_dpc_init(struct pci_dev *pdev) { }
drivers/pci/pcie/dpc.c +16 -3
index 2b779bd1d861..759d9f18812e 100644
@@ -43,12 +43,19 @@ static const char * const rp_pio_error_string[] = {
 	"Memory Request Completion Timeout",		 /* Bit Position 18 */
 };
 
+static bool pcie_dpc_disable;
+
+void pci_no_dpc(void)
+{
+	pcie_dpc_disable = true;
+}
+
 void pci_save_dpc_state(struct pci_dev *dev)
 {
 	struct pci_cap_saved_state *save_state;
 	u16 *cap;
 
-	if (!pci_is_pcie(dev))
+	if (pcie_dpc_disable || !pci_is_pcie(dev))
 		return;
 
 	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_DPC);
@@ -64,7 +71,7 @@ void pci_restore_dpc_state(struct pci_dev *dev)
 	struct pci_cap_saved_state *save_state;
 	u16 *cap;
 
-	if (!pci_is_pcie(dev))
+	if (pcie_dpc_disable || !pci_is_pcie(dev))
 		return;
 
 	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_DPC);
@@ -104,7 +111,7 @@ bool pci_dpc_recovered(struct pci_dev *pdev)
 {
 	struct pci_host_bridge *host;
 
-	if (!pdev->dpc_cap)
+	if (pcie_dpc_disable || !pdev->dpc_cap)
 		return false;
 
 	/*
@@ -404,6 +411,9 @@ void pci_dpc_init(struct pci_dev *pdev)
 {
 	u16 cap;
 
+	if (pcie_dpc_disable)
+		return;
+
 	pdev->dpc_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DPC);
 	if (!pdev->dpc_cap)
 		return;
@@ -532,5 +542,8 @@ static struct pcie_port_service_driver dpcdriver = {
 
 int __init pcie_dpc_init(void)
 {
+	if (pcie_dpc_disable)
+		return 0;
+
 	return pcie_port_service_register(&dpcdriver);
 }
Signature · 1 line
2.51.0
#4 lore raw

Re: [PATCH v2 2/2] PCI: Add pci=nodpc kernel boot option

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The `pci=nodpc` parameter disables native OS DPC but still claims DPC control via ACPI `_OSC` and…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The pci=nodpc parameter disables native OS DPC but still claims DPC control via ACPI _OSC and enables it via _DSM, causing permanent unhandled link errors. --

--- Patch [2]: [PATCH v2 2/2] PCI: Add pci=nodpc kernel boot option --- commit 9eea006773bbca0de0b0f501e83971ad7b74166e
Author: Yury Murashka <[email protected]>

PCI: Add pci=nodpc kernel boot option

This patch introduces the pci=nodpc kernel boot option to disable PCI Downstream Port Containment (DPC). When specified, DPC initialization, state operations, and driver registration are bypassed, allowing userspace to handle PCIe errors.

Quoted 4 lines
drivers/pci/pcie/dpc.c +0 -0
index 2b779bd1d861b..759d9f18812ee 100644

[ ... ]

drivers/pci/pcie/dpc.c void pci_dpc_init(struct pci_dev *pdev) · line 416

Quoted 7 lines
drivers/pci/pcie/dpc.c +3 -0
@@ -404,6 +411,9 @@ void pci_dpc_init(struct pci_dev *pdev)
 {
 	u16 cap;
 
+	if (pcie_dpc_disable)
+		return;
+

[Severity: High]
Does returning early here leave pdev->dpc_cap as 0 and cause issues with Error Disconnect Recover (EDR)?

When pci=nodpc is set, calculate_control() in drivers/acpi/pci_root.c still requests DPC control from firmware based solely on the compile-time flag:

drivers/acpi/pci_root.c:calculate_control() {
    ...
	if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR))
		control |= OSC_PCI_EXPRESS_DPC_CONTROL;
    ...
}

And pci_acpi_add_edr_notifier() in drivers/pci/pcie/edr.c unconditionally enables DPC in hardware:

drivers/pci/pcie/edr.c:pci_acpi_add_edr_notifier() {
    ...
	if (acpi_enable_dpc(pdev))
		acpi_remove_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
					   edr_handle_event);
    ...
}

If a PCIe error occurs and ACPI firmware notifies the OS, edr_handle_event() will trigger but immediately abort because edev->dpc_cap is 0:

drivers/pci/pcie/edr.c:edr_handle_event() {
    ...
	if (!edev->dpc_cap) {
		pci_err(edev, FW_BUG "This device doesn't support DPC\n");
		goto send_ost;
	}
    ...
}

Will this cause EDR to abort recovery, incorrectly log a firmware bug, and permanently abandon the link instead of letting userspace handle it?

Quoted 3 lines
drivers/pci/pcie/dpc.c +0 -0
 	pdev->dpc_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DPC);
 	if (!pdev->dpc_cap)
 		return;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw
In reply to Yury Murashka
Quoted 2 lines · Yury Murashka

On large modular systems with a complex PCIe tree, the default kernel AER recovery and DPC behavior could cause unexpected side effects.

I can't tell what the actual issues are, but if there are kernel defects in this area, we should fix them. If this is to work around platform defects, maybe we need quirks to work around them automatically?