Skip to content

Commit 3b55cde

Browse files
committed
drm/i915/pmu: Keep a reference to module while active
While a perf event is open, keep a reference to the module so we don't remove the driver internals mid-sampling. Testcase: igt/perf_pmu/module-unload Signed-off-by: Chris Wilson <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: [email protected] Reviewed-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 16e8745 commit 3b55cde

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/gpu/drm/i915/i915_pmu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ static u64 count_interrupts(struct drm_i915_private *i915)
442442
static void i915_pmu_event_destroy(struct perf_event *event)
443443
{
444444
WARN_ON(event->parent);
445+
module_put(THIS_MODULE);
445446
}
446447

447448
static int
@@ -533,8 +534,10 @@ static int i915_pmu_event_init(struct perf_event *event)
533534
if (ret)
534535
return ret;
535536

536-
if (!event->parent)
537+
if (!event->parent) {
538+
__module_get(THIS_MODULE);
537539
event->destroy = i915_pmu_event_destroy;
540+
}
538541

539542
return 0;
540543
}

0 commit comments

Comments
 (0)