Lines Matching refs:afu
25 static int afu_control(struct cxl_afu *afu, u64 command, u64 clear, in afu_control() argument
32 spin_lock(&afu->afu_cntl_lock); in afu_control()
35 trace_cxl_afu_ctrl(afu, command); in afu_control()
37 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in afu_control()
38 cxl_p2n_write(afu, CXL_AFU_Cntl_An, (AFU_Cntl & ~clear) | command); in afu_control()
40 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in afu_control()
43 dev_warn(&afu->dev, "WARNING: AFU control timed out!\n"); in afu_control()
48 if (!cxl_ops->link_ok(afu->adapter, afu)) { in afu_control()
49 afu->enabled = enabled; in afu_control()
57 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in afu_control()
66 cxl_p2n_write(afu, CXL_AFU_Cntl_An, AFU_Cntl & ~CXL_AFU_Cntl_An_RA); in afu_control()
70 afu->enabled = enabled; in afu_control()
72 trace_cxl_afu_ctrl_done(afu, command, rc); in afu_control()
73 spin_unlock(&afu->afu_cntl_lock); in afu_control()
78 static int afu_enable(struct cxl_afu *afu) in afu_enable() argument
82 return afu_control(afu, CXL_AFU_Cntl_An_E, 0, in afu_enable()
87 int cxl_afu_disable(struct cxl_afu *afu) in cxl_afu_disable() argument
91 return afu_control(afu, 0, CXL_AFU_Cntl_An_E, in cxl_afu_disable()
97 static int native_afu_reset(struct cxl_afu *afu) in native_afu_reset() argument
104 rc = afu_control(afu, CXL_AFU_Cntl_An_RA, 0, in native_afu_reset()
114 if (afu->current_mode == 0) { in native_afu_reset()
115 serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); in native_afu_reset()
117 cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); in native_afu_reset()
123 static int native_afu_check_and_enable(struct cxl_afu *afu) in native_afu_check_and_enable() argument
125 if (!cxl_ops->link_ok(afu->adapter, afu)) { in native_afu_check_and_enable()
129 if (afu->enabled) in native_afu_check_and_enable()
131 return afu_enable(afu); in native_afu_check_and_enable()
134 int cxl_psl_purge(struct cxl_afu *afu) in cxl_psl_purge() argument
136 u64 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); in cxl_psl_purge()
137 u64 AFU_Cntl = cxl_p2n_read(afu, CXL_AFU_Cntl_An); in cxl_psl_purge()
144 trace_cxl_psl_ctrl(afu, CXL_PSL_SCNTL_An_Pc); in cxl_psl_purge()
153 if (!cxl_ops->link_ok(afu->adapter, afu)) { in cxl_psl_purge()
154 dev_warn(&afu->dev, "PSL Purge called with link down, ignoring\n"); in cxl_psl_purge()
161 cxl_afu_disable(afu); in cxl_psl_purge()
164 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, in cxl_psl_purge()
167 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); in cxl_psl_purge()
171 dev_warn(&afu->dev, "WARNING: PSL Purge timed out!\n"); in cxl_psl_purge()
175 if (!cxl_ops->link_ok(afu->adapter, afu)) { in cxl_psl_purge()
180 dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in cxl_psl_purge()
185 dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); in cxl_psl_purge()
186 …dev_notice(&afu->dev, "PSL purge terminating pending translation, DSISR: 0x%016llx, DAR: 0x%016llx… in cxl_psl_purge()
188 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); in cxl_psl_purge()
190 … dev_notice(&afu->dev, "PSL purge acknowledging pending non-translation fault, DSISR: 0x%016llx\n", in cxl_psl_purge()
192 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); in cxl_psl_purge()
196 PSL_CNTL = cxl_p1n_read(afu, CXL_PSL_SCNTL_An); in cxl_psl_purge()
201 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, in cxl_psl_purge()
204 trace_cxl_psl_ctrl_done(afu, CXL_PSL_SCNTL_An_Pc, rc); in cxl_psl_purge()
226 static int cxl_alloc_spa(struct cxl_afu *afu, int mode) in cxl_alloc_spa() argument
231 afu->native->spa_order = -1; in cxl_alloc_spa()
233 afu->native->spa_order++; in cxl_alloc_spa()
234 spa_size = (1 << afu->native->spa_order) * PAGE_SIZE; in cxl_alloc_spa()
237 dev_warn(&afu->dev, "num_of_processes too large for the SPA, limiting to %i (0x%x)\n", in cxl_alloc_spa()
238 afu->native->spa_max_procs, afu->native->spa_size); in cxl_alloc_spa()
240 afu->num_procs = afu->native->spa_max_procs; in cxl_alloc_spa()
244 afu->native->spa_size = spa_size; in cxl_alloc_spa()
245 afu->native->spa_max_procs = spa_max_procs(afu->native->spa_size); in cxl_alloc_spa()
246 } while (afu->native->spa_max_procs < afu->num_procs); in cxl_alloc_spa()
248 if (!(afu->native->spa = (struct cxl_process_element *) in cxl_alloc_spa()
249 __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->native->spa_order))) { in cxl_alloc_spa()
254 1<<afu->native->spa_order, afu->native->spa_max_procs, afu->num_procs); in cxl_alloc_spa()
259 static void attach_spa(struct cxl_afu *afu) in attach_spa() argument
263 afu->native->sw_command_status = (__be64 *)((char *)afu->native->spa + in attach_spa()
264 ((afu->native->spa_max_procs + 3) * 128)); in attach_spa()
266 spap = virt_to_phys(afu->native->spa) & CXL_PSL_SPAP_Addr; in attach_spa()
267 spap |= ((afu->native->spa_size >> (12 - CXL_PSL_SPAP_Size_Shift)) - 1) & CXL_PSL_SPAP_Size; in attach_spa()
270 afu->native->spa, afu->native->spa_max_procs, in attach_spa()
271 afu->native->sw_command_status, spap); in attach_spa()
272 cxl_p1n_write(afu, CXL_PSL_SPAP_An, spap); in attach_spa()
275 static inline void detach_spa(struct cxl_afu *afu) in detach_spa() argument
277 cxl_p1n_write(afu, CXL_PSL_SPAP_An, 0); in detach_spa()
280 void cxl_release_spa(struct cxl_afu *afu) in cxl_release_spa() argument
282 if (afu->native->spa) { in cxl_release_spa()
283 free_pages((unsigned long) afu->native->spa, in cxl_release_spa()
284 afu->native->spa_order); in cxl_release_spa()
285 afu->native->spa = NULL; in cxl_release_spa()
391 static int cxl_write_sstp(struct cxl_afu *afu, u64 sstp0, u64 sstp1) in cxl_write_sstp() argument
396 cxl_p2n_write(afu, CXL_SSTP1_An, 0); in cxl_write_sstp()
399 if ((rc = cxl_afu_slbia(afu))) in cxl_write_sstp()
403 cxl_p2n_write(afu, CXL_SSTP0_An, sstp0); in cxl_write_sstp()
406 cxl_p2n_write(afu, CXL_SSTP1_An, sstp1); in cxl_write_sstp()
414 struct cxl *adapter = ctx->afu->adapter; in slb_invalid()
417 WARN_ON(!mutex_is_locked(&ctx->afu->native->spa_mutex)); in slb_invalid()
443 WARN_ON(!ctx->afu->enabled); in do_process_element_cmd()
447 *(ctx->afu->native->sw_command_status) = cpu_to_be64(cmd | 0 | ctx->pe); in do_process_element_cmd()
449 cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); in do_process_element_cmd()
452 dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n"); in do_process_element_cmd()
456 if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { in do_process_element_cmd()
457 dev_warn(&ctx->afu->dev, "WARNING: Device link down, aborting Process Element Command!\n"); in do_process_element_cmd()
461 state = be64_to_cpup(ctx->afu->native->sw_command_status); in do_process_element_cmd()
489 mutex_lock(&ctx->afu->native->spa_mutex); in add_process_element()
494 mutex_unlock(&ctx->afu->native->spa_mutex); in add_process_element()
506 mutex_lock(&ctx->afu->native->spa_mutex); in terminate_process_element()
512 if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) in terminate_process_element()
517 mutex_unlock(&ctx->afu->native->spa_mutex); in terminate_process_element()
525 mutex_lock(&ctx->afu->native->spa_mutex); in remove_process_element()
531 if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) in remove_process_element()
539 mutex_unlock(&ctx->afu->native->spa_mutex); in remove_process_element()
546 if (!ctx->afu->pp_size || ctx->master) { in cxl_assign_psn_space()
547 ctx->psn_phys = ctx->afu->psn_phys; in cxl_assign_psn_space()
548 ctx->psn_size = ctx->afu->adapter->ps_size; in cxl_assign_psn_space()
550 ctx->psn_phys = ctx->afu->psn_phys + in cxl_assign_psn_space()
551 (ctx->afu->native->pp_offset + ctx->afu->pp_size * ctx->pe); in cxl_assign_psn_space()
552 ctx->psn_size = ctx->afu->pp_size; in cxl_assign_psn_space()
556 static int activate_afu_directed(struct cxl_afu *afu) in activate_afu_directed() argument
560 dev_info(&afu->dev, "Activating AFU directed mode\n"); in activate_afu_directed()
562 afu->num_procs = afu->max_procs_virtualised; in activate_afu_directed()
563 if (afu->native->spa == NULL) { in activate_afu_directed()
564 if (cxl_alloc_spa(afu, CXL_MODE_DIRECTED)) in activate_afu_directed()
567 attach_spa(afu); in activate_afu_directed()
569 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_AFU); in activate_afu_directed()
571 cxl_p1n_write(afu, CXL_PSL_AMOR_An, 0xFFFFFFFFFFFFFFFFULL); in activate_afu_directed()
572 cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L); in activate_afu_directed()
574 afu->current_mode = CXL_MODE_DIRECTED; in activate_afu_directed()
576 if ((rc = cxl_chardev_m_afu_add(afu))) in activate_afu_directed()
579 if ((rc = cxl_sysfs_afu_m_add(afu))) in activate_afu_directed()
582 if ((rc = cxl_chardev_s_afu_add(afu))) in activate_afu_directed()
587 cxl_sysfs_afu_m_remove(afu); in activate_afu_directed()
589 cxl_chardev_afu_remove(afu); in activate_afu_directed()
711 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; in process_element_entry_psl9()
733 result = cxl_ops->afu_check_and_enable(ctx->afu); in cxl_attach_afu_directed_psl9()
774 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; in cxl_attach_afu_directed_psl8()
784 if ((result = cxl_ops->afu_check_and_enable(ctx->afu))) in cxl_attach_afu_directed_psl8()
790 static int deactivate_afu_directed(struct cxl_afu *afu) in deactivate_afu_directed() argument
792 dev_info(&afu->dev, "Deactivating AFU directed mode\n"); in deactivate_afu_directed()
794 afu->current_mode = 0; in deactivate_afu_directed()
795 afu->num_procs = 0; in deactivate_afu_directed()
797 cxl_sysfs_afu_m_remove(afu); in deactivate_afu_directed()
798 cxl_chardev_afu_remove(afu); in deactivate_afu_directed()
825 if (afu->adapter->native->sl_ops->needs_reset_before_disable) in deactivate_afu_directed()
826 cxl_ops->afu_reset(afu); in deactivate_afu_directed()
827 cxl_afu_disable(afu); in deactivate_afu_directed()
828 cxl_psl_purge(afu); in deactivate_afu_directed()
833 int cxl_activate_dedicated_process_psl9(struct cxl_afu *afu) in cxl_activate_dedicated_process_psl9() argument
835 dev_info(&afu->dev, "Activating dedicated process mode\n"); in cxl_activate_dedicated_process_psl9()
844 afu->num_procs = 1; in cxl_activate_dedicated_process_psl9()
845 if (afu->native->spa == NULL) { in cxl_activate_dedicated_process_psl9()
846 if (cxl_alloc_spa(afu, CXL_MODE_DEDICATED)) in cxl_activate_dedicated_process_psl9()
849 attach_spa(afu); in cxl_activate_dedicated_process_psl9()
851 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_Process); in cxl_activate_dedicated_process_psl9()
852 cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L); in cxl_activate_dedicated_process_psl9()
854 afu->current_mode = CXL_MODE_DEDICATED; in cxl_activate_dedicated_process_psl9()
856 return cxl_chardev_d_afu_add(afu); in cxl_activate_dedicated_process_psl9()
859 int cxl_activate_dedicated_process_psl8(struct cxl_afu *afu) in cxl_activate_dedicated_process_psl8() argument
861 dev_info(&afu->dev, "Activating dedicated process mode\n"); in cxl_activate_dedicated_process_psl8()
863 cxl_p1n_write(afu, CXL_PSL_SCNTL_An, CXL_PSL_SCNTL_An_PM_Process); in cxl_activate_dedicated_process_psl8()
865 cxl_p1n_write(afu, CXL_PSL_CtxTime_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
866 cxl_p1n_write(afu, CXL_PSL_SPAP_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
867 cxl_p1n_write(afu, CXL_PSL_AMOR_An, 0xFFFFFFFFFFFFFFFFULL); in cxl_activate_dedicated_process_psl8()
868 cxl_p1n_write(afu, CXL_PSL_LPID_An, mfspr(SPRN_LPID)); in cxl_activate_dedicated_process_psl8()
869 cxl_p1n_write(afu, CXL_HAURP_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
870 cxl_p1n_write(afu, CXL_PSL_SDR_An, mfspr(SPRN_SDR1)); in cxl_activate_dedicated_process_psl8()
872 cxl_p2n_write(afu, CXL_CSRP_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
873 cxl_p2n_write(afu, CXL_AURP0_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
874 cxl_p2n_write(afu, CXL_AURP1_An, 0); /* disable */ in cxl_activate_dedicated_process_psl8()
876 afu->current_mode = CXL_MODE_DEDICATED; in cxl_activate_dedicated_process_psl8()
877 afu->num_procs = 1; in cxl_activate_dedicated_process_psl8()
879 return cxl_chardev_d_afu_add(afu); in cxl_activate_dedicated_process_psl8()
894 struct cxl_afu *afu = ctx->afu; in cxl_update_dedicated_ivtes_psl8() local
896 cxl_p1n_write(afu, CXL_PSL_IVTE_Offset_An, in cxl_update_dedicated_ivtes_psl8()
901 cxl_p1n_write(afu, CXL_PSL_IVTE_Limit_An, (u64) in cxl_update_dedicated_ivtes_psl8()
910 struct cxl_afu *afu = ctx->afu; in cxl_attach_dedicated_process_psl9() local
918 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) in cxl_attach_dedicated_process_psl9()
919 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in cxl_attach_dedicated_process_psl9()
929 result = cxl_ops->afu_reset(afu); in cxl_attach_dedicated_process_psl9()
933 return afu_enable(afu); in cxl_attach_dedicated_process_psl9()
938 struct cxl_afu *afu = ctx->afu; in cxl_attach_dedicated_process_psl8() local
945 cxl_p2n_write(afu, CXL_PSL_PID_TID_An, pid); in cxl_attach_dedicated_process_psl8()
947 cxl_p1n_write(afu, CXL_PSL_SR_An, calculate_sr(ctx)); in cxl_attach_dedicated_process_psl8()
949 if ((rc = cxl_write_sstp(afu, ctx->sstp0, ctx->sstp1))) in cxl_attach_dedicated_process_psl8()
954 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) in cxl_attach_dedicated_process_psl8()
955 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in cxl_attach_dedicated_process_psl8()
957 cxl_p2n_write(afu, CXL_PSL_AMR_An, amr); in cxl_attach_dedicated_process_psl8()
962 if ((rc = cxl_ops->afu_reset(afu))) in cxl_attach_dedicated_process_psl8()
965 cxl_p2n_write(afu, CXL_PSL_WED_An, wed); in cxl_attach_dedicated_process_psl8()
967 return afu_enable(afu); in cxl_attach_dedicated_process_psl8()
970 static int deactivate_dedicated_process(struct cxl_afu *afu) in deactivate_dedicated_process() argument
972 dev_info(&afu->dev, "Deactivating dedicated process mode\n"); in deactivate_dedicated_process()
974 afu->current_mode = 0; in deactivate_dedicated_process()
975 afu->num_procs = 0; in deactivate_dedicated_process()
977 cxl_chardev_afu_remove(afu); in deactivate_dedicated_process()
982 static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode) in native_afu_deactivate_mode() argument
985 return deactivate_afu_directed(afu); in native_afu_deactivate_mode()
987 return deactivate_dedicated_process(afu); in native_afu_deactivate_mode()
991 static int native_afu_activate_mode(struct cxl_afu *afu, int mode) in native_afu_activate_mode() argument
995 if (!(mode & afu->modes_supported)) in native_afu_activate_mode()
998 if (!cxl_ops->link_ok(afu->adapter, afu)) { in native_afu_activate_mode()
1004 return activate_afu_directed(afu); in native_afu_activate_mode()
1006 (afu->adapter->native->sl_ops->activate_dedicated_process)) in native_afu_activate_mode()
1007 return afu->adapter->native->sl_ops->activate_dedicated_process(afu); in native_afu_activate_mode()
1015 if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { in native_attach_process()
1021 if ((ctx->afu->current_mode == CXL_MODE_DIRECTED) && in native_attach_process()
1022 (ctx->afu->adapter->native->sl_ops->attach_afu_directed)) in native_attach_process()
1023 return ctx->afu->adapter->native->sl_ops->attach_afu_directed(ctx, wed, amr); in native_attach_process()
1025 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && in native_attach_process()
1026 (ctx->afu->adapter->native->sl_ops->attach_dedicated_process)) in native_attach_process()
1027 return ctx->afu->adapter->native->sl_ops->attach_dedicated_process(ctx, wed, amr); in native_attach_process()
1050 cxl_ops->afu_reset(ctx->afu); in detach_process_native_dedicated()
1051 cxl_afu_disable(ctx->afu); in detach_process_native_dedicated()
1052 cxl_psl_purge(ctx->afu); in detach_process_native_dedicated()
1058 if (ctx->afu->current_mode == CXL_MODE_DIRECTED) in native_update_ivtes()
1060 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && in native_update_ivtes()
1061 (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes)) in native_update_ivtes()
1062 return ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in native_update_ivtes()
1082 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) in native_detach_process()
1088 static int native_get_irq_info(struct cxl_afu *afu, struct cxl_irq_info *info) in native_get_irq_info() argument
1093 if (!cxl_ops->link_ok(afu->adapter, afu)) in native_get_irq_info()
1096 info->dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in native_get_irq_info()
1097 info->dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); in native_get_irq_info()
1099 info->dsr = cxl_p2n_read(afu, CXL_PSL_DSR_An); in native_get_irq_info()
1100 info->afu_err = cxl_p2n_read(afu, CXL_AFU_ERR_An); in native_get_irq_info()
1101 info->errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); in native_get_irq_info()
1111 fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR1); in cxl_native_irq_dump_regs_psl9()
1113 dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); in cxl_native_irq_dump_regs_psl9()
1114 if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { in cxl_native_irq_dump_regs_psl9()
1115 serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); in cxl_native_irq_dump_regs_psl9()
1116 cxl_afu_decode_psl_serr(ctx->afu, serr); in cxl_native_irq_dump_regs_psl9()
1124 fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); in cxl_native_irq_dump_regs_psl8()
1125 fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); in cxl_native_irq_dump_regs_psl8()
1126 fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); in cxl_native_irq_dump_regs_psl8()
1127 afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); in cxl_native_irq_dump_regs_psl8()
1129 dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); in cxl_native_irq_dump_regs_psl8()
1130 dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); in cxl_native_irq_dump_regs_psl8()
1131 if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { in cxl_native_irq_dump_regs_psl8()
1132 serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); in cxl_native_irq_dump_regs_psl8()
1133 cxl_afu_decode_psl_serr(ctx->afu, serr); in cxl_native_irq_dump_regs_psl8()
1135 dev_crit(&ctx->afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); in cxl_native_irq_dump_regs_psl8()
1136 dev_crit(&ctx->afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); in cxl_native_irq_dump_regs_psl8()
1143 dev_crit(&ctx->afu->dev, "PSL ERROR STATUS: 0x%016llx\n", errstat); in native_handle_psl_slice_error()
1145 if (ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers) in native_handle_psl_slice_error()
1146 ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers(ctx); in native_handle_psl_slice_error()
1148 if (ctx->afu->adapter->native->sl_ops->debugfs_stop_trace) { in native_handle_psl_slice_error()
1149 dev_crit(&ctx->afu->dev, "STOPPING CXL TRACE\n"); in native_handle_psl_slice_error()
1150 ctx->afu->adapter->native->sl_ops->debugfs_stop_trace(ctx->afu->adapter); in native_handle_psl_slice_error()
1156 static bool cxl_is_translation_fault(struct cxl_afu *afu, u64 dsisr) in cxl_is_translation_fault() argument
1167 irqreturn_t cxl_fail_irq_psl(struct cxl_afu *afu, struct cxl_irq_info *irq_info) in cxl_fail_irq_psl() argument
1169 if (cxl_is_translation_fault(afu, irq_info->dsisr)) in cxl_fail_irq_psl()
1170 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE); in cxl_fail_irq_psl()
1172 cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A); in cxl_fail_irq_psl()
1179 struct cxl_afu *afu = data; in native_irq_multiplexed() local
1182 u64 phreg = cxl_p2n_read(afu, CXL_PSL_PEHandle_An); in native_irq_multiplexed()
1187 dev_warn(&afu->dev, in native_irq_multiplexed()
1194 if ((res = native_get_irq_info(afu, &irq_info))) { in native_irq_multiplexed()
1196 if (afu->adapter->native->sl_ops->fail_irq) in native_irq_multiplexed()
1197 return afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); in native_irq_multiplexed()
1202 ctx = idr_find(&afu->contexts_idr, ph); in native_irq_multiplexed()
1204 if (afu->adapter->native->sl_ops->handle_interrupt) in native_irq_multiplexed()
1205 ret = afu->adapter->native->sl_ops->handle_interrupt(irq, ctx, &irq_info); in native_irq_multiplexed()
1215 if (afu->adapter->native->sl_ops->fail_irq) in native_irq_multiplexed()
1216 ret = afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); in native_irq_multiplexed()
1231 ph = cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) & 0xffff; in native_irq_wait()
1234 dsisr = cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An); in native_irq_wait()
1248 dev_warn(&ctx->afu->dev, "WARNING: waiting on DSI for PE %i" in native_irq_wait()
1255 struct cxl_afu *afu = data; in native_slice_irq_err() local
1262 serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); in native_slice_irq_err()
1263 errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); in native_slice_irq_err()
1264 afu_error = cxl_p2n_read(afu, CXL_AFU_ERR_An); in native_slice_irq_err()
1265 dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in native_slice_irq_err()
1266 cxl_afu_decode_psl_serr(afu, serr); in native_slice_irq_err()
1269 fir_slice = cxl_p1n_read(afu, CXL_PSL_FIR_SLICE_An); in native_slice_irq_err()
1270 afu_debug = cxl_p1n_read(afu, CXL_AFU_DEBUG_An); in native_slice_irq_err()
1271 dev_crit(&afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); in native_slice_irq_err()
1272 dev_crit(&afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); in native_slice_irq_err()
1274 dev_crit(&afu->dev, "CXL_PSL_ErrStat_An: 0x%016llx\n", errstat); in native_slice_irq_err()
1275 dev_crit(&afu->dev, "AFU_ERR_An: 0x%.16llx\n", afu_error); in native_slice_irq_err()
1276 dev_crit(&afu->dev, "PSL_DSISR_An: 0x%.16llx\n", dsisr); in native_slice_irq_err()
1281 cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); in native_slice_irq_err()
1282 dev_info(&afu->dev, "Further such interrupts will be masked until the AFU is reset\n"); in native_slice_irq_err()
1364 int cxl_native_register_serr_irq(struct cxl_afu *afu) in cxl_native_register_serr_irq() argument
1369 afu->err_irq_name = kasprintf(GFP_KERNEL, "cxl-%s-err", in cxl_native_register_serr_irq()
1370 dev_name(&afu->dev)); in cxl_native_register_serr_irq()
1371 if (!afu->err_irq_name) in cxl_native_register_serr_irq()
1374 if ((rc = cxl_register_one_irq(afu->adapter, native_slice_irq_err, afu, in cxl_native_register_serr_irq()
1375 &afu->serr_hwirq, in cxl_native_register_serr_irq()
1376 &afu->serr_virq, afu->err_irq_name))) { in cxl_native_register_serr_irq()
1377 kfree(afu->err_irq_name); in cxl_native_register_serr_irq()
1378 afu->err_irq_name = NULL; in cxl_native_register_serr_irq()
1382 serr = cxl_p1n_read(afu, CXL_PSL_SERR_An); in cxl_native_register_serr_irq()
1384 serr = (serr & 0x00ffffffffff0000ULL) | (afu->serr_hwirq & 0xffff); in cxl_native_register_serr_irq()
1390 serr = (serr & ~0xff0000007fffffffULL) | (afu->serr_hwirq & 0xffff); in cxl_native_register_serr_irq()
1392 cxl_p1n_write(afu, CXL_PSL_SERR_An, serr); in cxl_native_register_serr_irq()
1397 void cxl_native_release_serr_irq(struct cxl_afu *afu) in cxl_native_release_serr_irq() argument
1399 if (afu->serr_virq == 0 || in cxl_native_release_serr_irq()
1400 afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) in cxl_native_release_serr_irq()
1403 cxl_p1n_write(afu, CXL_PSL_SERR_An, 0x0000000000000000); in cxl_native_release_serr_irq()
1404 cxl_unmap_irq(afu->serr_virq, afu); in cxl_native_release_serr_irq()
1405 cxl_ops->release_one_irq(afu->adapter, afu->serr_hwirq); in cxl_native_release_serr_irq()
1406 kfree(afu->err_irq_name); in cxl_native_release_serr_irq()
1407 afu->serr_virq = 0; in cxl_native_release_serr_irq()
1410 int cxl_native_register_psl_irq(struct cxl_afu *afu) in cxl_native_register_psl_irq() argument
1414 afu->psl_irq_name = kasprintf(GFP_KERNEL, "cxl-%s", in cxl_native_register_psl_irq()
1415 dev_name(&afu->dev)); in cxl_native_register_psl_irq()
1416 if (!afu->psl_irq_name) in cxl_native_register_psl_irq()
1419 if ((rc = cxl_register_one_irq(afu->adapter, native_irq_multiplexed, in cxl_native_register_psl_irq()
1420 afu, &afu->native->psl_hwirq, &afu->native->psl_virq, in cxl_native_register_psl_irq()
1421 afu->psl_irq_name))) { in cxl_native_register_psl_irq()
1422 kfree(afu->psl_irq_name); in cxl_native_register_psl_irq()
1423 afu->psl_irq_name = NULL; in cxl_native_register_psl_irq()
1428 void cxl_native_release_psl_irq(struct cxl_afu *afu) in cxl_native_release_psl_irq() argument
1430 if (afu->native->psl_virq == 0 || in cxl_native_release_psl_irq()
1431 afu->native->psl_virq != in cxl_native_release_psl_irq()
1432 irq_find_mapping(NULL, afu->native->psl_hwirq)) in cxl_native_release_psl_irq()
1435 cxl_unmap_irq(afu->native->psl_virq, afu); in cxl_native_release_psl_irq()
1436 cxl_ops->release_one_irq(afu->adapter, afu->native->psl_hwirq); in cxl_native_release_psl_irq()
1437 kfree(afu->psl_irq_name); in cxl_native_release_psl_irq()
1438 afu->native->psl_virq = 0; in cxl_native_release_psl_irq()
1441 static void recover_psl_err(struct cxl_afu *afu, u64 errstat) in recover_psl_err() argument
1448 dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in recover_psl_err()
1449 cxl_p2n_write(afu, CXL_PSL_DSISR_An, dsisr & ~CXL_PSL_DSISR_An_PE); in recover_psl_err()
1452 cxl_p2n_write(afu, CXL_PSL_ErrStat_An, errstat); in recover_psl_err()
1459 cxl_p2n_write(ctx->afu, CXL_PSL_TFC_An, tfc); in native_ack_irq()
1461 recover_psl_err(ctx->afu, psl_reset_mask); in native_ack_irq()
1466 int cxl_check_error(struct cxl_afu *afu) in cxl_check_error() argument
1468 return (cxl_p1n_read(afu, CXL_PSL_SCNTL_An) == ~0ULL); in cxl_check_error()
1477 static int native_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out) in native_afu_cr_read64() argument
1479 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_read64()
1481 if (unlikely(off >= afu->crs_len)) in native_afu_cr_read64()
1483 *out = in_le64(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_read64()
1484 (cr * afu->crs_len) + off); in native_afu_cr_read64()
1488 static int native_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off, u32 *out) in native_afu_cr_read32() argument
1490 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_read32()
1492 if (unlikely(off >= afu->crs_len)) in native_afu_cr_read32()
1494 *out = in_le32(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_read32()
1495 (cr * afu->crs_len) + off); in native_afu_cr_read32()
1499 static int native_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off, u16 *out) in native_afu_cr_read16() argument
1505 rc = native_afu_cr_read32(afu, cr, aligned_off, &val); in native_afu_cr_read16()
1511 static int native_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off, u8 *out) in native_afu_cr_read8() argument
1517 rc = native_afu_cr_read32(afu, cr, aligned_off, &val); in native_afu_cr_read8()
1523 static int native_afu_cr_write32(struct cxl_afu *afu, int cr, u64 off, u32 in) in native_afu_cr_write32() argument
1525 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_write32()
1527 if (unlikely(off >= afu->crs_len)) in native_afu_cr_write32()
1529 out_le32(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_write32()
1530 (cr * afu->crs_len) + off, in); in native_afu_cr_write32()
1534 static int native_afu_cr_write16(struct cxl_afu *afu, int cr, u64 off, u16 in) in native_afu_cr_write16() argument
1540 rc = native_afu_cr_read32(afu, cr, aligned_off, &val32); in native_afu_cr_write16()
1548 rc = native_afu_cr_write32(afu, cr, aligned_off, val32); in native_afu_cr_write16()
1552 static int native_afu_cr_write8(struct cxl_afu *afu, int cr, u64 off, u8 in) in native_afu_cr_write8() argument
1558 rc = native_afu_cr_read32(afu, cr, aligned_off, &val32); in native_afu_cr_write8()
1565 rc = native_afu_cr_write32(afu, cr, aligned_off, val32); in native_afu_cr_write8()