Lines Matching +full:version +full:- +full:minor

1 // SPDX-License-Identifier: MIT
3 * Copyright © 2023-2024 Intel Corporation
46 return ret > 0 ? -EPROTO : ret; in guc_action_vf_reset()
51 struct xe_guc *guc = &gt->uc.guc; in vf_reset_guc_state()
62 u32 *branch, u32 *major, u32 *minor, u32 *patch) in guc_action_match_version() argument
83 return -EPROTO; in guc_action_match_version()
87 *minor = FIELD_GET(VF2GUC_MATCH_VERSION_RESPONSE_MSG_1_MINOR, response[1]); in guc_action_match_version()
93 static void vf_minimum_guc_version(struct xe_gt *gt, u32 *branch, u32 *major, u32 *minor) in vf_minimum_guc_version() argument
97 switch (xe->info.platform) { in vf_minimum_guc_version()
102 *minor = 1; in vf_minimum_guc_version()
108 *minor = 2; 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()
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()
124 u32 branch, major, minor, patch; in vf_handshake_with_guc() local
129 /* select wanted version - prefer previous (if any) */ in vf_handshake_with_guc()
130 if (guc_version->major || guc_version->minor) { in vf_handshake_with_guc()
131 wanted_branch = guc_version->branch; in vf_handshake_with_guc()
132 wanted_major = guc_version->major; in vf_handshake_with_guc()
133 wanted_minor = guc_version->minor; in vf_handshake_with_guc()
140 &branch, &major, &minor, &patch); in vf_handshake_with_guc()
144 /* we don't support interface version change */ in vf_handshake_with_guc()
145 if ((guc_version->major || guc_version->minor) && in vf_handshake_with_guc()
146 (guc_version->branch != branch || guc_version->major != major || in vf_handshake_with_guc()
147 guc_version->minor != minor)) { 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()
149 branch, major, minor, patch); 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()
151 guc_version->branch, guc_version->major, in vf_handshake_with_guc()
152 guc_version->minor, guc_version->patch); in vf_handshake_with_guc()
153 err = -EREMCHG; in vf_handshake_with_guc()
159 err = -EPROTO; in vf_handshake_with_guc()
163 /* there's no fallback on major version. */ in vf_handshake_with_guc()
165 err = -ENOPKG; in vf_handshake_with_guc()
169 /* check against minimum version supported by us */ in vf_handshake_with_guc()
172 if (major < wanted_major || (major == wanted_major && minor < wanted_minor)) { in vf_handshake_with_guc()
173 err = -ENOKEY; 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()
178 branch, major, minor, patch); in vf_handshake_with_guc()
180 guc_version->branch = branch; in vf_handshake_with_guc()
181 guc_version->major = major; in vf_handshake_with_guc()
182 guc_version->minor = minor; in vf_handshake_with_guc()
183 guc_version->patch = patch; 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()
188 branch, major, minor, patch, ERR_PTR(err)); 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()
193 /* try again with *any* just to query which version is supported */ in vf_handshake_with_guc()
196 &branch, &major, &minor, &patch)) 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()
198 branch, major, minor, patch); in vf_handshake_with_guc()
203 * xe_gt_sriov_vf_bootstrap - Query and setup GuC ABI interface version.
246 return -EPROTO; in guc_action_query_single_klv()
250 return -EOVERFLOW; in guc_action_query_single_klv()
252 return -ENODATA; in guc_action_query_single_klv()
298 * xe_gt_sriov_vf_gmdid - Query GMDID over MMIO.
308 struct xe_guc *guc = &gt->uc.guc; 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()
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()
344 if (config->ggtt_size && config->ggtt_size != size) { in vf_get_ggtt_info()
346 size / SZ_1K, config->ggtt_size / SZ_1K); in vf_get_ggtt_info()
347 return -EREMCHG; in vf_get_ggtt_info()
350 xe_gt_sriov_dbg_verbose(gt, "GGTT %#llx-%#llx = %lluK\n", in vf_get_ggtt_info()
351 start, start + size - 1, size / SZ_1K); in vf_get_ggtt_info()
353 config->ggtt_base = start; in vf_get_ggtt_info()
354 config->ggtt_size = size; in vf_get_ggtt_info()
356 return config->ggtt_size ? 0 : -ENODATA; in vf_get_ggtt_info()
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()
373 if (config->lmem_size && config->lmem_size != size) { in vf_get_lmem_info()
375 size / SZ_1M, config->lmem_size / SZ_1M); in vf_get_lmem_info()
376 return -EREMCHG; in vf_get_lmem_info()
382 config->lmem_size = size; in vf_get_lmem_info()
384 return config->lmem_size ? 0 : -ENODATA; in vf_get_lmem_info()
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()
404 if (config->num_ctxs && config->num_ctxs != num_ctxs) { in vf_get_submission_cfg()
406 num_ctxs, config->num_ctxs); in vf_get_submission_cfg()
407 return -EREMCHG; in vf_get_submission_cfg()
409 if (config->num_dbs && config->num_dbs != num_dbs) { in vf_get_submission_cfg()
411 num_dbs, config->num_dbs); in vf_get_submission_cfg()
412 return -EREMCHG; in vf_get_submission_cfg()
417 config->num_ctxs = num_ctxs; in vf_get_submission_cfg()
418 config->num_dbs = num_dbs; in vf_get_submission_cfg()
420 return config->num_ctxs ? 0 : -ENODATA; in vf_get_submission_cfg()
428 gt->sriov.vf.runtime.gmdid = xe_gt_sriov_vf_gmdid(gt); in vf_cache_gmdid()
432 * xe_gt_sriov_vf_query_config - Query SR-IOV config data over MMIO.
465 * xe_gt_sriov_vf_guc_ids - VF GuC context IDs configuration.
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()
482 * xe_gt_sriov_vf_lmem - VF LMEM configuration.
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()
519 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in vf_balloon_ggtt()
521 struct xe_ggtt *ggtt = tile->mem.ggtt; in vf_balloon_ggtt()
528 if (!config->ggtt_size) in vf_balloon_ggtt()
529 return -ENODATA; in vf_balloon_ggtt()
535 * |<------------ Total GGTT size ------------------>| in vf_balloon_ggtt()
537 * VF GGTT base -->|<- size ->| in vf_balloon_ggtt()
539 * +--------------------+----------+-----------------+ in vf_balloon_ggtt()
541 * +--------------------+----------+-----------------+ in vf_balloon_ggtt()
543 * |<--- balloon[0] --->|<-- VF -->|<-- balloon[1] ->| in vf_balloon_ggtt()
547 end = config->ggtt_base; in vf_balloon_ggtt()
549 tile->sriov.vf.ggtt_balloon[0] = vf_balloon_ggtt_node(ggtt, start, end); in vf_balloon_ggtt()
550 if (IS_ERR(tile->sriov.vf.ggtt_balloon[0])) in vf_balloon_ggtt()
551 return PTR_ERR(tile->sriov.vf.ggtt_balloon[0]); in vf_balloon_ggtt()
554 start = config->ggtt_base + config->ggtt_size; in vf_balloon_ggtt()
557 tile->sriov.vf.ggtt_balloon[1] = vf_balloon_ggtt_node(ggtt, start, end); in vf_balloon_ggtt()
558 if (IS_ERR(tile->sriov.vf.ggtt_balloon[1])) { in vf_balloon_ggtt()
559 xe_ggtt_node_remove_balloon(tile->sriov.vf.ggtt_balloon[0]); in vf_balloon_ggtt()
560 return PTR_ERR(tile->sriov.vf.ggtt_balloon[1]); in vf_balloon_ggtt()
572 xe_ggtt_node_remove_balloon(tile->sriov.vf.ggtt_balloon[1]); in deballoon_ggtt()
573 xe_ggtt_node_remove_balloon(tile->sriov.vf.ggtt_balloon[0]); in deballoon_ggtt()
577 * xe_gt_sriov_vf_prepare_ggtt - Prepare a VF's GGTT configuration.
597 return drmm_add_action_or_reset(&xe->drm, deballoon_ggtt, tile); 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
607 FIELD_PREP(VF2PF_HANDSHAKE_REQUEST_MSG_1_MINOR, *minor), in relay_action_handshake()
614 ret = xe_guc_relay_send_to_pf(&gt->uc.guc.relay, in relay_action_handshake()
621 return -EPROTO; in relay_action_handshake()
624 return -EPROTO; in relay_action_handshake()
627 *minor = FIELD_GET(VF2PF_HANDSHAKE_RESPONSE_MSG_1_MINOR, response[1]); in relay_action_handshake()
632 static void vf_connect_pf(struct xe_gt *gt, u16 major, u16 minor) in vf_connect_pf() argument
636 gt->sriov.vf.pf_version.major = major; in vf_connect_pf()
637 gt->sriov.vf.pf_version.minor = minor; in vf_connect_pf()
649 u32 major = major_wanted, minor = minor_wanted; in vf_handshake_with_pf() local
652 err = relay_action_handshake(gt, &major, &minor); in vf_handshake_with_pf()
656 if (!major && !minor) { in vf_handshake_with_pf()
657 err = -ENODATA; 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()
667 major, minor, ERR_PTR(err)); in vf_handshake_with_pf()
673 * xe_gt_sriov_vf_connect - Establish connection with the PF driver.
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
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()
705 struct vf_runtime_reg *regs = gt->sriov.vf.runtime.regs; 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()
718 drmm_kfree(&xe->drm, 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()
724 regs = drmm_kcalloc(&xe->drm, regs_size, sizeof(*regs), GFP_KERNEL); in vf_prepare_runtime_info()
726 return -ENOMEM; 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()
738 u32 limit = (ARRAY_SIZE(response) - VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN) / 2; in vf_query_runtime_info()
748 return -ENOPKG; in vf_query_runtime_info()
758 ret = xe_guc_relay_send_to_pf(&gt->uc.guc.relay, in vf_query_runtime_info()
765 ret = -EPROTO; in vf_query_runtime_info()
768 if (unlikely((ret - VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN) % 2)) { in vf_query_runtime_info()
769 ret = -EPROTO; in vf_query_runtime_info()
773 num = (ret - VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN) / 2; in vf_query_runtime_info()
781 ret = -EPROTO; in vf_query_runtime_info()
789 } else if (unlikely(start + num > gt->sriov.vf.runtime.num_regs)) { in vf_query_runtime_info()
790 ret = -EPROTO; in vf_query_runtime_info()
795 struct vf_runtime_reg *reg = &gt->sriov.vf.runtime.regs[start + i]; in vf_query_runtime_info()
797 reg->offset = response[VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN + 2 * i]; in vf_query_runtime_info()
798 reg->value = response[VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN + 2 * i + 1]; in vf_query_runtime_info()
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()
820 for (; size--; vf_regs++) in vf_show_runtime_info()
822 vf_regs->offset, vf_regs->value); in vf_show_runtime_info()
826 * xe_gt_sriov_vf_query_runtime - Query SR-IOV runtime data.
857 return (int)ra->offset - (int)rb->offset; in vf_runtime_reg_cmp()
862 struct xe_gt_sriov_vf_runtime *runtime = &gt->sriov.vf.runtime; in vf_lookup_reg()
867 return bsearch(&key, runtime->regs, runtime->num_regs, sizeof(key), in vf_lookup_reg()
872 * xe_gt_sriov_vf_read32 - Get a register value from the runtime data.
888 xe_gt_assert(gt, gt->sriov.vf.pf_version.major); 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()
901 reg.addr, addr - reg.addr); 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()
906 return rr->value; in xe_gt_sriov_vf_read32()
910 * xe_gt_sriov_vf_write32 - Handle a write to an inaccessible register.
932 val, reg.addr, addr - reg.addr); in xe_gt_sriov_vf_write32()
936 * xe_gt_sriov_vf_print_config - Print VF self config.
944 struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config; in xe_gt_sriov_vf_print_config()
950 drm_printf(p, "GGTT range:\t%#llx-%#llx\n", in xe_gt_sriov_vf_print_config()
951 config->ggtt_base, in xe_gt_sriov_vf_print_config()
952 config->ggtt_base + config->ggtt_size - 1); in xe_gt_sriov_vf_print_config()
954 string_get_size(config->ggtt_size, 1, STRING_UNITS_2, buf, sizeof(buf)); in xe_gt_sriov_vf_print_config()
955 drm_printf(p, "GGTT size:\t%llu (%s)\n", config->ggtt_size, buf); in xe_gt_sriov_vf_print_config()
958 string_get_size(config->lmem_size, 1, STRING_UNITS_2, buf, sizeof(buf)); in xe_gt_sriov_vf_print_config()
959 drm_printf(p, "LMEM size:\t%llu (%s)\n", config->lmem_size, buf); in xe_gt_sriov_vf_print_config()
962 drm_printf(p, "GuC contexts:\t%u\n", config->num_ctxs); in xe_gt_sriov_vf_print_config()
963 drm_printf(p, "GuC doorbells:\t%u\n", config->num_dbs); in xe_gt_sriov_vf_print_config()
967 * xe_gt_sriov_vf_print_runtime - Print VF's runtime regs received from PF.
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()
980 for (; size--; vf_regs++) in xe_gt_sriov_vf_print_runtime()
981 drm_printf(p, "%#x = %#x\n", vf_regs->offset, vf_regs->value); in xe_gt_sriov_vf_print_runtime()
985 * xe_gt_sriov_vf_print_version - Print VF ABI versions.
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()
995 u32 branch, major, minor; in xe_gt_sriov_vf_print_version() local
1001 vf_minimum_guc_version(gt, &branch, &major, &minor); in xe_gt_sriov_vf_print_version()
1002 drm_printf(p, "\tbase:\t%u.%u.%u.*\n", 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()
1005 drm_printf(p, "\twanted:\t%u.%u.%u.*\n", branch, major, minor); in xe_gt_sriov_vf_print_version()
1008 guc_version->branch, guc_version->major, in xe_gt_sriov_vf_print_version()
1009 guc_version->minor, guc_version->patch); in xe_gt_sriov_vf_print_version()
1018 pf_version->major, pf_version->minor); in xe_gt_sriov_vf_print_version()