drm/i915/pmu: Check is pmu is closed before stopping event
Subsystems (2)
PATCH 1/1 drm/i915/pmu: Check is pmu is closed before stopping event
When the driver unbinds, pmu is unregistered and i915->uabi_engines is set to RB_ROOT. Due to this, when i915 PMU tries to stop the engine events, it issues a warn_on because engine lookup fails.
All perf hooks are taking care of this using a pmu->closed flag that is set when PMU unregisters. The stop event seems to have been left out.
Check for pmu->closed in pmu_event_stop as well.
Based on discussion here -
https://patchwork.freedesktop.org/patch/492079/?series=105790&rev=2
--- drivers/gpu/drm/i915/i915_pmu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_pmu.c +9 -0
@@ -831,9 +831,18 @@ static void i915_pmu_event_start(struct perf_event *event, int flags)static void i915_pmu_event_stop (struct perf_event *event,int flags) { +struct drm_i915_private *i915 = +container_of (event->pmu,typeof (*i915), pmu.base); +struct i915_pmu *pmu = &i915->pmu; + +if (pmu->closed) + goto out; +if (flags &PERF_EF_UPDATE )i915_pmu_event_read (event);i915_pmu_disable (event); + +out: event->hw.state =PERF_HES_STOPPED ; }
Signature · 1 line
2.38.1
Jani Nikula
maintainerQuoted 22 lines · Umesh Nerlige Ramappa
When the driver unbinds, pmu is unregistered and
i915->uabi_enginesis set toRB_ROOT. Due to this, when i915 PMU tries to stop the engine events, it issues awarn_onbecause engine lookup fails.All perf hooks are taking care of this using a
pmu->closedflag that is set when PMU unregisters. The stop event seems to have been left out.Check for
pmu->closedinpmu_event_stopas well.Based on discussion here -
https://patchwork.freedesktop.org/patch/492079/?series=105790&rev=2Signed-off-by Umesh Nerlige Ramappa <[email protected]>--- drivers/gpu/drm/i915/i915_pmu.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/gpu/drm/i915/i915_pmu.c +0
-0
drivers/gpu/drm/i915/i915_pmu.c static void i915_pmu_event_start(struct perf_event *event, int flags) · line 836
Quoted 6 lines
drivers/gpu/drm/i915/i915_pmu.c +3
-0@@ -831,9 +831,18 @@ static void i915_pmu_event_start(struct perf_event *event, int flags)static void i915_pmu_event_stop (struct perf_event *event,int flags) { +struct drm_i915_private *i915 = +container_of (event->pmu,typeof (*i915), pmu.base); +struct i915_pmu *pmu = &i915->pmu;
This inspired me to write [1]. Please review.
BR,
Jani.
Quoted 11 lines
drivers/gpu/drm/i915/i915_pmu.c +6
-0+ +if (pmu->closed) + goto out; +if (flags &PERF_EF_UPDATE )i915_pmu_event_read (event);i915_pmu_disable (event); + +out: event->hw.state =PERF_HES_STOPPED ; }
Signature · 1 line
Jani Nikula, Intel