[PATCH v11 20/23] CXL/PCI: Export and rename merge_result() to pci_ers_merge_result()

Terry Bowman
2025-08-27T01:39:32Z

CXL uncorrectable errors (UCE) will soon be handled separately from the PCI
AER handling. The merge_result() function can be made common to use in both
handling paths.

Rename the PCI subsystem's merge_result() to be pci_ers_merge_result().
Export pci_ers_merge_result() to make available for the CXL and other
drivers to use.

Update pci_ers_merge_result() to support recently introduced PCI_ERS_RESULT_PANIC
result.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>

---
Changes in v10->v11:
- New patch
- pci_ers_merge_result() - Change export to non-namespace and rename
to be pci_ers_merge_result()
- Move pci_ers_merge_result() definition to pci.h. Needs pci_ers_result
---
drivers/pci/pcie/err.c | 14 +++++++++-----
include/linux/pci.h | 11 +++++++++++
2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index de6381c690f5..368bad0cb90e 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -21,9 +21,12 @@
#include "portdrv.h"
#include "../pci.h"

-static pci_ers_result_t merge_result(enum pci_ers_result orig,
- enum pci_ers_result new)
+pci_ers_result_t pci_ers_merge_result(enum pci_ers_result orig,
+ enum pci_ers_result new)
{
+ if (new == PCI_ERS_RESULT_PANIC)
+ return PCI_ERS_RESULT_PANIC;
+
if (new == PCI_ERS_RESULT_NO_AER_DRIVER)
return PCI_ERS_RESULT_NO_AER_DRIVER;

@@ -45,6 +48,7 @@ static pci_ers_result_t merge_result(enum pci_ers_result orig,

return orig;
}
+EXPORT_SYMBOL(pci_ers_merge_result);

static int report_error_detected(struct pci_dev *dev,
pci_channel_state_t state,
@@ -81,7 +85,7 @@ static int report_error_detected(struct pci_dev *dev,
vote = err_handler->error_detected(dev, state);
}
pci_uevent_ers(dev, vote);
- *result = merge_result(*result, vote);
+ *result = pci_ers_merge_result(*result, vote);
device_unlock(&dev->dev);
return 0;
}
@@ -121,7 +125,7 @@ static int report_mmio_enabled(struct pci_dev *dev, void *data)

err_handler = pdrv->err_handler;
vote = err_handler->mmio_enabled(dev);
- *result = merge_result(*result, vote);
+ *result = pci_ers_merge_result(*result, vote);
out:
device_unlock(&dev->dev);
return 0;
@@ -140,7 +144,7 @@ static int report_slot_reset(struct pci_dev *dev, void *data)

err_handler = pdrv->err_handler;
vote = err_handler->slot_reset(dev);
- *result = merge_result(*result, vote);
+ *result = pci_ers_merge_result(*result, vote);
out:
device_unlock(&dev->dev);
return 0;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3407d687459d..ff6812b2b9b6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2760,6 +2760,17 @@ static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev)
void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type);
#endif

+#if defined(CONFIG_PCIEAER)
+pci_ers_result_t pci_ers_merge_result(enum pci_ers_result orig,
+ enum pci_ers_result new);
+#else
+static inline pci_ers_result_t pci_ers_merge_result(enum pci_ers_result orig,
+ enum pci_ers_result new)
+{
+ return PCI_ERS_RESULT_NONE;
+}
+#endif
+
#include <linux/dma-mapping.h>

#define pci_emerg(pdev, fmt, arg...) dev_emerg(&(pdev)->dev, fmt, ##arg)
--
2.51.0.rc2.21.ge5ab6b3e5a