Lines Matching refs:afu
22 static int afu_control(struct cxl_afu *afu, u64 command, u64 clear, in afu_control() argument
29 spin_lock(&afu->afu_cntl_lock); in afu_control()
32 trace_cxl_afu_ctrl(afu, command); in afu_control()
34 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in afu_control()
35 cxl_p2n_write(afu, CXL_AFU_Cntl_An, (AFU_Cntl & ~clear) | command); in afu_control()
37 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in afu_control()
40 dev_warn(&afu->dev, "WARNING: AFU control timed out!\n"); in afu_control()
45 if (!cxl_ops->link_ok(afu->adapter, afu)) { in afu_control()
46 afu->enabled = enabled; in afu_control()
54 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in afu_control()
63 cxl_p2n_write(afu, CXL_AFU_Cntl_An, AFU_Cntl & ~CXL_AFU_Cntl_An_RA); in afu_control()
67 afu->enabled = enabled; in afu_control()
69 trace_cxl_afu_ctrl_done(afu, command, rc); in afu_control()
70 spin_unlock(&afu->afu_cntl_lock); in afu_control()
75 static int afu_enable(struct cxl_afu *afu) in afu_enable() argument
79 return afu_control(afu, CXL_AFU_Cntl_An_E, 0, in afu_enable()
84 int cxl_afu_disable(struct cxl_afu *afu) in cxl_afu_disable() argument
88 return afu_control(afu, 0, CXL_AFU_Cntl_An_E, in cxl_afu_disable()
94 static int native_afu_reset(struct cxl_afu *afu) in native_afu_reset() argument
101 rc = afu_control(afu, CXL_AFU_Cntl_An_RA, 0, in native_afu_reset()
111 if (afu->current_mode == 0) { in native_afu_reset()
112 serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); in native_afu_reset()
114 cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); in native_afu_reset()
120 static int native_afu_check_and_enable(struct cxl_afu *afu) in native_afu_check_and_enable() argument
122 if (!cxl_ops->link_ok(afu->adapter, afu)) { in native_afu_check_and_enable()
126 if (afu->enabled) in native_afu_check_and_enable()
128 return afu_enable(afu); in native_afu_check_and_enable()
131 int cxl_psl_purge(struct cxl_afu *afu) in cxl_psl_purge() argument
133 u64 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); in cxl_psl_purge()
134 u64 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in cxl_psl_purge()
141 trace_cxl_psl_ctrl(afu, CXL_PSL_SCNTL_An_Pc); in cxl_psl_purge()
150 if (!cxl_ops->link_ok(afu->adapter, afu)) { in cxl_psl_purge()
151 dev_warn(&afu->dev, "PSL Purge called with link down, ignoring\n"); in cxl_psl_purge()
158 cxl_afu_disable(afu); in cxl_psl_purge()
161 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, in cxl_psl_purge()
164 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); in cxl_psl_purge()
168 dev_warn(&afu->dev, "WARNING: PSL Purge timed out!\n"); in cxl_psl_purge()
172 if (!cxl_ops->link_ok(afu->adapter, afu)) { in cxl_psl_purge()
177 dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in cxl_psl_purge()
182 dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); in cxl_psl_purge()
183 …dev_notice(&afu->dev, "PSL purge terminating pending translation, DSISR: 0x%016llx, DAR: 0x%016llx… in cxl_psl_purge()
185 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); in cxl_psl_purge()
187 … dev_notice(&afu->dev, "PSL purge acknowledging pending non-translation fault, DSISR: 0x%016llx\n", in cxl_psl_purge()
189 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); in cxl_psl_purge()
193 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); in cxl_psl_purge()
198 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, in cxl_psl_purge()
201 trace_cxl_psl_ctrl_done(afu, CXL_PSL_SCNTL_An_Pc, rc); in cxl_psl_purge()
223 static int cxl_alloc_spa(struct cxl_afu *afu, int mode) in cxl_alloc_spa() argument
228 afu->native->spa_order = -1; in cxl_alloc_spa()
230 afu->native->spa_order++; in cxl_alloc_spa()
231 spa_size = (1 << afu->native->spa_order) * PAGE_SIZE; in cxl_alloc_spa()
234 dev_warn(&afu->dev, "num_of_processes too large for the SPA, limiting to %i (0x%x)\n", in cxl_alloc_spa()
235 afu->native->spa_max_procs, afu->native->spa_size); in cxl_alloc_spa()
237 afu->num_procs = afu->native->spa_max_procs; in cxl_alloc_spa()
241 afu->native->spa_size = spa_size; in cxl_alloc_spa()
242 afu->native->spa_max_procs = spa_max_procs(afu->native->spa_size); in cxl_alloc_spa()
243 } while (afu->native->spa_max_procs < afu->num_procs); in cxl_alloc_spa()
245 if (!(afu->native->spa = (struct cxl_process_element *) in cxl_alloc_spa()
246 __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->native->spa_order))) { in cxl_alloc_spa()
251 1<<afu->native->spa_order, afu->native->spa_max_procs, afu->num_procs); in cxl_alloc_spa()
256 static void attach_spa(struct cxl_afu *afu) in attach_spa() argument
260 afu->native->sw_command_status = (__be64 *)((char *)afu->native->spa + in attach_spa()
261 ((afu->native->spa_max_procs + 3) * 128)); in attach_spa()
263 spap = virt_to_phys(afu->native->spa) & CXL_PSL_SPAP_Addr; in attach_spa()
264 spap |= ((afu->native->spa_size >> (12 - CXL_PSL_SPAP_Size_Shift)) - 1) & CXL_PSL_SPAP_Size; in attach_spa()
267 afu->native->spa, afu->native->spa_max_procs, in attach_spa()
268 afu->native->sw_command_status, spap); in attach_spa()
269 cxl_p1n_write(afu, CXL_PSL_SPAP_An, spap); in attach_spa()
272 void cxl_release_spa(struct cxl_afu *afu) in cxl_release_spa() argument
274 if (afu->native->spa) { in cxl_release_spa()
275 free_pages((unsigned long) afu->native->spa, in cxl_release_spa()
276 afu->native->spa_order); in cxl_release_spa()
277 afu->native->spa = NULL; in cxl_release_spa()
383 static int cxl_write_sstp(struct cxl_afu *afu, u64 sstp0, u64 sstp1) in cxl_write_sstp() argument
388 cxl_p2n_write(afu, CXL_SSTP1_An, 0); in cxl_write_sstp()
391 if ((rc = cxl_afu_slbia(afu))) in cxl_write_sstp()
395 cxl_p2n_write(afu, CXL_SSTP0_An, sstp0); in cxl_write_sstp()
398 cxl_p2n_write(afu, CXL_SSTP1_An, sstp1); in cxl_write_sstp()
406 struct cxl *adapter = ctx->afu->adapter; in slb_invalid()
409 WARN_ON(!mutex_is_locked(&ctx->afu->native->spa_mutex)); in slb_invalid()
435 WARN_ON(!ctx->afu->enabled); in do_process_element_cmd()
439 *(ctx->afu->native->sw_command_status) = cpu_to_be64(cmd | 0 | ctx->pe); in do_process_element_cmd()
441 cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); in do_process_element_cmd()
444 dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n"); in do_process_element_cmd()
448 if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { in do_process_element_cmd()
449 dev_warn(&ctx->afu->dev, "WARNING: Device link down, aborting Process Element Command!\n"); in do_process_element_cmd()
453 state = be64_to_cpup(ctx->afu->native->sw_command_status); in do_process_element_cmd()
481 mutex_lock(&ctx->afu->native->spa_mutex); in add_process_element()
486 mutex_unlock(&ctx->afu->native->spa_mutex); in add_process_element()
498 mutex_lock(&ctx->afu->native->spa_mutex); in terminate_process_element()
504 if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) in terminate_process_element()
509 mutex_unlock(&ctx->afu->native->spa_mutex); in terminate_process_element()
517 mutex_lock(&ctx->afu->native->spa_mutex); in remove_process_element()
523 if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) in remove_process_element()
531 mutex_unlock(&ctx->afu->native->spa_mutex); in remove_process_element()
538 if (!ctx->afu->pp_size || ctx->master) { in cxl_assign_psn_space()
539 ctx->psn_phys = ctx->afu->psn_phys; in cxl_assign_psn_space()
540 ctx->psn_size = ctx->afu->adapter->ps_size; in cxl_assign_psn_space()
542 ctx->psn_phys = ctx->afu->psn_phys + in cxl_assign_psn_space()
543 (ctx->afu->native->pp_offset + ctx->afu->pp_size * ctx->pe); in cxl_assign_psn_space()
544 ctx->psn_size = ctx->afu->pp_size; in cxl_assign_psn_space()
548 static int activate_afu_directed(struct cxl_afu *afu) in activate_afu_directed() argument
552 dev_info(&afu->dev, "Activating AFU directed mode\n"); in activate_afu_directed()
554 afu->num_procs = afu->max_procs_virtualised; in activate_afu_directed()
555 if (afu->native->spa == NULL) { in activate_afu_directed()
556 if (cxl_alloc_spa(afu, CXL_MODE_DIRECTED)) in activate_afu_directed()
559 attach_spa(afu); in activate_afu_directed()
561 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_AFU); in activate_afu_directed()
563 cxl_p1n_write(afu, CXL_PSL_AMOR_An, 0xFFFFFFFFFFFFFFFFULL); in activate_afu_directed()
564 cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L); in activate_afu_directed()
566 afu->current_mode = CXL_MODE_DIRECTED; in activate_afu_directed()
568 if ((rc = cxl_chardev_m_afu_add(afu))) in activate_afu_directed()
571 if ((rc = cxl_sysfs_afu_m_add(afu))) in activate_afu_directed()
574 if ((rc = cxl_chardev_s_afu_add(afu))) in activate_afu_directed()
579 cxl_sysfs_afu_m_remove(afu); in activate_afu_directed()
581 cxl_chardev_afu_remove(afu); in activate_afu_directed()
703 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; in process_element_entry_psl9()
725 result = cxl_ops->afu_check_and_enable(ctx->afu); in cxl_attach_afu_directed_psl9()
766 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; in cxl_attach_afu_directed_psl8()
776 if ((result = cxl_ops->afu_check_and_enable(ctx->afu))) in cxl_attach_afu_directed_psl8()
782 static int deactivate_afu_directed(struct cxl_afu *afu) in deactivate_afu_directed() argument
784 dev_info(&afu->dev, "Deactivating AFU directed mode\n"); in deactivate_afu_directed()
786 afu->current_mode = 0; in deactivate_afu_directed()
787 afu->num_procs = 0; in deactivate_afu_directed()
789 cxl_sysfs_afu_m_remove(afu); in deactivate_afu_directed()
790 cxl_chardev_afu_remove(afu); in deactivate_afu_directed()
817 if (afu->adapter->native->sl_ops->needs_reset_before_disable) in deactivate_afu_directed()
818 cxl_ops->afu_reset(afu); in deactivate_afu_directed()
819 cxl_afu_disable(afu); in deactivate_afu_directed()
820 cxl_psl_purge(afu); in deactivate_afu_directed()
825 int cxl_activate_dedicated_process_psl9(struct cxl_afu *afu) in cxl_activate_dedicated_process_psl9() argument
827 dev_info(&afu->dev, "Activating dedicated process mode\n"); in cxl_activate_dedicated_process_psl9()
836 afu->num_procs = 1; in cxl_activate_dedicated_process_psl9()
837 if (afu->native->spa == NULL) { in cxl_activate_dedicated_process_psl9()
838 if (cxl_alloc_spa(afu, CXL_MODE_DEDICATED)) in cxl_activate_dedicated_process_psl9()
841 attach_spa(afu); in cxl_activate_dedicated_process_psl9()
843 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_Process); in cxl_activate_dedicated_process_psl9()
844 cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L); in cxl_activate_dedicated_process_psl9()
846 afu->current_mode = CXL_MODE_DEDICATED; in cxl_activate_dedicated_process_psl9()
848 return cxl_chardev_d_afu_add(afu); in cxl_activate_dedicated_process_psl9()
851 int cxl_activate_dedicated_process_psl8(struct cxl_afu *afu) in cxl_activate_dedicated_process_psl8() argument
853 dev_info(&afu->dev, "Activating dedicated process mode\n"); in cxl_activate_dedicated_process_psl8()
855 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_Process); in cxl_activate_dedicated_process_psl8()
857 cxl_p1n_write(afu, CXL_PSL_CtxTime_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
858 cxl_p1n_write(afu, CXL_PSL_SPAP_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
859 cxl_p1n_write(afu, CXL_PSL_AMOR_An, 0xFFFFFFFFFFFFFFFFULL); in cxl_activate_dedicated_process_psl8()
860 cxl_p1n_write(afu, CXL_PSL_LPID_An, mfspr(SPRN_LPID)); in cxl_activate_dedicated_process_psl8()
861 cxl_p1n_write(afu, CXL_HAURP_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
862 cxl_p1n_write(afu, CXL_PSL_SDR_An, mfspr(SPRN_SDR1)); in cxl_activate_dedicated_process_psl8()
864 cxl_p2n_write(afu, CXL_CSRP_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
865 cxl_p2n_write(afu, CXL_AURP0_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
866 cxl_p2n_write(afu, CXL_AURP1_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
868 afu->current_mode = CXL_MODE_DEDICATED; in cxl_activate_dedicated_process_psl8()
869 afu->num_procs = 1; in cxl_activate_dedicated_process_psl8()
871 return cxl_chardev_d_afu_add(afu); in cxl_activate_dedicated_process_psl8()
886 struct cxl_afu *afu = ctx->afu; in cxl_update_dedicated_ivtes_psl8() local
888 cxl_p1n_write(afu, CXL_PSL_IVTE_Offset_An, in cxl_update_dedicated_ivtes_psl8()
893 cxl_p1n_write(afu, CXL_PSL_IVTE_Limit_An, (u64) in cxl_update_dedicated_ivtes_psl8()
902 struct cxl_afu *afu = ctx->afu; in cxl_attach_dedicated_process_psl9() local
910 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) in cxl_attach_dedicated_process_psl9()
911 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in cxl_attach_dedicated_process_psl9()
921 result = cxl_ops->afu_reset(afu); in cxl_attach_dedicated_process_psl9()
925 return afu_enable(afu); in cxl_attach_dedicated_process_psl9()
930 struct cxl_afu *afu = ctx->afu; in cxl_attach_dedicated_process_psl8() local
937 cxl_p2n_write(afu, CXL_PSL_PID_TID_An, pid); in cxl_attach_dedicated_process_psl8()
939 cxl_p1n_write(afu, CXL_PSL_SR_An, calculate_sr(ctx)); in cxl_attach_dedicated_process_psl8()
941 if ((rc = cxl_write_sstp(afu, ctx->sstp0, ctx->sstp1))) in cxl_attach_dedicated_process_psl8()
946 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) in cxl_attach_dedicated_process_psl8()
947 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in cxl_attach_dedicated_process_psl8()
949 cxl_p2n_write(afu, CXL_PSL_AMR_An, amr); in cxl_attach_dedicated_process_psl8()
954 if ((rc = cxl_ops->afu_reset(afu))) in cxl_attach_dedicated_process_psl8()
957 cxl_p2n_write(afu, CXL_PSL_WED_An, wed); in cxl_attach_dedicated_process_psl8()
959 return afu_enable(afu); in cxl_attach_dedicated_process_psl8()
962 static int deactivate_dedicated_process(struct cxl_afu *afu) in deactivate_dedicated_process() argument
964 dev_info(&afu->dev, "Deactivating dedicated process mode\n"); in deactivate_dedicated_process()
966 afu->current_mode = 0; in deactivate_dedicated_process()
967 afu->num_procs = 0; in deactivate_dedicated_process()
969 cxl_chardev_afu_remove(afu); in deactivate_dedicated_process()
974 static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode) in native_afu_deactivate_mode() argument
977 return deactivate_afu_directed(afu); in native_afu_deactivate_mode()
979 return deactivate_dedicated_process(afu); in native_afu_deactivate_mode()
983 static int native_afu_activate_mode(struct cxl_afu *afu, int mode) in native_afu_activate_mode() argument
987 if (!(mode & afu->modes_supported)) in native_afu_activate_mode()
990 if (!cxl_ops->link_ok(afu->adapter, afu)) { in native_afu_activate_mode()
996 return activate_afu_directed(afu); in native_afu_activate_mode()
998 (afu->adapter->native->sl_ops->activate_dedicated_process)) in native_afu_activate_mode()
999 return afu->adapter->native->sl_ops->activate_dedicated_process(afu); in native_afu_activate_mode()
1007 if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { in native_attach_process()
1013 if ((ctx->afu->current_mode == CXL_MODE_DIRECTED) && in native_attach_process()
1014 (ctx->afu->adapter->native->sl_ops->attach_afu_directed)) in native_attach_process()
1015 return ctx->afu->adapter->native->sl_ops->attach_afu_directed(ctx, wed, amr); in native_attach_process()
1017 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && in native_attach_process()
1018 (ctx->afu->adapter->native->sl_ops->attach_dedicated_process)) in native_attach_process()
1019 return ctx->afu->adapter->native->sl_ops->attach_dedicated_process(ctx, wed, amr); in native_attach_process()
1042 cxl_ops->afu_reset(ctx->afu); in detach_process_native_dedicated()
1043 cxl_afu_disable(ctx->afu); in detach_process_native_dedicated()
1044 cxl_psl_purge(ctx->afu); in detach_process_native_dedicated()
1050 if (ctx->afu->current_mode == CXL_MODE_DIRECTED) in native_update_ivtes()
1052 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && in native_update_ivtes()
1053 (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes)) in native_update_ivtes()
1054 return ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in native_update_ivtes()
1074 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) in native_detach_process()
1080 static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info) in native_get_irq_info() argument
1085 if (!cxl_ops->link_ok(afu->adapter, afu)) in native_get_irq_info()
1088 info->dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in native_get_irq_info()
1089 info->dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); in native_get_irq_info()
1091 info->dsr = cxl_p2n_read(afu, CXL_PSL_DSR_An); in native_get_irq_info()
1092 info->afu_err = cxl_p2n_read(afu, CXL_AFU_ERR_An); in native_get_irq_info()
1093 info->errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); in native_get_irq_info()
1103 fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR1); in cxl_native_irq_dump_regs_psl9()
1105 dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); in cxl_native_irq_dump_regs_psl9()
1106 if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { in cxl_native_irq_dump_regs_psl9()
1107 serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); in cxl_native_irq_dump_regs_psl9()
1108 cxl_afu_decode_psl_serr(ctx->afu, serr); in cxl_native_irq_dump_regs_psl9()
1116 fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); in cxl_native_irq_dump_regs_psl8()
1117 fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); in cxl_native_irq_dump_regs_psl8()
1118 fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); in cxl_native_irq_dump_regs_psl8()
1119 afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); in cxl_native_irq_dump_regs_psl8()
1121 dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); in cxl_native_irq_dump_regs_psl8()
1122 dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); in cxl_native_irq_dump_regs_psl8()
1123 if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { in cxl_native_irq_dump_regs_psl8()
1124 serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); in cxl_native_irq_dump_regs_psl8()
1125 cxl_afu_decode_psl_serr(ctx->afu, serr); in cxl_native_irq_dump_regs_psl8()
1127 dev_crit(&ctx->afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); in cxl_native_irq_dump_regs_psl8()
1128 dev_crit(&ctx->afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); in cxl_native_irq_dump_regs_psl8()
1135 dev_crit(&ctx->afu->dev, "PSL ERROR STATUS: 0x%016llx\n", errstat); in native_handle_psl_slice_error()
1137 if (ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers) in native_handle_psl_slice_error()
1138 ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers(ctx); in native_handle_psl_slice_error()
1140 if (ctx->afu->adapter->native->sl_ops->debugfs_stop_trace) { in native_handle_psl_slice_error()
1141 dev_crit(&ctx->afu->dev, "STOPPING CXL TRACE\n"); in native_handle_psl_slice_error()
1142 ctx->afu->adapter->native->sl_ops->debugfs_stop_trace(ctx->afu->adapter); in native_handle_psl_slice_error()
1148 static bool cxl_is_translation_fault(struct cxl_afu *afu, u64 dsisr) in cxl_is_translation_fault() argument
1159 irqreturn_t cxl_fail_irq_psl(struct cxl_afu *afu, struct cxl_irq_info *irq_info) in cxl_fail_irq_psl() argument
1161 if (cxl_is_translation_fault(afu, irq_info->dsisr)) in cxl_fail_irq_psl()
1162 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); in cxl_fail_irq_psl()
1164 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); in cxl_fail_irq_psl()
1171 struct cxl_afu *afu = data; in native_irq_multiplexed() local
1174 u64 phreg = cxl_p2n_read(afu, CXL_PSL_PEHandle_An); in native_irq_multiplexed()
1179 dev_warn(&afu->dev, in native_irq_multiplexed()
1186 if ((res = native_get_irq_info(afu, &irq_info))) { in native_irq_multiplexed()
1188 if (afu->adapter->native->sl_ops->fail_irq) in native_irq_multiplexed()
1189 return afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); in native_irq_multiplexed()
1194 ctx = idr_find(&afu->contexts_idr, ph); in native_irq_multiplexed()
1196 if (afu->adapter->native->sl_ops->handle_interrupt) in native_irq_multiplexed()
1197 ret = afu->adapter->native->sl_ops->handle_interrupt(irq, ctx, &irq_info); in native_irq_multiplexed()
1207 if (afu->adapter->native->sl_ops->fail_irq) in native_irq_multiplexed()
1208 ret = afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); in native_irq_multiplexed()
1223 ph = cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) & 0xffff; in native_irq_wait()
1226 dsisr = cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An); in native_irq_wait()
1240 dev_warn(&ctx->afu->dev, "WARNING: waiting on DSI for PE %i" in native_irq_wait()
1247 struct cxl_afu *afu = data; in native_slice_irq_err() local
1254 serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); in native_slice_irq_err()
1255 errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); in native_slice_irq_err()
1256 afu_error = cxl_p2n_read(afu, CXL_AFU_ERR_An); in native_slice_irq_err()
1257 dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in native_slice_irq_err()
1258 cxl_afu_decode_psl_serr(afu, serr); in native_slice_irq_err()
1261 fir_slice = cxl_p1n_read(afu, CXL_PSL_FIR_SLICE_An); in native_slice_irq_err()
1262 afu_debug = cxl_p1n_read(afu, CXL_AFU_DEBUG_An); in native_slice_irq_err()
1263 dev_crit(&afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); in native_slice_irq_err()
1264 dev_crit(&afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); in native_slice_irq_err()
1266 dev_crit(&afu->dev, "CXL_PSL_ErrStat_An: 0x%016llx\n", errstat); in native_slice_irq_err()
1267 dev_crit(&afu->dev, "AFU_ERR_An: 0x%.16llx\n", afu_error); in native_slice_irq_err()
1268 dev_crit(&afu->dev, "PSL_DSISR_An: 0x%.16llx\n", dsisr); in native_slice_irq_err()
1273 cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); in native_slice_irq_err()
1274 dev_info(&afu->dev, "Further such interrupts will be masked until the AFU is reset\n"); in native_slice_irq_err()
1356 int cxl_native_register_serr_irq(struct cxl_afu *afu) in cxl_native_register_serr_irq() argument
1361 afu->err_irq_name = kasprintf(GFP_KERNEL, "cxl-%s-err", in cxl_native_register_serr_irq()
1362 dev_name(&afu->dev)); in cxl_native_register_serr_irq()
1363 if (!afu->err_irq_name) in cxl_native_register_serr_irq()
1366 if ((rc = cxl_register_one_irq(afu->adapter, native_slice_irq_err, afu, in cxl_native_register_serr_irq()
1367 &afu->serr_hwirq, in cxl_native_register_serr_irq()
1368 &afu->serr_virq, afu->err_irq_name))) { in cxl_native_register_serr_irq()
1369 kfree(afu->err_irq_name); in cxl_native_register_serr_irq()
1370 afu->err_irq_name = NULL; in cxl_native_register_serr_irq()
1374 serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); in cxl_native_register_serr_irq()
1376 serr = (serr & 0x00ffffffffff0000ULL) | (afu->serr_hwirq & 0xffff); in cxl_native_register_serr_irq()
1382 serr = (serr & ~0xff0000007fffffffULL) | (afu->serr_hwirq & 0xffff); in cxl_native_register_serr_irq()
1384 cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); in cxl_native_register_serr_irq()
1389 void cxl_native_release_serr_irq(struct cxl_afu *afu) in cxl_native_release_serr_irq() argument
1391 if (afu->serr_virq == 0 || in cxl_native_release_serr_irq()
1392 afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) in cxl_native_release_serr_irq()
1395 cxl_p1n_write(afu, CXL_PSL_SERR_An, 0x0000000000000000); in cxl_native_release_serr_irq()
1396 cxl_unmap_irq(afu->serr_virq, afu); in cxl_native_release_serr_irq()
1397 cxl_ops->release_one_irq(afu->adapter, afu->serr_hwirq); in cxl_native_release_serr_irq()
1398 kfree(afu->err_irq_name); in cxl_native_release_serr_irq()
1399 afu->serr_virq = 0; in cxl_native_release_serr_irq()
1402 int cxl_native_register_psl_irq(struct cxl_afu *afu) in cxl_native_register_psl_irq() argument
1406 afu->psl_irq_name = kasprintf(GFP_KERNEL, "cxl-%s", in cxl_native_register_psl_irq()
1407 dev_name(&afu->dev)); in cxl_native_register_psl_irq()
1408 if (!afu->psl_irq_name) in cxl_native_register_psl_irq()
1411 if ((rc = cxl_register_one_irq(afu->adapter, native_irq_multiplexed, in cxl_native_register_psl_irq()
1412 afu, &afu->native->psl_hwirq, &afu->native->psl_virq, in cxl_native_register_psl_irq()
1413 afu->psl_irq_name))) { in cxl_native_register_psl_irq()
1414 kfree(afu->psl_irq_name); in cxl_native_register_psl_irq()
1415 afu->psl_irq_name = NULL; in cxl_native_register_psl_irq()
1420 void cxl_native_release_psl_irq(struct cxl_afu *afu) in cxl_native_release_psl_irq() argument
1422 if (afu->native->psl_virq == 0 || in cxl_native_release_psl_irq()
1423 afu->native->psl_virq != in cxl_native_release_psl_irq()
1424 irq_find_mapping(NULL, afu->native->psl_hwirq)) in cxl_native_release_psl_irq()
1427 cxl_unmap_irq(afu->native->psl_virq, afu); in cxl_native_release_psl_irq()
1428 cxl_ops->release_one_irq(afu->adapter, afu->native->psl_hwirq); in cxl_native_release_psl_irq()
1429 kfree(afu->psl_irq_name); in cxl_native_release_psl_irq()
1430 afu->native->psl_virq = 0; in cxl_native_release_psl_irq()
1433 static void recover_psl_err(struct cxl_afu *afu, u64 errstat) in recover_psl_err() argument
1440 dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in recover_psl_err()
1441 cxl_p2n_write(afu, CXL_PSL_DSISR_An, dsisr & ~CXL_PSL_DSISR_An_PE); in recover_psl_err()
1444 cxl_p2n_write(afu, CXL_PSL_ErrStat_An, errstat); in recover_psl_err()
1451 cxl_p2n_write(ctx->afu, CXL_PSL_TFC_An, tfc); in native_ack_irq()
1453 recover_psl_err(ctx->afu, psl_reset_mask); in native_ack_irq()
1458 int cxl_check_error(struct cxl_afu *afu) in cxl_check_error() argument
1460 return (cxl_p1n_read(afu, CXL_PSL_SCNTL_An) == ~0ULL); in cxl_check_error()
1469 static int native_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out) in native_afu_cr_read64() argument
1471 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_read64()
1473 if (unlikely(off >= afu->crs_len)) in native_afu_cr_read64()
1475 *out = in_le64(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_read64()
1476 (cr * afu->crs_len) + off); in native_afu_cr_read64()
1480 static int native_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off, u32 *out) in native_afu_cr_read32() argument
1482 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_read32()
1484 if (unlikely(off >= afu->crs_len)) in native_afu_cr_read32()
1486 *out = in_le32(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_read32()
1487 (cr * afu->crs_len) + off); in native_afu_cr_read32()
1491 static int native_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off, u16 *out) in native_afu_cr_read16() argument
1497 rc = native_afu_cr_read32(afu, cr, aligned_off, &val); in native_afu_cr_read16()
1503 static int native_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off, u8 *out) in native_afu_cr_read8() argument
1509 rc = native_afu_cr_read32(afu, cr, aligned_off, &val); in native_afu_cr_read8()
1515 static int native_afu_cr_write32(struct cxl_afu *afu, int cr, u64 off, u32 in) in native_afu_cr_write32() argument
1517 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_write32()
1519 if (unlikely(off >= afu->crs_len)) in native_afu_cr_write32()
1521 out_le32(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_write32()
1522 (cr * afu->crs_len) + off, in); in native_afu_cr_write32()
1526 static int native_afu_cr_write16(struct cxl_afu *afu, int cr, u64 off, u16 in) in native_afu_cr_write16() argument
1532 rc = native_afu_cr_read32(afu, cr, aligned_off, &val32); in native_afu_cr_write16()
1540 rc = native_afu_cr_write32(afu, cr, aligned_off, val32); in native_afu_cr_write16()
1544 static int native_afu_cr_write8(struct cxl_afu *afu, int cr, u64 off, u8 in) in native_afu_cr_write8() argument
1550 rc = native_afu_cr_read32(afu, cr, aligned_off, &val32); in native_afu_cr_write8()
1557 rc = native_afu_cr_write32(afu, cr, aligned_off, val32); in native_afu_cr_write8()