]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/v3d: Add parameter to retrieve the global number of GPU resets
authorMaíra Canal <mcanal@igalia.com>
Fri, 11 Jul 2025 15:18:31 +0000 (12:18 -0300)
committerMaíra Canal <mcanal@igalia.com>
Thu, 17 Jul 2025 14:17:27 +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 global number of
GPU resets that have happened since the driver was probed.

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

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://lore.kernel.org/r/20250711-v3d-reset-counter-v1-1-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 5e997ae8bc9c7ac110d79df8b5cf81a59dc0a291..0f53ca7460044e2a74c31d6282914f49844066b2 100644 (file)
@@ -107,6 +107,11 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
        case DRM_V3D_PARAM_SUPPORTS_SUPER_PAGES:
                args->value = !!v3d->gemfs;
                return 0;
+       case DRM_V3D_PARAM_GLOBAL_RESET_COUNTER:
+               mutex_lock(&v3d->reset_lock);
+               args->value = v3d->reset_counter;
+               mutex_unlock(&v3d->reset_lock);
+               return 0;
        default:
                DRM_DEBUG("Unknown parameter %d\n", args->param);
                return -EINVAL;
index b51f0b648a08011f737317ec1841d5ab316355b2..074cbccf88ddfe5961c779f0df93552264f54608 100644 (file)
@@ -196,6 +196,11 @@ struct v3d_dev {
         * all jobs.
         */
        struct v3d_perfmon *global_perfmon;
+
+       /* Global reset counter. The counter must be incremented when
+        * a GPU reset happens. It must be protected by @reset_lock.
+        */
+       unsigned int reset_counter;
 };
 
 static inline struct v3d_dev *
index cc85f1b19ac405146a2a516f335a46376684bc91..5f8198890e41c8fe86ec6cc25dfa7cd7f5a902f4 100644 (file)
@@ -731,6 +731,8 @@ v3d_gpu_reset_for_timeout(struct v3d_dev *v3d, struct drm_sched_job *sched_job)
        /* get the GPU back into the init state */
        v3d_reset(v3d);
 
+       v3d->reset_counter++;
+
        for (q = 0; q < V3D_MAX_QUEUES; q++)
                drm_sched_resubmit_jobs(&v3d->queue[q].sched);
 
index dbbc404d2b3dd6c8b8e3969b0b76b7d8b371dddb..0a7ce2f6be19d2cbccf090f0db301119eb4b28ba 100644 (file)
@@ -294,6 +294,7 @@ enum drm_v3d_param {
        DRM_V3D_PARAM_SUPPORTS_CPU_QUEUE,
        DRM_V3D_PARAM_MAX_PERF_COUNTERS,
        DRM_V3D_PARAM_SUPPORTS_SUPER_PAGES,
+       DRM_V3D_PARAM_GLOBAL_RESET_COUNTER,
 };
 
 struct drm_v3d_get_param {