Skip to content

Commit 9a8920c

Browse files
ktbowmandavejiang
authored andcommitted
cxl: Update RAS handler interfaces to also support CXL Ports
CXL PCIe Port Protocol Error handling support will be added to the CXL drivers in the future. In preparation, rename the existing interfaces to support handling all CXL PCIe Port Protocol Errors. The driver's RAS support functions currently rely on a 'struct cxl_dev_state' type parameter, which is not available for CXL Port devices. However, since the same CXL RAS capability structure is needed across most CXL components and devices, a common handling approach should be adopted. To accommodate this, update the __cxl_handle_cor_ras() and __cxl_handle_ras() functions to use a `struct device` instead of `struct cxl_dev_state`. No functional changes are introduced. [1] CXL 3.1 Spec, 8.2.4 CXL.cache and CXL.mem Registers Signed-off-by: Terry Bowman <terry.bowman@amd.com> Reviewed-by: Alejandro Lucero <alucerop@amd.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Gregory Price <gourry@gourry.net> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Link: https://patch.msgid.link/20260114182055.46029-18-terry.bowman@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent f953b7d commit 9a8920c

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

drivers/cxl/core/core.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port,
147147
#ifdef CONFIG_CXL_RAS
148148
int cxl_ras_init(void);
149149
void cxl_ras_exit(void);
150-
bool cxl_handle_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base);
151-
void cxl_handle_cor_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base);
150+
bool cxl_handle_ras(struct device *dev, void __iomem *ras_base);
151+
void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base);
152152
void cxl_dport_map_rch_aer(struct cxl_dport *dport);
153153
void cxl_disable_rch_root_ints(struct cxl_dport *dport);
154154
void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds);
@@ -157,16 +157,12 @@ static inline int cxl_ras_init(void)
157157
{
158158
return 0;
159159
}
160-
161-
static inline void cxl_ras_exit(void)
162-
{
163-
}
164-
165-
static inline bool cxl_handle_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base)
160+
static inline void cxl_ras_exit(void) { }
161+
static inline bool cxl_handle_ras(struct device *dev, void __iomem *ras_base)
166162
{
167163
return false;
168164
}
169-
static inline void cxl_handle_cor_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base) { }
165+
static inline void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base) { }
170166
static inline void cxl_dport_map_rch_aer(struct cxl_dport *dport) { }
171167
static inline void cxl_disable_rch_root_ints(struct cxl_dport *dport) { }
172168
static inline void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) { }

drivers/cxl/core/ras.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void cxl_dport_init_ras_reporting(struct cxl_dport *dport, struct device *host)
160160
}
161161
EXPORT_SYMBOL_NS_GPL(cxl_dport_init_ras_reporting, "CXL");
162162

163-
void cxl_handle_cor_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base)
163+
void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base)
164164
{
165165
void __iomem *addr;
166166
u32 status;
@@ -172,7 +172,7 @@ void cxl_handle_cor_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base)
172172
status = readl(addr);
173173
if (status & CXL_RAS_CORRECTABLE_STATUS_MASK) {
174174
writel(status & CXL_RAS_CORRECTABLE_STATUS_MASK, addr);
175-
trace_cxl_aer_correctable_error(cxlds->cxlmd, status);
175+
trace_cxl_aer_correctable_error(to_cxl_memdev(dev), status);
176176
}
177177
}
178178

@@ -197,7 +197,7 @@ static void header_log_copy(void __iomem *ras_base, u32 *log)
197197
* Log the state of the RAS status registers and prepare them to log the
198198
* next error status. Return 1 if reset needed.
199199
*/
200-
bool cxl_handle_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base)
200+
bool cxl_handle_ras(struct device *dev, void __iomem *ras_base)
201201
{
202202
u32 hl[CXL_HEADERLOG_SIZE_U32];
203203
void __iomem *addr;
@@ -224,7 +224,7 @@ bool cxl_handle_ras(struct cxl_dev_state *cxlds, void __iomem *ras_base)
224224
}
225225

226226
header_log_copy(ras_base, hl);
227-
trace_cxl_aer_uncorrectable_error(cxlds->cxlmd, status, fe, hl);
227+
trace_cxl_aer_uncorrectable_error(to_cxl_memdev(dev), status, fe, hl);
228228
writel(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK, addr);
229229

230230
return true;
@@ -246,7 +246,7 @@ void cxl_cor_error_detected(struct pci_dev *pdev)
246246
if (cxlds->rcd)
247247
cxl_handle_rdport_errors(cxlds);
248248

249-
cxl_handle_cor_ras(cxlds, cxlds->regs.ras);
249+
cxl_handle_cor_ras(&cxlds->cxlmd->dev, cxlds->regs.ras);
250250
}
251251
}
252252
EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, "CXL");
@@ -275,7 +275,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
275275
* chance the situation is recoverable dump the status of the RAS
276276
* capability registers and bounce the active state of the memdev.
277277
*/
278-
ue = cxl_handle_ras(cxlds, cxlds->regs.ras);
278+
ue = cxl_handle_ras(&cxlds->cxlmd->dev, cxlds->regs.ras);
279279
}
280280

281281

drivers/cxl/core/ras_rch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)
115115

116116
pci_print_aer(pdev, severity, &aer_regs);
117117
if (severity == AER_CORRECTABLE)
118-
cxl_handle_cor_ras(cxlds, dport->regs.ras);
118+
cxl_handle_cor_ras(&cxlds->cxlmd->dev, dport->regs.ras);
119119
else
120-
cxl_handle_ras(cxlds, dport->regs.ras);
120+
cxl_handle_ras(&cxlds->cxlmd->dev, dport->regs.ras);
121121
}

0 commit comments

Comments
 (0)