* [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters
@ 2025-07-11 15:18 Maíra Canal
2025-07-11 15:18 ` [PATCH 1/2] drm/v3d: Add parameter to retrieve the global number of GPU resets Maíra Canal
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Maíra Canal @ 2025-07-11 15:18 UTC (permalink / raw)
To: Juan A. Suarez, Iago Toral Quiroga, Melissa Wen
Cc: kernel-dev, dri-devel, Maíra Canal
The GL extension KHR_robustness requires a mechanism for a GL application
to learn about graphics resets that affect a GL context. With the goal
to provide support for such extension in Mesa, this series implements
global and per-context GPU reset counters that user-space can retrieve
using the DRM_IOCTL_V3D_GET_PARAM ioctl.
The corresponding user-space implementation for this series is available at [1].
[1] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35965
Best Regards,
- Maíra
---
Maíra Canal (2):
drm/v3d: Add parameter to retrieve the global number of GPU resets
drm/v3d: Add parameter to retrieve the number of GPU resets per-fd
drivers/gpu/drm/v3d/v3d_drv.c | 11 +++++++++++
drivers/gpu/drm/v3d/v3d_drv.h | 11 +++++++++++
drivers/gpu/drm/v3d/v3d_sched.c | 5 +++++
include/uapi/drm/v3d_drm.h | 2 ++
4 files changed, 29 insertions(+)
---
base-commit: 917b10d90990fd2138b5dbc2d22cfa428c070ade
change-id: 20250708-v3d-reset-counter-ab231c87bd35
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] drm/v3d: Add parameter to retrieve the global number of GPU resets
2025-07-11 15:18 [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Maíra Canal
@ 2025-07-11 15:18 ` Maíra Canal
2025-07-11 15:18 ` [PATCH 2/2] drm/v3d: Add parameter to retrieve the number of GPU resets per-fd Maíra Canal
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Maíra Canal @ 2025-07-11 15:18 UTC (permalink / raw)
To: Juan A. Suarez, Iago Toral Quiroga, Melissa Wen
Cc: kernel-dev, dri-devel, Maíra Canal
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.
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
drivers/gpu/drm/v3d/v3d_drv.c | 5 +++++
drivers/gpu/drm/v3d/v3d_drv.h | 5 +++++
drivers/gpu/drm/v3d/v3d_sched.c | 2 ++
include/uapi/drm/v3d_drm.h | 1 +
4 files changed, 13 insertions(+)
diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index 5e997ae8bc9c7ac110d79df8b5cf81a59dc0a291..0f53ca7460044e2a74c31d6282914f49844066b2 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -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;
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index b51f0b648a08011f737317ec1841d5ab316355b2..074cbccf88ddfe5961c779f0df93552264f54608 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -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 *
diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 35f131a46d0701cc8040d3b9654595a2bc260eab..29845917d7df5f9ff996fa52a728ff5d19dea90f 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -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);
diff --git a/include/uapi/drm/v3d_drm.h b/include/uapi/drm/v3d_drm.h
index dbbc404d2b3dd6c8b8e3969b0b76b7d8b371dddb..0a7ce2f6be19d2cbccf090f0db301119eb4b28ba 100644
--- a/include/uapi/drm/v3d_drm.h
+++ b/include/uapi/drm/v3d_drm.h
@@ -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 {
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] drm/v3d: Add parameter to retrieve the number of GPU resets per-fd
2025-07-11 15:18 [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Maíra Canal
2025-07-11 15:18 ` [PATCH 1/2] drm/v3d: Add parameter to retrieve the global number of GPU resets Maíra Canal
@ 2025-07-11 15:18 ` Maíra Canal
2025-07-14 6:53 ` [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Iago Toral
2025-07-17 14:31 ` Maíra Canal
3 siblings, 0 replies; 5+ messages in thread
From: Maíra Canal @ 2025-07-11 15:18 UTC (permalink / raw)
To: Juan A. Suarez, Iago Toral Quiroga, Melissa Wen
Cc: kernel-dev, dri-devel, Maíra Canal
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.
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
drivers/gpu/drm/v3d/v3d_drv.c | 6 ++++++
drivers/gpu/drm/v3d/v3d_drv.h | 6 ++++++
drivers/gpu/drm/v3d/v3d_sched.c | 3 +++
include/uapi/drm/v3d_drm.h | 1 +
4 files changed, 16 insertions(+)
diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index 0f53ca7460044e2a74c31d6282914f49844066b2..2def155ce496ec5f159f6bda9929aeaae141d1a6 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -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;
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index 074cbccf88ddfe5961c779f0df93552264f54608..dabda7aaf00074d8de42dcdb345d5f3331ac13b2 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -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 {
diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 29845917d7df5f9ff996fa52a728ff5d19dea90f..46003457a06e3c01637b2c0ed392660e4e569b4a 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -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);
diff --git a/include/uapi/drm/v3d_drm.h b/include/uapi/drm/v3d_drm.h
index 0a7ce2f6be19d2cbccf090f0db301119eb4b28ba..d9b01f4c3a047eac90899901cc603838ab5c9090 100644
--- a/include/uapi/drm/v3d_drm.h
+++ b/include/uapi/drm/v3d_drm.h
@@ -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 {
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters
2025-07-11 15:18 [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Maíra Canal
2025-07-11 15:18 ` [PATCH 1/2] drm/v3d: Add parameter to retrieve the global number of GPU resets Maíra Canal
2025-07-11 15:18 ` [PATCH 2/2] drm/v3d: Add parameter to retrieve the number of GPU resets per-fd Maíra Canal
@ 2025-07-14 6:53 ` Iago Toral
2025-07-17 14:31 ` Maíra Canal
3 siblings, 0 replies; 5+ messages in thread
From: Iago Toral @ 2025-07-14 6:53 UTC (permalink / raw)
To: Maíra Canal, Juan A. Suarez, Melissa Wen; +Cc: kernel-dev, dri-devel
Looks good to me:
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Iago
El vie, 11-07-2025 a las 12:18 -0300, Maíra Canal escribió:
> The GL extension KHR_robustness requires a mechanism for a GL
> application
> to learn about graphics resets that affect a GL context. With the
> goal
> to provide support for such extension in Mesa, this series implements
> global and per-context GPU reset counters that user-space can
> retrieve
> using the DRM_IOCTL_V3D_GET_PARAM ioctl.
>
> The corresponding user-space implementation for this series is
> available at [1].
>
> [1] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35965
>
> Best Regards,
> - Maíra
>
> ---
> Maíra Canal (2):
> drm/v3d: Add parameter to retrieve the global number of GPU
> resets
> drm/v3d: Add parameter to retrieve the number of GPU resets
> per-fd
>
> drivers/gpu/drm/v3d/v3d_drv.c | 11 +++++++++++
> drivers/gpu/drm/v3d/v3d_drv.h | 11 +++++++++++
> drivers/gpu/drm/v3d/v3d_sched.c | 5 +++++
> include/uapi/drm/v3d_drm.h | 2 ++
> 4 files changed, 29 insertions(+)
> ---
> base-commit: 917b10d90990fd2138b5dbc2d22cfa428c070ade
> change-id: 20250708-v3d-reset-counter-ab231c87bd35
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters
2025-07-11 15:18 [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Maíra Canal
` (2 preceding siblings ...)
2025-07-14 6:53 ` [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Iago Toral
@ 2025-07-17 14:31 ` Maíra Canal
3 siblings, 0 replies; 5+ messages in thread
From: Maíra Canal @ 2025-07-17 14:31 UTC (permalink / raw)
To: Juan A. Suarez, Iago Toral Quiroga, Melissa Wen, Maíra Canal
Cc: kernel-dev, dri-devel
On Fri, 11 Jul 2025 12:18:30 -0300, Maíra Canal wrote:
> The GL extension KHR_robustness requires a mechanism for a GL application
> to learn about graphics resets that affect a GL context. With the goal
> to provide support for such extension in Mesa, this series implements
> global and per-context GPU reset counters that user-space can retrieve
> using the DRM_IOCTL_V3D_GET_PARAM ioctl.
>
> The corresponding user-space implementation for this series is available at [1].
>
> [...]
Applied to drm-misc/drm-misc-next, thanks!
[1/2] drm/v3d: Add parameter to retrieve the global number of GPU resets
commit: 5774b3cfdedb3624ef0d2c82cccbfd61bcb60fd5
[2/2] drm/v3d: Add parameter to retrieve the number of GPU resets per-fd
commit: 769c153cfc3c6669c7b318f66c2b21ec3951fb4a
Best regards,
- Maíra
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-17 14:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 15:18 [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Maíra Canal
2025-07-11 15:18 ` [PATCH 1/2] drm/v3d: Add parameter to retrieve the global number of GPU resets Maíra Canal
2025-07-11 15:18 ` [PATCH 2/2] drm/v3d: Add parameter to retrieve the number of GPU resets per-fd Maíra Canal
2025-07-14 6:53 ` [PATCH 0/2] drm/v3d: Expose global and per-context GPU reset counters Iago Toral
2025-07-17 14:31 ` 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;
as well as URLs for NNTP newsgroup(s).