Lines Matching refs:uc_fw

166 __uc_fw_to_gt(struct xe_uc_fw *uc_fw, enum xe_uc_fw_type type)
172 return container_of(uc_fw, struct xe_gt, uc.guc.fw);
174 return container_of(uc_fw, struct xe_gt, uc.huc.fw);
176 return container_of(uc_fw, struct xe_gt, uc.gsc.fw);
182 static struct xe_gt *uc_fw_to_gt(struct xe_uc_fw *uc_fw)
184 return __uc_fw_to_gt(uc_fw, uc_fw->type);
187 static struct xe_device *uc_fw_to_xe(struct xe_uc_fw *uc_fw)
189 return gt_to_xe(uc_fw_to_gt(uc_fw));
193 uc_fw_auto_select(struct xe_device *xe, struct xe_uc_fw *uc_fw)
218 xe_assert(xe, uc_fw->type < ARRAY_SIZE(blobs_all));
219 entries = blobs_all[uc_fw->type].entries;
220 count = blobs_all[uc_fw->type].count;
224 uc_fw->path = entries[i].path;
225 uc_fw->versions.wanted.major = entries[i].major;
226 uc_fw->versions.wanted.minor = entries[i].minor;
227 uc_fw->versions.wanted.patch = entries[i].patch;
228 uc_fw->full_ver_required = entries[i].full_ver_required;
230 if (uc_fw->type == XE_UC_FW_TYPE_GSC)
231 uc_fw->versions.wanted_type = XE_UC_FW_VER_COMPATIBILITY;
233 uc_fw->versions.wanted_type = XE_UC_FW_VER_RELEASE;
241 uc_fw_override(struct xe_uc_fw *uc_fw)
246 switch (uc_fw->type) {
262 uc_fw->path = path_override;
263 uc_fw->user_overridden = true;
270 * @uc_fw: uC firmware
276 size_t xe_uc_fw_copy_rsa(struct xe_uc_fw *uc_fw, void *dst, u32 max_len)
278 struct xe_device *xe = uc_fw_to_xe(uc_fw);
279 u32 size = min_t(u32, uc_fw->rsa_size, max_len);
282 xe_assert(xe, xe_uc_fw_is_available(uc_fw));
284 xe_map_memcpy_from(xe, dst, &uc_fw->bo->vmap,
285 xe_uc_fw_rsa_offset(uc_fw), size);
292 struct xe_uc_fw *uc_fw = arg;
294 if (!xe_uc_fw_is_available(uc_fw))
297 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_SELECTED);
300 static int guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_header *css)
302 struct xe_gt *gt = uc_fw_to_gt(uc_fw);
303 struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
304 struct xe_uc_fw_version *compatibility = &uc_fw->versions.found[XE_UC_FW_VER_COMPATIBILITY];
306 xe_gt_assert(gt, uc_fw->type == XE_UC_FW_TYPE_GUC);
319 uc_fw->private_data_size = css->private_data_size;
324 int xe_uc_fw_check_version_requirements(struct xe_uc_fw *uc_fw)
326 struct xe_device *xe = uc_fw_to_xe(uc_fw);
327 struct xe_uc_fw_version *wanted = &uc_fw->versions.wanted;
328 struct xe_uc_fw_version *found = &uc_fw->versions.found[uc_fw->versions.wanted_type];
339 (uc_fw->full_ver_required &&
343 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path,
352 xe_uc_fw_type_repr(uc_fw->type),
355 uc_fw->path);
363 if (xe_uc_fw_is_overridden(uc_fw))
370 static int parse_css_header(struct xe_uc_fw *uc_fw, const void *fw_data, size_t fw_size)
372 struct xe_device *xe = uc_fw_to_xe(uc_fw);
373 struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
380 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path,
393 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path,
399 uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32);
402 uc_fw->rsa_size = css->key_size_dw * sizeof(u32);
405 size = sizeof(struct uc_css_header) + uc_fw->ucode_size +
406 uc_fw->rsa_size;
409 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path,
419 if (uc_fw->type == XE_UC_FW_TYPE_GUC)
420 return guc_read_css_info(uc_fw, css);
447 static int parse_cpd_header(struct xe_uc_fw *uc_fw, const void *data, size_t size,
450 struct xe_gt *gt = uc_fw_to_gt(uc_fw);
453 struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
479 xe_uc_fw_type_repr(uc_fw->type));
495 if (uc_fw->type == XE_UC_FW_TYPE_GSC) {
496 struct xe_gsc *gsc = container_of(uc_fw, struct xe_gsc, fw);
521 ret = parse_css_header(uc_fw, data + offset, size - offset);
525 uc_fw->css_offset = offset;
528 uc_fw->has_gsc_headers = true;
533 static int parse_gsc_layout(struct xe_uc_fw *uc_fw, const void *data, size_t size)
535 struct xe_gt *gt = uc_fw_to_gt(uc_fw);
590 return parse_cpd_header(uc_fw,
600 static int parse_headers(struct xe_uc_fw *uc_fw, const struct firmware *fw)
608 switch (uc_fw->type) {
610 return parse_gsc_layout(uc_fw, fw->data, fw->size);
612 ret = parse_cpd_header(uc_fw, fw->data, fw->size, "HUCP.man", "huc_fw");
617 return parse_css_header(uc_fw, fw->data, fw->size);
637 static int uc_fw_request(struct xe_uc_fw *uc_fw, const struct firmware **firmware_p)
639 struct xe_device *xe = uc_fw_to_xe(uc_fw);
646 * we use FIRMWARE_UNINITIALIZED to detect checks against uc_fw->status
650 xe_assert(xe, !uc_fw->status);
651 xe_assert(xe, !uc_fw->path);
653 uc_fw_auto_select(xe, uc_fw);
657 xe_uc_fw_change_status(uc_fw, uc_fw->path ?
663 uc_fw_override(uc_fw);
665 xe_uc_fw_change_status(uc_fw, uc_fw->path ?
669 if (!xe_uc_fw_is_supported(uc_fw)) {
670 if (uc_fw->type == XE_UC_FW_TYPE_GUC) {
678 if (!xe_device_uc_enabled(xe) || !(*uc_fw->path)) {
679 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_DISABLED);
680 drm_dbg(&xe->drm, "%s disabled", xe_uc_fw_type_repr(uc_fw->type));
684 err = request_firmware(&fw, uc_fw->path, dev);
688 err = parse_headers(uc_fw, fw);
693 &uc_fw->versions.found[XE_UC_FW_VER_RELEASE],
695 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path);
698 if (uc_fw->type != XE_UC_FW_TYPE_GSC) {
699 err = xe_uc_fw_check_version_requirements(uc_fw);
709 xe_uc_fw_change_status(uc_fw, err == -ENOENT ?
714 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, err);
716 xe_uc_fw_type_repr(uc_fw->type), XE_UC_FIRMWARE_URL);
728 static int uc_fw_copy(struct xe_uc_fw *uc_fw, const void *data, size_t size, u32 flags)
730 struct xe_device *xe = uc_fw_to_xe(uc_fw);
731 struct xe_gt *gt = uc_fw_to_gt(uc_fw);
739 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path);
744 uc_fw->bo = obj;
745 uc_fw->size = size;
747 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_AVAILABLE);
749 err = drmm_add_action_or_reset(&xe->drm, uc_fw_fini, uc_fw);
756 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_ERROR);
758 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, err);
763 int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
768 err = uc_fw_request(uc_fw, &fw);
776 err = uc_fw_copy(uc_fw, fw->data, fw->size,
785 static u32 uc_fw_ggtt_offset(struct xe_uc_fw *uc_fw)
787 return xe_bo_ggtt_addr(uc_fw->bo);
790 static int uc_fw_xfer(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags)
792 struct xe_device *xe = uc_fw_to_xe(uc_fw);
793 struct xe_gt *gt = uc_fw_to_gt(uc_fw);
801 src_offset = uc_fw_ggtt_offset(uc_fw) + uc_fw->css_offset;
815 sizeof(struct uc_css_header) + uc_fw->ucode_size);
826 xe_uc_fw_type_repr(uc_fw->type), dma_ctrl);
834 int xe_uc_fw_upload(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags)
836 struct xe_device *xe = uc_fw_to_xe(uc_fw);
840 xe_assert(xe, !xe_uc_fw_is_loaded(uc_fw));
842 if (!xe_uc_fw_is_loadable(uc_fw))
846 err = uc_fw_xfer(uc_fw, offset, dma_flags);
850 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_TRANSFERRED);
855 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path,
857 xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_LOAD_FAIL);
873 void xe_uc_fw_print(struct xe_uc_fw *uc_fw, struct drm_printer *p)
878 xe_uc_fw_type_repr(uc_fw->type), uc_fw->path);
880 xe_uc_fw_status_repr(uc_fw->status));
882 print_uc_fw_version(p, &uc_fw->versions.wanted, "\twanted %s",
883 version_type_repr(uc_fw->versions.wanted_type));
886 struct xe_uc_fw_version *ver = &uc_fw->versions.found[i];
893 if (uc_fw->ucode_size)
894 drm_printf(p, "\tuCode: %u bytes\n", uc_fw->ucode_size);
895 if (uc_fw->rsa_size)
896 drm_printf(p, "\tRSA: %u bytes\n", uc_fw->rsa_size);