This is intended to fix the pmu integration in i915 when the device unbinds. I don't have the hardware to test, but I belive a similar issue occurs with any driver using perf_pmu_unregister() if they can unbind from the device - in drm subsystem, that would be the amd driver. Previous attempts I could find: 1) https://lore.kernel.org/lkml/20240115170120.662220-1-tvrtko.ursulin@xxxxxxxxxxxxxxx/ 2) https://lore.kernel.org/all/20240213180302.47266-1-umesh.nerlige.ramappa@xxxxxxxxx/ I think (2) is a no-go as it tries to do everything from the i915 side by force-closing the fd. I believe this series is simpler* than (1), but that could could also be a good alternative if we want to go with that approach. First patch is to perf. The rest is to i915 that builds on that and moves the unregister bit by bit to be done later, after the last reference to i915 is dropped. Peter/Ingo, could I get your opinion on this or if (1) would be a good alternative? Thanks. * simpler, but see downside mentioned in patch 6 Lucas De Marchi (7): perf/core: Add pmu get/put drm/i915/pmu: Fix crash due to use-after-free drm/i915/pmu: Use event_to_pmu() drm/i915/pmu: Drop is_igp() drm/i915/pmu: Let resource survive unbind drm/i915/pmu: Lazy unregister drm/i915/pmu: Do not set event_init to NULL drivers/gpu/drm/i915/i915_pmu.c | 103 ++++++++++++++++---------------- include/linux/perf_event.h | 3 + kernel/events/core.c | 32 ++++++++-- 3 files changed, 81 insertions(+), 57 deletions(-) -- 2.43.0