drm/v3d: Add parameter to retrieve the global number of GPU resets

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>
This commit is contained in:
Maíra Canal
2025-07-11 12:18:31 -03:00
parent 2650bc4007
commit 5774b3cfde
4 changed files with 13 additions and 0 deletions

View 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;

View 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 *

View 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);

View 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 {