Lines Matching full:gsc
39 gsc_to_gt(struct xe_gsc *gsc) in gsc_to_gt() argument
41 return container_of(gsc, struct xe_gt, uc.gsc); in gsc_to_gt()
44 static int memcpy_fw(struct xe_gsc *gsc) in memcpy_fw() argument
46 struct xe_gt *gt = gsc_to_gt(gsc); in memcpy_fw()
48 u32 fw_size = gsc->fw.size; in memcpy_fw()
59 xe_map_memcpy_from(xe, storage, &gsc->fw.bo->vmap, 0, fw_size); in memcpy_fw()
60 xe_map_memcpy_to(xe, &gsc->private->vmap, 0, storage, fw_size); in memcpy_fw()
61 xe_map_memset(xe, &gsc->private->vmap, fw_size, 0, gsc->private->size - fw_size); in memcpy_fw()
68 static int emit_gsc_upload(struct xe_gsc *gsc) in emit_gsc_upload() argument
70 struct xe_gt *gt = gsc_to_gt(gsc); in emit_gsc_upload()
71 u64 offset = xe_bo_ggtt_addr(gsc->private); in emit_gsc_upload()
84 bb->cs[bb->len++] = (gsc->private->size / SZ_4K) | GSC_FW_LOAD_LIMIT_VALID; in emit_gsc_upload()
86 job = xe_bb_create_job(gsc->q, bb); in emit_gsc_upload()
124 static int query_compatibility_version(struct xe_gsc *gsc) in query_compatibility_version() argument
126 struct xe_uc_fw_version *compat = &gsc->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY]; in query_compatibility_version()
127 struct xe_gt *gt = gsc_to_gt(gsc); in query_compatibility_version()
141 xe_gt_err(gt, "failed to allocate bo for GSC version query\n"); in query_compatibility_version()
151 err = xe_gsc_pkt_submit_kernel(gsc, ggtt_offset, wr_offset, in query_compatibility_version()
156 "failed to submit GSC request for compatibility version: %d\n", in query_compatibility_version()
165 xe_gt_err(gt, "HuC: invalid GSC reply for version query (err=%d)\n", err); in query_compatibility_version()
173 xe_gt_info(gt, "found GSC cv%u.%u.%u\n", compat->major, compat->minor, compat->patch); in query_compatibility_version()
189 * GSC load can take up to 250ms from the moment the instruction is in gsc_fw_wait()
199 static int gsc_upload(struct xe_gsc *gsc) in gsc_upload() argument
201 struct xe_gt *gt = gsc_to_gt(gsc); in gsc_upload()
206 xe_assert(xe, xe_uc_fw_is_loadable(&gsc->fw) && gsc->q); in gsc_upload()
209 xe_gt_err(gt, "GSC already loaded at upload time\n"); in gsc_upload()
213 err = memcpy_fw(gsc); in gsc_upload()
215 xe_gt_err(gt, "Failed to memcpy GSC FW\n"); in gsc_upload()
220 * GSC is only killed by an FLR, so we need to trigger one on unload to in gsc_upload()
222 * the GSC as part of the FW load, so we need to make sure it stops in gsc_upload()
224 * this is not a problem of the unload per-se, because the GSC will not in gsc_upload()
227 * but if we re-load the driver then the GSC might wake up and try to in gsc_upload()
236 err = emit_gsc_upload(gsc); in gsc_upload()
238 xe_gt_err(gt, "Failed to emit GSC FW upload (%pe)\n", ERR_PTR(err)); in gsc_upload()
244 xe_gt_err(gt, "Failed to wait for GSC load (%pe)\n", ERR_PTR(err)); in gsc_upload()
248 err = query_compatibility_version(gsc); in gsc_upload()
252 err = xe_uc_fw_check_version_requirements(&gsc->fw); in gsc_upload()
259 static int gsc_upload_and_init(struct xe_gsc *gsc) in gsc_upload_and_init() argument
261 struct xe_gt *gt = gsc_to_gt(gsc); in gsc_upload_and_init()
281 ret = gsc_upload(gsc); in gsc_upload_and_init()
289 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED); in gsc_upload_and_init()
291 /* GSC load is done, restore expected GT frequencies */ in gsc_upload_and_init()
294 xe_gt_dbg(gt, "GSC FW async load completed\n"); in gsc_upload_and_init()
300 ret = xe_gsc_proxy_start(gsc); in gsc_upload_and_init()
304 xe_gt_dbg(gt, "GSC proxy init completed\n"); in gsc_upload_and_init()
319 * and a success is reported, but the GSC shim keeps resetting in the in gsc_er_complete()
341 xe_gt_err(gt, "GSC ER timed out!\n"); in gsc_er_complete()
351 struct xe_gsc *gsc = container_of(work, typeof(*gsc), work); in gsc_work() local
352 struct xe_gt *gt = gsc_to_gt(gsc); in gsc_work()
357 spin_lock_irq(&gsc->lock); in gsc_work()
358 actions = gsc->work_actions; in gsc_work()
359 gsc->work_actions = 0; in gsc_work()
360 spin_unlock_irq(&gsc->lock); in gsc_work()
372 ret = gsc_upload_and_init(gsc); in gsc_work()
374 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_LOAD_FAIL); in gsc_work()
376 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_RUNNING); in gsc_work()
380 xe_gsc_proxy_request_handler(gsc); in gsc_work()
390 struct xe_gsc *gsc = >->uc.gsc; in xe_gsc_hwe_irq_handler() local
396 spin_lock(&gsc->lock); in xe_gsc_hwe_irq_handler()
397 gsc->work_actions |= GSC_ACTION_ER_COMPLETE; in xe_gsc_hwe_irq_handler()
398 spin_unlock(&gsc->lock); in xe_gsc_hwe_irq_handler()
400 queue_work(gsc->wq, &gsc->work); in xe_gsc_hwe_irq_handler()
404 int xe_gsc_init(struct xe_gsc *gsc) in xe_gsc_init() argument
406 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_init()
410 gsc->fw.type = XE_UC_FW_TYPE_GSC; in xe_gsc_init()
411 INIT_WORK(&gsc->work, gsc_work); in xe_gsc_init()
412 spin_lock_init(&gsc->lock); in xe_gsc_init()
414 /* The GSC uC is only available on the media GT */ in xe_gsc_init()
416 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_NOT_SUPPORTED); in xe_gsc_init()
421 * Some platforms can have GuC but not GSC. That would cause in xe_gsc_init()
422 * xe_uc_fw_init(gsc) to return a "not supported" failure code and abort in xe_gsc_init()
423 * all firmware loading. So check for GSC being enabled before in xe_gsc_init()
427 ret = xe_uc_fw_init(&gsc->fw); in xe_gsc_init()
428 if (!xe_uc_fw_is_enabled(&gsc->fw)) in xe_gsc_init()
433 ret = xe_gsc_proxy_init(gsc); in xe_gsc_init()
440 xe_gt_err(gt, "GSC init failed with %d", ret); in xe_gsc_init()
446 struct xe_gsc *gsc = arg; in free_resources() local
448 if (gsc->wq) { in free_resources()
449 destroy_workqueue(gsc->wq); in free_resources()
450 gsc->wq = NULL; in free_resources()
453 if (gsc->q) { in free_resources()
454 xe_exec_queue_put(gsc->q); in free_resources()
455 gsc->q = NULL; in free_resources()
459 int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc) in xe_gsc_init_post_hwconfig() argument
461 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_init_post_hwconfig()
470 if (!xe_uc_fw_is_available(&gsc->fw)) in xe_gsc_init_post_hwconfig()
487 xe_gt_err(gt, "Failed to create queue for GSC submission\n"); in xe_gsc_init_post_hwconfig()
492 wq = alloc_ordered_workqueue("gsc-ordered-wq", 0); in xe_gsc_init_post_hwconfig()
498 gsc->private = bo; in xe_gsc_init_post_hwconfig()
499 gsc->q = q; in xe_gsc_init_post_hwconfig()
500 gsc->wq = wq; in xe_gsc_init_post_hwconfig()
502 err = devm_add_action_or_reset(xe->drm.dev, free_resources, gsc); in xe_gsc_init_post_hwconfig()
506 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_LOADABLE); in xe_gsc_init_post_hwconfig()
517 void xe_gsc_load_start(struct xe_gsc *gsc) in xe_gsc_load_start() argument
519 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_load_start()
522 if (!xe_uc_fw_is_loadable(&gsc->fw) || !gsc->q) in xe_gsc_load_start()
526 * The GSC HW is only reset by driver FLR or D3cold entry. We don't in xe_gsc_load_start()
528 * DGFX, for which we don't support GSC. Therefore, if GSC failed to in xe_gsc_load_start()
533 if (xe_uc_fw_is_in_error_state(&gsc->fw)) in xe_gsc_load_start()
536 /* GSC FW survives GT reset and D3Hot */ in xe_gsc_load_start()
538 if (xe_gsc_proxy_init_done(gsc)) in xe_gsc_load_start()
539 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_RUNNING); in xe_gsc_load_start()
541 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED); in xe_gsc_load_start()
545 spin_lock_irq(&gsc->lock); in xe_gsc_load_start()
546 gsc->work_actions |= GSC_ACTION_FW_LOAD; in xe_gsc_load_start()
547 spin_unlock_irq(&gsc->lock); in xe_gsc_load_start()
549 queue_work(gsc->wq, &gsc->work); in xe_gsc_load_start()
552 void xe_gsc_wait_for_worker_completion(struct xe_gsc *gsc) in xe_gsc_wait_for_worker_completion() argument
554 if (xe_uc_fw_is_loadable(&gsc->fw) && gsc->wq) in xe_gsc_wait_for_worker_completion()
555 flush_work(&gsc->work); in xe_gsc_wait_for_worker_completion()
559 * xe_gsc_remove() - Clean up the GSC structures before driver removal
560 * @gsc: the GSC uC
562 void xe_gsc_remove(struct xe_gsc *gsc) in xe_gsc_remove() argument
564 xe_gsc_proxy_remove(gsc); in xe_gsc_remove()
568 * wa_14015076503: if the GSC FW is loaded, we need to alert it before doing a
569 * GSC engine reset by writing a notification bit in the GS1 register and then
570 * triggering an interrupt to GSC; from the interrupt it will take up to 200ms
580 /* WA only applies if the GSC is loaded */ in xe_gsc_wa_14015076503()
595 * xe_gsc_print_info - print info about GSC FW status
596 * @gsc: the GSC structure
599 void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p) in xe_gsc_print_info() argument
601 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_print_info()
604 xe_uc_fw_print(&gsc->fw, p); in xe_gsc_print_info()
606 drm_printf(p, "\tfound security version %u\n", gsc->security_version); in xe_gsc_print_info()
608 if (!xe_uc_fw_is_enabled(&gsc->fw)) in xe_gsc_print_info()