* [PATCH v10 09/15] cxl/pci: Update CXL error logging to use RAS register address
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
2023-08-31 17:02 ` [PATCH v10 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors Terry Bowman
` (5 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
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
Co-developed-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/core/pci.c | 44 +++++++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
index c7a7887ebdcf..edfee8035820 100644
--- a/drivers/cxl/core/pci.c
+++ b/drivers/cxl/core/pci.c
@@ -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:
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v10 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
2023-08-31 17:02 ` [PATCH v10 09/15] cxl/pci: Update CXL error logging to use RAS register address Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
2023-09-15 0:27 ` Dan Williams
2023-08-31 17:02 ` [PATCH v10 11/15] cxl/pci: Add RCH downstream port error logging Terry Bowman
` (4 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
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 'struct cxl_dport' for saving a pointer to
the RCH downstream port's AER and RAS registers.
Co-developed-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/core/port.c | 34 ++++++++++++++++++++++++++++++++++
drivers/cxl/core/regs.c | 1 +
drivers/cxl/cxl.h | 12 ++++++++++++
3 files changed, 47 insertions(+)
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 45f8846d8c8a..2a22a7ed4704 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -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);
diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c
index c8562cdbd17b..5cb78b76c757 100644
--- a/drivers/cxl/core/regs.c
+++ b/drivers/cxl/core/regs.c
@@ -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,
diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index b4383697180f..251cda10c283 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -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;
};
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* RE: [PATCH v10 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors
2023-08-31 17:02 ` [PATCH v10 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors Terry Bowman
@ 2023-09-15 0:27 ` Dan Williams
0 siblings, 0 replies; 16+ messages in thread
From: Dan Williams @ 2023-09-15 0:27 UTC (permalink / raw)
To: Terry Bowman, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
Terry Bowman wrote:
> 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 'struct cxl_dport' for saving a pointer to
> the RCH downstream port's AER and RAS registers.
>
> Co-developed-by: Robert Richter <rrichter@amd.com>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/cxl/core/port.c | 34 ++++++++++++++++++++++++++++++++++
> drivers/cxl/core/regs.c | 1 +
> drivers/cxl/cxl.h | 12 ++++++++++++
> 3 files changed, 47 insertions(+)
>
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 45f8846d8c8a..2a22a7ed4704 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -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);
> +
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v10 11/15] cxl/pci: Add RCH downstream port error logging
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
2023-08-31 17:02 ` [PATCH v10 09/15] cxl/pci: Update CXL error logging to use RAS register address Terry Bowman
2023-08-31 17:02 ` [PATCH v10 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
2023-08-31 17:02 ` [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode Terry Bowman
` (3 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
RCH 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.
Co-developed-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/core/pci.c | 101 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
index edfee8035820..1c40270968b6 100644
--- a/drivers/cxl/core/pci.c
+++ b/drivers/cxl/core/pci.c
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
` (2 preceding siblings ...)
2023-08-31 17:02 ` [PATCH v10 11/15] cxl/pci: Add RCH downstream port error logging Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
2023-09-15 18:43 ` Dan Williams
2023-08-31 17:02 ` [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler Terry Bowman
` (2 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
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 <terry.bowman@amd.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/core/core.h | 6 ++++++
drivers/cxl/core/pci.c | 29 +++++++++++++++++++++++++++++
drivers/cxl/core/port.c | 3 +++
3 files changed, 38 insertions(+)
diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
index f470ef5c0a6a..6b037030b936 100644
--- a/drivers/cxl/core/core.h
+++ b/drivers/cxl/core/core.h
@@ -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__ */
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
index 1c40270968b6..e306d3c9638b 100644
--- a/drivers/cxl/core/pci.c
+++ b/drivers/cxl/core/pci.c
@@ -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
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 2a22a7ed4704..d195af72ed65 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* RE: [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
2023-08-31 17:02 ` [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode Terry Bowman
@ 2023-09-15 18:43 ` Dan Williams
2023-09-19 15:08 ` Terry Bowman
0 siblings, 1 reply; 16+ messages in thread
From: Dan Williams @ 2023-09-15 18:43 UTC (permalink / raw)
To: Terry Bowman, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
Terry Bowman wrote:
> 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 <terry.bowman@amd.com>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
[..]
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 2a22a7ed4704..d195af72ed65 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
2023-09-15 18:43 ` Dan Williams
@ 2023-09-19 15:08 ` Terry Bowman
2023-09-26 21:47 ` Dan Williams
0 siblings, 1 reply; 16+ messages in thread
From: Terry Bowman @ 2023-09-19 15:08 UTC (permalink / raw)
To: Dan Williams, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: rrichter, linux-kernel, bhelgaas
Hi Dan,
I added comments below.
On 9/15/23 13:43, Dan Williams wrote:
> Terry Bowman wrote:
>> 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 <terry.bowman@amd.com>
>> Signed-off-by: Robert Richter <rrichter@amd.com>
>> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> [..]
>> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
>> index 2a22a7ed4704..d195af72ed65 100644
>> --- a/drivers/cxl/core/port.c
>> +++ b/drivers/cxl/core/port.c
>> @@ -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".
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode
2023-09-19 15:08 ` Terry Bowman
@ 2023-09-26 21:47 ` Dan Williams
0 siblings, 0 replies; 16+ messages in thread
From: Dan Williams @ 2023-09-26 21:47 UTC (permalink / raw)
To: Terry Bowman, Dan Williams, alison.schofield, vishal.l.verma,
ira.weiny, bwidawsk, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: rrichter, linux-kernel, bhelgaas
Terry Bowman wrote:
> Hi Dan,
>
> I added comments below.
>
> On 9/15/23 13:43, Dan Williams wrote:
> > Terry Bowman wrote:
> >> 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 <terry.bowman@amd.com>
> >> Signed-off-by: Robert Richter <rrichter@amd.com>
> >> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> > [..]
> >> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> >> index 2a22a7ed4704..d195af72ed65 100644
> >> --- a/drivers/cxl/core/port.c
> >> +++ b/drivers/cxl/core/port.c
> >> @@ -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".
>
> 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?
> 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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
` (3 preceding siblings ...)
2023-08-31 17:02 ` [PATCH v10 12/15] cxl/pci: Disable root port interrupts in RCH mode Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
2023-08-31 20:35 ` Dan Williams
2023-08-31 17:02 ` [PATCH v10 14/15] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling Terry Bowman
2023-08-31 17:02 ` [PATCH v10 15/15] cxl/core/regs: Rename phys_addr in cxl_map_component_regs() Terry Bowman
6 siblings, 1 reply; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas,
Oliver O'Halloran, linuxppc-dev, linux-pci
From: Robert Richter <rrichter@amd.com>
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
Co-developed-by: Terry Bowman <terry.bowman@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Cc: "Oliver O'Halloran" <oohall@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-pci@vger.kernel.org
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/pci/pcie/Kconfig | 12 +++++
drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 106 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
index 228652a59f27..4f0e70fafe2d 100644
--- a/drivers/pci/pcie/Kconfig
+++ b/drivers/pci/pcie/Kconfig
@@ -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
#
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index d3344fcf1f79..c354ca5e8f2b 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -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)
+ return false;
+
+ 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
+ * 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);
+}
+
+#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);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* RE: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
2023-08-31 17:02 ` [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler Terry Bowman
@ 2023-08-31 20:35 ` Dan Williams
2023-09-19 20:58 ` Terry Bowman
0 siblings, 1 reply; 16+ messages in thread
From: Dan Williams @ 2023-08-31 20:35 UTC (permalink / raw)
To: Terry Bowman, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas,
Oliver O'Halloran, linuxppc-dev, linux-pci
Terry Bowman wrote:
> From: Robert Richter <rrichter@amd.com>
>
> 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
>
> Co-developed-by: Terry Bowman <terry.bowman@amd.com>
> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> Cc: "Oliver O'Halloran" <oohall@gmail.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-pci@vger.kernel.org
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/pci/pcie/Kconfig | 12 +++++
> drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 106 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
> index 228652a59f27..4f0e70fafe2d 100644
> --- a/drivers/pci/pcie/Kconfig
> +++ b/drivers/pci/pcie/Kconfig
> @@ -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.
> + default y
Minor, but I think "default PCIEAER" makes it slightly clearer that CXL
error handling comes along for the ride with PCIE AER.
> + 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
> #
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index d3344fcf1f79..c354ca5e8f2b 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -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)
> + 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.
> +
> + 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
> + * 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.
> +}
> +
> +#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);
> }
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
2023-08-31 20:35 ` Dan Williams
@ 2023-09-19 20:58 ` Terry Bowman
2023-09-20 15:28 ` Terry Bowman
2023-09-26 23:58 ` Dan Williams
0 siblings, 2 replies; 16+ messages in thread
From: Terry Bowman @ 2023-09-19 20:58 UTC (permalink / raw)
To: Dan Williams, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: rrichter, linux-kernel, bhelgaas, Oliver O'Halloran,
linuxppc-dev, linux-pci
Hi Dan,
On 8/31/23 15:35, Dan Williams wrote:
> Terry Bowman wrote:
>> From: Robert Richter <rrichter@amd.com>
>>
>> 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
>>
>> Co-developed-by: Terry Bowman <terry.bowman@amd.com>
>> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
>> Signed-off-by: Robert Richter <rrichter@amd.com>
>> Cc: "Oliver O'Halloran" <oohall@gmail.com>
>> Cc: Bjorn Helgaas <bhelgaas@google.com>
>> Cc: linuxppc-dev@lists.ozlabs.org
>> Cc: linux-pci@vger.kernel.org
>> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
>> ---
>> drivers/pci/pcie/Kconfig | 12 +++++
>> drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++-
>> 2 files changed, 106 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
>> index 228652a59f27..4f0e70fafe2d 100644
>> --- a/drivers/pci/pcie/Kconfig
>> +++ b/drivers/pci/pcie/Kconfig
>> @@ -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.
>
The same option can be used in VH mode. Will remove the RCH reference.
>
>> + default y
>
> Minor, 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.
>> + 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
>> #
>> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
>> index d3344fcf1f79..c354ca5e8f2b 100644
>> --- a/drivers/pci/pcie/aer.c
>> +++ b/drivers/pci/pcie/aer.c
>> @@ -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)
>> + 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.
>> +
>> + 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
>> + * 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
>> +}
>> +
>> +#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);
>> }
>>
>> --
>> 2.34.1
>>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
2023-09-19 20:58 ` Terry Bowman
@ 2023-09-20 15:28 ` Terry Bowman
2023-09-26 23:58 ` Dan Williams
1 sibling, 0 replies; 16+ messages in thread
From: Terry Bowman @ 2023-09-20 15:28 UTC (permalink / raw)
To: Dan Williams, alison.schofield, vishal.l.verma, ira.weiny,
bwidawsk, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: rrichter, linux-kernel, bhelgaas, Oliver O'Halloran,
linuxppc-dev, linux-pci
Hi Dan,
I adde danothe comment below.
On 9/19/23 15:58, Terry Bowman wrote:
> Hi Dan,
>
> On 8/31/23 15:35, Dan Williams wrote:
>> Terry Bowman wrote:
>>> From: Robert Richter <rrichter@amd.com>
>>>
>>> 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
>>>
>>> Co-developed-by: Terry Bowman <terry.bowman@amd.com>
>>> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
>>> Signed-off-by: Robert Richter <rrichter@amd.com>
>>> Cc: "Oliver O'Halloran" <oohall@gmail.com>
>>> Cc: Bjorn Helgaas <bhelgaas@google.com>
>>> Cc: linuxppc-dev@lists.ozlabs.org
>>> Cc: linux-pci@vger.kernel.org
>>> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>>> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>>> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
>>> ---
>>> drivers/pci/pcie/Kconfig | 12 +++++
>>> drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++-
>>> 2 files changed, 106 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
>>> index 228652a59f27..4f0e70fafe2d 100644
>>> --- a/drivers/pci/pcie/Kconfig
>>> +++ b/drivers/pci/pcie/Kconfig
>>> @@ -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.
>>
>
> The same option can be used in VH mode. Will remove the RCH reference.
>
>>
>>> + default y
>>
>> Minor, 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.
>
>>> + 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
>>> #
>>> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
>>> index d3344fcf1f79..c354ca5e8f2b 100644
>>> --- a/drivers/pci/pcie/aer.c
>>> +++ b/drivers/pci/pcie/aer.c
>>> @@ -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)
>>> + 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.
>
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
>>> +
>>> + 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
>>> + * 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
>
>>> +}
>>> +
>>> +#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);
>>> }
>>>
>>> --
>>> 2.34.1
>>>
>>
>>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
2023-09-19 20:58 ` Terry Bowman
2023-09-20 15:28 ` Terry Bowman
@ 2023-09-26 23:58 ` Dan Williams
1 sibling, 0 replies; 16+ messages in thread
From: Dan Williams @ 2023-09-26 23:58 UTC (permalink / raw)
To: Terry Bowman, Dan Williams, alison.schofield, vishal.l.verma,
ira.weiny, bwidawsk, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: rrichter, linux-kernel, bhelgaas, Oliver O'Halloran,
linuxppc-dev, linux-pci
Terry Bowman wrote:
> Hi Dan,
>
> On 8/31/23 15:35, Dan Williams wrote:
> > Terry Bowman wrote:
> >> From: Robert Richter <rrichter@amd.com>
> >>
> >> 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
> >>
> >> Co-developed-by: Terry Bowman <terry.bowman@amd.com>
> >> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
> >> Signed-off-by: Robert Richter <rrichter@amd.com>
> >> Cc: "Oliver O'Halloran" <oohall@gmail.com>
> >> Cc: Bjorn Helgaas <bhelgaas@google.com>
> >> Cc: linuxppc-dev@lists.ozlabs.org
> >> Cc: linux-pci@vger.kernel.org
> >> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> >> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> >> ---
> >> drivers/pci/pcie/Kconfig | 12 +++++
> >> drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++-
> >> 2 files changed, 106 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
> >> index 228652a59f27..4f0e70fafe2d 100644
> >> --- a/drivers/pci/pcie/Kconfig
> >> +++ b/drivers/pci/pcie/Kconfig
> >> @@ -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.
> >
>
> The same option can be used in VH mode. Will remove the RCH reference.
>
> >
> >> + default y
> >
> > Minor, 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.
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.
>
> >> + 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
> >> #
> >> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> >> index d3344fcf1f79..c354ca5e8f2b 100644
> >> --- a/drivers/pci/pcie/aer.c
> >> +++ b/drivers/pci/pcie/aer.c
> >> @@ -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)
> >> + 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.
Fair enough.
>
> >> +
> >> + 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
> >> + * 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.
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v10 14/15] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
` (4 preceding siblings ...)
2023-08-31 17:02 ` [PATCH v10 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
2023-08-31 17:02 ` [PATCH v10 15/15] cxl/core/regs: Rename phys_addr in cxl_map_component_regs() Terry Bowman
6 siblings, 0 replies; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
From: Robert Richter <rrichter@amd.com>
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
Co-developed-by: Terry Bowman <terry.bowman@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/pci/pcie/aer.c | 57 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index c354ca5e8f2b..916fbca95e53 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v10 15/15] cxl/core/regs: Rename phys_addr in cxl_map_component_regs()
2023-08-31 17:02 [PATCH v10 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Terry Bowman
` (5 preceding siblings ...)
2023-08-31 17:02 ` [PATCH v10 14/15] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling Terry Bowman
@ 2023-08-31 17:02 ` Terry Bowman
6 siblings, 0 replies; 16+ messages in thread
From: Terry Bowman @ 2023-08-31 17:02 UTC (permalink / raw)
To: alison.schofield, vishal.l.verma, ira.weiny, bwidawsk,
dan.j.williams, dave.jiang, Jonathan.Cameron, linux-cxl
Cc: terry.bowman, rrichter, linux-kernel, bhelgaas
From: Robert Richter <rrichter@amd.com>
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.
Signed-off-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/cxl/core/regs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c
index 5cb78b76c757..f8f26fe80489 100644
--- a/drivers/cxl/core/regs.c
+++ b/drivers/cxl/core/regs.c
@@ -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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 16+ messages in thread