From: "Maíra Canal" <mcanal@igalia.com>
To: "Juan A. Suarez" <jasuarez@igalia.com>,
Iago Toral Quiroga <itoral@igalia.com>,
Melissa Wen <mwen@igalia.com>
Cc: kernel-dev@igalia.com, dri-devel@lists.freedesktop.org,
"Maíra Canal" <mcanal@igalia.com>
Subject: [PATCH 2/2] drm/v3d: Add parameter to retrieve the number of GPU resets per-fd
Date: Fri, 11 Jul 2025 12:18:32 -0300 [thread overview]
Message-ID: <20250711-v3d-reset-counter-v1-2-1ac73e9fca2d@igalia.com> (raw)
In-Reply-To: <20250711-v3d-reset-counter-v1-0-1ac73e9fca2d@igalia.com>
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
next prev parent reply other threads:[~2025-07-11 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250711-v3d-reset-counter-v1-2-1ac73e9fca2d@igalia.com \
--to=mcanal@igalia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=itoral@igalia.com \
--cc=jasuarez@igalia.com \
--cc=kernel-dev@igalia.com \
--cc=mwen@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).