Skip to content

Commit ef1df6c

Browse files
ktbowmandavejiang
authored andcommitted
cxl/port: Map Port RAS registers
In preparation for CXL VH (Virtual Host) topology protocol error handling, add RAS capability registered mapping for all ports in a CXL VH topology. This includes the RAS capabilities of Switch Upstream Ports, Switch Downstream Ports, Host Bridge Ports ("upstream"), and Root Ports ("downstream") Update cxl_port_add_dport() to map the upstream RAS capability on first 'dport' attach. 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> Co-developed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Tested-by: Terry Bowman <terry.bowman@amd.com> Link: https://patch.msgid.link/20260131000403.2135324-8-dan.j.williams@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 7f5ff74 commit ef1df6c

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

drivers/cxl/core/ras.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,22 @@ void devm_cxl_dport_rch_ras_setup(struct cxl_dport *dport)
166166
}
167167
EXPORT_SYMBOL_NS_GPL(devm_cxl_dport_rch_ras_setup, "CXL");
168168

169+
void devm_cxl_port_ras_setup(struct cxl_port *port)
170+
{
171+
struct cxl_register_map *map = &port->reg_map;
172+
173+
if (!map->component_map.ras.valid) {
174+
dev_dbg(&port->dev, "RAS registers not found\n");
175+
return;
176+
}
177+
178+
map->host = &port->dev;
179+
if (cxl_map_component_regs(map, &port->regs,
180+
BIT(CXL_CM_CAP_CAP_ID_RAS)))
181+
dev_dbg(&port->dev, "Failed to map RAS capability\n");
182+
}
183+
EXPORT_SYMBOL_NS_GPL(devm_cxl_port_ras_setup, "CXL");
184+
169185
void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base)
170186
{
171187
void __iomem *addr;

drivers/cxl/cxl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ struct cxl_dax_region {
607607
* @parent_dport: dport that points to this port in the parent
608608
* @decoder_ida: allocator for decoder ids
609609
* @reg_map: component and ras register mapping parameters
610+
* @regs: mapped component registers
610611
* @nr_dports: number of entries in @dports
611612
* @hdm_end: track last allocated HDM decoder instance for allocation ordering
612613
* @commit_end: cursor to track highest committed decoder for commit ordering
@@ -628,6 +629,7 @@ struct cxl_port {
628629
struct cxl_dport *parent_dport;
629630
struct ida decoder_ida;
630631
struct cxl_register_map reg_map;
632+
struct cxl_component_regs regs;
631633
int nr_dports;
632634
int hdm_end;
633635
int commit_end;

drivers/cxl/cxlpci.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void cxl_cor_error_detected(struct pci_dev *pdev);
8282
pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
8383
pci_channel_state_t state);
8484
void devm_cxl_dport_rch_ras_setup(struct cxl_dport *dport);
85+
void devm_cxl_port_ras_setup(struct cxl_port *port);
8586
#else
8687
static inline void cxl_cor_error_detected(struct pci_dev *pdev) { }
8788

@@ -94,6 +95,10 @@ static inline pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,
9495
static inline void devm_cxl_dport_rch_ras_setup(struct cxl_dport *dport)
9596
{
9697
}
98+
99+
static inline void devm_cxl_port_ras_setup(struct cxl_port *port)
100+
{
101+
}
97102
#endif
98103

99104
#endif /* __CXL_PCI_H__ */

drivers/cxl/port.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ static struct cxl_dport *cxl_port_add_dport(struct cxl_port *port,
192192
rc = devm_cxl_switch_port_decoders_setup(port);
193193
if (rc)
194194
return ERR_PTR(rc);
195+
196+
/*
197+
* RAS setup is optional, either driver operation can continue
198+
* on failure, or the device does not implement RAS registers.
199+
*/
200+
devm_cxl_port_ras_setup(port);
195201
}
196202

197203
dport = devm_cxl_add_dport_by_dev(port, dport_dev);

0 commit comments

Comments
 (0)