summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorMaíra Canal <mcanal@igalia.com>2026-01-12 08:51:36 -0300
committerMaíra Canal <mcanal@igalia.com>2026-01-19 07:12:25 -0300
commiteaba54b8a67bdec7f834d61ff6cf5f0f3f4ea5bc (patch)
treecaab75a70b9b9d23950813b5c2879bb13b50a715 /drivers/gpu/drm
parent26b4309a3ab82a0697751cde52eb336c29c19035 (diff)
drm/v3d: Consolidate CPU job validation in a function
All CPU job extension parsers duplicate the same validation procedure: ensure the extension is attached to a CPU job (not a GPU job) and that only a single CPU job extension is associated with a given job. Create a function to consolidate these checks and reduce the boilerplate across the various CPU job extension handlers. While here, convert the legacy DRM_DEBUG with a more appropriate drm_dbg(). Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Link: https://patch.msgid.link/20260112-v3d-drm-debug-v2-1-8ef6244c97bb@igalia.com Signed-off-by: Maíra Canal <mcanal@igalia.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/v3d/v3d_submit.c74
1 files changed, 26 insertions, 48 deletions
diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
index 7de5a95ee7ca..55e810b7417d 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -404,6 +404,26 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
return 0;
}
+/* Returns false if the CPU job has an invalid configuration. */
+static bool
+v3d_validate_cpu_job(struct drm_file *file_priv, struct v3d_cpu_job *job)
+{
+ struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
+ struct v3d_dev *v3d = v3d_priv->v3d;
+
+ if (!job) {
+ drm_dbg(&v3d->drm, "CPU job extension was attached to a GPU job.\n");
+ return false;
+ }
+
+ if (job->job_type) {
+ drm_dbg(&v3d->drm, "Two CPU job extensions were added to the same CPU job.\n");
+ return false;
+ }
+
+ return true;
+}
+
/* Get data for the indirect CSD job submission. */
static int
v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,
@@ -415,15 +435,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,
struct drm_v3d_indirect_csd indirect_csd;
struct v3d_indirect_csd_info *info = &job->indirect_csd;
- if (!job) {
- DRM_DEBUG("CPU job extension was attached to a GPU job.\n");
- return -EINVAL;
- }
-
- if (job->job_type) {
- DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n");
+ if (!v3d_validate_cpu_job(file_priv, job))
return -EINVAL;
- }
if (copy_from_user(&indirect_csd, ext, sizeof(indirect_csd)))
return -EFAULT;
@@ -458,15 +471,8 @@ v3d_get_cpu_timestamp_query_params(struct drm_file *file_priv,
unsigned int i;
int err;
- if (!job) {
- DRM_DEBUG("CPU job extension was attached to a GPU job.\n");
- return -EINVAL;
- }
-
- if (job->job_type) {
- DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n");
+ if (!v3d_validate_cpu_job(file_priv, job))
return -EINVAL;
- }
if (copy_from_user(&timestamp, ext, sizeof(timestamp)))
return -EFAULT;
@@ -527,15 +533,8 @@ v3d_get_cpu_reset_timestamp_params(struct drm_file *file_priv,
unsigned int i;
int err;
- if (!job) {
- DRM_DEBUG("CPU job extension was attached to a GPU job.\n");
- return -EINVAL;
- }
-
- if (job->job_type) {
- DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n");
+ if (!v3d_validate_cpu_job(file_priv, job))
return -EINVAL;
- }
if (copy_from_user(&reset, ext, sizeof(reset)))
return -EFAULT;
@@ -588,15 +587,8 @@ v3d_get_cpu_copy_query_results_params(struct drm_file *file_priv,
unsigned int i;
int err;
- if (!job) {
- DRM_DEBUG("CPU job extension was attached to a GPU job.\n");
- return -EINVAL;
- }
-
- if (job->job_type) {
- DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n");
+ if (!v3d_validate_cpu_job(file_priv, job))
return -EINVAL;
- }
if (copy_from_user(&copy, ext, sizeof(copy)))
return -EFAULT;
@@ -724,15 +716,8 @@ v3d_get_cpu_reset_performance_params(struct drm_file *file_priv,
struct drm_v3d_reset_performance_query reset;
int err;
- if (!job) {
- DRM_DEBUG("CPU job extension was attached to a GPU job.\n");
- return -EINVAL;
- }
-
- if (job->job_type) {
- DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n");
+ if (!v3d_validate_cpu_job(file_priv, job))
return -EINVAL;
- }
if (copy_from_user(&reset, ext, sizeof(reset)))
return -EFAULT;
@@ -770,15 +755,8 @@ v3d_get_cpu_copy_performance_query_params(struct drm_file *file_priv,
struct drm_v3d_copy_performance_query copy;
int err;
- if (!job) {
- DRM_DEBUG("CPU job extension was attached to a GPU job.\n");
- return -EINVAL;
- }
-
- if (job->job_type) {
- DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n");
+ if (!v3d_validate_cpu_job(file_priv, job))
return -EINVAL;
- }
if (copy_from_user(&copy, ext, sizeof(copy)))
return -EFAULT;