Skip to content

Commit 2d299f5

Browse files
dceraolorodrigovivi
authored andcommitted
drm/i915/huc: always init the delayed load fence
The fence is only tracking if the HuC load is in progress or not and doesn't distinguish between already loaded, not supported or disabled, so we can always initialize it to completed, no matter the actual support. We already do that for most platforms, but we skip it on GTs that lack VCS engines (e.g. MTL root GT), so fix that. Note that the cleanup is already unconditional. While at it, move the init/fini to helper functions. Fixes: 8e5f378 ("drm/i915/huc: fix leak of debug object in huc load fence on driver unload") Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: John Harrison <[email protected]> Cc: Alan Previn <[email protected]> Reviewed-by: John Harrison <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 14347a9) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent f9cdf41 commit 2d299f5

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

drivers/gpu/drm/i915/gt/uc/intel_huc.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,30 @@ void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *b
211211
huc->delayed_load.nb.notifier_call = NULL;
212212
}
213213

214+
static void delayed_huc_load_init(struct intel_huc *huc)
215+
{
216+
/*
217+
* Initialize fence to be complete as this is expected to be complete
218+
* unless there is a delayed HuC load in progress.
219+
*/
220+
i915_sw_fence_init(&huc->delayed_load.fence,
221+
sw_fence_dummy_notify);
222+
i915_sw_fence_commit(&huc->delayed_load.fence);
223+
224+
hrtimer_init(&huc->delayed_load.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
225+
huc->delayed_load.timer.function = huc_delayed_load_timer_callback;
226+
}
227+
228+
static void delayed_huc_load_fini(struct intel_huc *huc)
229+
{
230+
/*
231+
* the fence is initialized in init_early, so we need to clean it up
232+
* even if HuC loading is off.
233+
*/
234+
delayed_huc_load_complete(huc);
235+
i915_sw_fence_fini(&huc->delayed_load.fence);
236+
}
237+
214238
static bool vcs_supported(struct intel_gt *gt)
215239
{
216240
intel_engine_mask_t mask = gt->info.engine_mask;
@@ -241,6 +265,15 @@ void intel_huc_init_early(struct intel_huc *huc)
241265

242266
intel_uc_fw_init_early(&huc->fw, INTEL_UC_FW_TYPE_HUC);
243267

268+
/*
269+
* we always init the fence as already completed, even if HuC is not
270+
* supported. This way we don't have to distinguish between HuC not
271+
* supported/disabled or already loaded, and can focus on if the load
272+
* is currently in progress (fence not complete) or not, which is what
273+
* we care about for stalling userspace submissions.
274+
*/
275+
delayed_huc_load_init(huc);
276+
244277
if (!vcs_supported(gt)) {
245278
intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_NOT_SUPPORTED);
246279
return;
@@ -255,17 +288,6 @@ void intel_huc_init_early(struct intel_huc *huc)
255288
huc->status.mask = HUC_FW_VERIFIED;
256289
huc->status.value = HUC_FW_VERIFIED;
257290
}
258-
259-
/*
260-
* Initialize fence to be complete as this is expected to be complete
261-
* unless there is a delayed HuC reload in progress.
262-
*/
263-
i915_sw_fence_init(&huc->delayed_load.fence,
264-
sw_fence_dummy_notify);
265-
i915_sw_fence_commit(&huc->delayed_load.fence);
266-
267-
hrtimer_init(&huc->delayed_load.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
268-
huc->delayed_load.timer.function = huc_delayed_load_timer_callback;
269291
}
270292

271293
#define HUC_LOAD_MODE_STRING(x) (x ? "GSC" : "legacy")
@@ -333,8 +355,7 @@ void intel_huc_fini(struct intel_huc *huc)
333355
* the fence is initialized in init_early, so we need to clean it up
334356
* even if HuC loading is off.
335357
*/
336-
delayed_huc_load_complete(huc);
337-
i915_sw_fence_fini(&huc->delayed_load.fence);
358+
delayed_huc_load_fini(huc);
338359

339360
if (intel_uc_fw_is_loadable(&huc->fw))
340361
intel_uc_fw_fini(&huc->fw);

0 commit comments

Comments
 (0)