Lines Matching +full:native +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-or-later
16 #include <misc/cxl-base.h>
28 spin_lock(&afu->afu_cntl_lock); in afu_control()
39 dev_warn(&afu->dev, "WARNING: AFU control timed out!\n"); in afu_control()
40 rc = -EBUSY; in afu_control()
44 if (!cxl_ops->link_ok(afu->adapter, afu)) { in afu_control()
45 afu->enabled = enabled; in afu_control()
46 rc = -EIO; in afu_control()
66 afu->enabled = enabled; in afu_control()
69 spin_unlock(&afu->afu_cntl_lock); in afu_control()
106 * Re-enable any masked interrupts when the AFU is not in native_afu_reset()
108 * in dedicated mode. in native_afu_reset()
110 if (afu->current_mode == 0) { in native_afu_reset()
121 if (!cxl_ops->link_ok(afu->adapter, afu)) { in native_afu_check_and_enable()
123 return -EIO; in native_afu_check_and_enable()
125 if (afu->enabled) in native_afu_check_and_enable()
149 if (!cxl_ops->link_ok(afu->adapter, afu)) { in cxl_psl_purge()
150 dev_warn(&afu->dev, "PSL Purge called with link down, ignoring\n"); in cxl_psl_purge()
151 rc = -EIO; in cxl_psl_purge()
167 dev_warn(&afu->dev, "WARNING: PSL Purge timed out!\n"); in cxl_psl_purge()
168 rc = -EBUSY; in cxl_psl_purge()
171 if (!cxl_ops->link_ok(afu->adapter, afu)) { in cxl_psl_purge()
172 rc = -EIO; in cxl_psl_purge()
182 …dev_notice(&afu->dev, "PSL purge terminating pending translation, DSISR: 0x%016llx, DAR: 0x%016llx… in cxl_psl_purge()
186 … dev_notice(&afu->dev, "PSL purge acknowledging pending non-translation fault, DSISR: 0x%016llx\n", in cxl_psl_purge()
195 pr_devel("PSL purged in %lld ns\n", end - start); in cxl_psl_purge()
209 * Most of that junk is really just an overly-complicated way of saying in spa_max_procs()
213 * end_of_PSL_queue_area = SPA_Base + ((n+4) * 128) + (n*8) - 1 in spa_max_procs()
219 return ((spa_size / 8) - 96) / 17; in spa_max_procs()
222 static int cxl_alloc_spa(struct cxl_afu *afu, int mode) in cxl_alloc_spa() argument
227 afu->native->spa_order = -1; in cxl_alloc_spa()
229 afu->native->spa_order++; in cxl_alloc_spa()
230 spa_size = (1 << afu->native->spa_order) * PAGE_SIZE; in cxl_alloc_spa()
233 dev_warn(&afu->dev, "num_of_processes too large for the SPA, limiting to %i (0x%x)\n", in cxl_alloc_spa()
234 afu->native->spa_max_procs, afu->native->spa_size); in cxl_alloc_spa()
235 if (mode != CXL_MODE_DEDICATED) in cxl_alloc_spa()
236 afu->num_procs = afu->native->spa_max_procs; in cxl_alloc_spa()
240 afu->native->spa_size = spa_size; in cxl_alloc_spa()
241 afu->native->spa_max_procs = spa_max_procs(afu->native->spa_size); in cxl_alloc_spa()
242 } while (afu->native->spa_max_procs < afu->num_procs); in cxl_alloc_spa()
244 if (!(afu->native->spa = (struct cxl_process_element *) in cxl_alloc_spa()
245 __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->native->spa_order))) { in cxl_alloc_spa()
247 return -ENOMEM; in cxl_alloc_spa()
249 pr_devel("spa pages: %i afu->spa_max_procs: %i afu->num_procs: %i\n", in cxl_alloc_spa()
250 1<<afu->native->spa_order, afu->native->spa_max_procs, afu->num_procs); in cxl_alloc_spa()
259 afu->native->sw_command_status = (__be64 *)((char *)afu->native->spa + in attach_spa()
260 ((afu->native->spa_max_procs + 3) * 128)); in attach_spa()
262 spap = virt_to_phys(afu->native->spa) & CXL_PSL_SPAP_Addr; in attach_spa()
263 spap |= ((afu->native->spa_size >> (12 - CXL_PSL_SPAP_Size_Shift)) - 1) & CXL_PSL_SPAP_Size; in attach_spa()
266 afu->native->spa, afu->native->spa_max_procs, in attach_spa()
267 afu->native->sw_command_status, spap); in attach_spa()
278 if (afu->native->spa) { in cxl_release_spa()
279 free_pages((unsigned long) afu->native->spa, in cxl_release_spa()
280 afu->native->spa_order); in cxl_release_spa()
281 afu->native->spa = NULL; in cxl_release_spa()
294 pr_devel("CXL adapter - invalidation of all ERAT entries\n"); in cxl_invalidate_all_psl9()
304 dev_warn(&adapter->dev, in cxl_invalidate_all_psl9()
306 return -EBUSY; in cxl_invalidate_all_psl9()
308 if (!cxl_ops->link_ok(adapter, NULL)) in cxl_invalidate_all_psl9()
309 return -EIO; in cxl_invalidate_all_psl9()
326 dev_warn(&adapter->dev, "WARNING: CXL adapter wide TLBIA timed out!\n"); in cxl_invalidate_all_psl8()
327 return -EBUSY; in cxl_invalidate_all_psl8()
329 if (!cxl_ops->link_ok(adapter, NULL)) in cxl_invalidate_all_psl8()
330 return -EIO; in cxl_invalidate_all_psl8()
337 dev_warn(&adapter->dev, "WARNING: CXL adapter wide SLBIA timed out!\n"); in cxl_invalidate_all_psl8()
338 return -EBUSY; in cxl_invalidate_all_psl8()
340 if (!cxl_ops->link_ok(adapter, NULL)) in cxl_invalidate_all_psl8()
341 return -EIO; in cxl_invalidate_all_psl8()
357 if (adapter->native->no_data_cache) { in cxl_data_cache_flush()
370 dev_warn(&adapter->dev, "WARNING: cache flush timed out!\n"); in cxl_data_cache_flush()
371 return -EBUSY; in cxl_data_cache_flush()
374 if (!cxl_ops->link_ok(adapter, NULL)) { in cxl_data_cache_flush()
375 dev_warn(&adapter->dev, "WARNING: link down when flushing cache\n"); in cxl_data_cache_flush()
376 return -EIO; in cxl_data_cache_flush()
410 struct cxl *adapter = ctx->afu->adapter; in slb_invalid()
413 WARN_ON(!mutex_is_locked(&ctx->afu->native->spa_mutex)); in slb_invalid()
416 ((u64)be32_to_cpu(ctx->elem->common.pid) << 32) | in slb_invalid()
417 be32_to_cpu(ctx->elem->lpid)); in slb_invalid()
421 if (!cxl_ops->link_ok(adapter, NULL)) in slb_invalid()
439 WARN_ON(!ctx->afu->enabled); in do_process_element_cmd()
441 ctx->elem->software_state = cpu_to_be32(pe_state); in do_process_element_cmd()
443 *(ctx->afu->native->sw_command_status) = cpu_to_be64(cmd | 0 | ctx->pe); in do_process_element_cmd()
445 cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); in do_process_element_cmd()
448 dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n"); in do_process_element_cmd()
449 rc = -EBUSY; in do_process_element_cmd()
452 if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { in do_process_element_cmd()
453 dev_warn(&ctx->afu->dev, "WARNING: Device link down, aborting Process Element Command!\n"); in do_process_element_cmd()
454 rc = -EIO; in do_process_element_cmd()
457 state = be64_to_cpup(ctx->afu->native->sw_command_status); in do_process_element_cmd()
460 rc = -1; in do_process_element_cmd()
464 (cmd | (cmd >> 16) | ctx->pe)) in do_process_element_cmd()
485 mutex_lock(&ctx->afu->native->spa_mutex); in add_process_element()
486 pr_devel("%s Adding pe: %i started\n", __func__, ctx->pe); in add_process_element()
488 ctx->pe_inserted = true; in add_process_element()
489 pr_devel("%s Adding pe: %i finished\n", __func__, ctx->pe); in add_process_element()
490 mutex_unlock(&ctx->afu->native->spa_mutex); in add_process_element()
499 if (!(ctx->elem->software_state & cpu_to_be32(CXL_PE_SOFTWARE_STATE_V))) in terminate_process_element()
502 mutex_lock(&ctx->afu->native->spa_mutex); in terminate_process_element()
503 pr_devel("%s Terminate pe: %i started\n", __func__, ctx->pe); in terminate_process_element()
508 if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) in terminate_process_element()
511 ctx->elem->software_state = 0; /* Remove Valid bit */ in terminate_process_element()
512 pr_devel("%s Terminate pe: %i finished\n", __func__, ctx->pe); in terminate_process_element()
513 mutex_unlock(&ctx->afu->native->spa_mutex); in terminate_process_element()
521 mutex_lock(&ctx->afu->native->spa_mutex); in remove_process_element()
522 pr_devel("%s Remove pe: %i started\n", __func__, ctx->pe); in remove_process_element()
527 if (cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) in remove_process_element()
531 ctx->pe_inserted = false; in remove_process_element()
534 pr_devel("%s Remove pe: %i finished\n", __func__, ctx->pe); in remove_process_element()
535 mutex_unlock(&ctx->afu->native->spa_mutex); in remove_process_element()
542 if (!ctx->afu->pp_size || ctx->master) { in cxl_assign_psn_space()
543 ctx->psn_phys = ctx->afu->psn_phys; in cxl_assign_psn_space()
544 ctx->psn_size = ctx->afu->adapter->ps_size; in cxl_assign_psn_space()
546 ctx->psn_phys = ctx->afu->psn_phys + in cxl_assign_psn_space()
547 (ctx->afu->native->pp_offset + ctx->afu->pp_size * ctx->pe); in cxl_assign_psn_space()
548 ctx->psn_size = ctx->afu->pp_size; in cxl_assign_psn_space()
556 dev_info(&afu->dev, "Activating AFU directed mode\n"); in activate_afu_directed()
558 afu->num_procs = afu->max_procs_virtualised; in activate_afu_directed()
559 if (afu->native->spa == NULL) { in activate_afu_directed()
561 return -ENOMEM; in activate_afu_directed()
570 afu->current_mode = CXL_MODE_DIRECTED; in activate_afu_directed()
629 return cxl_calculate_sr(ctx->master, ctx->kernel, false, in calculate_sr()
635 bool need_update = (ctx->status == STARTED); in update_ivtes_directed()
644 ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]); in update_ivtes_directed()
645 ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]); in update_ivtes_directed()
669 ctx->elem->ctxtime = 0; /* disable */ in process_element_entry_psl9()
670 ctx->elem->lpid = cpu_to_be32(mfspr(SPRN_LPID)); in process_element_entry_psl9()
671 ctx->elem->haurp = 0; /* disable */ in process_element_entry_psl9()
673 if (ctx->kernel) in process_element_entry_psl9()
676 if (ctx->mm == NULL) { in process_element_entry_psl9()
678 __func__, ctx->pe, pid_nr(ctx->pid)); in process_element_entry_psl9()
679 return -EINVAL; in process_element_entry_psl9()
681 pid = ctx->mm->context.id; in process_element_entry_psl9()
685 if (!(ctx->tidr) && (ctx->assign_tidr)) { in process_element_entry_psl9()
688 return -ENODEV; in process_element_entry_psl9()
689 ctx->tidr = current->thread.tidr; in process_element_entry_psl9()
690 pr_devel("%s: current tidr: %d\n", __func__, ctx->tidr); in process_element_entry_psl9()
693 ctx->elem->common.tid = cpu_to_be32(ctx->tidr); in process_element_entry_psl9()
694 ctx->elem->common.pid = cpu_to_be32(pid); in process_element_entry_psl9()
696 ctx->elem->sr = cpu_to_be64(calculate_sr(ctx)); in process_element_entry_psl9()
698 ctx->elem->common.csrp = 0; /* disable */ in process_element_entry_psl9()
706 if (ctx->irqs.range[0] == 0) { in process_element_entry_psl9()
707 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; in process_element_entry_psl9()
708 ctx->irqs.range[0] = 1; in process_element_entry_psl9()
711 ctx->elem->common.amr = cpu_to_be64(amr); in process_element_entry_psl9()
712 ctx->elem->common.wed = cpu_to_be64(wed); in process_element_entry_psl9()
729 result = cxl_ops->afu_check_and_enable(ctx->afu); in cxl_attach_afu_directed_psl9()
743 ctx->elem->ctxtime = 0; /* disable */ in cxl_attach_afu_directed_psl8()
744 ctx->elem->lpid = cpu_to_be32(mfspr(SPRN_LPID)); in cxl_attach_afu_directed_psl8()
745 ctx->elem->haurp = 0; /* disable */ in cxl_attach_afu_directed_psl8()
746 ctx->elem->u.sdr = cpu_to_be64(mfspr(SPRN_SDR1)); in cxl_attach_afu_directed_psl8()
748 pid = current->pid; in cxl_attach_afu_directed_psl8()
749 if (ctx->kernel) in cxl_attach_afu_directed_psl8()
751 ctx->elem->common.tid = 0; in cxl_attach_afu_directed_psl8()
752 ctx->elem->common.pid = cpu_to_be32(pid); in cxl_attach_afu_directed_psl8()
754 ctx->elem->sr = cpu_to_be64(calculate_sr(ctx)); in cxl_attach_afu_directed_psl8()
756 ctx->elem->common.csrp = 0; /* disable */ in cxl_attach_afu_directed_psl8()
757 ctx->elem->common.u.psl8.aurp0 = 0; /* disable */ in cxl_attach_afu_directed_psl8()
758 ctx->elem->common.u.psl8.aurp1 = 0; /* disable */ in cxl_attach_afu_directed_psl8()
762 ctx->elem->common.u.psl8.sstp0 = cpu_to_be64(ctx->sstp0); in cxl_attach_afu_directed_psl8()
763 ctx->elem->common.u.psl8.sstp1 = cpu_to_be64(ctx->sstp1); in cxl_attach_afu_directed_psl8()
769 if (ctx->irqs.range[0] == 0) { in cxl_attach_afu_directed_psl8()
770 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq; in cxl_attach_afu_directed_psl8()
771 ctx->irqs.range[0] = 1; in cxl_attach_afu_directed_psl8()
776 ctx->elem->common.amr = cpu_to_be64(amr); in cxl_attach_afu_directed_psl8()
777 ctx->elem->common.wed = cpu_to_be64(wed); in cxl_attach_afu_directed_psl8()
780 if ((result = cxl_ops->afu_check_and_enable(ctx->afu))) in cxl_attach_afu_directed_psl8()
788 dev_info(&afu->dev, "Deactivating AFU directed mode\n"); in deactivate_afu_directed()
790 afu->current_mode = 0; in deactivate_afu_directed()
791 afu->num_procs = 0; in deactivate_afu_directed()
798 * stopping an AFU in AFU directed mode is AFU specific, which is not in deactivate_afu_directed()
821 if (afu->adapter->native->sl_ops->needs_reset_before_disable) in deactivate_afu_directed()
822 cxl_ops->afu_reset(afu); in deactivate_afu_directed()
831 dev_info(&afu->dev, "Activating dedicated process mode\n"); in cxl_activate_dedicated_process_psl9()
834 * If XSL is set to dedicated mode (Set in PSL_SCNTL reg), the in cxl_activate_dedicated_process_psl9()
840 afu->num_procs = 1; in cxl_activate_dedicated_process_psl9()
841 if (afu->native->spa == NULL) { in cxl_activate_dedicated_process_psl9()
843 return -ENOMEM; in cxl_activate_dedicated_process_psl9()
850 afu->current_mode = CXL_MODE_DEDICATED; in cxl_activate_dedicated_process_psl9()
857 dev_info(&afu->dev, "Activating dedicated process mode\n"); in cxl_activate_dedicated_process_psl8()
872 afu->current_mode = CXL_MODE_DEDICATED; in cxl_activate_dedicated_process_psl8()
873 afu->num_procs = 1; in cxl_activate_dedicated_process_psl8()
883 ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]); in cxl_update_dedicated_ivtes_psl9()
884 ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]); in cxl_update_dedicated_ivtes_psl9()
890 struct cxl_afu *afu = ctx->afu; in cxl_update_dedicated_ivtes_psl8()
893 (((u64)ctx->irqs.offset[0] & 0xffff) << 48) | in cxl_update_dedicated_ivtes_psl8()
894 (((u64)ctx->irqs.offset[1] & 0xffff) << 32) | in cxl_update_dedicated_ivtes_psl8()
895 (((u64)ctx->irqs.offset[2] & 0xffff) << 16) | in cxl_update_dedicated_ivtes_psl8()
896 ((u64)ctx->irqs.offset[3] & 0xffff)); in cxl_update_dedicated_ivtes_psl8()
898 (((u64)ctx->irqs.range[0] & 0xffff) << 48) | in cxl_update_dedicated_ivtes_psl8()
899 (((u64)ctx->irqs.range[1] & 0xffff) << 32) | in cxl_update_dedicated_ivtes_psl8()
900 (((u64)ctx->irqs.range[2] & 0xffff) << 16) | in cxl_update_dedicated_ivtes_psl8()
901 ((u64)ctx->irqs.range[3] & 0xffff)); in cxl_update_dedicated_ivtes_psl8()
906 struct cxl_afu *afu = ctx->afu; in cxl_attach_dedicated_process_psl9()
914 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) in cxl_attach_dedicated_process_psl9()
915 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in cxl_attach_dedicated_process_psl9()
917 ctx->elem->software_state = cpu_to_be32(CXL_PE_SOFTWARE_STATE_V); in cxl_attach_dedicated_process_psl9()
925 result = cxl_ops->afu_reset(afu); in cxl_attach_dedicated_process_psl9()
934 struct cxl_afu *afu = ctx->afu; in cxl_attach_dedicated_process_psl8()
938 pid = (u64)current->pid << 32; in cxl_attach_dedicated_process_psl8()
939 if (ctx->kernel) in cxl_attach_dedicated_process_psl8()
945 if ((rc = cxl_write_sstp(afu, ctx->sstp0, ctx->sstp1))) in cxl_attach_dedicated_process_psl8()
950 if (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes) in cxl_attach_dedicated_process_psl8()
951 afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in cxl_attach_dedicated_process_psl8()
958 if ((rc = cxl_ops->afu_reset(afu))) in cxl_attach_dedicated_process_psl8()
968 dev_info(&afu->dev, "Deactivating dedicated process mode\n"); in deactivate_dedicated_process()
970 afu->current_mode = 0; in deactivate_dedicated_process()
971 afu->num_procs = 0; in deactivate_dedicated_process()
978 static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode) in native_afu_deactivate_mode() argument
980 if (mode == CXL_MODE_DIRECTED) in native_afu_deactivate_mode()
982 if (mode == CXL_MODE_DEDICATED) in native_afu_deactivate_mode()
987 static int native_afu_activate_mode(struct cxl_afu *afu, int mode) in native_afu_activate_mode() argument
989 if (!mode) in native_afu_activate_mode()
991 if (!(mode & afu->modes_supported)) in native_afu_activate_mode()
992 return -EINVAL; in native_afu_activate_mode()
994 if (!cxl_ops->link_ok(afu->adapter, afu)) { in native_afu_activate_mode()
996 return -EIO; in native_afu_activate_mode()
999 if (mode == CXL_MODE_DIRECTED) in native_afu_activate_mode()
1001 if ((mode == CXL_MODE_DEDICATED) && in native_afu_activate_mode()
1002 (afu->adapter->native->sl_ops->activate_dedicated_process)) in native_afu_activate_mode()
1003 return afu->adapter->native->sl_ops->activate_dedicated_process(afu); in native_afu_activate_mode()
1005 return -EINVAL; in native_afu_activate_mode()
1011 if (!cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)) { in native_attach_process()
1013 return -EIO; in native_attach_process()
1016 ctx->kernel = kernel; in native_attach_process()
1017 if ((ctx->afu->current_mode == CXL_MODE_DIRECTED) && in native_attach_process()
1018 (ctx->afu->adapter->native->sl_ops->attach_afu_directed)) in native_attach_process()
1019 return ctx->afu->adapter->native->sl_ops->attach_afu_directed(ctx, wed, amr); in native_attach_process()
1021 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && in native_attach_process()
1022 (ctx->afu->adapter->native->sl_ops->attach_dedicated_process)) in native_attach_process()
1023 return ctx->afu->adapter->native->sl_ops->attach_dedicated_process(ctx, wed, amr); in native_attach_process()
1025 return -EINVAL; in native_attach_process()
1032 * stop the AFU in dedicated mode (we therefore do not make that in detach_process_native_dedicated()
1046 cxl_ops->afu_reset(ctx->afu); in detach_process_native_dedicated()
1047 cxl_afu_disable(ctx->afu); in detach_process_native_dedicated()
1048 cxl_psl_purge(ctx->afu); in detach_process_native_dedicated()
1054 if (ctx->afu->current_mode == CXL_MODE_DIRECTED) in native_update_ivtes()
1056 if ((ctx->afu->current_mode == CXL_MODE_DEDICATED) && in native_update_ivtes()
1057 (ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes)) in native_update_ivtes()
1058 return ctx->afu->adapter->native->sl_ops->update_dedicated_ivtes(ctx); in native_update_ivtes()
1059 WARN(1, "native_update_ivtes: Bad mode\n"); in native_update_ivtes()
1064 if (!ctx->pe_inserted) in detach_process_native_afu_directed()
1067 return -1; in detach_process_native_afu_directed()
1069 return -1; in detach_process_native_afu_directed()
1078 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) in native_detach_process()
1089 if (!cxl_ops->link_ok(afu->adapter, afu)) in native_get_irq_info()
1090 return -EIO; in native_get_irq_info()
1092 info->dsisr = cxl_p2n_read(afu, CXL_PSL_DSISR_An); in native_get_irq_info()
1093 info->dar = cxl_p2n_read(afu, CXL_PSL_DAR_An); in native_get_irq_info()
1095 info->dsr = cxl_p2n_read(afu, CXL_PSL_DSR_An); in native_get_irq_info()
1096 info->afu_err = cxl_p2n_read(afu, CXL_AFU_ERR_An); in native_get_irq_info()
1097 info->errstat = cxl_p2n_read(afu, CXL_PSL_ErrStat_An); in native_get_irq_info()
1098 info->proc_handle = 0; in native_get_irq_info()
1107 fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL9_FIR1); in cxl_native_irq_dump_regs_psl9()
1109 dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); in cxl_native_irq_dump_regs_psl9()
1110 if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { in cxl_native_irq_dump_regs_psl9()
1111 serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); in cxl_native_irq_dump_regs_psl9()
1112 cxl_afu_decode_psl_serr(ctx->afu, serr); in cxl_native_irq_dump_regs_psl9()
1120 fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); in cxl_native_irq_dump_regs_psl8()
1121 fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); in cxl_native_irq_dump_regs_psl8()
1122 fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); in cxl_native_irq_dump_regs_psl8()
1123 afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); in cxl_native_irq_dump_regs_psl8()
1125 dev_crit(&ctx->afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); in cxl_native_irq_dump_regs_psl8()
1126 dev_crit(&ctx->afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); in cxl_native_irq_dump_regs_psl8()
1127 if (ctx->afu->adapter->native->sl_ops->register_serr_irq) { in cxl_native_irq_dump_regs_psl8()
1128 serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); in cxl_native_irq_dump_regs_psl8()
1129 cxl_afu_decode_psl_serr(ctx->afu, serr); in cxl_native_irq_dump_regs_psl8()
1131 dev_crit(&ctx->afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); in cxl_native_irq_dump_regs_psl8()
1132 dev_crit(&ctx->afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); in cxl_native_irq_dump_regs_psl8()
1139 dev_crit(&ctx->afu->dev, "PSL ERROR STATUS: 0x%016llx\n", errstat); in native_handle_psl_slice_error()
1141 if (ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers) in native_handle_psl_slice_error()
1142 ctx->afu->adapter->native->sl_ops->psl_irq_dump_registers(ctx); in native_handle_psl_slice_error()
1144 if (ctx->afu->adapter->native->sl_ops->debugfs_stop_trace) { in native_handle_psl_slice_error()
1145 dev_crit(&ctx->afu->dev, "STOPPING CXL TRACE\n"); in native_handle_psl_slice_error()
1146 ctx->afu->adapter->native->sl_ops->debugfs_stop_trace(ctx->afu->adapter); in native_handle_psl_slice_error()
1149 return cxl_ops->ack_irq(ctx, 0, errstat); in native_handle_psl_slice_error()
1165 if (cxl_is_translation_fault(afu, irq_info->dsisr)) in cxl_fail_irq_psl()
1183 dev_warn(&afu->dev, in native_irq_multiplexed()
1188 /* Mask the pe-handle from register value */ in native_irq_multiplexed()
1192 if (afu->adapter->native->sl_ops->fail_irq) in native_irq_multiplexed()
1193 return afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); in native_irq_multiplexed()
1198 ctx = idr_find(&afu->contexts_idr, ph); in native_irq_multiplexed()
1200 if (afu->adapter->native->sl_ops->handle_interrupt) in native_irq_multiplexed()
1201 ret = afu->adapter->native->sl_ops->handle_interrupt(irq, ctx, &irq_info); in native_irq_multiplexed()
1208 " %016llx\n(Possible AFU HW issue - was a term/remove acked" in native_irq_multiplexed()
1211 if (afu->adapter->native->sl_ops->fail_irq) in native_irq_multiplexed()
1212 ret = afu->adapter->native->sl_ops->fail_irq(afu, &irq_info); in native_irq_multiplexed()
1226 while (timeout--) { in native_irq_wait()
1227 ph = cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) & 0xffff; in native_irq_wait()
1228 if (ph != ctx->pe) in native_irq_wait()
1230 dsisr = cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An); in native_irq_wait()
1244 dev_warn(&ctx->afu->dev, "WARNING: waiting on DSI for PE %i" in native_irq_wait()
1267 dev_crit(&afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); in native_slice_irq_err()
1268 dev_crit(&afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); in native_slice_irq_err()
1270 dev_crit(&afu->dev, "CXL_PSL_ErrStat_An: 0x%016llx\n", errstat); in native_slice_irq_err()
1271 dev_crit(&afu->dev, "AFU_ERR_An: 0x%.16llx\n", afu_error); in native_slice_irq_err()
1272 dev_crit(&afu->dev, "PSL_DSISR_An: 0x%.16llx\n", dsisr); in native_slice_irq_err()
1278 dev_info(&afu->dev, "Further such interrupts will be masked until the AFU is reset\n"); in native_slice_irq_err()
1288 dev_crit(&adapter->dev, "PSL_FIR: 0x%016llx\n", fir1); in cxl_native_err_irq_dump_regs_psl9()
1297 dev_crit(&adapter->dev, in cxl_native_err_irq_dump_regs_psl8()
1310 dev_crit(&adapter->dev, "PSL_ErrIVTE: 0x%016llx\n", err_ivte); in native_irq_err()
1312 if (adapter->native->sl_ops->debugfs_stop_trace) { in native_irq_err()
1313 dev_crit(&adapter->dev, "STOPPING CXL TRACE\n"); in native_irq_err()
1314 adapter->native->sl_ops->debugfs_stop_trace(adapter); in native_irq_err()
1317 if (adapter->native->sl_ops->err_irq_dump_registers) in native_irq_err()
1318 adapter->native->sl_ops->err_irq_dump_registers(adapter); in native_irq_err()
1327 adapter->irq_name = kasprintf(GFP_KERNEL, "cxl-%s-err", in cxl_native_register_psl_err_irq()
1328 dev_name(&adapter->dev)); in cxl_native_register_psl_err_irq()
1329 if (!adapter->irq_name) in cxl_native_register_psl_err_irq()
1330 return -ENOMEM; in cxl_native_register_psl_err_irq()
1333 &adapter->native->err_hwirq, in cxl_native_register_psl_err_irq()
1334 &adapter->native->err_virq, in cxl_native_register_psl_err_irq()
1335 adapter->irq_name))) { in cxl_native_register_psl_err_irq()
1336 kfree(adapter->irq_name); in cxl_native_register_psl_err_irq()
1337 adapter->irq_name = NULL; in cxl_native_register_psl_err_irq()
1341 cxl_p1_write(adapter, CXL_PSL_ErrIVTE, adapter->native->err_hwirq & 0xffff); in cxl_native_register_psl_err_irq()
1348 if (adapter->native->err_virq == 0 || in cxl_native_release_psl_err_irq()
1349 adapter->native->err_virq != in cxl_native_release_psl_err_irq()
1350 irq_find_mapping(NULL, adapter->native->err_hwirq)) in cxl_native_release_psl_err_irq()
1354 cxl_unmap_irq(adapter->native->err_virq, adapter); in cxl_native_release_psl_err_irq()
1355 cxl_ops->release_one_irq(adapter, adapter->native->err_hwirq); in cxl_native_release_psl_err_irq()
1356 kfree(adapter->irq_name); in cxl_native_release_psl_err_irq()
1357 adapter->native->err_virq = 0; in cxl_native_release_psl_err_irq()
1365 afu->err_irq_name = kasprintf(GFP_KERNEL, "cxl-%s-err", in cxl_native_register_serr_irq()
1366 dev_name(&afu->dev)); in cxl_native_register_serr_irq()
1367 if (!afu->err_irq_name) in cxl_native_register_serr_irq()
1368 return -ENOMEM; in cxl_native_register_serr_irq()
1370 if ((rc = cxl_register_one_irq(afu->adapter, native_slice_irq_err, afu, in cxl_native_register_serr_irq()
1371 &afu->serr_hwirq, in cxl_native_register_serr_irq()
1372 &afu->serr_virq, afu->err_irq_name))) { in cxl_native_register_serr_irq()
1373 kfree(afu->err_irq_name); in cxl_native_register_serr_irq()
1374 afu->err_irq_name = NULL; in cxl_native_register_serr_irq()
1380 serr = (serr & 0x00ffffffffff0000ULL) | (afu->serr_hwirq & 0xffff); in cxl_native_register_serr_irq()
1386 serr = (serr & ~0xff0000007fffffffULL) | (afu->serr_hwirq & 0xffff); in cxl_native_register_serr_irq()
1395 if (afu->serr_virq == 0 || in cxl_native_release_serr_irq()
1396 afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) in cxl_native_release_serr_irq()
1400 cxl_unmap_irq(afu->serr_virq, afu); in cxl_native_release_serr_irq()
1401 cxl_ops->release_one_irq(afu->adapter, afu->serr_hwirq); in cxl_native_release_serr_irq()
1402 kfree(afu->err_irq_name); in cxl_native_release_serr_irq()
1403 afu->serr_virq = 0; in cxl_native_release_serr_irq()
1410 afu->psl_irq_name = kasprintf(GFP_KERNEL, "cxl-%s", in cxl_native_register_psl_irq()
1411 dev_name(&afu->dev)); in cxl_native_register_psl_irq()
1412 if (!afu->psl_irq_name) in cxl_native_register_psl_irq()
1413 return -ENOMEM; in cxl_native_register_psl_irq()
1415 if ((rc = cxl_register_one_irq(afu->adapter, native_irq_multiplexed, in cxl_native_register_psl_irq()
1416 afu, &afu->native->psl_hwirq, &afu->native->psl_virq, in cxl_native_register_psl_irq()
1417 afu->psl_irq_name))) { in cxl_native_register_psl_irq()
1418 kfree(afu->psl_irq_name); in cxl_native_register_psl_irq()
1419 afu->psl_irq_name = NULL; in cxl_native_register_psl_irq()
1426 if (afu->native->psl_virq == 0 || in cxl_native_release_psl_irq()
1427 afu->native->psl_virq != in cxl_native_release_psl_irq()
1428 irq_find_mapping(NULL, afu->native->psl_hwirq)) in cxl_native_release_psl_irq()
1431 cxl_unmap_irq(afu->native->psl_virq, afu); in cxl_native_release_psl_irq()
1432 cxl_ops->release_one_irq(afu->adapter, afu->native->psl_hwirq); in cxl_native_release_psl_irq()
1433 kfree(afu->psl_irq_name); in cxl_native_release_psl_irq()
1434 afu->native->psl_virq = 0; in cxl_native_release_psl_irq()
1455 cxl_p2n_write(ctx->afu, CXL_PSL_TFC_An, tfc); in native_ack_irq()
1457 recover_psl_err(ctx->afu, psl_reset_mask); in native_ack_irq()
1475 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_read64()
1476 return -EIO; in native_afu_cr_read64()
1477 if (unlikely(off >= afu->crs_len)) in native_afu_cr_read64()
1478 return -ERANGE; in native_afu_cr_read64()
1479 *out = in_le64(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_read64()
1480 (cr * afu->crs_len) + off); in native_afu_cr_read64()
1486 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_read32()
1487 return -EIO; in native_afu_cr_read32()
1488 if (unlikely(off >= afu->crs_len)) in native_afu_cr_read32()
1489 return -ERANGE; in native_afu_cr_read32()
1490 *out = in_le32(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_read32()
1491 (cr * afu->crs_len) + off); in native_afu_cr_read32()
1521 if (unlikely(!cxl_ops->link_ok(afu->adapter, afu))) in native_afu_cr_write32()
1522 return -EIO; in native_afu_cr_write32()
1523 if (unlikely(off >= afu->crs_len)) in native_afu_cr_write32()
1524 return -ERANGE; in native_afu_cr_write32()
1525 out_le32(afu->native->afu_desc_mmio + afu->crs_offset + in native_afu_cr_write32()
1526 (cr * afu->crs_len) + off, in); in native_afu_cr_write32()