Skip to content

Commit c5c0c15

Browse files
Christian Gmeinerpopcornmix
authored andcommitted
drm/v3d: Stop active perfmon if it is being destroyed
Commit 21f1435 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 7d1fd36 ("drm/v3d: Stop the active perfmon before being destroyed"). Cc: stable@vger.kernel.org # v5.15+ Fixes: 26a4dc2 ("drm/v3d: Expose performance counters to userspace") Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> Signed-off-by: Maíra Canal <mcanal@igalia.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241118221948.1758130-1-christian.gmeiner@gmail.com
1 parent 63e66eb commit c5c0c15

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
@@ -384,6 +384,7 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
384384
{
385385
struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
386386
struct drm_v3d_perfmon_destroy *req = data;
387+
struct v3d_dev *v3d = v3d_priv->v3d;
387388
struct v3d_perfmon *perfmon;
388389

389390
mutex_lock(&v3d_priv->perfmon.lock);
@@ -393,6 +394,10 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
393394
if (!perfmon)
394395
return -EINVAL;
395396

397+
/* If the active perfmon is being destroyed, stop it first */
398+
if (perfmon == v3d->active_perfmon)
399+
v3d_perfmon_stop(v3d, perfmon, false);
400+
396401
v3d_perfmon_put(perfmon);
397402

398403
return 0;

0 commit comments

Comments
 (0)