]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/v3d: Add parameter to retrieve the number of GPU resets per-fd
authorMaíra Canal <mcanal@igalia.com>
Fri, 11 Jul 2025 15:18:32 +0000 (12:18 -0300)
committerMaíra Canal <mcanal@igalia.com>
Thu, 17 Jul 2025 14:17:32 +0000 (11:17 -0300)
The GL extension KHR_robustness uses the number of global and per-context
GPU resets to learn about graphics resets that affect a GL context. This
commit introduces a new V3D parameter to retrieve the number of GPU resets
triggered by jobs submitted through a file descriptor.

To retrieve this information, user-space must use DRM_V3D_PARAM_CONTEXT_RESET_COUNTER.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://lore.kernel.org/r/20250711-v3d-reset-counter-v1-2-1ac73e9fca2d@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
drivers/gpu/drm/v3d/v3d_drv.c
drivers/gpu/drm/v3d/v3d_drv.h
drivers/gpu/drm/v3d/v3d_sched.c
include/uapi/drm/v3d_drm.h

index 0f53ca7460044e2a74c31d6282914f49844066b2..2def155ce496ec5f159f6bda9929aeaae141d1a6 100644 (file)
@@ -46,6 +46,7 @@ MODULE_PARM_DESC(super_pages, "Enable/Disable Super Pages support.");
 static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
                               struct drm_file *file_priv)
 {
+       struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
        struct v3d_dev *v3d = to_v3d_dev(dev);
        struct drm_v3d_get_param *args = data;
        static const u32 reg_map[] = {
@@ -112,6 +113,11 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
                args->value = v3d->reset_counter;
                mutex_unlock(&v3d->reset_lock);
                return 0;
+       case DRM_V3D_PARAM_CONTEXT_RESET_COUNTER:
+               mutex_lock(&v3d->reset_lock);
+               args->value = v3d_priv->reset_counter;
+               mutex_unlock(&v3d->reset_lock);
+               return 0;
        default:
                DRM_DEBUG("Unknown parameter %d\n", args->param);
                return -EINVAL;
index 074cbccf88ddfe5961c779f0df93552264f54608..dabda7aaf00074d8de42dcdb345d5f3331ac13b2 100644 (file)
@@ -230,6 +230,12 @@ struct v3d_file_priv {
 
        /* Stores the GPU stats for a specific queue for this fd. */
        struct v3d_stats stats[V3D_MAX_QUEUES];
+
+       /* Per-fd reset counter, must be incremented when a job submitted
+        * by this fd causes a GPU reset. It must be protected by
+        * &struct v3d_dev->reset_lock.
+        */
+       unsigned int reset_counter;
 };
 
 struct v3d_bo {
index 5f8198890e41c8fe86ec6cc25dfa7cd7f5a902f4..7d45664f03c714bbb754ea22902147a64e63d115 100644 (file)
@@ -717,6 +717,8 @@ v3d_cache_clean_job_run(struct drm_sched_job *sched_job)
 static enum drm_gpu_sched_stat
 v3d_gpu_reset_for_timeout(struct v3d_dev *v3d, struct drm_sched_job *sched_job)
 {
+       struct v3d_job *job = to_v3d_job(sched_job);
+       struct v3d_file_priv *v3d_priv = job->file->driver_priv;
        enum v3d_queue q;
 
        mutex_lock(&v3d->reset_lock);
@@ -732,6 +734,7 @@ v3d_gpu_reset_for_timeout(struct v3d_dev *v3d, struct drm_sched_job *sched_job)
        v3d_reset(v3d);
 
        v3d->reset_counter++;
+       v3d_priv->reset_counter++;
 
        for (q = 0; q < V3D_MAX_QUEUES; q++)
                drm_sched_resubmit_jobs(&v3d->queue[q].sched);
index 0a7ce2f6be19d2cbccf090f0db301119eb4b28ba..d9b01f4c3a047eac90899901cc603838ab5c9090 100644 (file)
@@ -295,6 +295,7 @@ enum drm_v3d_param {
        DRM_V3D_PARAM_MAX_PERF_COUNTERS,
        DRM_V3D_PARAM_SUPPORTS_SUPER_PAGES,
        DRM_V3D_PARAM_GLOBAL_RESET_COUNTER,
+       DRM_V3D_PARAM_CONTEXT_RESET_COUNTER,
 };
 
 struct drm_v3d_get_param {