Lines Matching full:gt

65 	struct xe_gt *gt = arg;  in gt_fini()  local
67 destroy_workqueue(gt->ordered_wq); in gt_fini()
72 struct xe_gt *gt; in xe_gt_alloc() local
75 gt = drmm_kzalloc(&tile_to_xe(tile)->drm, sizeof(*gt), GFP_KERNEL); in xe_gt_alloc()
76 if (!gt) in xe_gt_alloc()
79 gt->tile = tile; in xe_gt_alloc()
80 gt->ordered_wq = alloc_ordered_workqueue("gt-ordered-wq", 0); in xe_gt_alloc()
82 err = drmm_add_action_or_reset(&gt_to_xe(gt)->drm, gt_fini, gt); in xe_gt_alloc()
86 return gt; in xe_gt_alloc()
89 void xe_gt_sanitize(struct xe_gt *gt) in xe_gt_sanitize() argument
95 gt->uc.guc.submission_state.enabled = false; in xe_gt_sanitize()
98 static void xe_gt_enable_host_l2_vram(struct xe_gt *gt) in xe_gt_enable_host_l2_vram() argument
103 if (!XE_WA(gt, 16023588340)) in xe_gt_enable_host_l2_vram()
106 err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_enable_host_l2_vram()
110 if (!xe_gt_is_media_type(gt)) { in xe_gt_enable_host_l2_vram()
111 xe_mmio_write32(gt, SCRATCH1LPFC, EN_L3_RW_CCS_CACHE_FLUSH); in xe_gt_enable_host_l2_vram()
112 reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMREQSTRM_CTRL); in xe_gt_enable_host_l2_vram()
114 xe_gt_mcr_multicast_write(gt, XE2_GAMREQSTRM_CTRL, reg); in xe_gt_enable_host_l2_vram()
117 xe_gt_mcr_multicast_write(gt, XEHPC_L3CLOS_MASK(3), 0x3); in xe_gt_enable_host_l2_vram()
118 xe_force_wake_put(gt_to_fw(gt), XE_FW_GT); in xe_gt_enable_host_l2_vram()
121 static void xe_gt_disable_host_l2_vram(struct xe_gt *gt) in xe_gt_disable_host_l2_vram() argument
126 if (!XE_WA(gt, 16023588340)) in xe_gt_disable_host_l2_vram()
129 if (xe_gt_is_media_type(gt)) in xe_gt_disable_host_l2_vram()
132 err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_disable_host_l2_vram()
136 reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMREQSTRM_CTRL); in xe_gt_disable_host_l2_vram()
138 xe_gt_mcr_multicast_write(gt, XE2_GAMREQSTRM_CTRL, reg); in xe_gt_disable_host_l2_vram()
140 xe_force_wake_put(gt_to_fw(gt), XE_FW_GT); in xe_gt_disable_host_l2_vram()
144 * xe_gt_remove() - Clean up the GT structures before driver removal
145 * @gt: the GT object
151 void xe_gt_remove(struct xe_gt *gt) in xe_gt_remove() argument
155 xe_uc_remove(&gt->uc); in xe_gt_remove()
158 xe_hw_fence_irq_finish(&gt->fence_irq[i]); in xe_gt_remove()
160 xe_gt_disable_host_l2_vram(gt); in xe_gt_remove()
165 static int emit_nop_job(struct xe_gt *gt, struct xe_exec_queue *q) in emit_nop_job() argument
172 bb = xe_bb_new(gt, 4, false); in emit_nop_job()
206 static int emit_wa_job(struct xe_gt *gt, struct xe_exec_queue *q) in emit_wa_job() argument
219 bb = xe_bb_new(gt, xe_gt_lrc_size(gt, q->hwe->class), false); in emit_wa_job()
222 bb = xe_bb_new(gt, SZ_4K, false); in emit_wa_job()
231 xe_gt_dbg(gt, "LRC WA %s save-restore batch\n", sr->name); in emit_wa_job()
247 xe_gt_mcr_unicast_read_any(gt, reg_mcr) : in emit_wa_job()
248 xe_mmio_read32(gt, reg)) & (~entry->clr_bits); in emit_wa_job()
256 xe_gt_dbg(gt, "REG[0x%x] = 0x%08x", reg.addr, val); in emit_wa_job()
283 int xe_gt_record_default_lrcs(struct xe_gt *gt) in xe_gt_record_default_lrcs() argument
285 struct xe_device *xe = gt_to_xe(gt); in xe_gt_record_default_lrcs()
290 for_each_hw_engine(hwe, gt, id) { in xe_gt_record_default_lrcs()
294 if (gt->default_lrc[hwe->class]) in xe_gt_record_default_lrcs()
303 xe_gt_lrc_size(gt, hwe->class), in xe_gt_record_default_lrcs()
312 xe_gt_err(gt, "hwe %s: xe_exec_queue_create failed (%pe)\n", in xe_gt_record_default_lrcs()
318 err = emit_wa_job(gt, q); in xe_gt_record_default_lrcs()
320 xe_gt_err(gt, "hwe %s: emit_wa_job failed (%pe) guc_id=%u\n", in xe_gt_record_default_lrcs()
329 xe_gt_err(gt, "hwe %s: nop xe_exec_queue_create failed (%pe)\n", in xe_gt_record_default_lrcs()
335 err = emit_nop_job(gt, nop_q); in xe_gt_record_default_lrcs()
337 xe_gt_err(gt, "hwe %s: nop emit_nop_job failed (%pe) guc_id=%u\n", in xe_gt_record_default_lrcs()
343 err = emit_nop_job(gt, q); in xe_gt_record_default_lrcs()
345 xe_gt_err(gt, "hwe %s: emit_nop_job failed (%pe) guc_id=%u\n", in xe_gt_record_default_lrcs()
353 xe_gt_lrc_size(gt, hwe->class)); in xe_gt_record_default_lrcs()
355 gt->default_lrc[hwe->class] = default_lrc; in xe_gt_record_default_lrcs()
367 int xe_gt_init_early(struct xe_gt *gt) in xe_gt_init_early() argument
371 if (IS_SRIOV_PF(gt_to_xe(gt))) { in xe_gt_init_early()
372 err = xe_gt_sriov_pf_init_early(gt); in xe_gt_init_early()
377 xe_reg_sr_init(&gt->reg_sr, "GT", gt_to_xe(gt)); in xe_gt_init_early()
379 err = xe_wa_init(gt); in xe_gt_init_early()
383 xe_wa_process_gt(gt); in xe_gt_init_early()
384 xe_wa_process_oob(gt); in xe_gt_init_early()
385 xe_tuning_process_gt(gt); in xe_gt_init_early()
387 xe_force_wake_init_gt(gt, gt_to_fw(gt)); in xe_gt_init_early()
388 spin_lock_init(&gt->global_invl_lock); in xe_gt_init_early()
393 static void dump_pat_on_error(struct xe_gt *gt) in dump_pat_on_error() argument
398 snprintf(prefix, sizeof(prefix), "[GT%u Error]", gt->info.id); in dump_pat_on_error()
399 p = drm_dbg_printer(&gt_to_xe(gt)->drm, DRM_UT_DRIVER, prefix); in dump_pat_on_error()
401 xe_pat_dump(gt, &p); in dump_pat_on_error()
404 static int gt_fw_domain_init(struct xe_gt *gt) in gt_fw_domain_init() argument
408 err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in gt_fw_domain_init()
412 if (!xe_gt_is_media_type(gt)) { in gt_fw_domain_init()
413 err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt); in gt_fw_domain_init()
416 if (IS_SRIOV_PF(gt_to_xe(gt))) in gt_fw_domain_init()
417 xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt); in gt_fw_domain_init()
421 xe_irq_enable_hwe(gt); in gt_fw_domain_init()
424 xe_gt_mcr_init(gt); in gt_fw_domain_init()
426 err = xe_hw_engines_init_early(gt); in gt_fw_domain_init()
430 err = xe_hw_engine_class_sysfs_init(gt); in gt_fw_domain_init()
435 err = xe_gt_ccs_mode_sysfs_init(gt); in gt_fw_domain_init()
443 gt->info.gmdid = xe_mmio_read32(gt, GMD_ID); in gt_fw_domain_init()
445 err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT); in gt_fw_domain_init()
451 dump_pat_on_error(gt); in gt_fw_domain_init()
452 xe_force_wake_put(gt_to_fw(gt), XE_FW_GT); in gt_fw_domain_init()
455 xe_hw_fence_irq_finish(&gt->fence_irq[i]); in gt_fw_domain_init()
460 static int all_fw_domain_init(struct xe_gt *gt) in all_fw_domain_init() argument
464 err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); in all_fw_domain_init()
468 xe_gt_mcr_set_implicit_defaults(gt); in all_fw_domain_init()
469 xe_reg_sr_apply_mmio(&gt->reg_sr, gt); in all_fw_domain_init()
471 err = xe_gt_clock_init(gt); in all_fw_domain_init()
475 xe_mocs_init(gt); in all_fw_domain_init()
476 err = xe_execlist_init(gt); in all_fw_domain_init()
480 err = xe_hw_engines_init(gt); in all_fw_domain_init()
484 err = xe_uc_init_post_hwconfig(&gt->uc); in all_fw_domain_init()
488 if (!xe_gt_is_media_type(gt)) { in all_fw_domain_init()
492 if (gt_to_xe(gt)->info.has_usm) { in all_fw_domain_init()
493 struct xe_device *xe = gt_to_xe(gt); in all_fw_domain_init()
495 gt->usm.bb_pool = xe_sa_bo_manager_init(gt_to_tile(gt), in all_fw_domain_init()
497 if (IS_ERR(gt->usm.bb_pool)) { in all_fw_domain_init()
498 err = PTR_ERR(gt->usm.bb_pool); in all_fw_domain_init()
504 if (!xe_gt_is_media_type(gt)) { in all_fw_domain_init()
505 struct xe_tile *tile = gt_to_tile(gt); in all_fw_domain_init()
514 err = xe_uc_init_hw(&gt->uc); in all_fw_domain_init()
519 if (xe_gt_ccs_mode_enabled(gt)) { in all_fw_domain_init()
520 gt->ccs_mode = 1; in all_fw_domain_init()
521 xe_gt_apply_ccs_mode(gt); in all_fw_domain_init()
524 if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt)) in all_fw_domain_init()
525 xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt); in all_fw_domain_init()
527 if (IS_SRIOV_PF(gt_to_xe(gt))) in all_fw_domain_init()
528 xe_gt_sriov_pf_init_hw(gt); in all_fw_domain_init()
530 err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL); in all_fw_domain_init()
536 xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL); in all_fw_domain_init()
539 xe_hw_fence_irq_finish(&gt->fence_irq[i]); in all_fw_domain_init()
545 * Initialize enough GT to be able to load GuC in order to obtain hwconfig and
548 int xe_gt_init_hwconfig(struct xe_gt *gt) in xe_gt_init_hwconfig() argument
552 err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_init_hwconfig()
556 xe_gt_mcr_init_early(gt); in xe_gt_init_hwconfig()
557 xe_pat_init(gt); in xe_gt_init_hwconfig()
559 err = xe_uc_init(&gt->uc); in xe_gt_init_hwconfig()
563 err = xe_uc_init_hwconfig(&gt->uc); in xe_gt_init_hwconfig()
567 xe_gt_topology_init(gt); in xe_gt_init_hwconfig()
568 xe_gt_mcr_init(gt); in xe_gt_init_hwconfig()
569 xe_gt_enable_host_l2_vram(gt); in xe_gt_init_hwconfig()
572 xe_force_wake_put(gt_to_fw(gt), XE_FW_GT); in xe_gt_init_hwconfig()
577 int xe_gt_init(struct xe_gt *gt) in xe_gt_init() argument
582 INIT_WORK(&gt->reset.worker, gt_reset_worker); in xe_gt_init()
585 gt->ring_ops[i] = xe_ring_ops_get(gt, i); in xe_gt_init()
586 xe_hw_fence_irq_init(&gt->fence_irq[i]); in xe_gt_init()
589 err = xe_gt_tlb_invalidation_init(gt); in xe_gt_init()
593 err = xe_gt_pagefault_init(gt); in xe_gt_init()
597 xe_mocs_init_early(gt); in xe_gt_init()
599 err = xe_gt_sysfs_init(gt); in xe_gt_init()
603 err = gt_fw_domain_init(gt); in xe_gt_init()
607 err = xe_gt_idle_init(&gt->gtidle); in xe_gt_init()
611 err = xe_gt_freq_init(gt); in xe_gt_init()
615 xe_force_wake_init_engines(gt, gt_to_fw(gt)); in xe_gt_init()
617 err = all_fw_domain_init(gt); in xe_gt_init()
621 xe_gt_record_user_engines(gt); in xe_gt_init()
626 void xe_gt_record_user_engines(struct xe_gt *gt) in xe_gt_record_user_engines() argument
631 gt->user_engines.mask = 0; in xe_gt_record_user_engines()
632 memset(gt->user_engines.instances_per_class, 0, in xe_gt_record_user_engines()
633 sizeof(gt->user_engines.instances_per_class)); in xe_gt_record_user_engines()
635 for_each_hw_engine(hwe, gt, id) { in xe_gt_record_user_engines()
639 gt->user_engines.mask |= BIT_ULL(id); in xe_gt_record_user_engines()
640 gt->user_engines.instances_per_class[hwe->class]++; in xe_gt_record_user_engines()
643 xe_gt_assert(gt, (gt->user_engines.mask | gt->info.engine_mask) in xe_gt_record_user_engines()
644 == gt->info.engine_mask); in xe_gt_record_user_engines()
647 static int do_gt_reset(struct xe_gt *gt) in do_gt_reset() argument
651 xe_gsc_wa_14015076503(gt, true); in do_gt_reset()
653 xe_mmio_write32(gt, GDRST, GRDOM_FULL); in do_gt_reset()
654 err = xe_mmio_wait32(gt, GDRST, GRDOM_FULL, 0, 5000, NULL, false); in do_gt_reset()
656 xe_gt_err(gt, "failed to clear GRDOM_FULL (%pe)\n", in do_gt_reset()
659 xe_gsc_wa_14015076503(gt, false); in do_gt_reset()
664 static int vf_gt_restart(struct xe_gt *gt) in vf_gt_restart() argument
668 err = xe_uc_sanitize_reset(&gt->uc); in vf_gt_restart()
672 err = xe_uc_init_hw(&gt->uc); in vf_gt_restart()
676 err = xe_uc_start(&gt->uc); in vf_gt_restart()
683 static int do_gt_restart(struct xe_gt *gt) in do_gt_restart() argument
689 if (IS_SRIOV_VF(gt_to_xe(gt))) in do_gt_restart()
690 return vf_gt_restart(gt); in do_gt_restart()
692 xe_pat_init(gt); in do_gt_restart()
694 xe_gt_enable_host_l2_vram(gt); in do_gt_restart()
696 xe_gt_mcr_set_implicit_defaults(gt); in do_gt_restart()
697 xe_reg_sr_apply_mmio(&gt->reg_sr, gt); in do_gt_restart()
699 err = xe_wopcm_init(&gt->uc.wopcm); in do_gt_restart()
703 for_each_hw_engine(hwe, gt, id) in do_gt_restart()
706 err = xe_uc_sanitize_reset(&gt->uc); in do_gt_restart()
710 err = xe_uc_init_hw(&gt->uc); in do_gt_restart()
714 if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt)) in do_gt_restart()
715 xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt); in do_gt_restart()
717 if (IS_SRIOV_PF(gt_to_xe(gt))) in do_gt_restart()
718 xe_gt_sriov_pf_init_hw(gt); in do_gt_restart()
720 xe_mocs_init(gt); in do_gt_restart()
721 err = xe_uc_start(&gt->uc); in do_gt_restart()
725 for_each_hw_engine(hwe, gt, id) { in do_gt_restart()
726 xe_reg_sr_apply_mmio(&hwe->reg_sr, gt); in do_gt_restart()
731 xe_gt_apply_ccs_mode(gt); in do_gt_restart()
733 /* Restore GT freq to expected values */ in do_gt_restart()
734 xe_gt_sanitize_freq(gt); in do_gt_restart()
736 if (IS_SRIOV_PF(gt_to_xe(gt))) in do_gt_restart()
737 xe_gt_sriov_pf_restart(gt); in do_gt_restart()
742 static int gt_reset(struct xe_gt *gt) in gt_reset() argument
746 if (xe_device_wedged(gt_to_xe(gt))) in gt_reset()
749 /* We only support GT resets with GuC submission */ in gt_reset()
750 if (!xe_device_uc_enabled(gt_to_xe(gt))) in gt_reset()
753 xe_gt_info(gt, "reset started\n"); in gt_reset()
755 xe_pm_runtime_get(gt_to_xe(gt)); in gt_reset()
762 xe_gt_sanitize(gt); in gt_reset()
764 err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); in gt_reset()
768 xe_uc_gucrc_disable(&gt->uc); in gt_reset()
769 xe_uc_stop_prepare(&gt->uc); in gt_reset()
770 xe_gt_pagefault_reset(gt); in gt_reset()
772 xe_uc_stop(&gt->uc); in gt_reset()
774 xe_gt_tlb_invalidation_reset(gt); in gt_reset()
776 err = do_gt_reset(gt); in gt_reset()
780 err = do_gt_restart(gt); in gt_reset()
784 err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL); in gt_reset()
786 xe_pm_runtime_put(gt_to_xe(gt)); in gt_reset()
788 xe_gt_info(gt, "reset done\n"); in gt_reset()
793 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in gt_reset()
795 XE_WARN_ON(xe_uc_start(&gt->uc)); in gt_reset()
797 xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err)); in gt_reset()
799 xe_device_declare_wedged(gt_to_xe(gt)); in gt_reset()
800 xe_pm_runtime_put(gt_to_xe(gt)); in gt_reset()
807 struct xe_gt *gt = container_of(w, typeof(*gt), reset.worker); in gt_reset_worker() local
809 gt_reset(gt); in gt_reset_worker()
812 void xe_gt_reset_async(struct xe_gt *gt) in xe_gt_reset_async() argument
814 xe_gt_info(gt, "trying reset\n"); in xe_gt_reset_async()
817 if (!xe_fault_inject_gt_reset() && xe_uc_reset_prepare(&gt->uc)) in xe_gt_reset_async()
820 xe_gt_info(gt, "reset queued\n"); in xe_gt_reset_async()
821 queue_work(gt->ordered_wq, &gt->reset.worker); in xe_gt_reset_async()
824 void xe_gt_suspend_prepare(struct xe_gt *gt) in xe_gt_suspend_prepare() argument
826 XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in xe_gt_suspend_prepare()
828 xe_uc_stop_prepare(&gt->uc); in xe_gt_suspend_prepare()
830 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in xe_gt_suspend_prepare()
833 int xe_gt_suspend(struct xe_gt *gt) in xe_gt_suspend() argument
837 xe_gt_dbg(gt, "suspending\n"); in xe_gt_suspend()
838 xe_gt_sanitize(gt); in xe_gt_suspend()
840 err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); in xe_gt_suspend()
844 err = xe_uc_suspend(&gt->uc); in xe_gt_suspend()
848 xe_gt_idle_disable_pg(gt); in xe_gt_suspend()
850 xe_gt_disable_host_l2_vram(gt); in xe_gt_suspend()
852 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in xe_gt_suspend()
853 xe_gt_dbg(gt, "suspended\n"); in xe_gt_suspend()
858 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in xe_gt_suspend()
860 xe_gt_err(gt, "suspend failed (%pe)\n", ERR_PTR(err)); in xe_gt_suspend()
867 * @gt: the GT object
869 * Called after driver init/GSC load completes to restore GT frequencies if we
872 int xe_gt_sanitize_freq(struct xe_gt *gt) in xe_gt_sanitize_freq() argument
876 if ((!xe_uc_fw_is_available(&gt->uc.gsc.fw) || in xe_gt_sanitize_freq()
877 xe_uc_fw_is_loaded(&gt->uc.gsc.fw)) && XE_WA(gt, 22019338487)) in xe_gt_sanitize_freq()
878 ret = xe_guc_pc_restore_stashed_freq(&gt->uc.guc.pc); in xe_gt_sanitize_freq()
883 int xe_gt_resume(struct xe_gt *gt) in xe_gt_resume() argument
887 xe_gt_dbg(gt, "resuming\n"); in xe_gt_resume()
888 err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); in xe_gt_resume()
892 err = do_gt_restart(gt); in xe_gt_resume()
896 xe_gt_idle_enable_pg(gt); in xe_gt_resume()
898 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in xe_gt_resume()
899 xe_gt_dbg(gt, "resumed\n"); in xe_gt_resume()
904 XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); in xe_gt_resume()
906 xe_gt_err(gt, "resume failed (%pe)\n", ERR_PTR(err)); in xe_gt_resume()
911 struct xe_hw_engine *xe_gt_hw_engine(struct xe_gt *gt, in xe_gt_hw_engine() argument
918 for_each_hw_engine(hwe, gt, id) in xe_gt_hw_engine()
927 struct xe_hw_engine *xe_gt_any_hw_engine_by_reset_domain(struct xe_gt *gt, in xe_gt_any_hw_engine_by_reset_domain() argument
933 for_each_hw_engine(hwe, gt, id) { in xe_gt_any_hw_engine_by_reset_domain()
950 struct xe_hw_engine *xe_gt_any_hw_engine(struct xe_gt *gt) in xe_gt_any_hw_engine() argument
955 for_each_hw_engine(hwe, gt, id) in xe_gt_any_hw_engine()
962 * xe_gt_declare_wedged() - Declare GT wedged
963 * @gt: the GT object
965 * Wedge the GT which stops all submission, saves desired debug state, and
968 void xe_gt_declare_wedged(struct xe_gt *gt) in xe_gt_declare_wedged() argument
970 xe_gt_assert(gt, gt_to_xe(gt)->wedged.mode); in xe_gt_declare_wedged()
972 xe_uc_declare_wedged(&gt->uc); in xe_gt_declare_wedged()
973 xe_gt_tlb_invalidation_reset(gt); in xe_gt_declare_wedged()