Lines Matching refs:huc

68 static void __delayed_huc_load_complete(struct intel_huc *huc)  in __delayed_huc_load_complete()  argument
70 if (!i915_sw_fence_done(&huc->delayed_load.fence)) in __delayed_huc_load_complete()
71 i915_sw_fence_complete(&huc->delayed_load.fence); in __delayed_huc_load_complete()
74 static void delayed_huc_load_complete(struct intel_huc *huc) in delayed_huc_load_complete() argument
76 hrtimer_cancel(&huc->delayed_load.timer); in delayed_huc_load_complete()
77 __delayed_huc_load_complete(huc); in delayed_huc_load_complete()
80 static void __gsc_init_error(struct intel_huc *huc) in __gsc_init_error() argument
82 huc->delayed_load.status = INTEL_HUC_DELAYED_LOAD_ERROR; in __gsc_init_error()
83 __delayed_huc_load_complete(huc); in __gsc_init_error()
86 static void gsc_init_error(struct intel_huc *huc) in gsc_init_error() argument
88 hrtimer_cancel(&huc->delayed_load.timer); in gsc_init_error()
89 __gsc_init_error(huc); in gsc_init_error()
92 static void gsc_init_done(struct intel_huc *huc) in gsc_init_done() argument
94 hrtimer_cancel(&huc->delayed_load.timer); in gsc_init_done()
97 huc->delayed_load.status = INTEL_HUC_WAITING_ON_PXP; in gsc_init_done()
98 if (!i915_sw_fence_done(&huc->delayed_load.fence)) in gsc_init_done()
99 hrtimer_start(&huc->delayed_load.timer, in gsc_init_done()
106 struct intel_huc *huc = container_of(hrtimer, struct intel_huc, delayed_load.timer); in huc_delayed_load_timer_callback() local
108 if (!intel_huc_is_authenticated(huc)) { in huc_delayed_load_timer_callback()
109 if (huc->delayed_load.status == INTEL_HUC_WAITING_ON_GSC) in huc_delayed_load_timer_callback()
110 drm_notice(&huc_to_gt(huc)->i915->drm, in huc_delayed_load_timer_callback()
112 else if (huc->delayed_load.status == INTEL_HUC_WAITING_ON_PXP) in huc_delayed_load_timer_callback()
113 drm_notice(&huc_to_gt(huc)->i915->drm, in huc_delayed_load_timer_callback()
116 MISSING_CASE(huc->delayed_load.status); in huc_delayed_load_timer_callback()
118 __gsc_init_error(huc); in huc_delayed_load_timer_callback()
124 static void huc_delayed_load_start(struct intel_huc *huc) in huc_delayed_load_start() argument
128 GEM_BUG_ON(intel_huc_is_authenticated(huc)); in huc_delayed_load_start()
134 switch (huc->delayed_load.status) { in huc_delayed_load_start()
142 gsc_init_error(huc); in huc_delayed_load_start()
152 GEM_BUG_ON(!i915_sw_fence_done(&huc->delayed_load.fence)); in huc_delayed_load_start()
153 i915_sw_fence_fini(&huc->delayed_load.fence); in huc_delayed_load_start()
154 i915_sw_fence_reinit(&huc->delayed_load.fence); in huc_delayed_load_start()
155 i915_sw_fence_await(&huc->delayed_load.fence); in huc_delayed_load_start()
156 i915_sw_fence_commit(&huc->delayed_load.fence); in huc_delayed_load_start()
158 hrtimer_start(&huc->delayed_load.timer, delay, HRTIMER_MODE_REL); in huc_delayed_load_start()
164 struct intel_huc *huc = container_of(nb, struct intel_huc, delayed_load.nb); in gsc_notifier() local
165 struct intel_gsc_intf *intf = &huc_to_gt(huc)->gsc.intf[0]; in gsc_notifier()
172 gsc_init_done(huc); in gsc_notifier()
177 drm_info(&huc_to_gt(huc)->i915->drm, in gsc_notifier()
179 gsc_init_error(huc); in gsc_notifier()
186 void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus) in intel_huc_register_gsc_notifier() argument
190 if (!intel_huc_is_loaded_by_gsc(huc)) in intel_huc_register_gsc_notifier()
193 huc->delayed_load.nb.notifier_call = gsc_notifier; in intel_huc_register_gsc_notifier()
194 ret = bus_register_notifier(bus, &huc->delayed_load.nb); in intel_huc_register_gsc_notifier()
196 drm_err(&huc_to_gt(huc)->i915->drm, in intel_huc_register_gsc_notifier()
198 huc->delayed_load.nb.notifier_call = NULL; in intel_huc_register_gsc_notifier()
199 gsc_init_error(huc); in intel_huc_register_gsc_notifier()
203 void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *bus) in intel_huc_unregister_gsc_notifier() argument
205 if (!huc->delayed_load.nb.notifier_call) in intel_huc_unregister_gsc_notifier()
208 delayed_huc_load_complete(huc); in intel_huc_unregister_gsc_notifier()
210 bus_unregister_notifier(bus, &huc->delayed_load.nb); in intel_huc_unregister_gsc_notifier()
211 huc->delayed_load.nb.notifier_call = NULL; in intel_huc_unregister_gsc_notifier()
214 static void delayed_huc_load_init(struct intel_huc *huc) in delayed_huc_load_init() argument
220 i915_sw_fence_init(&huc->delayed_load.fence, in delayed_huc_load_init()
222 i915_sw_fence_commit(&huc->delayed_load.fence); in delayed_huc_load_init()
224 hrtimer_init(&huc->delayed_load.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in delayed_huc_load_init()
225 huc->delayed_load.timer.function = huc_delayed_load_timer_callback; in delayed_huc_load_init()
228 static void delayed_huc_load_fini(struct intel_huc *huc) in delayed_huc_load_fini() argument
234 delayed_huc_load_complete(huc); in delayed_huc_load_fini()
235 i915_sw_fence_fini(&huc->delayed_load.fence); in delayed_huc_load_fini()
261 void intel_huc_init_early(struct intel_huc *huc) in intel_huc_init_early() argument
263 struct drm_i915_private *i915 = huc_to_gt(huc)->i915; in intel_huc_init_early()
264 struct intel_gt *gt = huc_to_gt(huc); in intel_huc_init_early()
266 intel_uc_fw_init_early(&huc->fw, INTEL_UC_FW_TYPE_HUC); in intel_huc_init_early()
275 delayed_huc_load_init(huc); in intel_huc_init_early()
278 intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_NOT_SUPPORTED); in intel_huc_init_early()
283 huc->status.reg = GEN11_HUC_KERNEL_LOAD_INFO; in intel_huc_init_early()
284 huc->status.mask = HUC_LOAD_SUCCESSFUL; in intel_huc_init_early()
285 huc->status.value = HUC_LOAD_SUCCESSFUL; in intel_huc_init_early()
287 huc->status.reg = HUC_STATUS2; in intel_huc_init_early()
288 huc->status.mask = HUC_FW_VERIFIED; in intel_huc_init_early()
289 huc->status.value = HUC_FW_VERIFIED; in intel_huc_init_early()
294 static int check_huc_loading_mode(struct intel_huc *huc) in check_huc_loading_mode() argument
296 struct intel_gt *gt = huc_to_gt(huc); in check_huc_loading_mode()
297 bool fw_needs_gsc = intel_huc_is_loaded_by_gsc(huc); in check_huc_loading_mode()
329 int intel_huc_init(struct intel_huc *huc) in intel_huc_init() argument
331 struct drm_i915_private *i915 = huc_to_gt(huc)->i915; in intel_huc_init()
334 err = check_huc_loading_mode(huc); in intel_huc_init()
338 err = intel_uc_fw_init(&huc->fw); in intel_huc_init()
342 intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_LOADABLE); in intel_huc_init()
347 intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_INIT_FAIL); in intel_huc_init()
352 void intel_huc_fini(struct intel_huc *huc) in intel_huc_fini() argument
358 delayed_huc_load_fini(huc); in intel_huc_fini()
360 if (intel_uc_fw_is_loadable(&huc->fw)) in intel_huc_fini()
361 intel_uc_fw_fini(&huc->fw); in intel_huc_fini()
364 void intel_huc_suspend(struct intel_huc *huc) in intel_huc_suspend() argument
366 if (!intel_uc_fw_is_loadable(&huc->fw)) in intel_huc_suspend()
374 delayed_huc_load_complete(huc); in intel_huc_suspend()
377 int intel_huc_wait_for_auth_complete(struct intel_huc *huc) in intel_huc_wait_for_auth_complete() argument
379 struct intel_gt *gt = huc_to_gt(huc); in intel_huc_wait_for_auth_complete()
383 huc->status.reg, in intel_huc_wait_for_auth_complete()
384 huc->status.mask, in intel_huc_wait_for_auth_complete()
385 huc->status.value, in intel_huc_wait_for_auth_complete()
389 delayed_huc_load_complete(huc); in intel_huc_wait_for_auth_complete()
393 intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_LOAD_FAIL); in intel_huc_wait_for_auth_complete()
397 intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_RUNNING); in intel_huc_wait_for_auth_complete()
412 int intel_huc_auth(struct intel_huc *huc) in intel_huc_auth() argument
414 struct intel_gt *gt = huc_to_gt(huc); in intel_huc_auth()
418 if (!intel_uc_fw_is_loaded(&huc->fw)) in intel_huc_auth()
422 if (intel_huc_is_loaded_by_gsc(huc)) in intel_huc_auth()
429 GEM_BUG_ON(intel_uc_fw_is_running(&huc->fw)); in intel_huc_auth()
431 ret = intel_guc_auth_huc(guc, intel_guc_ggtt_offset(guc, huc->fw.rsa_data)); in intel_huc_auth()
438 ret = intel_huc_wait_for_auth_complete(huc); in intel_huc_auth()
449 bool intel_huc_is_authenticated(struct intel_huc *huc) in intel_huc_is_authenticated() argument
451 struct intel_gt *gt = huc_to_gt(huc); in intel_huc_is_authenticated()
456 status = intel_uncore_read(gt->uncore, huc->status.reg); in intel_huc_is_authenticated()
458 return (status & huc->status.mask) == huc->status.value; in intel_huc_is_authenticated()
471 int intel_huc_check_status(struct intel_huc *huc) in intel_huc_check_status() argument
473 switch (__intel_uc_fw_status(&huc->fw)) { in intel_huc_check_status()
490 return intel_huc_is_authenticated(huc); in intel_huc_check_status()
493 static bool huc_has_delayed_load(struct intel_huc *huc) in huc_has_delayed_load() argument
495 return intel_huc_is_loaded_by_gsc(huc) && in huc_has_delayed_load()
496 (huc->delayed_load.status != INTEL_HUC_DELAYED_LOAD_ERROR); in huc_has_delayed_load()
499 void intel_huc_update_auth_status(struct intel_huc *huc) in intel_huc_update_auth_status() argument
501 if (!intel_uc_fw_is_loadable(&huc->fw)) in intel_huc_update_auth_status()
504 if (intel_huc_is_authenticated(huc)) in intel_huc_update_auth_status()
505 intel_uc_fw_change_status(&huc->fw, in intel_huc_update_auth_status()
507 else if (huc_has_delayed_load(huc)) in intel_huc_update_auth_status()
508 huc_delayed_load_start(huc); in intel_huc_update_auth_status()
518 void intel_huc_load_status(struct intel_huc *huc, struct drm_printer *p) in intel_huc_load_status() argument
520 struct intel_gt *gt = huc_to_gt(huc); in intel_huc_load_status()
523 if (!intel_huc_is_supported(huc)) { in intel_huc_load_status()
528 if (!intel_huc_is_wanted(huc)) { in intel_huc_load_status()
533 intel_uc_fw_dump(&huc->fw, p); in intel_huc_load_status()
537 intel_uncore_read(gt->uncore, huc->status.reg)); in intel_huc_load_status()