Lines Matching full:gsc

29 gsc_to_gt(struct xe_gsc *gsc)  in gsc_to_gt()  argument
31 return container_of(gsc, struct xe_gt, uc.gsc); in gsc_to_gt()
34 static int memcpy_fw(struct xe_gsc *gsc) in memcpy_fw() argument
36 struct xe_gt *gt = gsc_to_gt(gsc); in memcpy_fw()
38 u32 fw_size = gsc->fw.size; in memcpy_fw()
49 xe_map_memcpy_from(xe, storage, &gsc->fw.bo->vmap, 0, fw_size); in memcpy_fw()
50 xe_map_memcpy_to(xe, &gsc->private->vmap, 0, storage, fw_size); in memcpy_fw()
51 xe_map_memset(xe, &gsc->private->vmap, fw_size, 0, gsc->private->size - fw_size); in memcpy_fw()
58 static int emit_gsc_upload(struct xe_gsc *gsc) in emit_gsc_upload() argument
60 struct xe_gt *gt = gsc_to_gt(gsc); in emit_gsc_upload()
61 u64 offset = xe_bo_ggtt_addr(gsc->private); in emit_gsc_upload()
74 bb->cs[bb->len++] = (gsc->private->size / SZ_4K) | GSC_FW_LOAD_LIMIT_VALID; in emit_gsc_upload()
76 job = xe_bb_create_job(gsc->q, bb); in emit_gsc_upload()
114 static int query_compatibility_version(struct xe_gsc *gsc) in query_compatibility_version() argument
116 struct xe_uc_fw_version *compat = &gsc->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY]; in query_compatibility_version()
117 struct xe_gt *gt = gsc_to_gt(gsc); in query_compatibility_version()
131 xe_gt_err(gt, "failed to allocate bo for GSC version query\n"); in query_compatibility_version()
141 err = xe_gsc_pkt_submit_kernel(gsc, ggtt_offset, wr_offset, in query_compatibility_version()
146 "failed to submit GSC request for compatibility version: %d\n", in query_compatibility_version()
155 xe_gt_err(gt, "HuC: invalid GSC reply for version query (err=%d)\n", err); in query_compatibility_version()
162 xe_gt_info(gt, "found GSC cv%u.%u\n", compat->major, compat->minor); in query_compatibility_version()
178 * GSC load can take up to 250ms from the moment the instruction is in gsc_fw_wait()
188 static int gsc_upload(struct xe_gsc *gsc) in gsc_upload() argument
190 struct xe_gt *gt = gsc_to_gt(gsc); in gsc_upload()
195 xe_assert(xe, xe_uc_fw_is_loadable(&gsc->fw) && gsc->q); in gsc_upload()
198 xe_gt_err(gt, "GSC already loaded at upload time\n"); in gsc_upload()
202 err = memcpy_fw(gsc); in gsc_upload()
204 xe_gt_err(gt, "Failed to memcpy GSC FW\n"); in gsc_upload()
209 * GSC is only killed by an FLR, so we need to trigger one on unload to in gsc_upload()
211 * the GSC as part of the FW load, so we need to make sure it stops in gsc_upload()
213 * this is not a problem of the unload per-se, because the GSC will not in gsc_upload()
216 * but if we re-load the driver then the GSC might wake up and try to in gsc_upload()
225 err = emit_gsc_upload(gsc); in gsc_upload()
227 xe_gt_err(gt, "Failed to emit GSC FW upload (%pe)\n", ERR_PTR(err)); in gsc_upload()
233 xe_gt_err(gt, "Failed to wait for GSC load (%pe)\n", ERR_PTR(err)); in gsc_upload()
237 err = query_compatibility_version(gsc); in gsc_upload()
241 err = xe_uc_fw_check_version_requirements(&gsc->fw); in gsc_upload()
245 xe_gt_dbg(gt, "GSC FW async load completed\n"); in gsc_upload()
252 struct xe_gsc *gsc = container_of(work, typeof(*gsc), work); in gsc_work() local
253 struct xe_gt *gt = gsc_to_gt(gsc); in gsc_work()
260 ret = gsc_upload(gsc); in gsc_work()
262 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_LOAD_FAIL); in gsc_work()
266 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED); in gsc_work()
277 int xe_gsc_init(struct xe_gsc *gsc) in xe_gsc_init() argument
279 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_init()
283 gsc->fw.type = XE_UC_FW_TYPE_GSC; in xe_gsc_init()
284 INIT_WORK(&gsc->work, gsc_work); in xe_gsc_init()
286 /* The GSC uC is only available on the media GT */ in xe_gsc_init()
288 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_NOT_SUPPORTED); in xe_gsc_init()
293 * Some platforms can have GuC but not GSC. That would cause in xe_gsc_init()
294 * xe_uc_fw_init(gsc) to return a "not supported" failure code and abort in xe_gsc_init()
295 * all firmware loading. So check for GSC being enabled before in xe_gsc_init()
299 ret = xe_uc_fw_init(&gsc->fw); in xe_gsc_init()
300 if (!xe_uc_fw_is_enabled(&gsc->fw)) in xe_gsc_init()
308 xe_gt_err(gt, "GSC init failed with %d", ret); in xe_gsc_init()
314 struct xe_gsc *gsc = arg; in free_resources() local
316 if (gsc->wq) { in free_resources()
317 destroy_workqueue(gsc->wq); in free_resources()
318 gsc->wq = NULL; in free_resources()
321 if (gsc->q) { in free_resources()
322 xe_exec_queue_put(gsc->q); in free_resources()
323 gsc->q = NULL; in free_resources()
326 if (gsc->private) { in free_resources()
327 xe_bo_unpin_map_no_vm(gsc->private); in free_resources()
328 gsc->private = NULL; in free_resources()
332 int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc) in xe_gsc_init_post_hwconfig() argument
334 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_init_post_hwconfig()
343 if (!xe_uc_fw_is_available(&gsc->fw)) in xe_gsc_init_post_hwconfig()
361 xe_gt_err(gt, "Failed to create queue for GSC submission\n"); in xe_gsc_init_post_hwconfig()
366 wq = alloc_ordered_workqueue("gsc-ordered-wq", 0); in xe_gsc_init_post_hwconfig()
372 gsc->private = bo; in xe_gsc_init_post_hwconfig()
373 gsc->q = q; in xe_gsc_init_post_hwconfig()
374 gsc->wq = wq; in xe_gsc_init_post_hwconfig()
376 err = drmm_add_action_or_reset(&xe->drm, free_resources, gsc); in xe_gsc_init_post_hwconfig()
380 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_LOADABLE); in xe_gsc_init_post_hwconfig()
391 void xe_gsc_load_start(struct xe_gsc *gsc) in xe_gsc_load_start() argument
393 struct xe_gt *gt = gsc_to_gt(gsc); in xe_gsc_load_start()
395 if (!xe_uc_fw_is_loadable(&gsc->fw) || !gsc->q) in xe_gsc_load_start()
398 /* GSC FW survives GT reset and D3Hot */ in xe_gsc_load_start()
400 xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED); in xe_gsc_load_start()
404 queue_work(gsc->wq, &gsc->work); in xe_gsc_load_start()
407 void xe_gsc_wait_for_worker_completion(struct xe_gsc *gsc) in xe_gsc_wait_for_worker_completion() argument
409 if (xe_uc_fw_is_loadable(&gsc->fw) && gsc->wq) in xe_gsc_wait_for_worker_completion()
410 flush_work(&gsc->work); in xe_gsc_wait_for_worker_completion()
414 * wa_14015076503: if the GSC FW is loaded, we need to alert it before doing a
415 * GSC engine reset by writing a notification bit in the GS1 register and then
416 * triggering an interrupt to GSC; from the interrupt it will take up to 200ms
426 /* WA only applies if the GSC is loaded */ in xe_gsc_wa_14015076503()