PCI/AER: Refactor cper_print_aer() for use by CXL driver module
Subsystems (3)
PATCH v10 8/15 PCI/AER: Refactor cper_print_aer() for use by CXL driver module
The CXL driver plans to use cper_print_aer() for logging restricted CXL host (RCH) AER errors. cper_print_aer() is not currently exported and therefore not usable by the CXL drivers built as loadable modules. Export the cper_print_aer() function. Use the EXPORT_SYMBOL_NS_GPL() variant to restrict the export to CXL drivers.
The CONFIG_ACPI_APEI_PCIEAER kernel config is currently used to enable cper_print_aer(). cper_print_aer() logs the AER registers and is useful in PCIE AER logging outside of APEI. Remove the CONFIG_ACPI_APEI_PCIEAER dependency to enable cper_print_aer().
The cper_print_aer() function name implies CPER specific use but is useful in non-CPER cases as well. Rename cper_print_aer() to pci_print_aer().
Also, update cxl_core to import CXL namespace imports.
--- drivers/cxl/core/port.c | 1 + drivers/pci/pcie/aer.c | 9 +++++---- include/linux/aer.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/cxl/core/port.c +1 -0
@@ -2063,3 +2063,4 @@ static void cxl_core_exit(void)subsys_initcall (cxl_core_init);module_exit (cxl_core_exit);MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (CXL );
drivers/pci/pcie/aer.c +5 -4
@@ -771,9 +771,10 @@ int cper_severity_to_aer(int cper_severity) } }EXPORT_SYMBOL_GPL (cper_severity_to_aer); +#endif -void cper_print_aer (struct pci_dev *dev,int aer_severity, -struct aer_capability_regs *aer) +void pci_print_aer (struct pci_dev *dev,int aer_severity, +struct aer_capability_regs *aer) {int layer, agent, tlp_header_valid =0 ;u32 status, mask;
@@ -812,7 +813,7 @@ void cper_print_aer(struct pci_dev *dev, int aer_severity,trace_aer_event (dev_name (&dev->dev), (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log); } -#endif +EXPORT_SYMBOL_NS_GPL (pci_print_aer,CXL );/** * add_error_device - list device to be handled
@@ -1009,7 +1010,7 @@ static void aer_recover_work_func(struct work_struct *work) PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));continue ; } -cper_print_aer (pdev, entry.severity, entry.regs); +pci_print_aer (pdev, entry.severity, entry.regs);if (entry.severity ==AER_NONFATAL )pcie_do_recovery (pdev, pci_channel_io_normal, aer_root_reset);
include/linux/aer.h +1 -1
@@ -64,7 +64,7 @@ static inline void pci_save_aer_state(struct pci_dev *dev) {}static inline void pci_restore_aer_state (struct pci_dev *dev) {}#endif -void cper_print_aer (struct pci_dev *dev,int aer_severity, +void pci_print_aer (struct pci_dev *dev,int aer_severity,struct aer_capability_regs *aer);int cper_severity_to_aer (int cper_severity); void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
Signature · 1 line
2.34.1
PATCH v10 9/15 cxl/pci: Update CXL error logging to use RAS register address
The CXL error handler currently only logs endpoint RAS status. The CXL topology includes several components providing RAS details to be logged during error handling.[1] Update the current handler's RAS logging to use a RAS register address. Also, update the error handler function names to be consistent with correctable and uncorrectable RAS. This will allow for adding support to log other CXL component's RAS details in the future.
[1] CXL3.0 Table 8-22 CXL_Capability_ID Assignment
--- drivers/cxl/core/pci.c | 44 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-)
drivers/cxl/core/pci.c +31 -13
@@ -646,32 +646,36 @@ void read_cdat_data(struct cxl_port *port) }EXPORT_SYMBOL_NS_GPL (read_cdat_data,CXL ); -void cxl_cor_error_detected (struct pci_dev *pdev) +static void __cxl_handle_cor_ras (struct cxl_dev_state *cxlds, +void __iomem *ras_base) { -struct cxl_dev_state *cxlds =pci_get_drvdata (pdev);void __iomem *addr;u32 status; -if (!cxlds->regs.ras) +if (!ras_base)return ; - addr = cxlds->regs.ras +CXL_RAS_CORRECTABLE_STATUS_OFFSET ; + addr = ras_base +CXL_RAS_CORRECTABLE_STATUS_OFFSET ; status =readl (addr);if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) {writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr);trace_cxl_aer_correctable_error (cxlds->cxlmd, status); } } -EXPORT_SYMBOL_NS_GPL (cxl_cor_error_detected,CXL ); + +static void cxl_handle_endpoint_cor_ras (struct cxl_dev_state *cxlds) +{ +return __cxl_handle_cor_ras (cxlds, cxlds->regs.ras); +}/* CXL spec rev3.0 8.2.4.16.1 */ -static void header_log_copy (struct cxl_dev_state *cxlds,u32 *log) +static void header_log_copy (void __iomem *ras_base,u32 *log) {void __iomem *addr;u32 *log_addr;int i, log_u32_size =CXL_HEADERLOG_SIZE /sizeof (u32); - addr = cxlds->regs.ras +CXL_RAS_HEADER_LOG_OFFSET ; + addr = ras_base +CXL_RAS_HEADER_LOG_OFFSET ; log_addr = log;for (i =0 ; i < log_u32_size; i++) {
@@ -685,17 +689,18 @@ static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log)* Log the state of the RAS status registers and prepare them to log the * next error status. Return 1 if reset needed. */ -static bool cxl_report_and_clear (struct cxl_dev_state *cxlds) +static bool __cxl_handle_ras (struct cxl_dev_state *cxlds, +void __iomem *ras_base) {u32 hl[CXL_HEADERLOG_SIZE_U32 ];void __iomem *addr;u32 status;u32 fe; -if (!cxlds->regs.ras) +if (!ras_base)return false; - addr = cxlds->regs.ras +CXL_RAS_UNCORRECTABLE_STATUS_OFFSET ; + addr = ras_base +CXL_RAS_UNCORRECTABLE_STATUS_OFFSET ; status =readl (addr);if (!(status &CXL_RAS_UNCORRECTABLE_STATUS_MASK ))return false;
@@ -703,7 +708,7 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds)/* If multiple errors, log header points to first error from ctrl reg */ if (hweight32 (status) >1 ) {void __iomem *rcc_addr = - cxlds->regs.ras +CXL_RAS_CAP_CONTROL_OFFSET ; + ras_base +CXL_RAS_CAP_CONTROL_OFFSET ; fe =BIT (FIELD_GET (CXL_RAS_CAP_CONTROL_FE_MASK ,readl (rcc_addr)));
@@ -711,13 +716,26 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) fe = status; } -header_log_copy (cxlds, hl); +header_log_copy (ras_base, hl);trace_cxl_aer_uncorrectable_error (cxlds->cxlmd, status, fe, hl);writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);return true; } +static bool cxl_handle_endpoint_ras (struct cxl_dev_state *cxlds) +{ +return __cxl_handle_ras (cxlds, cxlds->regs.ras); +} + +void cxl_cor_error_detected (struct pci_dev *pdev) +{ +struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); + +cxl_handle_endpoint_cor_ras (cxlds); +} +EXPORT_SYMBOL_NS_GPL (cxl_cor_error_detected,CXL ); +pci_ers_result_t cxl_error_detected (struct pci_dev *pdev,pci_channel_state_t state) {
@@ -732,7 +750,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,* chance the situation is recoverable dump the status of the RAS * capability registers and bounce the active state of the memdev. */ - ue =cxl_report_and_clear (cxlds); + ue =cxl_handle_endpoint_ras (cxlds);switch (state) {case pci_channel_io_normal:
Signature · 1 line
2.34.1
PATCH v10 10/15 cxl/pci: Map RCH downstream AER registers for logging protocol errors
In reply to Terry BowmanThe restricted CXL host (RCH) error handler will log protocol errors using AER and RAS status registers. The AER and RAS registers need to be virtually memory mapped before enabling interrupts. Update __devm_cxl_add_dport() to include RCH RAS and AER mapping.
Add 'struct cxl_regs' to 'struct cxl_dport' for saving a pointer to the RCH downstream port's AER and RAS registers.
--- drivers/cxl/core/port.c | 34 ++++++++++++++++++++++++++++++++++ drivers/cxl/core/regs.c | 1 + drivers/cxl/cxl.h | 12 ++++++++++++ 3 files changed, 47 insertions(+)
drivers/cxl/core/port.c +34 -0
@@ -8,6 +8,7 @@#include <linux/pci.h> #include <linux/slab.h> #include <linux/idr.h> +#include <linux/aer.h> #include <cxlmem.h> #include <cxlpci.h> #include <cxl.h>
@@ -949,6 +950,37 @@ static void cxl_dport_unlink(void *data)sysfs_remove_link (&port->dev.kobj, link_name); } +static void cxl_dport_map_rch_aer (struct cxl_dport *dport) +{ +struct cxl_rcrb_info *ri = &dport->rcrb; +struct cxl_port *port = dport->port; +void __iomem *dport_aer =NULL ; +resource_size_t aer_phys; + +if (dport->rch && ri->aer_cap) { + aer_phys = ri->aer_cap + ri->base; + dport_aer =devm_cxl_iomap_block (&port->dev, aer_phys, +sizeof (struct aer_capability_regs )); + } + + dport->regs.dport_aer = dport_aer; +} + +static void cxl_dport_map_regs (struct cxl_dport *dport) +{ +struct cxl_register_map *map = &dport->comp_map; +struct device *dev = dport->dport_dev; + +if (!map->component_map.ras.valid) +dev_dbg (dev,"RAS registers not found\n" ); +else if (cxl_map_component_regs (map, dev, &dport->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS ))) +dev_dbg (dev,"Failed to map RAS capability.\n" ); + +if (dport->rch) +cxl_dport_map_rch_aer (dport); +} +static struct cxl_dport * __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, int port_id, resource_size_t component_reg_phys,
@@ -1008,6 +1040,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,if (rc)return ERR_PTR (rc); +cxl_dport_map_regs (dport); +cond_cxl_root_lock (port); rc =add_dport (port, dport);cond_cxl_root_unlock (port);
drivers/cxl/core/regs.c +1 -0
@@ -199,6 +199,7 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr,return ret_val; } +EXPORT_SYMBOL_NS_GPL (devm_cxl_iomap_block,CXL ); int cxl_map_component_regs(const struct cxl_register_map *map, struct device *dev,
drivers/cxl/cxl.h +12 -0
@@ -221,6 +221,14 @@ struct cxl_regs {struct_group_tagged (cxl_pmu_regs, pmu_regs, void __iomem *pmu; ); + +/* +* RCH downstream port specific RAS register +* @aer: CXL 3.0 8.2.1.1 RCH Downstream Port RCRB +*/ +struct_group_tagged (cxl_rch_regs, rch_regs, + void __iomem *dport_aer; + ); };struct cxl_reg_map {
@@ -273,6 +281,8 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map);void cxl_probe_device_regs (struct device *dev,void __iomem *base,struct cxl_device_reg_map *map); +void __iomem *devm_cxl_iomap_block (struct device *dev,resource_size_t addr, +resource_size_t length); int cxl_map_component_regs(const struct cxl_register_map *map, struct device *dev, struct cxl_component_regs *regs,
@@ -625,6 +635,7 @@ struct cxl_rcrb_info {* @rcrb: Data about the Root Complex Register Block layout * @rch: Indicate whether this dport was enumerated in RCH or VH mode * @port: reference to cxl_port that contains this downstream port +* @regs: Dport parsed register blocks */ struct cxl_dport {struct device *dport_dev;
@@ -633,6 +644,7 @@ struct cxl_dport {struct cxl_rcrb_info rcrb;bool rch;struct cxl_port *port; +struct cxl_regs regs; };/**
Signature · 1 line
2.34.1
RE: [PATCH v10 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors
Quoted 70 lines · Terry Bowman
The restricted CXL host (RCH) error handler will log protocol errors using AER and RAS status registers. The AER and RAS registers need to be virtually memory mapped before enabling interrupts. Update
__devm_cxl_add_dport()to include RCH RAS and AER mapping.Add 'struct
cxl_regs' to 'structcxl_dport' for saving a pointer to the RCH downstream port's AER and RAS registers.Co-developed-by Robert Richter <[email protected]>Signed-off-by Robert Richter <[email protected]>Signed-off-by Terry Bowman <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>--- drivers/cxl/core/port.c | 34 ++++++++++++++++++++++++++++++++++ drivers/cxl/core/regs.c | 1 + drivers/cxl/cxl.h | 12 ++++++++++++ 3 files changed, 47 insertions(+)drivers/cxl/core/port.c +32
-0@@ -8,6 +8,7 @@#include <linux/pci.h> #include <linux/slab.h> #include <linux/idr.h> +#include <linux/aer.h> #include <cxlmem.h> #include <cxlpci.h> #include <cxl.h> @@ -949,6 +950,37 @@ static void cxl_dport_unlink(void *data)sysfs_remove_link (&port->dev.kobj, link_name); } +static void cxl_dport_map_rch_aer (struct cxl_dport *dport) +{ +struct cxl_rcrb_info *ri = &dport->rcrb; +struct cxl_port *port = dport->port; +void __iomem *dport_aer =NULL ; +resource_size_t aer_phys; + +if (dport->rch && ri->aer_cap) { + aer_phys = ri->aer_cap + ri->base; + dport_aer =devm_cxl_iomap_block (&port->dev, aer_phys, +sizeof (struct aer_capability_regs )); + } + + dport->regs.dport_aer = dport_aer; +} + +static void cxl_dport_map_regs (struct cxl_dport *dport) +{ +struct cxl_register_map *map = &dport->comp_map; +struct device *dev = dport->dport_dev; + +if (!map->component_map.ras.valid) +dev_dbg (dev,"RAS registers not found\n" ); +else if (cxl_map_component_regs (map, dev, &dport->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS ))) +dev_dbg (dev,"Failed to map RAS capability.\n" ); + +if (dport->rch) +cxl_dport_map_rch_aer (dport); +} +static struct cxl_dport * __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, int port_id, resource_size_t component_reg_phys,
drivers/cxl/core/port.c __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, · line 1044
Quoted 5 lines
drivers/cxl/core/port.c +2
-0@@ -1008,6 +1040,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,if (rc)return ERR_PTR (rc); +cxl_dport_map_regs (dport); +
Mapping registers for usage is a driver operation, not an enumeration operation, so this should move out of add_dport, and it should fail the driver load if it fails.
Yes this happens to be the case that dports are only enumerated in cxl_port driver probe path, but that need not be the case forever and no other parts of the CXL core are lighting up registers from an enumeration routine.
PATCH v10 11/15 cxl/pci: Add RCH downstream port error logging
In reply to Terry BowmanRCH downstream port error logging is missing in the current CXL driver. The missing AER and RAS error logging is needed for communicating driver error details to userspace. Update the driver to include PCIe AER and CXL RAS error logging.
Add RCH downstream port error handling into the existing RCiEP handler. The downstream port error handler is added to the RCiEP error handler because the downstream port is implemented in a RCRB, is not PCI enumerable, and as a result is not directly accessible to the PCI AER root port driver. The AER root port driver calls the RCiEP handler for handling RCD errors and RCH downstream port protocol errors.
Update existing RCiEP correctable and uncorrectable handlers to also call the RCH handler. The RCH handler will read the RCH AER registers, check for error severity, and if an error exists will log using an existing kernel AER trace routine. The RCH handler will also log downstream port RAS errors if they exist.
--- drivers/cxl/core/pci.c | 101 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)
drivers/cxl/core/pci.c +101 -0
@@ -5,6 +5,7 @@#include <linux/delay.h> #include <linux/pci.h> #include <linux/pci-doe.h> +#include <linux/aer.h> #include <cxlpci.h> #include <cxlmem.h> #include <cxl.h>
@@ -728,10 +729,107 @@ static bool cxl_handle_endpoint_ras(struct cxl_dev_state *cxlds)return __cxl_handle_ras (cxlds, cxlds->regs.ras); } +#ifdef CONFIG_PCIEAER_CXL + +static void cxl_handle_rdport_cor_ras (struct cxl_dev_state *cxlds, +struct cxl_dport *dport) +{ +return __cxl_handle_cor_ras (cxlds, dport->regs.ras); +} + +static bool cxl_handle_rdport_ras (struct cxl_dev_state *cxlds, +struct cxl_dport *dport) +{ +return __cxl_handle_ras (cxlds, dport->regs.ras); +} + +/* +* Copy the AER capability registers using 32 bit read accesses. +* This is necessary because RCRB AER capability is MMIO mapped. Clear the +* status after copying. +* +* @aer_base: base address of AER capability block in RCRB +* @aer_regs: destination for copying AER capability +*/ +static bool cxl_rch_get_aer_info (void __iomem *aer_base, +struct aer_capability_regs *aer_regs) +{ +int read_cnt =sizeof (struct aer_capability_regs ) /sizeof (u32); +u32 *aer_regs_buf = (u32 *)aer_regs; +int n; + +if (!aer_base) +return false; + +/* Use readl() to guarantee 32-bit accesses */ +for (n =0 ; n < read_cnt; n++) + aer_regs_buf[n] =readl (aer_base + n *sizeof (u32)); + +writel (aer_regs->uncor_status, aer_base +PCI_ERR_UNCOR_STATUS ); +writel (aer_regs->cor_status, aer_base +PCI_ERR_COR_STATUS ); + +return true; +} + +/* Get AER severity. Return false if there is no error. */ +static bool cxl_rch_get_aer_severity (struct aer_capability_regs *aer_regs, +int *severity) +{ +if (aer_regs->uncor_status & ~aer_regs->uncor_mask) { +if (aer_regs->uncor_status &PCI_ERR_ROOT_FATAL_RCV ) + *severity =AER_FATAL ; +else + *severity =AER_NONFATAL ; +return true; + } + +if (aer_regs->cor_status & ~aer_regs->cor_mask) { + *severity =AER_CORRECTABLE ; +return true; + } + +return false; +} + +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; +struct cxl_dport *dport; +struct cxl_port *port; +int severity; + + port =cxl_pci_find_port (pdev, &dport); +if (!port) +return ; + +put_device (&port->dev); + +if (!cxl_rch_get_aer_info (dport->regs.dport_aer, &aer_regs)) +return ; + +if (!cxl_rch_get_aer_severity (&aer_regs, &severity)) +return ; + +pci_print_aer (pdev, severity, &aer_regs); + +if (severity ==AER_CORRECTABLE ) +cxl_handle_rdport_cor_ras (cxlds, dport); +else +cxl_handle_rdport_ras (cxlds, dport); +} + +#else +static void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds) { } +#endif +void cxl_cor_error_detected (struct pci_dev *pdev) {struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); +if (cxlds->rcd) +cxl_handle_rdport_errors (cxlds); +cxl_handle_endpoint_cor_ras (cxlds); }EXPORT_SYMBOL_NS_GPL (cxl_cor_error_detected,CXL );
@@ -744,6 +842,9 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,struct device *dev = &cxlmd->dev;bool ue; +if (cxlds->rcd) +cxl_handle_rdport_errors (cxlds); +/* * A frozen channel indicates an impending reset which is fatal to * CXL.mem operation, and will likely crash the system. On the off
Signature · 1 line
2.34.1
PATCH v10 12/15 cxl/pci: Disable root port interrupts in RCH mode
In reply to Terry BowmanThe RCH root port contains root command AER registers that should not be enabled.[1] Disable these to prevent root port interrupts.
[1] CXL 3.0 - 12.2.1.1 RCH Downstream Port-detected Errors
--- drivers/cxl/core/core.h | 6 ++++++ drivers/cxl/core/pci.c | 29 +++++++++++++++++++++++++++++ drivers/cxl/core/port.c | 3 +++ 3 files changed, 38 insertions(+)
drivers/cxl/core/core.h +6 -0
@@ -87,4 +87,10 @@ enum cxl_poison_trace_type { CXL_POISON_TRACE_CLEAR, }; +#ifdef CONFIG_PCIEAER_CXL +void cxl_disable_rch_root_ints (struct cxl_dport *dport); +#else +static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { }; +#endif +#endif /* __CXL_CORE_H__ */
drivers/cxl/core/pci.c +29 -0
@@ -819,6 +819,35 @@ static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) cxl_handle_rdport_ras(cxlds, dport); } +void cxl_disable_rch_root_ints (struct cxl_dport *dport) +{ +void __iomem *aer_base = dport->regs.dport_aer; +struct pci_host_bridge *bridge; +u32 aer_cmd_mask, aer_cmd; + +if (!aer_base) +return ; + + bridge =to_pci_host_bridge (dport->dport_dev); + +/* +* Disable RCH root port command interrupts. +* CXL 3.0 12.2.1.1 - RCH Downstream Port-detected Errors +* +* This sequence may not be necessary. CXL spec states disabling +* the root cmd register's interrupts is required. But, PCI spec +* shows these are disabled by default on reset. +*/ +if (bridge->native_cxl_error) { + aer_cmd_mask = (PCI_ERR_ROOT_CMD_COR_EN | +PCI_ERR_ROOT_CMD_NONFATAL_EN | +PCI_ERR_ROOT_CMD_FATAL_EN ); + aer_cmd =readl (aer_base +PCI_ERR_ROOT_COMMAND ); + aer_cmd &= ~aer_cmd_mask; +writel (aer_cmd, aer_base +PCI_ERR_ROOT_COMMAND ); + } +} +#else static void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds) { }#endif
drivers/cxl/core/port.c +3 -0
@@ -1042,6 +1042,9 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,cxl_dport_map_regs (dport); +if (dport->rch) +cxl_disable_rch_root_ints (dport); +cond_cxl_root_lock (port); rc =add_dport (port, dport);cond_cxl_root_unlock (port);
Signature · 1 line
2.34.1
RE: [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
Quoted 9 lines · Terry Bowman
The RCH root port contains root command AER registers that should not be enabled.[1] Disable these to prevent root port interrupts.
[1] CXL 3.0 - 12.2.1.1 RCH Downstream Port-detected Errors
Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>
[..]
drivers/cxl/core/port.c __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, · line 1047
Quoted 11 lines
drivers/cxl/core/port.c +3
-0@@ -1042,6 +1042,9 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,cxl_dport_map_regs (dport); +if (dport->rch) +cxl_disable_rch_root_ints (dport); +
Similar to the comment about cxl_dport_map_regs() not being appropriate in an enumeration routine, this also needs to move out of _add_dport. It occurs to me that it should also be undone on driver detach just like other device "enables".
Re: [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
Hi Dan,
I added comments below.
Quoted 19 lines · Dan Williams
Quoted 9 lines · Terry Bowman
The RCH root port contains root command AER registers that should not be enabled.[1] Disable these to prevent root port interrupts.
[1] CXL 3.0 - 12.2.1.1 RCH Downstream Port-detected Errors
Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>[..]
Quoted 8 lines
drivers/cxl/core/port.c +0
-0@@ -1042,6 +1042,9 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,cxl_dport_map_regs (dport);
Quoted 8 lines
drivers/cxl/core/port.c __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, · line 1047
Quoted 3 lines
drivers/cxl/core/port.c +3
-0+if (dport->rch) +cxl_disable_rch_root_ints (dport); +Similar to the comment about
cxl_dport_map_regs()not being appropriate in an enumeration routine, this also needs to move out of_add_dport. It occurs to me that it should also be undone on driver detach just like other device "enables".
Ok. I will move out of enumeration.
Per the 'undo' request: This is a RCH downstream port (dport) with PCIe root port capability. PCI spec states root port error reporting is disabled by default at powerup. And SW does *not* enable the root port errors because the RCH dport is *not* bound to a root port driver (missing BDF, etc). This mask is added to follow the CXL spec precisely and if the rest of the system behaves as expected should not be necessary.
I don't believe masking should be 'undone' in driver detach or elsewhere. Adding the 'undo' masking would potentially introduce RCH dport root port interrupt reporting which is incorrect for the RCH/RCD mode. Only CXL components (device, uport, switch) may reside under the RCH dport and never want RCH dport reporting root port errors. RCEC reports the root complex errors in RCH/RCD mode.
Regards,
Terry
Re: [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
Quoted 33 lines · Terry Bowman
Hi Dan,
I added comments below.
Quoted 19 lines · Dan Williams
Quoted 9 lines · Terry Bowman
The RCH root port contains root command AER registers that should not be enabled.[1] Disable these to prevent root port interrupts.
[1] CXL 3.0 - 12.2.1.1 RCH Downstream Port-detected Errors
Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>[..]
Quoted 8 lines
drivers/cxl/core/port.c +0
-0@@ -1042,6 +1042,9 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,cxl_dport_map_regs (dport);Quoted 8 lines
drivers/cxl/core/port.c __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, · line 1047
Quoted 3 lines
drivers/cxl/core/port.c +3
-0+if (dport->rch) +cxl_disable_rch_root_ints (dport); +Similar to the comment about
cxl_dport_map_regs()not being appropriate in an enumeration routine, this also needs to move out of_add_dport. It occurs to me that it should also be undone on driver detach just like other device "enables".
Quoted 8 lines
Ok. I will move out of enumeration.
Per the 'undo' request: This is a RCH downstream port (dport) with PCIe root port capability. PCI spec states root port error reporting is disabled by default at powerup. And SW does *not* enable the root port errors because the RCH dport is *not* bound to a root port driver (missing BDF, etc). This mask is added to follow the CXL spec precisely and if the rest of the system behaves as expected should not be necessary.
Ah, got it perhaps add a comment to sanity check that the hardware is in the per-spec state. Are you certain that even in firmware-first error handling it is safe for the driver to unconditionally disable these interrupts?
Quoted 5 lines
I don't believe masking should be 'undone' in driver detach or elsewhere. Adding the 'undo' masking would potentially introduce RCH dport root port interrupt reporting which is incorrect for the RCH/RCD mode. Only CXL components (device, uport, switch) may reside under the RCH dport and never want RCH dport reporting root port errors. RCEC reports the root complex errors in RCH/RCD mode.
Ok, that also seems to suggest that even in the firmware-first case the driver should make sure they are off per-spec.
PATCH v10 13/15 PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
In reply to Terry BowmanFrom: Robert Richter <[email protected]>
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device, PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device's cxl_pci driver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.
To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices
--- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-)
drivers/pci/pcie/Kconfig +12 -0
@@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/ +config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)" + default y + depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC #
drivers/pci/pcie/aer.c +94 -2
114 lines not on this page · raw message
Signature · 1 line
2.34.1
RE: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
Quoted 71 lines · Terry Bowman
From: Robert Richter <[email protected]>
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device,
PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device'scxl_pcidriver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL DevicesCo-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Cc "Oliver O'Halloran" <[email protected]>Cc Bjorn Helgaas <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>--- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-)drivers/pci/pcie/Kconfig +0
-0
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 53
Quoted 5 lines
drivers/pci/pcie/Kconfig +2
-0@@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/ +config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)"
Why the "for Restricted Hosts (RCH)" clarification? I am seeing nothing that prevents this from working with RCECs on VH topologies.
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 54
Quoted 1 line
drivers/pci/pcie/Kconfig +1
-0+ default y
Minor, but I think "default PCIEAER" makes it slightly clearer that CXL error handling comes along for the ride with PCIE AER.
Quoted 28 lines
drivers/pci/pcie/Kconfig +9
-0+ depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC #drivers/pci/pcie/aer.c +8
-0@@ -946,14 +946,100 @@ static bool find_source_device(struct pci_dev *parent,return true; } +#ifdef CONFIG_PCIEAER_CXL + +static bool is_cxl_mem_dev (struct pci_dev *dev) +{ +/* +* The capability, status, and control fields in Device 0, +* Function 0 DVSEC control the CXL functionality of the +* entire device (CXL 3.0, 8.1.3).
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 966
Quoted 10 lines
drivers/pci/pcie/aer.c +10
-0+*/ +if (dev->devfn !=PCI_DEVFN (0 ,0 )) +return false; + +/* +* CXL Memory Devices must have the 502h class code set (CXL +* 3.0, 8.1.12.1). +*/ +if ((dev->class >>8 ) !=PCI_CLASS_MEMORY_CXL ) +return false;
Type-2 devices are going to support the same error flows but without advertising the CXL class code. Should this perhaps be something that CXL drivers can opt into by setting a flag in the pci_dev? It is already the case that the driver needs to be attached for the error handler to be found, so might as well allow the CXL AER handling to be opted-in by the driver as well.
Quoted 51 lines
drivers/pci/pcie/aer.c +51
-0+ +return true; +} + +static bool cxl_error_is_native (struct pci_dev *dev) +{ +struct pci_host_bridge *host =pci_find_host_bridge (dev->bus); + +if (pcie_ports_native) +return true; + +return host->native_aer && host->native_cxl_error; +} + +static bool is_internal_error (struct aer_err_info *info) +{ +if (info->severity ==AER_CORRECTABLE ) +return info->status &PCI_ERR_COR_INTERNAL ; + +return info->status &PCI_ERR_UNC_INTN ; +} + +static int cxl_rch_handle_error_iter (struct pci_dev *dev,void *data) +{ +struct aer_err_info *info = (struct aer_err_info *)data; +const struct pci_error_handlers *err_handler; + +if (!is_cxl_mem_dev (dev) || !cxl_error_is_native (dev)) +return 0 ; + +/* protect dev->driver */ +device_lock (&dev->dev); + + err_handler = dev->driver ? dev->driver->err_handler :NULL ; +if (!err_handler) + goto out; + +if (info->severity ==AER_CORRECTABLE ) { +if (err_handler->cor_error_detected) + err_handler->cor_error_detected (dev); + }else if (err_handler->error_detected) { +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); + } +out: +device_unlock (&dev->dev); +return 0 ; +} +
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 1027
Quoted 10 lines
drivers/pci/pcie/aer.c +10
-0+static void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +{ +/* +* Internal errors of an RCEC indicate an AER error in an +* RCH's downstream port. Check and handle them in the CXL.mem +* device driver. +*/ +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && +is_internal_error (info)) +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info);
This would seem to work generically for RCEC reported errors in a VH topology, so I think the "_rch" distinction can be dropped.
Quoted 36 lines
drivers/pci/pcie/aer.c +15
-2+} + +#else +static inline void cxl_rch_handle_error (struct pci_dev *dev, +struct aer_err_info *info) { } +#endif +/** -* handle_error_source - handle logging error into an event log +* pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device * @info: comprehensive error information * * Invoked when an error being detected by Root Port. */ -static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) +static void pci_aer_handle_error (struct pci_dev *dev,struct aer_err_info *info) {int aer = dev->aer_cap;@@ -977,6 +1063,12 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)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) +{ +cxl_rch_handle_error (dev, info); +pci_aer_handle_error (dev, info);pci_dev_put (dev); }Signature · 1 line
2.34.1
Re: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
Hi Dan,
Quoted 75 lines · Dan Williams
Quoted 74 lines · Terry Bowman
From: Robert Richter <[email protected]>
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device,
PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device'scxl_pcidriver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL DevicesCo-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Cc "Oliver O'Halloran" <[email protected]>Cc Bjorn Helgaas <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>--- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-)drivers/pci/pcie/Kconfig +0
-0@@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/
Quoted 6 lines
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 53
Quoted 2 lines
drivers/pci/pcie/Kconfig +2
-0+config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)"Why the "for Restricted Hosts (RCH)" clarification? I am seeing nothing that prevents this from working with RCECs on VH topologies.
The same option can be used in VH mode. Will remove the RCH reference.
Quoted 6 lines
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 54
Quoted 2 lines
drivers/pci/pcie/Kconfig +1
-0+ default yMinor, but I think "default PCIEAER" makes it slightly clearer that CXL error handling comes along for the ride with PCIE AER.
We found Kconfig entries do not typically list a dependancy and the default to be the same. We prefer to leave as 'default y'. If you want we can make your requested change.
Quoted 37 lines
Quoted 37 lines
drivers/pci/pcie/Kconfig +9
-0+ depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC #drivers/pci/pcie/aer.c +17
-0@@ -946,14 +946,100 @@ static bool find_source_device(struct pci_dev *parent,return true; } +#ifdef CONFIG_PCIEAER_CXL + +static bool is_cxl_mem_dev (struct pci_dev *dev) +{ +/* +* The capability, status, and control fields in Device 0, +* Function 0 DVSEC control the CXL functionality of the +* entire device (CXL 3.0, 8.1.3). +*/ +if (dev->devfn !=PCI_DEVFN (0 ,0 )) +return false; + +/* +* CXL Memory Devices must have the 502h class code set (CXL +* 3.0, 8.1.12.1). +*/ +if ((dev->class >>8 ) !=PCI_CLASS_MEMORY_CXL )
Quoted 9 lines
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 966
Quoted 1 line
drivers/pci/pcie/aer.c +1
-0+return false;Type-2 devices are going to support the same error flows but without advertising the CXL class code. Should this perhaps be something that CXL drivers can opt into by setting a flag in the
pci_dev? It is already the case that the driver needs to be attached for the error handler to be found, so might as well allow the CXL AER handling to be opted-in by the driver as well.
At the momment type-2 devices are unsupported and the drivers are not available. The absence of CXL class information in type-2 devices will present a challenge in identifying here. We would like to defer making change here and address this in a future a patchset.
Quoted 56 lines
Quoted 56 lines
drivers/pci/pcie/aer.c +56
-0+ +return true; +} + +static bool cxl_error_is_native (struct pci_dev *dev) +{ +struct pci_host_bridge *host =pci_find_host_bridge (dev->bus); + +if (pcie_ports_native) +return true; + +return host->native_aer && host->native_cxl_error; +} + +static bool is_internal_error (struct aer_err_info *info) +{ +if (info->severity ==AER_CORRECTABLE ) +return info->status &PCI_ERR_COR_INTERNAL ; + +return info->status &PCI_ERR_UNC_INTN ; +} + +static int cxl_rch_handle_error_iter (struct pci_dev *dev,void *data) +{ +struct aer_err_info *info = (struct aer_err_info *)data; +const struct pci_error_handlers *err_handler; + +if (!is_cxl_mem_dev (dev) || !cxl_error_is_native (dev)) +return 0 ; + +/* protect dev->driver */ +device_lock (&dev->dev); + + err_handler = dev->driver ? dev->driver->err_handler :NULL ; +if (!err_handler) + goto out; + +if (info->severity ==AER_CORRECTABLE ) { +if (err_handler->cor_error_detected) + err_handler->cor_error_detected (dev); + }else if (err_handler->error_detected) { +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); + } +out: +device_unlock (&dev->dev); +return 0 ; +} + +static void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +{ +/* +* Internal errors of an RCEC indicate an AER error in an +* RCH's downstream port. Check and handle them in the CXL.mem
Quoted 9 lines
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 1027
Quoted 5 lines
drivers/pci/pcie/aer.c +5
-0+* device driver. +*/ +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && +is_internal_error (info)) +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info);This would seem to work generically for RCEC reported errors in a VH topology, so I think the "
_rch" distinction can be dropped.
The pcie_walk_rcec() filters on PCI_EXP_TYPE_RC_END devices. As a result this iterator will not apply to VH mode devices (PCI_EXP_TYPE_ENDPOINT, PCI_EXP_TYPE_ROOT_PORT, PCI_EXP_TYPE_DOWNSTREAM). This series is focused on RCH mode. VH mode port error handling will be addressed in future patchset.
Regards,
Terry
Quoted 38 lines
Quoted 36 lines
drivers/pci/pcie/aer.c +15
-2+} + +#else +static inline void cxl_rch_handle_error (struct pci_dev *dev, +struct aer_err_info *info) { } +#endif +/** -* handle_error_source - handle logging error into an event log +* pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device * @info: comprehensive error information * * Invoked when an error being detected by Root Port. */ -static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) +static void pci_aer_handle_error (struct pci_dev *dev,struct aer_err_info *info) {int aer = dev->aer_cap;@@ -977,6 +1063,12 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)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) +{ +cxl_rch_handle_error (dev, info); +pci_aer_handle_error (dev, info);pci_dev_put (dev); }Signature · 1 line
2.34.1
Re: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
Hi Dan,
I adde danothe comment below.
Quoted 145 lines · Terry Bowman
Hi Dan,
Quoted 75 lines · Dan Williams
Quoted 74 lines · Terry Bowman
From: Robert Richter <[email protected]>
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device,
PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device'scxl_pcidriver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL DevicesCo-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Cc "Oliver O'Halloran" <[email protected]>Cc Bjorn Helgaas <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>--- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-)drivers/pci/pcie/Kconfig +0
-0@@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/Quoted 6 lines
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 53
Quoted 2 lines
drivers/pci/pcie/Kconfig +2
-0+config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)"Why the "for Restricted Hosts (RCH)" clarification? I am seeing nothing that prevents this from working with RCECs on VH topologies.
The same option can be used in VH mode. Will remove the RCH reference.
Quoted 6 lines
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 54
Quoted 2 lines
drivers/pci/pcie/Kconfig +1
-0+ default yMinor, but I think "default PCIEAER" makes it slightly clearer that CXL error handling comes along for the ride with PCIE AER.
We found
Kconfigentries do not typically list a dependancy and the default to be the same. We prefer to leave as 'default y'. If you want we can make your requested change.Quoted 37 lines
Quoted 37 lines
drivers/pci/pcie/Kconfig +9
-0+ depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC #drivers/pci/pcie/aer.c +17
-0@@ -946,14 +946,100 @@ static bool find_source_device(struct pci_dev *parent,return true; } +#ifdef CONFIG_PCIEAER_CXL + +static bool is_cxl_mem_dev (struct pci_dev *dev) +{ +/* +* The capability, status, and control fields in Device 0, +* Function 0 DVSEC control the CXL functionality of the +* entire device (CXL 3.0, 8.1.3). +*/ +if (dev->devfn !=PCI_DEVFN (0 ,0 )) +return false; + +/* +* CXL Memory Devices must have the 502h class code set (CXL +* 3.0, 8.1.12.1). +*/ +if ((dev->class >>8 ) !=PCI_CLASS_MEMORY_CXL )Quoted 9 lines
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 966
Quoted 1 line
drivers/pci/pcie/aer.c +1
-0+return false;Type-2 devices are going to support the same error flows but without advertising the CXL class code. Should this perhaps be something that CXL drivers can opt into by setting a flag in the
pci_dev? It is already the case that the driver needs to be attached for the error handler to be found, so might as well allow the CXL AER handling to be opted-in by the driver as well.
Quoted 5 lines
At the momment type-2 devices are unsupported and the drivers are not available. The absence of CXL class information in type-2 devices will present a challenge in identifying here. We would like to defer making change here and address this in a future a patchset.
CXL type 2 PCIe device AER errors are handled the same as other PCIe devices. Device AER is reported to the OS by the parent root port with the BDF value in the root port's error root src register. Device AER handling flow is different than the RCH handling flow here. The RCH handling discussed here is needed because the RCH dport is missing a BDF and uses a RCEC instead of root port.[1]
[1] - 12.2.1.1 - RCH Downstream Port-detected Errors
Quoted 112 lines
Quoted 56 lines
Quoted 56 lines
drivers/pci/pcie/aer.c +56
-0+ +return true; +} + +static bool cxl_error_is_native (struct pci_dev *dev) +{ +struct pci_host_bridge *host =pci_find_host_bridge (dev->bus); + +if (pcie_ports_native) +return true; + +return host->native_aer && host->native_cxl_error; +} + +static bool is_internal_error (struct aer_err_info *info) +{ +if (info->severity ==AER_CORRECTABLE ) +return info->status &PCI_ERR_COR_INTERNAL ; + +return info->status &PCI_ERR_UNC_INTN ; +} + +static int cxl_rch_handle_error_iter (struct pci_dev *dev,void *data) +{ +struct aer_err_info *info = (struct aer_err_info *)data; +const struct pci_error_handlers *err_handler; + +if (!is_cxl_mem_dev (dev) || !cxl_error_is_native (dev)) +return 0 ; + +/* protect dev->driver */ +device_lock (&dev->dev); + + err_handler = dev->driver ? dev->driver->err_handler :NULL ; +if (!err_handler) + goto out; + +if (info->severity ==AER_CORRECTABLE ) { +if (err_handler->cor_error_detected) + err_handler->cor_error_detected (dev); + }else if (err_handler->error_detected) { +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); + } +out: +device_unlock (&dev->dev); +return 0 ; +} + +static void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +{ +/* +* Internal errors of an RCEC indicate an AER error in an +* RCH's downstream port. Check and handle them in the CXL.mem Quoted 9 lines
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 1027
Quoted 5 lines
drivers/pci/pcie/aer.c +5
-0+* device driver. +*/ +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && +is_internal_error (info)) +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info);This would seem to work generically for RCEC reported errors in a VH topology, so I think the "
_rch" distinction can be dropped.The
pcie_walk_rcec()filters onPCI_EXP_TYPE_RC_ENDdevices. As a result this iterator will not apply to VH mode devices (PCI_EXP_TYPE_ENDPOINT,PCI_EXP_TYPE_ROOT_PORT,PCI_EXP_TYPE_DOWNSTREAM). This series is focused on RCH mode. VH mode port error handling will be addressed in future patchset.Regards,
TerryQuoted 38 lines
Quoted 36 lines
drivers/pci/pcie/aer.c +15
-2+} + +#else +static inline void cxl_rch_handle_error (struct pci_dev *dev, +struct aer_err_info *info) { } +#endif +/** -* handle_error_source - handle logging error into an event log +* pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device * @info: comprehensive error information * * Invoked when an error being detected by Root Port. */ -static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) +static void pci_aer_handle_error (struct pci_dev *dev,struct aer_err_info *info) {int aer = dev->aer_cap;@@ -977,6 +1063,12 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)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) +{ +cxl_rch_handle_error (dev, info); +pci_aer_handle_error (dev, info);pci_dev_put (dev); }Signature · 1 line
2.34.1
Re: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
In reply to Terry BowmanQuoted 94 lines · Terry Bowman
Hi Dan,
Quoted 75 lines · Dan Williams
Quoted 74 lines · Terry Bowman
From: Robert Richter <[email protected]>
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device,
PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device'scxl_pcidriver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL DevicesCo-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Robert Richter <[email protected]>Cc "Oliver O'Halloran" <[email protected]>Cc Bjorn Helgaas <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>--- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-)drivers/pci/pcie/Kconfig +0
-0@@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/Quoted 6 lines
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 53
Quoted 2 lines
drivers/pci/pcie/Kconfig +2
-0+config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)"Why the "for Restricted Hosts (RCH)" clarification? I am seeing nothing that prevents this from working with RCECs on VH topologies.
The same option can be used in VH mode. Will remove the RCH reference.
Quoted 6 lines
drivers/pci/pcie/Kconfig config PCIEAER_INJECT · line 54
Quoted 2 lines
drivers/pci/pcie/Kconfig +1
-0+ default yMinor, but I think "default PCIEAER" makes it slightly clearer that CXL error handling comes along for the ride with PCIE AER.
Quoted 3 lines
We found
Kconfigentries do not typically list a dependancy and the default to be the same. We prefer to leave as 'default y'. If you want we can make your requested change.
The tie breaker would be to follow whatever the local precedent is. Indeed, it looks like "depends with default y" is consistent with other drivers/pci/pcie/Kconfig entries. So I retract my comment.
Quoted 48 lines
Quoted 38 lines
Quoted 38 lines
drivers/pci/pcie/Kconfig +9
-0+ depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC #drivers/pci/pcie/aer.c +17
-0@@ -946,14 +946,100 @@ static bool find_source_device(struct pci_dev *parent,return true; } +#ifdef CONFIG_PCIEAER_CXL + +static bool is_cxl_mem_dev (struct pci_dev *dev) +{ +/* +* The capability, status, and control fields in Device 0, +* Function 0 DVSEC control the CXL functionality of the +* entire device (CXL 3.0, 8.1.3). +*/ +if (dev->devfn !=PCI_DEVFN (0 ,0 )) +return false; + +/* +* CXL Memory Devices must have the 502h class code set (CXL +* 3.0, 8.1.12.1). +*/ +if ((dev->class >>8 ) !=PCI_CLASS_MEMORY_CXL )Quoted 9 lines
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 966
Quoted 1 line
drivers/pci/pcie/aer.c +1
-0+return false;Type-2 devices are going to support the same error flows but without advertising the CXL class code. Should this perhaps be something that CXL drivers can opt into by setting a flag in the
pci_dev? It is already the case that the driver needs to be attached for the error handler to be found, so might as well allow the CXL AER handling to be opted-in by the driver as well.
Quoted 4 lines
At the momment type-2 devices are unsupported and the drivers are not available. The absence of CXL class information in type-2 devices will present a challenge in identifying here. We would like to defer making change here and address this in a future a patchset.
Fair enough.
Quoted 67 lines
Quoted 57 lines
Quoted 57 lines
drivers/pci/pcie/aer.c +56
-0+ +return true; +} + +static bool cxl_error_is_native (struct pci_dev *dev) +{ +struct pci_host_bridge *host =pci_find_host_bridge (dev->bus); + +if (pcie_ports_native) +return true; + +return host->native_aer && host->native_cxl_error; +} + +static bool is_internal_error (struct aer_err_info *info) +{ +if (info->severity ==AER_CORRECTABLE ) +return info->status &PCI_ERR_COR_INTERNAL ; + +return info->status &PCI_ERR_UNC_INTN ; +} + +static int cxl_rch_handle_error_iter (struct pci_dev *dev,void *data) +{ +struct aer_err_info *info = (struct aer_err_info *)data; +const struct pci_error_handlers *err_handler; + +if (!is_cxl_mem_dev (dev) || !cxl_error_is_native (dev)) +return 0 ; + +/* protect dev->driver */ +device_lock (&dev->dev); + + err_handler = dev->driver ? dev->driver->err_handler :NULL ; +if (!err_handler) + goto out; + +if (info->severity ==AER_CORRECTABLE ) { +if (err_handler->cor_error_detected) + err_handler->cor_error_detected (dev); + }else if (err_handler->error_detected) { +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); + } +out: +device_unlock (&dev->dev); +return 0 ; +} + +static void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +{ +/* +* Internal errors of an RCEC indicate an AER error in an +* RCH's downstream port. Check and handle them in the CXL.mem Quoted 9 lines
drivers/pci/pcie/aer.c static bool find_source_device(struct pci_dev *parent, · line 1027
Quoted 5 lines
drivers/pci/pcie/aer.c +5
-0+* device driver. +*/ +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && +is_internal_error (info)) +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info);This would seem to work generically for RCEC reported errors in a VH topology, so I think the "
_rch" distinction can be dropped.
Quoted 4 lines
The
pcie_walk_rcec()filters onPCI_EXP_TYPE_RC_ENDdevices. As a result this iterator will not apply to VH mode devices (PCI_EXP_TYPE_ENDPOINT,PCI_EXP_TYPE_ROOT_PORT,PCI_EXP_TYPE_DOWNSTREAM). This series is focused on RCH mode. VH mode port error handling will be addressed in future patchset.
True, yeah, makes sense. My concern was potential cases where there is an RCEC that needs to be consulted on VH protocol errors, but that can be addressed as you say in a future patchset.
PATCH v10 14/15 PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling
In reply to Terry BowmanFrom: Robert Richter <[email protected]>
AER corrected and uncorrectable internal errors (CIE/UIE) are masked in their corresponding mask registers per default once in power-up state. [1][2] Enable internal errors for RCECs to receive CXL downstream port errors of Restricted CXL Hosts (RCHs).
[1] CXL 3.0 Spec, 12.2.1.1 - RCH Downstream Port Detected Errors
[2] PCIe Base Spec r6.0, 7.8.4.3 Uncorrectable Error Mask Register, 7.8.4.6 Correctable Error Mask Register
--- drivers/pci/pcie/aer.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
drivers/pci/pcie/aer.c +57 -0
@@ -948,6 +948,30 @@ static bool find_source_device(struct pci_dev *parent,#ifdef CONFIG_PCIEAER_CXL +/** +* pci_aer_unmask_internal_errors - unmask internal errors +* @dev: pointer to the pcie_dev data structure +* +* Unmasks internal errors in the Uncorrectable and Correctable Error +* Mask registers. +* +* Note: AER must be enabled and supported by the device which must be +* checked in advance, e.g. with pcie_aer_is_native(). +*/ +static void pci_aer_unmask_internal_errors (struct pci_dev *dev) +{ +int aer = dev->aer_cap; +u32 mask; + +pci_read_config_dword (dev, aer +PCI_ERR_UNCOR_MASK , &mask); + mask &= ~PCI_ERR_UNC_INTN ; +pci_write_config_dword (dev, aer +PCI_ERR_UNCOR_MASK , mask); + +pci_read_config_dword (dev, aer +PCI_ERR_COR_MASK , &mask); + mask &= ~PCI_ERR_COR_INTERNAL ; +pci_write_config_dword (dev, aer +PCI_ERR_COR_MASK , mask); +} +static bool is_cxl_mem_dev (struct pci_dev *dev) {/*
@@ -1027,7 +1051,39 @@ static void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info)pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); } +static int handles_cxl_error_iter (struct pci_dev *dev,void *data) +{ +bool *handles_cxl = data; + +if (!*handles_cxl) + *handles_cxl =is_cxl_mem_dev (dev) &&cxl_error_is_native (dev); + +/* Non-zero terminates iteration */ +return *handles_cxl; +} + +static bool handles_cxl_errors (struct pci_dev *rcec) +{ +bool handles_cxl = false; + +if (pci_pcie_type (rcec) ==PCI_EXP_TYPE_RC_EC && +pcie_aer_is_native (rcec)) +pcie_walk_rcec (rcec, handles_cxl_error_iter, &handles_cxl); + +return handles_cxl; +} + +static void cxl_rch_enable_rcec (struct pci_dev *rcec) +{ +if (!handles_cxl_errors (rcec)) +return ; + +pci_aer_unmask_internal_errors (rcec); +pci_info (rcec,"CXL: Internal errors unmasked" ); +} +#else +static inline void cxl_rch_enable_rcec (struct pci_dev *dev) { }static inline void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) { }#endif
@@ -1428,6 +1484,7 @@ static int aer_probe(struct pcie_device *dev)return status; } +cxl_rch_enable_rcec (port);aer_enable_rootport (rpc);pci_info (port,"enabled with IRQ %d\n" , dev->irq);return 0 ;
Signature · 1 line
2.34.1
PATCH v10 15/15 cxl/core/regs: Rename phys_addr in cxl_map_component_regs()
In reply to Terry BowmanFrom: Robert Richter <[email protected]>
Trivial change that renames variable phys_addr in cxl_map_component_regs() to shorten its length to keep the 80 char size limit for the line and also for consistency between the different paths.
--- drivers/cxl/core/regs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cxl/core/regs.c +3 -3
@@ -217,16 +217,16 @@ int cxl_map_component_regs(const struct cxl_register_map *map,for (i =0 ; i <ARRAY_SIZE (mapinfo); i++) {struct mapinfo *mi = &mapinfo[i]; -resource_size_t phys_addr; +resource_size_t addr;resource_size_t length;if (!mi->rmap->valid)continue ;if (!test_bit (mi->rmap->id, &map_mask))continue ; - phys_addr = map->resource + mi->rmap->offset; + addr = map->resource + mi->rmap->offset; length = mi->rmap->size; - *(mi->addr) =devm_cxl_iomap_block (dev, phys_addr, length); + *(mi->addr) =devm_cxl_iomap_block (dev, addr, length);if (!*(mi->addr))return -ENOMEM ; }
Signature · 1 line
2.34.1