Skip to content

Commit 6c5f3aa

Browse files
ktbowman-amddjbw
authored andcommitted
cxl/pci: Map RCH downstream AER registers for logging protocol errors
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. Create the initializer function devm_cxl_setup_parent_dport() for this when the endpoint is connected with the dport. The initialization sets up the RCH RAS and AER mappings. Add 'struct cxl_regs' to 'struct cxl_dport' for saving a pointer to the RCH downstream port's AER and RAS registers. Signed-off-by: Terry Bowman <terry.bowman@amd.com> Co-developed-by: Robert Richter <rrichter@amd.com> Signed-off-by: Robert Richter <rrichter@amd.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20231018171713.1883517-15-rrichter@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent bf6c9fa commit 6c5f3aa

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

drivers/cxl/core/pci.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/delay.h>
66
#include <linux/pci.h>
77
#include <linux/pci-doe.h>
8+
#include <linux/aer.h>
89
#include <cxlpci.h>
910
#include <cxlmem.h>
1011
#include <cxl.h>
@@ -730,6 +731,38 @@ static bool cxl_handle_endpoint_ras(struct cxl_dev_state *cxlds)
730731

731732
#ifdef CONFIG_PCIEAER_CXL
732733

734+
static void cxl_dport_map_rch_aer(struct cxl_dport *dport)
735+
{
736+
struct cxl_rcrb_info *ri = &dport->rcrb;
737+
void __iomem *dport_aer = NULL;
738+
resource_size_t aer_phys;
739+
struct device *host;
740+
741+
if (dport->rch && ri->aer_cap) {
742+
host = dport->reg_map.host;
743+
aer_phys = ri->aer_cap + ri->base;
744+
dport_aer = devm_cxl_iomap_block(host, aer_phys,
745+
sizeof(struct aer_capability_regs));
746+
}
747+
748+
dport->regs.dport_aer = dport_aer;
749+
}
750+
751+
static void cxl_dport_map_regs(struct cxl_dport *dport)
752+
{
753+
struct cxl_register_map *map = &dport->reg_map;
754+
struct device *dev = dport->dport_dev;
755+
756+
if (!map->component_map.ras.valid)
757+
dev_dbg(dev, "RAS registers not found\n");
758+
else if (cxl_map_component_regs(map, &dport->regs.component,
759+
BIT(CXL_CM_CAP_CAP_ID_RAS)))
760+
dev_dbg(dev, "Failed to map RAS capability.\n");
761+
762+
if (dport->rch)
763+
cxl_dport_map_rch_aer(dport);
764+
}
765+
733766
void cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport)
734767
{
735768
struct device *dport_dev = dport->dport_dev;
@@ -738,6 +771,9 @@ void cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport)
738771
host_bridge = to_pci_host_bridge(dport_dev);
739772
if (host_bridge->native_cxl_error)
740773
dport->rcrb.aer_cap = cxl_rcrb_to_aer(dport_dev, dport->rcrb.base);
774+
775+
dport->reg_map.host = host;
776+
cxl_dport_map_regs(dport);
741777
}
742778
EXPORT_SYMBOL_NS_GPL(cxl_setup_parent_dport, CXL);
743779

drivers/cxl/cxl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ struct cxl_regs {
221221
struct_group_tagged(cxl_pmu_regs, pmu_regs,
222222
void __iomem *pmu;
223223
);
224+
225+
/*
226+
* RCH downstream port specific RAS register
227+
* @aer: CXL 3.0 8.2.1.1 RCH Downstream Port RCRB
228+
*/
229+
struct_group_tagged(cxl_rch_regs, rch_regs,
230+
void __iomem *dport_aer;
231+
);
224232
};
225233

226234
struct cxl_reg_map {
@@ -623,6 +631,7 @@ struct cxl_rcrb_info {
623631
* @rcrb: Data about the Root Complex Register Block layout
624632
* @rch: Indicate whether this dport was enumerated in RCH or VH mode
625633
* @port: reference to cxl_port that contains this downstream port
634+
* @regs: Dport parsed register blocks
626635
*/
627636
struct cxl_dport {
628637
struct device *dport_dev;
@@ -631,6 +640,7 @@ struct cxl_dport {
631640
struct cxl_rcrb_info rcrb;
632641
bool rch;
633642
struct cxl_port *port;
643+
struct cxl_regs regs;
634644
};
635645

636646
/**

0 commit comments

Comments
 (0)