Lines Matching full:gt

49 static int vf_reset_guc_state(struct xe_gt *gt)  in vf_reset_guc_state()  argument
51 struct xe_guc *guc = &gt->uc.guc; in vf_reset_guc_state()
56 xe_gt_sriov_err(gt, "Failed to reset GuC state (%pe)\n", ERR_PTR(err)); in vf_reset_guc_state()
93 static void vf_minimum_guc_version(struct xe_gt *gt, u32 *branch, u32 *major, u32 *minor) in vf_minimum_guc_version() argument
95 struct xe_device *xe = gt_to_xe(gt); in vf_minimum_guc_version()
113 static void vf_wanted_guc_version(struct xe_gt *gt, u32 *branch, u32 *major, u32 *minor) in vf_wanted_guc_version() argument
116 return vf_minimum_guc_version(gt, branch, major, minor); in vf_wanted_guc_version()
119 static int vf_handshake_with_guc(struct xe_gt *gt) in vf_handshake_with_guc() argument
121 struct xe_gt_sriov_vf_guc_version *guc_version = &gt->sriov.vf.guc_version; in vf_handshake_with_guc()
122 struct xe_guc *guc = &gt->uc.guc; in vf_handshake_with_guc()
127 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_handshake_with_guc()
135 vf_wanted_guc_version(gt, &wanted_branch, &wanted_major, &wanted_minor); in vf_handshake_with_guc()
136 xe_gt_assert(gt, wanted_major != GUC_VERSION_MAJOR_ANY); in vf_handshake_with_guc()
148 xe_gt_sriov_err(gt, "New GuC interface version detected: %u.%u.%u.%u\n", in vf_handshake_with_guc()
150 xe_gt_sriov_info(gt, "Previously used version was: %u.%u.%u.%u\n", in vf_handshake_with_guc()
170 vf_minimum_guc_version(gt, &wanted_branch, &wanted_major, &wanted_minor); in vf_handshake_with_guc()
171 xe_gt_assert(gt, major != GUC_VERSION_MAJOR_ANY); in vf_handshake_with_guc()
177 xe_gt_sriov_dbg(gt, "using GuC interface version %u.%u.%u.%u\n", in vf_handshake_with_guc()
187 xe_gt_sriov_err(gt, "Unsupported GuC version %u.%u.%u.%u (%pe)\n", in vf_handshake_with_guc()
190 xe_gt_sriov_err(gt, "Unable to confirm GuC version %u.%u (%pe)\n", in vf_handshake_with_guc()
197 xe_gt_sriov_notice(gt, "GuC reports interface version %u.%u.%u.%u\n", in vf_handshake_with_guc()
204 * @gt: the &xe_gt
211 int xe_gt_sriov_vf_bootstrap(struct xe_gt *gt) in xe_gt_sriov_vf_bootstrap() argument
215 err = vf_reset_guc_state(gt); in xe_gt_sriov_vf_bootstrap()
219 err = vf_handshake_with_guc(gt); in xe_gt_sriov_vf_bootstrap()
299 * @gt: the &xe_gt
305 u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt) in xe_gt_sriov_vf_gmdid() argument
307 const char *type = xe_gt_is_media_type(gt) ? "media" : "graphics"; in xe_gt_sriov_vf_gmdid()
308 struct xe_guc *guc = &gt->uc.guc; in xe_gt_sriov_vf_gmdid()
312 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_gmdid()
313 xe_gt_assert(gt, !GRAPHICS_VERx100(gt_to_xe(gt)) || has_gmdid(gt_to_xe(gt))); in xe_gt_sriov_vf_gmdid()
314 xe_gt_assert(gt, gt->sriov.vf.guc_version.major > 1 || gt->sriov.vf.guc_version.minor >= 2); in xe_gt_sriov_vf_gmdid()
318 xe_gt_sriov_err(gt, "Failed to obtain %s GMDID (%pe)\n", in xe_gt_sriov_vf_gmdid()
323 xe_gt_sriov_dbg(gt, "%s GMDID = %#x\n", type, value); in xe_gt_sriov_vf_gmdid()
327 static int vf_get_ggtt_info(struct xe_gt *gt) in vf_get_ggtt_info() argument
329 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in vf_get_ggtt_info()
330 struct xe_guc *guc = &gt->uc.guc; in vf_get_ggtt_info()
334 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_get_ggtt_info()
345 xe_gt_sriov_err(gt, "Unexpected GGTT reassignment: %lluK != %lluK\n", in vf_get_ggtt_info()
350 xe_gt_sriov_dbg_verbose(gt, "GGTT %#llx-%#llx = %lluK\n", in vf_get_ggtt_info()
359 static int vf_get_lmem_info(struct xe_gt *gt) in vf_get_lmem_info() argument
361 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in vf_get_lmem_info()
362 struct xe_guc *guc = &gt->uc.guc; in vf_get_lmem_info()
367 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_get_lmem_info()
374 xe_gt_sriov_err(gt, "Unexpected LMEM reassignment: %lluM != %lluM\n", in vf_get_lmem_info()
380 xe_gt_sriov_dbg_verbose(gt, "LMEM %lluM %s\n", size / SZ_1M, size_str); in vf_get_lmem_info()
387 static int vf_get_submission_cfg(struct xe_gt *gt) in vf_get_submission_cfg() argument
389 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in vf_get_submission_cfg()
390 struct xe_guc *guc = &gt->uc.guc; in vf_get_submission_cfg()
394 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_get_submission_cfg()
405 xe_gt_sriov_err(gt, "Unexpected CTXs reassignment: %u != %u\n", in vf_get_submission_cfg()
410 xe_gt_sriov_err(gt, "Unexpected DBs reassignment: %u != %u\n", in vf_get_submission_cfg()
415 xe_gt_sriov_dbg_verbose(gt, "CTXs %u DBs %u\n", num_ctxs, num_dbs); in vf_get_submission_cfg()
423 static void vf_cache_gmdid(struct xe_gt *gt) in vf_cache_gmdid() argument
425 xe_gt_assert(gt, has_gmdid(gt_to_xe(gt))); in vf_cache_gmdid()
426 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_cache_gmdid()
428 gt->sriov.vf.runtime.gmdid = xe_gt_sriov_vf_gmdid(gt); in vf_cache_gmdid()
433 * @gt: the &xe_gt
439 int xe_gt_sriov_vf_query_config(struct xe_gt *gt) in xe_gt_sriov_vf_query_config() argument
441 struct xe_device *xe = gt_to_xe(gt); in xe_gt_sriov_vf_query_config()
444 err = vf_get_ggtt_info(gt); in xe_gt_sriov_vf_query_config()
448 if (IS_DGFX(xe) && !xe_gt_is_media_type(gt)) { in xe_gt_sriov_vf_query_config()
449 err = vf_get_lmem_info(gt); in xe_gt_sriov_vf_query_config()
454 err = vf_get_submission_cfg(gt); in xe_gt_sriov_vf_query_config()
459 vf_cache_gmdid(gt); in xe_gt_sriov_vf_query_config()
466 * @gt: the &xe_gt
472 u16 xe_gt_sriov_vf_guc_ids(struct xe_gt *gt) in xe_gt_sriov_vf_guc_ids() argument
474 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_guc_ids()
475 xe_gt_assert(gt, gt->sriov.vf.guc_version.major); in xe_gt_sriov_vf_guc_ids()
476 xe_gt_assert(gt, gt->sriov.vf.self_config.num_ctxs); in xe_gt_sriov_vf_guc_ids()
478 return gt->sriov.vf.self_config.num_ctxs; in xe_gt_sriov_vf_guc_ids()
483 * @gt: the &xe_gt
489 u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt) in xe_gt_sriov_vf_lmem() argument
491 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_lmem()
492 xe_gt_assert(gt, gt->sriov.vf.guc_version.major); in xe_gt_sriov_vf_lmem()
493 xe_gt_assert(gt, gt->sriov.vf.self_config.lmem_size); in xe_gt_sriov_vf_lmem()
495 return gt->sriov.vf.self_config.lmem_size; in xe_gt_sriov_vf_lmem()
517 static int vf_balloon_ggtt(struct xe_gt *gt) in vf_balloon_ggtt() argument
519 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in vf_balloon_ggtt()
520 struct xe_tile *tile = gt_to_tile(gt); in vf_balloon_ggtt()
522 struct xe_device *xe = gt_to_xe(gt); in vf_balloon_ggtt()
525 xe_gt_assert(gt, IS_SRIOV_VF(xe)); in vf_balloon_ggtt()
526 xe_gt_assert(gt, !xe_gt_is_media_type(gt)); in vf_balloon_ggtt()
578 * @gt: the &xe_gt
584 int xe_gt_sriov_vf_prepare_ggtt(struct xe_gt *gt) in xe_gt_sriov_vf_prepare_ggtt() argument
586 struct xe_tile *tile = gt_to_tile(gt); in xe_gt_sriov_vf_prepare_ggtt()
590 if (xe_gt_is_media_type(gt)) in xe_gt_sriov_vf_prepare_ggtt()
593 err = vf_balloon_ggtt(gt); in xe_gt_sriov_vf_prepare_ggtt()
600 static int relay_action_handshake(struct xe_gt *gt, u32 *major, u32 *minor) in relay_action_handshake() argument
612 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in relay_action_handshake()
614 ret = xe_guc_relay_send_to_pf(&gt->uc.guc.relay, in relay_action_handshake()
632 static void vf_connect_pf(struct xe_gt *gt, u16 major, u16 minor) in vf_connect_pf() argument
634 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_connect_pf()
636 gt->sriov.vf.pf_version.major = major; in vf_connect_pf()
637 gt->sriov.vf.pf_version.minor = minor; in vf_connect_pf()
640 static void vf_disconnect_pf(struct xe_gt *gt) in vf_disconnect_pf() argument
642 vf_connect_pf(gt, 0, 0); in vf_disconnect_pf()
645 static int vf_handshake_with_pf(struct xe_gt *gt) in vf_handshake_with_pf() argument
652 err = relay_action_handshake(gt, &major, &minor); in vf_handshake_with_pf()
661 xe_gt_sriov_dbg(gt, "using VF/PF ABI %u.%u\n", major, minor); in vf_handshake_with_pf()
662 vf_connect_pf(gt, major, minor); in vf_handshake_with_pf()
666 xe_gt_sriov_err(gt, "Unable to confirm VF/PF ABI version %u.%u (%pe)\n", in vf_handshake_with_pf()
668 vf_disconnect_pf(gt); in vf_handshake_with_pf()
674 * @gt: the &xe_gt
680 int xe_gt_sriov_vf_connect(struct xe_gt *gt) in xe_gt_sriov_vf_connect() argument
684 err = vf_handshake_with_pf(gt); in xe_gt_sriov_vf_connect()
691 xe_gt_sriov_err(gt, "Failed to get version info (%pe)\n", ERR_PTR(err)); in xe_gt_sriov_vf_connect()
695 static bool vf_is_negotiated(struct xe_gt *gt, u16 major, u16 minor) in vf_is_negotiated() argument
697 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_is_negotiated()
699 return major == gt->sriov.vf.pf_version.major && in vf_is_negotiated()
700 minor <= gt->sriov.vf.pf_version.minor; in vf_is_negotiated()
703 static int vf_prepare_runtime_info(struct xe_gt *gt, unsigned int num_regs) in vf_prepare_runtime_info() argument
705 struct vf_runtime_reg *regs = gt->sriov.vf.runtime.regs; in vf_prepare_runtime_info()
707 struct xe_device *xe = gt_to_xe(gt); in vf_prepare_runtime_info()
709 xe_gt_assert(gt, IS_SRIOV_VF(xe)); in vf_prepare_runtime_info()
712 if (num_regs <= gt->sriov.vf.runtime.regs_size) { in vf_prepare_runtime_info()
714 gt->sriov.vf.runtime.num_regs = num_regs; in vf_prepare_runtime_info()
719 gt->sriov.vf.runtime.regs = NULL; in vf_prepare_runtime_info()
720 gt->sriov.vf.runtime.num_regs = 0; in vf_prepare_runtime_info()
721 gt->sriov.vf.runtime.regs_size = 0; in vf_prepare_runtime_info()
728 gt->sriov.vf.runtime.regs = regs; in vf_prepare_runtime_info()
729 gt->sriov.vf.runtime.num_regs = num_regs; in vf_prepare_runtime_info()
730 gt->sriov.vf.runtime.regs_size = regs_size; in vf_prepare_runtime_info()
734 static int vf_query_runtime_info(struct xe_gt *gt) in vf_query_runtime_info() argument
743 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_query_runtime_info()
744 xe_gt_assert(gt, limit); in vf_query_runtime_info()
747 if (!vf_is_negotiated(gt, 1, 0)) in vf_query_runtime_info()
758 ret = xe_guc_relay_send_to_pf(&gt->uc.guc.relay, in vf_query_runtime_info()
777 xe_gt_sriov_dbg_verbose(gt, "count=%u num=%u ret=%d start=%u remaining=%u\n", in vf_query_runtime_info()
786 ret = vf_prepare_runtime_info(gt, num + remaining); in vf_query_runtime_info()
789 } else if (unlikely(start + num > gt->sriov.vf.runtime.num_regs)) { in vf_query_runtime_info()
795 struct vf_runtime_reg *reg = &gt->sriov.vf.runtime.regs[start + i]; in vf_query_runtime_info()
809 vf_prepare_runtime_info(gt, 0); in vf_query_runtime_info()
813 static void vf_show_runtime_info(struct xe_gt *gt) in vf_show_runtime_info() argument
815 struct vf_runtime_reg *vf_regs = gt->sriov.vf.runtime.regs; in vf_show_runtime_info()
816 unsigned int size = gt->sriov.vf.runtime.num_regs; in vf_show_runtime_info()
818 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_show_runtime_info()
821 xe_gt_sriov_dbg(gt, "runtime(%#x) = %#x\n", in vf_show_runtime_info()
827 * @gt: the &xe_gt
833 int xe_gt_sriov_vf_query_runtime(struct xe_gt *gt) in xe_gt_sriov_vf_query_runtime() argument
837 err = vf_query_runtime_info(gt); in xe_gt_sriov_vf_query_runtime()
842 vf_show_runtime_info(gt); in xe_gt_sriov_vf_query_runtime()
847 xe_gt_sriov_err(gt, "Failed to get runtime info (%pe)\n", in xe_gt_sriov_vf_query_runtime()
860 static struct vf_runtime_reg *vf_lookup_reg(struct xe_gt *gt, u32 addr) in vf_lookup_reg() argument
862 struct xe_gt_sriov_vf_runtime *runtime = &gt->sriov.vf.runtime; in vf_lookup_reg()
865 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in vf_lookup_reg()
873 * @gt: the &xe_gt
882 u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg) in xe_gt_sriov_vf_read32() argument
884 u32 addr = xe_mmio_adjusted_addr(gt, reg.addr); in xe_gt_sriov_vf_read32()
887 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_read32()
888 xe_gt_assert(gt, gt->sriov.vf.pf_version.major); in xe_gt_sriov_vf_read32()
889 xe_gt_assert(gt, !reg.vf); in xe_gt_sriov_vf_read32()
892 xe_gt_sriov_dbg_verbose(gt, "gmdid(%#x) = %#x\n", in xe_gt_sriov_vf_read32()
893 addr, gt->sriov.vf.runtime.gmdid); in xe_gt_sriov_vf_read32()
894 return gt->sriov.vf.runtime.gmdid; in xe_gt_sriov_vf_read32()
897 rr = vf_lookup_reg(gt, addr); in xe_gt_sriov_vf_read32()
899 xe_gt_WARN(gt, IS_ENABLED(CONFIG_DRM_XE_DEBUG), in xe_gt_sriov_vf_read32()
905 xe_gt_sriov_dbg_verbose(gt, "runtime[%#x] = %#x\n", addr, rr->value); in xe_gt_sriov_vf_read32()
911 * @gt: the &xe_gt
918 void xe_gt_sriov_vf_write32(struct xe_gt *gt, struct xe_reg reg, u32 val) in xe_gt_sriov_vf_write32() argument
920 u32 addr = xe_mmio_adjusted_addr(gt, reg.addr); in xe_gt_sriov_vf_write32()
922 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_write32()
923 xe_gt_assert(gt, !reg.vf); in xe_gt_sriov_vf_write32()
930 xe_gt_WARN(gt, IS_ENABLED(CONFIG_DRM_XE_DEBUG), in xe_gt_sriov_vf_write32()
937 * @gt: the &xe_gt
942 void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p) in xe_gt_sriov_vf_print_config() argument
944 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in xe_gt_sriov_vf_print_config()
945 struct xe_device *xe = gt_to_xe(gt); in xe_gt_sriov_vf_print_config()
948 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_print_config()
957 if (IS_DGFX(xe) && !xe_gt_is_media_type(gt)) { in xe_gt_sriov_vf_print_config()
968 * @gt: the &xe_gt
973 void xe_gt_sriov_vf_print_runtime(struct xe_gt *gt, struct drm_printer *p) in xe_gt_sriov_vf_print_runtime() argument
975 struct vf_runtime_reg *vf_regs = gt->sriov.vf.runtime.regs; in xe_gt_sriov_vf_print_runtime()
976 unsigned int size = gt->sriov.vf.runtime.num_regs; in xe_gt_sriov_vf_print_runtime()
978 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_print_runtime()
986 * @gt: the &xe_gt
991 void xe_gt_sriov_vf_print_version(struct xe_gt *gt, struct drm_printer *p) in xe_gt_sriov_vf_print_version() argument
993 struct xe_gt_sriov_vf_guc_version *guc_version = &gt->sriov.vf.guc_version; in xe_gt_sriov_vf_print_version()
994 struct xe_gt_sriov_vf_relay_version *pf_version = &gt->sriov.vf.pf_version; in xe_gt_sriov_vf_print_version()
997 xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt))); in xe_gt_sriov_vf_print_version()
1001 vf_minimum_guc_version(gt, &branch, &major, &minor); in xe_gt_sriov_vf_print_version()
1004 vf_wanted_guc_version(gt, &branch, &major, &minor); in xe_gt_sriov_vf_print_version()