Lines Matching refs:uc_fw
177 __uc_fw_to_gt(struct xe_uc_fw *uc_fw, enum xe_uc_fw_type type) in XE_GUC_FIRMWARE_DEFS()
183 return container_of(uc_fw, struct xe_gt, uc.guc.fw); in XE_GUC_FIRMWARE_DEFS()
185 return container_of(uc_fw, struct xe_gt, uc.huc.fw); in XE_GUC_FIRMWARE_DEFS()
187 return container_of(uc_fw, struct xe_gt, uc.gsc.fw); in XE_GUC_FIRMWARE_DEFS()
193 static struct xe_gt *uc_fw_to_gt(struct xe_uc_fw *uc_fw) in uc_fw_to_gt() argument
195 return __uc_fw_to_gt(uc_fw, uc_fw->type); in uc_fw_to_gt()
198 static struct xe_device *uc_fw_to_xe(struct xe_uc_fw *uc_fw) in uc_fw_to_xe() argument
200 return gt_to_xe(uc_fw_to_gt(uc_fw)); in uc_fw_to_xe()
204 uc_fw_auto_select(struct xe_device *xe, struct xe_uc_fw *uc_fw) in uc_fw_auto_select() argument
229 xe_assert(xe, uc_fw->type < ARRAY_SIZE(blobs_all)); in uc_fw_auto_select()
230 entries = blobs_all[uc_fw->type].entries; in uc_fw_auto_select()
231 count = blobs_all[uc_fw->type].count; in uc_fw_auto_select()
235 uc_fw->path = entries[i].path; in uc_fw_auto_select()
236 uc_fw->versions.wanted.major = entries[i].major; in uc_fw_auto_select()
237 uc_fw->versions.wanted.minor = entries[i].minor; in uc_fw_auto_select()
238 uc_fw->versions.wanted.patch = entries[i].patch; in uc_fw_auto_select()
239 uc_fw->full_ver_required = entries[i].full_ver_required; in uc_fw_auto_select()
241 if (uc_fw->type == XE_UC_FW_TYPE_GSC) in uc_fw_auto_select()
242 uc_fw->versions.wanted_type = XE_UC_FW_VER_COMPATIBILITY; in uc_fw_auto_select()
244 uc_fw->versions.wanted_type = XE_UC_FW_VER_RELEASE; in uc_fw_auto_select()
252 uc_fw_override(struct xe_uc_fw *uc_fw) in uc_fw_override() argument
257 switch (uc_fw->type) { in uc_fw_override()
273 uc_fw->path = path_override; in uc_fw_override()
274 uc_fw->user_overridden = true; in uc_fw_override()
287 size_t xe_uc_fw_copy_rsa(struct xe_uc_fw *uc_fw, void *dst, u32 max_len) in xe_uc_fw_copy_rsa() argument
289 struct xe_device *xe = uc_fw_to_xe(uc_fw); in xe_uc_fw_copy_rsa()
290 u32 size = min_t(u32, uc_fw->rsa_size, max_len); in xe_uc_fw_copy_rsa()
293 xe_assert(xe, xe_uc_fw_is_available(uc_fw)); in xe_uc_fw_copy_rsa()
295 xe_map_memcpy_from(xe, dst, &uc_fw->bo->vmap, in xe_uc_fw_copy_rsa()
296 xe_uc_fw_rsa_offset(uc_fw), size); in xe_uc_fw_copy_rsa()
303 struct xe_uc_fw *uc_fw = arg; in uc_fw_fini() local
305 if (!xe_uc_fw_is_available(uc_fw)) in uc_fw_fini()
308 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_SELECTED); in uc_fw_fini()
311 static int guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_header *css) in guc_read_css_info() argument
313 struct xe_gt *gt = uc_fw_to_gt(uc_fw); in guc_read_css_info()
314 struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE]; in guc_read_css_info()
315 struct xe_uc_fw_version *compatibility = &uc_fw->versions.found[XE_UC_FW_VER_COMPATIBILITY]; in guc_read_css_info()
317 xe_gt_assert(gt, uc_fw->type == XE_UC_FW_TYPE_GUC); in guc_read_css_info()
330 uc_fw->private_data_size = css->private_data_size; in guc_read_css_info()
335 int xe_uc_fw_check_version_requirements(struct xe_uc_fw *uc_fw) in xe_uc_fw_check_version_requirements() argument
337 struct xe_device *xe = uc_fw_to_xe(uc_fw); in xe_uc_fw_check_version_requirements()
338 struct xe_uc_fw_version *wanted = &uc_fw->versions.wanted; in xe_uc_fw_check_version_requirements()
339 struct xe_uc_fw_version *found = &uc_fw->versions.found[uc_fw->versions.wanted_type]; in xe_uc_fw_check_version_requirements()
350 (uc_fw->full_ver_required && in xe_uc_fw_check_version_requirements()
354 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, in xe_uc_fw_check_version_requirements()
363 xe_uc_fw_type_repr(uc_fw->type), in xe_uc_fw_check_version_requirements()
366 uc_fw->path); in xe_uc_fw_check_version_requirements()
374 if (xe_uc_fw_is_overridden(uc_fw)) in xe_uc_fw_check_version_requirements()
381 static int parse_css_header(struct xe_uc_fw *uc_fw, const void *fw_data, size_t fw_size) in parse_css_header() argument
383 struct xe_device *xe = uc_fw_to_xe(uc_fw); in parse_css_header()
384 struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE]; in parse_css_header()
391 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, in parse_css_header()
404 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, in parse_css_header()
410 uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32); in parse_css_header()
413 uc_fw->rsa_size = css->key_size_dw * sizeof(u32); in parse_css_header()
416 size = sizeof(struct uc_css_header) + uc_fw->ucode_size + in parse_css_header()
417 uc_fw->rsa_size; in parse_css_header()
420 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, in parse_css_header()
430 if (uc_fw->type == XE_UC_FW_TYPE_GUC) in parse_css_header()
431 return guc_read_css_info(uc_fw, css); in parse_css_header()
458 static int parse_cpd_header(struct xe_uc_fw *uc_fw, const void *data, size_t size, in parse_cpd_header() argument
461 struct xe_gt *gt = uc_fw_to_gt(uc_fw); in parse_cpd_header()
464 struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE]; in parse_cpd_header()
490 xe_uc_fw_type_repr(uc_fw->type)); in parse_cpd_header()
506 if (uc_fw->type == XE_UC_FW_TYPE_GSC) { in parse_cpd_header()
507 struct xe_gsc *gsc = container_of(uc_fw, struct xe_gsc, fw); in parse_cpd_header()
532 ret = parse_css_header(uc_fw, data + offset, size - offset); in parse_cpd_header()
536 uc_fw->css_offset = offset; in parse_cpd_header()
539 uc_fw->has_gsc_headers = true; in parse_cpd_header()
544 static int parse_gsc_layout(struct xe_uc_fw *uc_fw, const void *data, size_t size) in parse_gsc_layout() argument
546 struct xe_gt *gt = uc_fw_to_gt(uc_fw); in parse_gsc_layout()
601 return parse_cpd_header(uc_fw, in parse_gsc_layout()
611 static int parse_headers(struct xe_uc_fw *uc_fw, const struct firmware *fw) in parse_headers() argument
619 switch (uc_fw->type) { in parse_headers()
621 return parse_gsc_layout(uc_fw, fw->data, fw->size); in parse_headers()
623 ret = parse_cpd_header(uc_fw, fw->data, fw->size, "HUCP.man", "huc_fw"); in parse_headers()
628 return parse_css_header(uc_fw, fw->data, fw->size); in parse_headers()
648 static int uc_fw_request(struct xe_uc_fw *uc_fw, const struct firmware **firmware_p) in uc_fw_request() argument
650 struct xe_device *xe = uc_fw_to_xe(uc_fw); in uc_fw_request()
661 xe_assert(xe, !uc_fw->status); in uc_fw_request()
662 xe_assert(xe, !uc_fw->path); in uc_fw_request()
664 uc_fw_auto_select(xe, uc_fw); in uc_fw_request()
668 if (uc_fw->type != XE_UC_FW_TYPE_GUC && in uc_fw_request()
669 uc_fw->type != XE_UC_FW_TYPE_HUC) in uc_fw_request()
670 uc_fw->path = NULL; in uc_fw_request()
672 xe_uc_fw_change_status(uc_fw, uc_fw->path ? in uc_fw_request()
678 uc_fw_override(uc_fw); in uc_fw_request()
680 xe_uc_fw_change_status(uc_fw, uc_fw->path ? in uc_fw_request()
684 if (!xe_uc_fw_is_supported(uc_fw)) { in uc_fw_request()
685 if (uc_fw->type == XE_UC_FW_TYPE_GUC) { in uc_fw_request()
693 if (!xe_device_uc_enabled(xe) || !(*uc_fw->path)) { in uc_fw_request()
694 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_DISABLED); in uc_fw_request()
695 drm_dbg(&xe->drm, "%s disabled", xe_uc_fw_type_repr(uc_fw->type)); in uc_fw_request()
699 err = request_firmware(&fw, uc_fw->path, dev); in uc_fw_request()
703 err = parse_headers(uc_fw, fw); in uc_fw_request()
708 &uc_fw->versions.found[XE_UC_FW_VER_RELEASE], in uc_fw_request()
710 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path); in uc_fw_request()
713 if (uc_fw->type != XE_UC_FW_TYPE_GSC) { in uc_fw_request()
714 err = xe_uc_fw_check_version_requirements(uc_fw); in uc_fw_request()
724 xe_uc_fw_change_status(uc_fw, err == -ENOENT ? in uc_fw_request()
729 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, err); in uc_fw_request()
731 xe_uc_fw_type_repr(uc_fw->type), XE_UC_FIRMWARE_URL); in uc_fw_request()
743 static int uc_fw_copy(struct xe_uc_fw *uc_fw, const void *data, size_t size, u32 flags) in uc_fw_copy() argument
745 struct xe_device *xe = uc_fw_to_xe(uc_fw); in uc_fw_copy()
746 struct xe_gt *gt = uc_fw_to_gt(uc_fw); in uc_fw_copy()
754 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path); in uc_fw_copy()
759 uc_fw->bo = obj; in uc_fw_copy()
760 uc_fw->size = size; in uc_fw_copy()
762 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_AVAILABLE); in uc_fw_copy()
764 err = drmm_add_action_or_reset(&xe->drm, uc_fw_fini, uc_fw); in uc_fw_copy()
771 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_ERROR); in uc_fw_copy()
773 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, err); in uc_fw_copy()
778 int xe_uc_fw_init(struct xe_uc_fw *uc_fw) in xe_uc_fw_init() argument
783 err = uc_fw_request(uc_fw, &fw); in xe_uc_fw_init()
791 err = uc_fw_copy(uc_fw, fw->data, fw->size, in xe_uc_fw_init()
800 static u32 uc_fw_ggtt_offset(struct xe_uc_fw *uc_fw) in uc_fw_ggtt_offset() argument
802 return xe_bo_ggtt_addr(uc_fw->bo); in uc_fw_ggtt_offset()
805 static int uc_fw_xfer(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags) in uc_fw_xfer() argument
807 struct xe_device *xe = uc_fw_to_xe(uc_fw); in uc_fw_xfer()
808 struct xe_gt *gt = uc_fw_to_gt(uc_fw); in uc_fw_xfer()
816 src_offset = uc_fw_ggtt_offset(uc_fw) + uc_fw->css_offset; in uc_fw_xfer()
830 sizeof(struct uc_css_header) + uc_fw->ucode_size); in uc_fw_xfer()
841 xe_uc_fw_type_repr(uc_fw->type), dma_ctrl); in uc_fw_xfer()
849 int xe_uc_fw_upload(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags) in xe_uc_fw_upload() argument
851 struct xe_device *xe = uc_fw_to_xe(uc_fw); in xe_uc_fw_upload()
855 xe_assert(xe, !xe_uc_fw_is_loaded(uc_fw)); in xe_uc_fw_upload()
857 if (!xe_uc_fw_is_loadable(uc_fw)) in xe_uc_fw_upload()
861 err = uc_fw_xfer(uc_fw, offset, dma_flags); in xe_uc_fw_upload()
865 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_TRANSFERRED); in xe_uc_fw_upload()
870 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, in xe_uc_fw_upload()
872 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_LOAD_FAIL); in xe_uc_fw_upload()
888 void xe_uc_fw_print(struct xe_uc_fw *uc_fw, struct drm_printer *p) in xe_uc_fw_print() argument
893 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path); in xe_uc_fw_print()
895 xe_uc_fw_status_repr(uc_fw->status)); in xe_uc_fw_print()
897 print_uc_fw_version(p, &uc_fw->versions.wanted, "\twanted %s", in xe_uc_fw_print()
898 version_type_repr(uc_fw->versions.wanted_type)); in xe_uc_fw_print()
901 struct xe_uc_fw_version *ver = &uc_fw->versions.found[i]; in xe_uc_fw_print()
908 if (uc_fw->ucode_size) in xe_uc_fw_print()
909 drm_printf(p, "\tuCode: %u bytes\n", uc_fw->ucode_size); in xe_uc_fw_print()
910 if (uc_fw->rsa_size) in xe_uc_fw_print()
911 drm_printf(p, "\tRSA: %u bytes\n", uc_fw->rsa_size); in xe_uc_fw_print()