* [PATCH] drm/v3d: Stop active perfmon if it is being destroyed
@ 2024-11-18 22:19 Christian Gmeiner
2024-11-22 11:59 ` Maíra Canal
0 siblings, 1 reply; 2+ messages in thread
From: Christian Gmeiner @ 2024-11-18 22:19 UTC (permalink / raw)
To: Melissa Wen, Maíra Canal, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Juan A. Suarez Romero
Cc: kernel-dev, Christian Gmeiner, stable, dri-devel, linux-kernel
From: Christian Gmeiner <cgmeiner@igalia.com>
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: stable@vger.kernel.org # v5.15+
Fixes: 26a4dc29b74a ("drm/v3d: Expose performance counters to userspace")
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
---
drivers/gpu/drm/v3d/v3d_perfmon.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/v3d/v3d_perfmon.c b/drivers/gpu/drm/v3d/v3d_perfmon.c
index 00cd081d7873..909288d43f2f 100644
--- a/drivers/gpu/drm/v3d/v3d_perfmon.c
+++ b/drivers/gpu/drm/v3d/v3d_perfmon.c
@@ -383,6 +383,7 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
{
struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
struct drm_v3d_perfmon_destroy *req = data;
+ struct v3d_dev *v3d = v3d_priv->v3d;
struct v3d_perfmon *perfmon;
mutex_lock(&v3d_priv->perfmon.lock);
@@ -392,6 +393,10 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
if (!perfmon)
return -EINVAL;
+ /* If the active perfmon is being destroyed, stop it first */
+ if (perfmon == v3d->active_perfmon)
+ v3d_perfmon_stop(v3d, perfmon, false);
+
v3d_perfmon_put(perfmon);
return 0;
--
2.47.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/v3d: Stop active perfmon if it is being destroyed
2024-11-18 22:19 [PATCH] drm/v3d: Stop active perfmon if it is being destroyed Christian Gmeiner
@ 2024-11-22 11:59 ` Maíra Canal
0 siblings, 0 replies; 2+ messages in thread
From: Maíra Canal @ 2024-11-22 11:59 UTC (permalink / raw)
To: Christian Gmeiner, Melissa Wen, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter,
Juan A. Suarez Romero
Cc: kernel-dev, Christian Gmeiner, stable, dri-devel, linux-kernel
Hi Christian,
On 18/11/24 19:19, Christian Gmeiner wrote:
> From: Christian Gmeiner <cgmeiner@igalia.com>
>
> 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: stable@vger.kernel.org # v5.15+
> Fixes: 26a4dc29b74a ("drm/v3d: Expose performance counters to userspace")
> Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Applied to misc/kernel.git (drm-misc-next).
Maxime, Thomas, if possible, could you cherry-pick this commit to be
included in 6.13? Thanks!
Best Regards,
- Maíra
> ---
> drivers/gpu/drm/v3d/v3d_perfmon.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/v3d/v3d_perfmon.c b/drivers/gpu/drm/v3d/v3d_perfmon.c
> index 00cd081d7873..909288d43f2f 100644
> --- a/drivers/gpu/drm/v3d/v3d_perfmon.c
> +++ b/drivers/gpu/drm/v3d/v3d_perfmon.c
> @@ -383,6 +383,7 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
> {
> struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
> struct drm_v3d_perfmon_destroy *req = data;
> + struct v3d_dev *v3d = v3d_priv->v3d;
> struct v3d_perfmon *perfmon;
>
> mutex_lock(&v3d_priv->perfmon.lock);
> @@ -392,6 +393,10 @@ int v3d_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
> if (!perfmon)
> return -EINVAL;
>
> + /* If the active perfmon is being destroyed, stop it first */
> + if (perfmon == v3d->active_perfmon)
> + v3d_perfmon_stop(v3d, perfmon, false);
> +
> v3d_perfmon_put(perfmon);
>
> return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-22 11:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-18 22:19 [PATCH] drm/v3d: Stop active perfmon if it is being destroyed Christian Gmeiner
2024-11-22 11:59 ` Maíra Canal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®