Add functions to enable and disable CXL isolation interrupts. Use these functions to enable interrupts as part of isolation set up. Signed-off-by: Ben Cheatham <Benjamin.Cheatham@xxxxxxx> --- drivers/cxl/core/core.h | 2 ++ drivers/cxl/core/pci.c | 22 ++++++++++++++++++++++ drivers/cxl/core/port.c | 10 +++++++++- drivers/cxl/cxl.h | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index a84151238e17..4702a1f27318 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -146,4 +146,6 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, u16 *return_code); #endif +void cxl_enable_isolation_interrupts(struct cxl_dport *dport); +void cxl_disable_isolation_interrupts(struct cxl_dport *dport); #endif /* __CXL_CORE_H__ */ diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index c4d8d9690214..89fb6d3854e3 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -1172,6 +1172,28 @@ int cxl_port_update_total_dports(struct cxl_port *port) } EXPORT_SYMBOL_NS_GPL(cxl_port_update_total_dports, "CXL"); +void cxl_enable_isolation_interrupts(struct cxl_dport *dport) +{ + u32 ctrl; + + ctrl = readl(dport->regs.isolation + CXL_ISOLATION_CTRL_OFFSET); + ctrl |= CXL_ISOLATION_CTRL_MEM_INTR_ENABLE; + writel(ctrl, dport->regs.isolation + CXL_ISOLATION_CTRL_OFFSET); + + dev_dbg(dport->dport_dev, "Enabled CXL isolation interrupts\n"); +} + +void cxl_disable_isolation_interrupts(struct cxl_dport *dport) +{ + u32 ctrl; + + ctrl = readl(dport->regs.isolation + CXL_ISOLATION_CTRL_OFFSET); + ctrl &= ~CXL_ISOLATION_CTRL_MEM_INTR_ENABLE; + writel(ctrl, dport->regs.isolation + CXL_ISOLATION_CTRL_OFFSET); + + dev_dbg(dport->dport_dev, "Disabled CXL isolation interrupts\n"); +} + void cxl_enable_isolation(struct cxl_dport *dport) { u32 ctrl; diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index a36440e85647..90588bf927e0 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1236,6 +1236,9 @@ static void cxl_dport_free_interrupts(void *data) struct cxl_dport *dport = data; struct pci_dev *pdev = to_pci_dev(dport->dport_dev); + if (dport->regs.isolation) + cxl_disable_isolation_interrupts(dport); + info = pcie_cxl_dport_get_isolation_info(pdev); if (!info) return; @@ -1272,7 +1275,12 @@ static int cxl_dport_setup_interrupts(struct device *host, if (rc) return rc; - return devm_add_action_or_reset(host, cxl_dport_free_interrupts, dport); + rc = devm_add_action_or_reset(host, cxl_dport_free_interrupts, dport); + if (rc) + return rc; + + cxl_enable_isolation_interrupts(dport); + return 0; } /** diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 9e3ca754251d..62b3ed188949 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -141,6 +141,7 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) #define CXL_ISOLATION_CAP_INTR_MASK GENMASK(31, 27) #define CXL_ISOLATION_CTRL_OFFSET 0x8 #define CXL_ISOLATION_CTRL_MEM_ISO_ENABLE BIT(16) +#define CXL_ISOLATION_CTRL_MEM_INTR_ENABLE BIT(26) #define CXL_ISOLATION_STATUS_OFFSET 0xC #define CXL_ISOLATION_STAT_MEM_ISO BIT(8) #define CXL_ISOLATION_STAT_LNK_DOWN BIT(9) -- 2.34.1