Skip to contentSkip to conversation

cxl: Remove ifdef blocks of CONFIG_PCIEAER_CXL from core/pci.c

PATCH Superseded Dave Jiang 2 participants 2 messages Jul 29, 2025 CXL

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Dave Jiang

author maintainer
#0 lore raw

PATCH v4 1/1 cxl: Remove ifdef blocks of CONFIG_PCIEAER_CXL from core/pci.c

Create new config CONFIG_CXL_RAS and put all CXL RAS items behind the config. The config will depend on CPER or PCIE AER to build. Move the related RAS code from core/pci.c to core/ras.c.

---
v4:
- Drop PCIEAER dep. (Dan)
- Drop header prototypes that can be static. (Dan)
- Use PCI_ERS_RESULT_NONE as return. (Dan)

---
 drivers/cxl/Kconfig       |   4 +
 drivers/cxl/core/Makefile |   2 +-
 drivers/cxl/core/core.h   |   6 +
 drivers/cxl/core/pci.c    | 319 --------------------------------------
 drivers/cxl/core/ras.c    | 313 +++++++++++++++++++++++++++++++++++++
 drivers/cxl/cxl.h         |   8 -
 drivers/cxl/cxlpci.h      |  16 ++
 tools/testing/cxl/Kbuild  |   1 +
 8 files changed, 341 insertions(+), 328 deletions(-)
drivers/cxl/Kconfig +4 -0
index 48b7314afdb8..b36bb0cabe58 100644
@@ -233,4 +233,8 @@ config CXL_MCE
 	def_bool y
 	depends on X86_MCE && MEMORY_FAILURE
 
+config CXL_RAS
+	def_bool y
+	depends on ACPI_APEI_GHES || PCIEAER_CXL
+
 endif
drivers/cxl/core/Makefile +1 -1
index 79e2ef81fde8..1c652e575aaa 100644
@@ -14,10 +14,10 @@ cxl_core-y += pci.o
 cxl_core-y += hdm.o
 cxl_core-y += pmu.o
 cxl_core-y += cdat.o
-cxl_core-y += ras.o
 cxl_core-y += acpi.o
 cxl_core-$(CONFIG_TRACING) += trace.o
 cxl_core-$(CONFIG_CXL_REGION) += region.o
 cxl_core-$(CONFIG_CXL_MCE) += mce.o
 cxl_core-$(CONFIG_CXL_FEATURES) += features.o
 cxl_core-$(CONFIG_CXL_EDAC_MEM_FEATURES) += edac.o
+cxl_core-$(CONFIG_CXL_RAS) += ras.o
drivers/cxl/core/core.h +6 -0
index 29b61828a847..e9fa8b8e45f5 100644
@@ -136,4 +136,10 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 		    u16 *return_code);
 #endif
 
+#ifdef CONFIG_CXL_RAS
+void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds);
+#else
+static inline void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) {}
+#endif
+
 #endif /* __CXL_CORE_H__ */
drivers/cxl/core/pci.c +0 -319

331 lines not on this page · raw message

drivers/cxl/core/ras.c +313 -0

323 lines not on this page · raw message

drivers/cxl/cxl.h +0 -8
index f68a9414da26..ddf0ee46b116 100644
@@ -760,14 +760,6 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port,
 					 struct device *dport_dev, int port_id,
 					 resource_size_t rcrb);
 
-#ifdef CONFIG_PCIEAER_CXL
-void cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport);
-void cxl_dport_init_ras_reporting(struct cxl_dport *dport, struct device *host);
-#else
-static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport,
-						struct device *host) { }
-#endif
-
 struct cxl_decoder *to_cxl_decoder(struct device *dev);
 struct cxl_root_decoder *to_cxl_root_decoder(struct device *dev);
 struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev);
drivers/cxl/cxlpci.h +16 -0
index 54e219b0049e..3959fa7e2ead 100644
@@ -132,7 +132,23 @@ struct cxl_dev_state;
 int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
 			struct cxl_endpoint_dvsec_info *info);
 void read_cdat_data(struct cxl_port *port);
+
+#ifdef CONFIG_CXL_RAS
 void cxl_cor_error_detected(struct pci_dev *pdev);
 pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
 				    pci_channel_state_t state);
+void cxl_dport_init_ras_reporting(struct cxl_dport *dport, struct device *host);
+#else
+static inline void cxl_cor_error_detected(struct pci_dev *pdev) { }
+
+static inline pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
+						  pci_channel_state_t state)
+{
+	return PCI_ERS_RESULT_NONE;
+}
+
+static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport,
+						struct device *host) { }
+#endif
+
 #endif /* __CXL_PCI_H__ */
tools/testing/cxl/Kbuild +1 -0
index 31a2d73c963f..4cc8099bbcd2 100644
@@ -68,6 +68,7 @@ cxl_core-$(CONFIG_CXL_REGION) += $(CXL_CORE_SRC)/region.o
 cxl_core-$(CONFIG_CXL_MCE) += $(CXL_CORE_SRC)/mce.o
 cxl_core-$(CONFIG_CXL_FEATURES) += $(CXL_CORE_SRC)/features.o
 cxl_core-$(CONFIG_CXL_EDAC_MEM_FEATURES) += $(CXL_CORE_SRC)/edac.o
+cxl_core-$(CONFIG_CXL_RAS) += $(CXL_CORE_SRC)/ras.o
 cxl_core-y += config_check.o
 cxl_core-y += cxl_core_test.o
 cxl_core-y += cxl_core_exports.o

base-commit: 6e130ce1dfd47a1ef953d0be127934760aecb769

Signature · 1 line
2.50.1
#1 lore raw
Quoted 14 lines · Dave Jiang

Create new config CONFIG_CXL_RAS and put all CXL RAS items behind the config. The config will depend on CPER or PCIE AER to build. Move the related RAS code from core/pci.c to core/ras.c.

---
v4:
- Drop PCIEAER dep. (Dan)
- Drop header prototypes that can be static. (Dan)
- Use PCI_ERS_RESULT_NONE as return. (Dan)

[..]

drivers/cxl/core/core.h int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, · line 143

Quoted 13 lines
drivers/cxl/core/core.h +5 -0
index 29b61828a847..e9fa8b8e45f5 100644
@@ -136,4 +136,10 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 		    u16 *return_code);
 #endif
 
+#ifdef CONFIG_CXL_RAS
+void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds);
+#else
+static inline void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) {}
+#endif

...but the only caller moved into ras.c? So, why not the following too?

-- 8< --

drivers/cxl/core/core.h +0 -6
index bfc05f95f1fd..f796731deedf 100644
@@ -160,10 +160,4 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,
 		    u16 *return_code);
 #endif
 
-#ifdef CONFIG_CXL_RAS
-void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds);
-#else
-static inline void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) {}
-#endif
-
 #endif /* __CXL_CORE_H__ */
drivers/cxl/core/ras.c +1 -1
index da301f5e163c..6adc52abd0af 100644
@@ -331,7 +331,7 @@ static bool cxl_rch_get_aer_severity(struct aer_capability_regs *aer_regs,
 	return false;
 }
 
-void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)
+static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)
 {
 	struct pci_dev *pdev = to_pci_dev(cxlds->dev);
 	struct aer_capability_regs aer_regs;