Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/v3d: Add parameter to retrieve the number of GPU resets per-fd

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>

+16
+6
drivers/gpu/drm/v3d/v3d_drv.c
··· 46 46 static int v3d_get_param_ioctl(struct drm_device *dev, void *data, 47 47 struct drm_file *file_priv) 48 48 { 49 + struct v3d_file_priv *v3d_priv = file_priv->driver_priv; 49 50 struct v3d_dev *v3d = to_v3d_dev(dev); 50 51 struct drm_v3d_get_param *args = data; 51 52 static const u32 reg_map[] = { ··· 111 110 case DRM_V3D_PARAM_GLOBAL_RESET_COUNTER: 112 111 mutex_lock(&v3d->reset_lock); 113 112 args->value = v3d->reset_counter; 113 + mutex_unlock(&v3d->reset_lock); 114 + return 0; 115 + case DRM_V3D_PARAM_CONTEXT_RESET_COUNTER: 116 + mutex_lock(&v3d->reset_lock); 117 + args->value = v3d_priv->reset_counter; 114 118 mutex_unlock(&v3d->reset_lock); 115 119 return 0; 116 120 default:
+6
drivers/gpu/drm/v3d/v3d_drv.h
··· 230 230 231 231 /* Stores the GPU stats for a specific queue for this fd. */ 232 232 struct v3d_stats stats[V3D_MAX_QUEUES]; 233 + 234 + /* Per-fd reset counter, must be incremented when a job submitted 235 + * by this fd causes a GPU reset. It must be protected by 236 + * &struct v3d_dev->reset_lock. 237 + */ 238 + unsigned int reset_counter; 233 239 }; 234 240 235 241 struct v3d_bo {
+3
drivers/gpu/drm/v3d/v3d_sched.c
··· 717 717 static enum drm_gpu_sched_stat 718 718 v3d_gpu_reset_for_timeout(struct v3d_dev *v3d, struct drm_sched_job *sched_job) 719 719 { 720 + struct v3d_job *job = to_v3d_job(sched_job); 721 + struct v3d_file_priv *v3d_priv = job->file->driver_priv; 720 722 enum v3d_queue q; 721 723 722 724 mutex_lock(&v3d->reset_lock); ··· 734 732 v3d_reset(v3d); 735 733 736 734 v3d->reset_counter++; 735 + v3d_priv->reset_counter++; 737 736 738 737 for (q = 0; q < V3D_MAX_QUEUES; q++) 739 738 drm_sched_resubmit_jobs(&v3d->queue[q].sched);
+1
include/uapi/drm/v3d_drm.h
··· 295 295 DRM_V3D_PARAM_MAX_PERF_COUNTERS, 296 296 DRM_V3D_PARAM_SUPPORTS_SUPER_PAGES, 297 297 DRM_V3D_PARAM_GLOBAL_RESET_COUNTER, 298 + DRM_V3D_PARAM_CONTEXT_RESET_COUNTER, 298 299 }; 299 300 300 301 struct drm_v3d_get_param {