Skip to content

Commit 8e5f378

Browse files
dceraolorodrigovivi
authored andcommitted
drm/i915/huc: fix leak of debug object in huc load fence on driver unload
The fence is always initialized in huc_init_early, but the cleanup in huc_fini is only being run if HuC is enabled. This causes a leaking of the debug object when HuC is disabled/not supported, which can in turn trigger a warning if we try to register a new debug offset at the same address on driver reload. To fix the issue, make sure to always run the cleanup code. Reported-by: Tvrtko Ursulin <[email protected]> Reported-by: Brian Norris <[email protected]> Fixes: 27536e0 ("drm/i915/huc: track delayed HuC load with a fence") Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: Brian Norris <[email protected]> Cc: Alan Previn <[email protected]> Cc: John Harrison <[email protected]> Tested-by: Brian Norris <[email protected]> Reviewed-by: John Harrison <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 0222469) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 264bc5d commit 8e5f378

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,15 @@ int intel_huc_init(struct intel_huc *huc)
329329

330330
void intel_huc_fini(struct intel_huc *huc)
331331
{
332-
if (!intel_uc_fw_is_loadable(&huc->fw))
333-
return;
334-
332+
/*
333+
* the fence is initialized in init_early, so we need to clean it up
334+
* even if HuC loading is off.
335+
*/
335336
delayed_huc_load_complete(huc);
336-
337337
i915_sw_fence_fini(&huc->delayed_load.fence);
338-
intel_uc_fw_fini(&huc->fw);
338+
339+
if (intel_uc_fw_is_loadable(&huc->fw))
340+
intel_uc_fw_fini(&huc->fw);
339341
}
340342

341343
void intel_huc_suspend(struct intel_huc *huc)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ int intel_uc_runtime_resume(struct intel_uc *uc)
722722

723723
static const struct intel_uc_ops uc_ops_off = {
724724
.init_hw = __uc_check_hw,
725+
.fini = __uc_fini, /* to clean-up the init_early initialization */
725726
};
726727

727728
static const struct intel_uc_ops uc_ops_on = {

0 commit comments

Comments
 (0)