Skip to content

Commit 95036d4

Browse files
Christian Gmeinergregkh
authored andcommitted
drm/v3d: Stop active perfmon if it is being destroyed
commit 21f1435b1e6b012a07c42f36b206d2b66fc8f13b upstream. If the active performance monitor (`v3d->active_perfmon`) is being destroyed, stop it first. Currently, the active perfmon is not stopped during destruction, leaving the `v3d->active_perfmon` pointer stale. This can lead to undefined behavior and instability. This patch ensures that the active perfmon is stopped before being destroyed, aligning with the behavior introduced in commit 7d1fd3638ee3 ("drm/v3d: Stop the active perfmon before being destroyed"). Cc: [email protected] # v5.15+ Fixes: 26a4dc2 ("drm/v3d: Expose performance counters to userspace") Signed-off-by: Christian Gmeiner <[email protected]> Signed-off-by: Maíra Canal <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 042eeba commit 95036d4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/gpu/drm/v3d/v3d_perfmon.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
175175
{
176176
struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
177177
struct drm_v3d_perfmon_destroy *req = data;
178+
struct v3d_dev *v3d = v3d_priv->v3d;
178179
struct v3d_perfmon *perfmon;
179180

180181
mutex_lock(&v3d_priv->perfmon.lock);
@@ -184,6 +185,10 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
184185
if (!perfmon)
185186
return -EINVAL;
186187

188+
/* If the active perfmon is being destroyed, stop it first */
189+
if (perfmon == v3d->active_perfmon)
190+
v3d_perfmon_stop(v3d, perfmon, false);
191+
187192
v3d_perfmon_put(perfmon);
188193

189194
return 0;

0 commit comments

Comments
 (0)