irqreturn_t cxl_slice_irq_err(int irq, void *data) { struct cxl_afu *afu = data; u64 fir_slice, errstat, serr, afu_debug; WARN(irq, "CXL SLICE ERROR interrupt %i\n", irq); serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); fir_slice = cxl_p1n_read(afu, CXL_PSL_FIR_SLICE_An); errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); afu_debug = cxl_p1n_read(afu, CXL_AFU_DEBUG_An); dev_crit(&afu->dev, "PSL_SERR_An: 0x%.16llx\n", serr); dev_crit(&afu->dev, "PSL_FIR_SLICE_An: 0x%.16llx\n", fir_slice); dev_crit(&afu->dev, "CXL_PSL_ErrStat_An: 0x%.16llx\n", errstat); dev_crit(&afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%.16llx\n", afu_debug); cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); return IRQ_HANDLED; }
static int sanitise_afu_regs(struct cxl_afu *afu) { u64 reg; /* * Clear out any regs that contain either an IVTE or address or may be * waiting on an acknowledgement to try to be a bit safer as we bring * it online */ reg = cxl_p2n_read(afu, CXL_AFU_Cntl_An); if ((reg & CXL_AFU_Cntl_An_ES_MASK) != CXL_AFU_Cntl_An_ES_Disabled) { dev_warn(&afu->dev, "WARNING: AFU was not disabled: %#.16llx\n", reg); if (__cxl_afu_reset(afu)) return -EIO; if (cxl_afu_disable(afu)) return -EIO; if (cxl_psl_purge(afu)) return -EIO; } cxl_p1n_write(afu, CXL_PSL_SPAP_An, 0x0000000000000000); cxl_p1n_write(afu, CXL_PSL_IVTE_Limit_An, 0x0000000000000000); cxl_p1n_write(afu, CXL_PSL_IVTE_Offset_An, 0x0000000000000000); cxl_p1n_write(afu, CXL_PSL_AMBAR_An, 0x0000000000000000); cxl_p1n_write(afu, CXL_PSL_SPOffset_An, 0x0000000000000000); cxl_p1n_write(afu, CXL_HAURP_An, 0x0000000000000000); cxl_p2n_write(afu, CXL_CSRP_An, 0x0000000000000000); cxl_p2n_write(afu, CXL_AURP1_An, 0x0000000000000000); cxl_p2n_write(afu, CXL_AURP0_An, 0x0000000000000000); cxl_p2n_write(afu, CXL_SSTP1_An, 0x0000000000000000); cxl_p2n_write(afu, CXL_SSTP0_An, 0x0000000000000000); reg = cxl_p2n_read(afu, CXL_PSL_DSISR_An); if (reg) { dev_warn(&afu->dev, "AFU had pending DSISR: %#.16llx\n", reg); if (reg & CXL_PSL_DSISR_TRANS) cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); else cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); } reg = cxl_p1n_read(afu, CXL_PSL_SERR_An); if (reg) { if (reg & ~0xffff) dev_warn(&afu->dev, "AFU had pending SERR: %#.16llx\n", reg); cxl_p1n_write(afu, CXL_PSL_SERR_An, reg & ~0xffff); } reg = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); if (reg) { dev_warn(&afu->dev, "AFU had pending error status: %#.16llx\n", reg); cxl_p2n_write(afu, CXL_PSL_ErrStat_An, reg); } return 0; }
/* XXX: This is implementation specific */ static irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, u64 errstat) { u64 fir1, fir2, fir_slice, serr, afu_debug; fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); dev_crit(&ctx->afu->dev, "PSL ERROR STATUS: 0x%.16llx\n", errstat); dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%.16llx\n", fir1); dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%.16llx\n", fir2); dev_crit(&ctx->afu->dev, "PSL_SERR_An: 0x%.16llx\n", serr); dev_crit(&ctx->afu->dev, "PSL_FIR_SLICE_An: 0x%.16llx\n", fir_slice); dev_crit(&ctx->afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%.16llx\n", afu_debug); dev_crit(&ctx->afu->dev, "STOPPING CXL TRACE\n"); cxl_stop_trace(ctx->afu->adapter); return cxl_ack_irq(ctx, 0, errstat); }
int cxl_register_serr_irq(struct cxl_afu *afu) { u64 serr; int rc; if ((rc = cxl_register_one_irq(afu->adapter, cxl_slice_irq_err, afu, &afu->serr_hwirq, &afu->serr_virq))) return rc; serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); serr = (serr & 0x00ffffffffff0000ULL) | (afu->serr_hwirq & 0xffff); cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); return 0; }