drm/v3d: Convert v3d logging to device-based DRM helpers
Subsystems (3)
Maíra Canal
maintainercover drm/v3d: Convert v3d logging to device-based DRM helpers
This small series intends to replace the legacy DRM_DEBUG/INFO/WARN/ERROR logging with the corresponding device-based drm_dbg(), drm_info(), drm_warn() and drm_err() helpers. I split the series in two patches to ease the reviewing process as the first one has a minor code-refactor.
Thanks for the review!
Best regards,
- Maíra
---
Maíra Canal (2):
drm/v3d: Consolidate CPU job validation in a function drm/v3d: Convert v3d logging to device-based DRM helpers
drivers/gpu/drm/v3d/v3d_bo.c | 8 +- drivers/gpu/drm/v3d/v3d_drv.c | 6 +- drivers/gpu/drm/v3d/v3d_gem.c | 16 ++-- drivers/gpu/drm/v3d/v3d_irq.c | 8 +- drivers/gpu/drm/v3d/v3d_mmu.c | 6 +- drivers/gpu/drm/v3d/v3d_sched.c | 6 +- drivers/gpu/drm/v3d/v3d_submit.c | 181 ++++++++++++++++++--------------------- 7 files changed, 108 insertions(+), 123 deletions(-)
---
base-commit: 44e4c88951fa9c73bfbde8269e443ea5343dd2af
change-id: 20260109-v3d-drm-debug-412cec00a4ac
Maíra Canal
maintainerPATCH 1/2 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().
--- drivers/gpu/drm/v3d/v3d_submit.c | 111 ++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 65 deletions(-)
drivers/gpu/drm/v3d/v3d_submit.c +46 -65
@@ -404,27 +404,36 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,return 0 ; } -/* Get data for the indirect CSD job submission. */ -static int -v3d_get_cpu_indirect_csd_params (struct drm_file *file_priv, -struct drm_v3d_extension __user *ext, -struct v3d_cpu_job *job) +/* Returns false if the CPU job has an invalid configuration. */ +static bool +v3d_validate_cpu_job (struct v3d_dev *v3d,struct v3d_cpu_job *job) { -struct v3d_file_priv *v3d_priv = file_priv->driver_priv; -struct v3d_dev *v3d = v3d_priv->v3d; -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 ; +drm_dbg (&v3d->drm,"CPU job extension was attached to a GPU job.\n" ); +return false; }if (job->job_type) { -DRM_DEBUG ("Two CPU job extensions were added to the same CPU job.\n" ); -return -EINVAL ; +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 v3d_dev *v3d, +struct drm_file *file_priv, +struct drm_v3d_extension __user *ext, +struct v3d_cpu_job *job) +{ +struct drm_v3d_indirect_csd indirect_csd; +struct v3d_indirect_csd_info *info = &job->indirect_csd; + +if (!v3d_validate_cpu_job (v3d, job)) +return -EINVAL ; +if (copy_from_user (&indirect_csd, ext,sizeof (indirect_csd)))return -EFAULT ;
@@ -448,7 +457,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,/* Get data for the query timestamp job submission. */ static int -v3d_get_cpu_timestamp_query_params (struct drm_file *file_priv, +v3d_get_cpu_timestamp_query_params (struct v3d_dev *v3d, +struct drm_file *file_priv,struct drm_v3d_extension __user *ext,struct v3d_cpu_job *job) {
@@ -458,15 +468,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" ); +if (!v3d_validate_cpu_job (v3d, job))return -EINVAL ; - } - -if (job->job_type) { -DRM_DEBUG ("Two CPU job extensions were added to the same CPU job.\n" ); -return -EINVAL ; - }if (copy_from_user (×tamp, ext,sizeof (timestamp)))return -EFAULT ;
@@ -517,7 +520,8 @@ v3d_get_cpu_timestamp_query_params(struct drm_file *file_priv, }static int -v3d_get_cpu_reset_timestamp_params (struct drm_file *file_priv, +v3d_get_cpu_reset_timestamp_params (struct v3d_dev *v3d, +struct drm_file *file_priv,struct drm_v3d_extension __user *ext,struct v3d_cpu_job *job) {
@@ -527,15 +531,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" ); +if (!v3d_validate_cpu_job (v3d, job))return -EINVAL ; - } - -if (job->job_type) { -DRM_DEBUG ("Two CPU job extensions were added to the same CPU job.\n" ); -return -EINVAL ; - }if (copy_from_user (&reset, ext,sizeof (reset)))return -EFAULT ;
@@ -578,7 +575,8 @@ v3d_get_cpu_reset_timestamp_params(struct drm_file *file_priv,/* Get data for the copy timestamp query results job submission. */ static int -v3d_get_cpu_copy_query_results_params (struct drm_file *file_priv, +v3d_get_cpu_copy_query_results_params (struct v3d_dev *v3d, +struct drm_file *file_priv,struct drm_v3d_extension __user *ext,struct v3d_cpu_job *job) {
@@ -588,15 +586,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" ); +if (!v3d_validate_cpu_job (v3d, job))return -EINVAL ; - } - -if (job->job_type) { -DRM_DEBUG ("Two CPU job extensions were added to the same CPU job.\n" ); -return -EINVAL ; - }if (copy_from_user (©, ext,sizeof (copy)))return -EFAULT ;
@@ -716,7 +707,8 @@ v3d_copy_query_info(struct v3d_performance_query_info *query_info, }static int -v3d_get_cpu_reset_performance_params (struct drm_file *file_priv, +v3d_get_cpu_reset_performance_params (struct v3d_dev *v3d, +struct drm_file *file_priv,struct drm_v3d_extension __user *ext,struct v3d_cpu_job *job) {
@@ -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" ); +if (!v3d_validate_cpu_job (v3d, job))return -EINVAL ; - } - -if (job->job_type) { -DRM_DEBUG ("Two CPU job extensions were added to the same CPU job.\n" ); -return -EINVAL ; - }if (copy_from_user (&reset, ext,sizeof (reset)))return -EFAULT ;
@@ -762,7 +747,8 @@ v3d_get_cpu_reset_performance_params(struct drm_file *file_priv, }static int -v3d_get_cpu_copy_performance_query_params (struct drm_file *file_priv, +v3d_get_cpu_copy_performance_query_params (struct v3d_dev *v3d, +struct drm_file *file_priv,struct drm_v3d_extension __user *ext,struct v3d_cpu_job *job) {
@@ -770,15 +756,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" ); +if (!v3d_validate_cpu_job (v3d, job))return -EINVAL ; - } - -if (job->job_type) { -DRM_DEBUG ("Two CPU job extensions were added to the same CPU job.\n" ); -return -EINVAL ; - }if (copy_from_user (©, ext,sizeof (copy)))return -EFAULT ;
@@ -826,6 +805,8 @@ v3d_get_extensions(struct drm_file *file_priv,struct v3d_submit_ext *se, struct v3d_cpu_job *job) { + struct v3d_file_priv *v3d_priv = file_priv->driver_priv; +struct v3d_dev *v3d = v3d_priv->v3d;struct drm_v3d_extension __user *user_ext;int ret;
@@ -843,22 +824,22 @@ v3d_get_extensions(struct drm_file *file_priv, ret =v3d_get_multisync_submit_deps (file_priv, user_ext, se);break ;case DRM_V3D_EXT_ID_CPU_INDIRECT_CSD : - ret =v3d_get_cpu_indirect_csd_params (file_priv, user_ext, job); + ret =v3d_get_cpu_indirect_csd_params (v3d, file_priv, user_ext, job);break ;case DRM_V3D_EXT_ID_CPU_TIMESTAMP_QUERY : - ret =v3d_get_cpu_timestamp_query_params (file_priv, user_ext, job); + ret =v3d_get_cpu_timestamp_query_params (v3d, file_priv, user_ext, job);break ;case DRM_V3D_EXT_ID_CPU_RESET_TIMESTAMP_QUERY : - ret =v3d_get_cpu_reset_timestamp_params (file_priv, user_ext, job); + ret =v3d_get_cpu_reset_timestamp_params (v3d, file_priv, user_ext, job);break ;case DRM_V3D_EXT_ID_CPU_COPY_TIMESTAMP_QUERY : - ret =v3d_get_cpu_copy_query_results_params (file_priv, user_ext, job); + ret =v3d_get_cpu_copy_query_results_params (v3d, file_priv, user_ext, job);break ;case DRM_V3D_EXT_ID_CPU_RESET_PERFORMANCE_QUERY : - ret =v3d_get_cpu_reset_performance_params (file_priv, user_ext, job); + ret =v3d_get_cpu_reset_performance_params (v3d, file_priv, user_ext, job);break ;case DRM_V3D_EXT_ID_CPU_COPY_PERFORMANCE_QUERY : - ret =v3d_get_cpu_copy_performance_query_params (file_priv, user_ext, job); + ret =v3d_get_cpu_copy_performance_query_params (v3d, file_priv, user_ext, job);break ;default :DRM_DEBUG_DRIVER ("Unknown extension id: %d\n" , ext.id);
Signature · 1 line
2.52.0
Re: [PATCH 1/2] drm/v3d: Consolidate CPU job validation in a function
El vie, 09-01-2026 a las 15:35 -0300, Maíra Canal escribió:
(...)
Quoted 217 lines
drivers/gpu/drm/v3d/v3d_submit.c +0
-4-/* Get data for the indirect CSD job submission. */ -static int -v3d_get_cpu_indirect_csd_params (struct drm_file *file_priv, - struct drm_v3d_extension __user*ext,
drivers/gpu/drm/v3d/v3d_submit.c +3
-1- struct v3d_cpu_job *job) +/* Returns false if the CPU job has an invalid configuration. */ +static bool +v3d_validate_cpu_job (struct v3d_dev *v3d,struct v3d_cpu_job *job){
drivers/gpu/drm/v3d/v3d_submit.c +0
-5-struct v3d_file_priv *v3d_priv = file_priv->driver_priv; -struct v3d_dev *v3d = v3d_priv->v3d; -struct drm_v3d_indirect_csd indirect_csd; -struct v3d_indirect_csd_info *info = &job->indirect_csd; -if (!job) {
(quoted diff) +0
-1- DRM_DEBUG("CPU job extension was attached to a GPUjob.\n");
(quoted diff) +1
-1- return -EINVAL; + drm_dbg(&v3d->drm, "CPU job extension was attachedto a GPU job.\n");
(quoted diff) +1
-0+ return false;}
if (job->job_type) {(quoted diff) +0
-1- DRM_DEBUG("Two CPU job extensions were added to thesame CPU job.\n");
(quoted diff) +1
-1- return -EINVAL; + drm_dbg(&v3d->drm, "Two CPU job extensions wereadded to the same CPU job.\n");
(quoted diff) +1
-0+ return false;}
drivers/gpu/drm/v3d/v3d_submit.c +8
-0+return true; +} + +/* Get data for the indirect CSD job submission. */ +static int +v3d_get_cpu_indirect_csd_params (struct v3d_dev *v3d, +struct drm_file *file_priv, + struct drm_v3d_extension __user*ext,
drivers/gpu/drm/v3d/v3d_submit.c +8
-0+ struct v3d_cpu_job *job) +{ +struct drm_v3d_indirect_csd indirect_csd; +struct v3d_indirect_csd_info *info = &job->indirect_csd; + +if (!v3d_validate_cpu_job (v3d, job)) +return -EINVAL ; +if (copy_from_user(&indirect_csd, ext,
sizeof(indirect_csd)))
return-EFAULT;(quoted diff) +0
-0@@ -448,7 +457,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,
/* Get data for the query timestamp job submission. */ static intdrivers/gpu/drm/v3d/v3d_submit.c +2
-1-v3d_get_cpu_timestamp_query_params(struct drm_file *file_priv, +v3d_get_cpu_timestamp_query_params(struct v3d_dev *v3d, + struct drm_file *file_priv,struct
drm_v3d_extension__user*ext,
structv3d_cpu_job*job) {drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -458,15 +468,8 @@ v3d_get_cpu_timestamp_query_params(structdrm_file *file_priv, unsigned int i; int err;(quoted diff) +0
-2- if (!job) { - DRM_DEBUG("CPU job extension was attached to a GPUjob.\n");
(quoted diff) +1
-0+ if (!v3d_validate_cpu_job(v3d, job))return
-EINVAL;drivers/gpu/drm/v3d/v3d_submit.c +0
-4- } - -if (job->job_type) { - DRM_DEBUG("Two CPU job extensions were added to thesame CPU job.\n");
(quoted diff) +0
-2- return -EINVAL; - }
if (copy_from_user(×tamp, ext, sizeof(timestamp))) return-EFAULT;(quoted diff) +0
-0@@ -517,7 +520,8 @@ v3d_get_cpu_timestamp_query_params(struct drm_file *file_priv, }
static intdrivers/gpu/drm/v3d/v3d_submit.c +2
-1-v3d_get_cpu_reset_timestamp_params(struct drm_file *file_priv, +v3d_get_cpu_reset_timestamp_params(struct v3d_dev *v3d, + struct drm_file *file_priv,struct
drm_v3d_extension__user*ext,
structv3d_cpu_job*job) {drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -527,15 +531,8 @@ v3d_get_cpu_reset_timestamp_params(structdrm_file *file_priv, unsigned int i; int err;(quoted diff) +0
-2- if (!job) { - DRM_DEBUG("CPU job extension was attached to a GPUjob.\n");
(quoted diff) +1
-0+ if (!v3d_validate_cpu_job(v3d, job))return
-EINVAL;drivers/gpu/drm/v3d/v3d_submit.c +0
-4- } - -if (job->job_type) { - DRM_DEBUG("Two CPU job extensions were added to thesame CPU job.\n");
(quoted diff) +0
-2- return -EINVAL; - }
if (copy_from_user(&reset, ext, sizeof(reset))) return-EFAULT;(quoted diff) +0
-0@@ -578,7 +575,8 @@ v3d_get_cpu_reset_timestamp_params(struct drm_file *file_priv,
/* Get data for the copy timestamp query results job submission. */ static intdrivers/gpu/drm/v3d/v3d_submit.c +2
-1-v3d_get_cpu_copy_query_results_params(struct drm_file *file_priv, +v3d_get_cpu_copy_query_results_params(struct v3d_dev *v3d, + struct drm_file *file_priv,struct
drm_v3d_extension__user*ext,
structv3d_cpu_job*job) {drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -588,15 +586,8 @@ v3d_get_cpu_copy_query_results_params(structdrm_file *file_priv, unsigned int i; int err;(quoted diff) +0
-2- if (!job) { - DRM_DEBUG("CPU job extension was attached to a GPUjob.\n");
(quoted diff) +1
-0+ if (!v3d_validate_cpu_job(v3d, job))return
-EINVAL;drivers/gpu/drm/v3d/v3d_submit.c +0
-4- } - -if (job->job_type) { - DRM_DEBUG("Two CPU job extensions were added to thesame CPU job.\n");
(quoted diff) +0
-2- return -EINVAL; - }
if (copy_from_user(©, ext, sizeof(copy))) return-EFAULT;(quoted diff) +0
-0@@ -716,7 +707,8 @@ v3d_copy_query_info(struct v3d_performance_query_info *query_info, }
static intdrivers/gpu/drm/v3d/v3d_submit.c +2
-1-v3d_get_cpu_reset_performance_params(struct drm_file *file_priv, +v3d_get_cpu_reset_performance_params(struct v3d_dev *v3d, + struct drm_file *file_priv,struct
drm_v3d_extension__user*ext,
structv3d_cpu_job*job) {drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -724,15 +716,8 @@ v3d_get_cpu_reset_performance_params(struct drm_file *file_priv, struct drm_v3d_reset_performance_query reset; int err;(quoted diff) +0
-2- if (!job) { - DRM_DEBUG("CPU job extension was attached to a GPUjob.\n");
(quoted diff) +1
-0+ if (!v3d_validate_cpu_job(v3d, job))return
-EINVAL;drivers/gpu/drm/v3d/v3d_submit.c +0
-4- } - -if (job->job_type) { - DRM_DEBUG("Two CPU job extensions were added to thesame CPU job.\n");
(quoted diff) +0
-2- return -EINVAL; - }
if (copy_from_user(&reset, ext, sizeof(reset))) return-EFAULT;(quoted diff) +0
-0@@ -762,7 +747,8 @@ v3d_get_cpu_reset_performance_params(struct drm_file *file_priv, }
static int -v3d_get_cpu_copy_performance_query_params(structdrm_file*file_priv,(quoted diff) +2
-0+v3d_get_cpu_copy_performance_query_params(struct v3d_dev *v3d, + struct drm_file
*file_priv,
structdrm_v3d_extension__user*ext,
structv3d_cpu_job*job) {drivers/gpu/drm/v3d/v3d_submit.c +0
-0@@ -770,15 +756,8 @@ v3d_get_cpu_copy_performance_query_params(struct drm_file *file_priv, struct drm_v3d_copy_performance_query copy; int err;(quoted diff) +0
-2- if (!job) { - DRM_DEBUG("CPU job extension was attached to a GPUjob.\n");
(quoted diff) +1
-0+ if (!v3d_validate_cpu_job(v3d, job))return
-EINVAL;drivers/gpu/drm/v3d/v3d_submit.c +0
-4- } - -if (job->job_type) { - DRM_DEBUG("Two CPU job extensions were added to thesame CPU job.\n");
(quoted diff) +0
-2- return -EINVAL; - }
if (copy_from_user(©, ext, sizeof(copy))) return-EFAULT;
drivers/gpu/drm/v3d/v3d_submit.c v3d_get_extensions(struct drm_file *file_priv, · line 809
Quoted 5 lines
drivers/gpu/drm/v3d/v3d_submit.c +2
-0@@ -826,6 +805,8 @@ v3d_get_extensions(struct drm_file *file_priv, struct v3d_submit_ext *se, struct v3d_cpu_job *job) { +struct v3d_file_priv *v3d_priv = file_priv->driver_priv; +struct v3d_dev *v3d = v3d_priv->v3d;
Since we can get the v3d_dev from the file_priv and we are already passing file_priv around, does it really give us anything to also pass the v3d_dev around if we only need it in that function? Not that I am necessarily against it, just making sure that was a conscious decision.
Iago
Quoted 48 lines
drivers/gpu/drm/v3d/v3d_submit.c +0
-0struct drm_v3d_extension __user *user_ext; int ret;(quoted diff) +0
-0@@ -843,22 +824,22 @@ v3d_get_extensions(struct drm_file *file_priv,ret =
v3d_get_multisync_submit_deps(file_priv, user_ext, se); break;
caseDRM_V3D_EXT_ID_CPU_INDIRECT_CSD:(quoted diff) +0
-1- ret =
v3d_get_cpu_indirect_csd_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret = v3d_get_cpu_indirect_csd_params(v3d,
file_priv,user_ext, job);
break;
caseDRM_V3D_EXT_ID_CPU_TIMESTAMP_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_timestamp_query_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_timestamp_query_params(v3d, file_priv, user_ext, job); break;
caseDRM_V3D_EXT_ID_CPU_RESET_TIMESTAMP_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_reset_timestamp_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_reset_timestamp_params(v3d, file_priv, user_ext, job); break;
caseDRM_V3D_EXT_ID_CPU_COPY_TIMESTAMP_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_copy_query_results_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_copy_query_results_params(v3d, file_priv, user_ext, job); break;
caseDRM_V3D_EXT_ID_CPU_RESET_PERFORMANCE_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_reset_performance_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_reset_performance_params(v3d, file_priv, user_ext, job); break;
caseDRM_V3D_EXT_ID_CPU_COPY_PERFORMANCE_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_copy_performance_query_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_copy_performance_query_params(v3d, file_priv, user_ext, job);
break;
default:
DRM_DEBUG_DRIVER("Unknown extension id:
%d\n", ext.id);
Maíra Canal
maintainerRe: [PATCH 1/2] drm/v3d: Consolidate CPU job validation in a function
Hi Iago,
Quoted 2 lines · Iago Toral
El vie, 09-01-2026 a las 15:35 -0300, Maíra Canal escribió:
(...)
[...]
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/v3d/v3d_submit.c +1
-8@@ -770,15 +756,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"); + if (!v3d_validate_cpu_job(v3d, job)) return -EINVAL; - } - -if (job->job_type) { - DRM_DEBUG("Two CPU job extensions were added to the same CPU job.\n"); -return -EINVAL ; - }
Quoted 13 lines
drivers/gpu/drm/v3d/v3d_submit.c v3d_get_extensions(struct drm_file *file_priv, · line 809
Quoted 8 lines
if (
copy_from_user(©, ext, sizeof(copy))) return-EFAULT;drivers/gpu/drm/v3d/v3d_submit.c +2
-0@@ -826,6 +805,8 @@ v3d_get_extensions(struct drm_file *file_priv, struct v3d_submit_ext *se, struct v3d_cpu_job *job) { +struct v3d_file_priv *v3d_priv = file_priv->driver_priv; +struct v3d_dev *v3d = v3d_priv->v3d;Since we can get the
v3d_devfrom thefile_privand we are already passingfile_privaround, does it really give us anything to also pass thev3d_devaround if we only need it in that function? Not that I am necessarily against it, just making sure that was a conscious decision.
Initially, I thought it would be more semantic to use v3d_dev, but rethinking it, I can agree that it would be better to use file_priv. I'll address it in v2.
Best regards,
- Maíra
Quoted 52 lines
Iago
Quoted 48 lines
drivers/gpu/drm/v3d/v3d_submit.c +4
-4struct drm_v3d_extension __user *user_ext; int ret;@@ -843,22 +824,22 @@ v3d_get_extensions(struct drm_file *file_priv, ret =v3d_get_multisync_submit_deps (file_priv, user_ext, se); break; case DRM_V3D_EXT_ID_CPU_INDIRECT_CSD: - ret =v3d_get_cpu_indirect_csd_params (file_priv, user_ext, job); + ret =v3d_get_cpu_indirect_csd_params (v3d, file_priv, user_ext, job); break; case DRM_V3D_EXT_ID_CPU_TIMESTAMP_QUERY: - ret =v3d_get_cpu_timestamp_query_params (file_priv, user_ext, job); + ret =v3d_get_cpu_timestamp_query_params (v3d, file_priv, user_ext, job); break; case DRM_V3D_EXT_ID_CPU_RESET_TIMESTAMP_QUERY: - ret =v3d_get_cpu_reset_timestamp_params (file_priv, user_ext, job); + ret =v3d_get_cpu_reset_timestamp_params (v3d, file_priv, user_ext, job); break; case DRM_V3D_EXT_ID_CPU_COPY_TIMESTAMP_QUERY: - ret =v3d_get_cpu_copy_query_results_params (file_priv, user_ext, job); + ret =v3d_get_cpu_copy_query_results_params (v3d, file_priv, user_ext, job);break;
caseDRM_V3D_EXT_ID_CPU_RESET_PERFORMANCE_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_reset_performance_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_reset_performance_params(v3d, file_priv, user_ext, job);
break;
caseDRM_V3D_EXT_ID_CPU_COPY_PERFORMANCE_QUERY:(quoted diff) +0
-1- ret =
v3d_get_cpu_copy_performance_query_params(file_priv, user_ext, job);(quoted diff) +1
-0+ ret =
v3d_get_cpu_copy_performance_query_params(v3d, file_priv, user_ext, job);
break;
default:
DRM_DEBUG_DRIVER("Unknown extension id:
%d\n", ext.id);
Maíra Canal
maintainerPATCH 2/2 drm/v3d: Convert v3d logging to device-based DRM helpers
In reply to Maíra CanalReplace legacy DRM_DEBUG/INFO/WARN/ERROR logging with the corresponding device-based drm_dbg(), drm_info(), drm_warn() and drm_err() helpers. For some messages, adjust the log level to better reflect their severity.
This allows filtering via drm.debug, reduces log spam, and helps differentiate v3d logs from vc4 logs.
--- drivers/gpu/drm/v3d/v3d_bo.c | 8 ++--- drivers/gpu/drm/v3d/v3d_drv.c | 6 ++-- drivers/gpu/drm/v3d/v3d_gem.c | 16 ++++----- drivers/gpu/drm/v3d/v3d_irq.c | 8 ++--- drivers/gpu/drm/v3d/v3d_mmu.c | 6 ++-- drivers/gpu/drm/v3d/v3d_sched.c | 6 ++-- drivers/gpu/drm/v3d/v3d_submit.c | 70 +++++++++++++++++++++------------------- 7 files changed, 62 insertions(+), 58 deletions(-)
drivers/gpu/drm/v3d/v3d_bo.c +4 -4
@@ -213,7 +213,7 @@ int v3d_create_bo_ioctl(struct drm_device *dev, void *data,int ret;if (args->flags !=0 ) { -DRM_INFO ("unknown create_bo flags: %d\n" , args->flags); +drm_dbg (dev,"unknown create_bo flags: %d\n" , args->flags);return -EINVAL ; }
@@ -236,13 +236,13 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,struct drm_gem_object *gem_obj;if (args->flags !=0 ) { -DRM_INFO ("unknown mmap_bo flags: %d\n" , args->flags); +drm_dbg (dev,"unknown mmap_bo flags: %d\n" , args->flags);return -EINVAL ; } gem_obj =drm_gem_object_lookup (file_priv, args->handle);if (!gem_obj) { -DRM_DEBUG ("Failed to look up GEM BO %d\n" , args->handle); +drm_dbg (dev,"Failed to look up GEM BO %d\n" , args->handle);return -ENOENT ; }
@@ -261,7 +261,7 @@ int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data, gem_obj =drm_gem_object_lookup (file_priv, args->handle);if (!gem_obj) { -DRM_DEBUG ("Failed to look up GEM BO %d\n" , args->handle); +drm_dbg (dev,"Failed to look up GEM BO %d\n" , args->handle);return -ENOENT ; } bo =to_v3d_bo (gem_obj);
drivers/gpu/drm/v3d/v3d_drv.c +3 -3
@@ -120,7 +120,7 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,mutex_unlock (&v3d->reset_lock);return 0 ;default : -DRM_DEBUG ("Unknown parameter %d\n" , args->param); +drm_dbg (dev,"Unknown parameter %d\n" , args->param);return -EINVAL ; } }
@@ -297,7 +297,7 @@ v3d_idle_sms(struct v3d_dev *v3d)if (wait_for ((V3D_GET_FIELD (V3D_SMS_READ (V3D_SMS_TEE_CS ),V3D_SMS_STATE ) ==V3D_SMS_IDLE ),100 )) { -DRM_ERROR ("Failed to power up SMS\n" ); +drm_err (&v3d->drm,"Failed to power up SMS\n" ); }v3d_reset_sms (v3d);
@@ -313,7 +313,7 @@ v3d_power_off_sms(struct v3d_dev *v3d)if (wait_for ((V3D_GET_FIELD (V3D_SMS_READ (V3D_SMS_TEE_CS ),V3D_SMS_STATE ) ==V3D_SMS_POWER_OFF_STATE ),100 )) { -DRM_ERROR ("Failed to power off SMS\n" ); +drm_err (&v3d->drm,"Failed to power off SMS\n" ); } }
drivers/gpu/drm/v3d/v3d_gem.c +8 -8
@@ -52,7 +52,7 @@ v3d_idle_axi(struct v3d_dev *v3d, int core) (V3D_GMP_STATUS_RD_COUNT_MASK | V3D_GMP_STATUS_WR_COUNT_MASK | V3D_GMP_STATUS_CFG_BUSY)) == 0, 100)) { -DRM_ERROR ("Failed to wait for safe GMP shutdown\n" ); +drm_err (&v3d->drm,"Failed to wait for safe GMP shutdown\n" ); } }
@@ -67,7 +67,7 @@ v3d_idle_gca(struct v3d_dev *v3d)if (wait_for ((V3D_GCA_READ (V3D_GCA_SAFE_SHUTDOWN_ACK ) &V3D_GCA_SAFE_SHUTDOWN_ACK_ACKED ) ==V3D_GCA_SAFE_SHUTDOWN_ACK_ACKED ,100 )) { -DRM_ERROR ("Failed to wait for safe GCA shutdown\n" ); +drm_err (&v3d->drm,"Failed to wait for safe GCA shutdown\n" ); } }
@@ -117,7 +117,7 @@ v3d_reset_sms(struct v3d_dev *v3d) V3D_SMS_STATE) == V3D_SMS_ISOLATING_FOR_RESET) && !(V3D_GET_FIELD(V3D_SMS_READ(V3D_SMS_REE_CS), V3D_SMS_STATE) == V3D_SMS_RESETTING), 100)) { -DRM_ERROR ("Failed to wait for SMS reset\n" ); +drm_err (&v3d->drm,"Failed to wait for SMS reset\n" ); } }
@@ -126,9 +126,9 @@ v3d_reset(struct v3d_dev *v3d) {struct drm_device *dev = &v3d->drm; -DRM_DEV_ERROR (dev->dev,"Resetting GPU for hang.\n" ); -DRM_DEV_ERROR (dev->dev,"V3D_ERR_STAT: 0x%08x\n" , -V3D_CORE_READ (0 ,V3D_ERR_STAT )); +drm_warn (dev,"Resetting GPU for hang.\n" ); +drm_warn (dev,"V3D_ERR_STAT: 0x%08x\n" ,V3D_CORE_READ (0 ,V3D_ERR_STAT )); +trace_v3d_reset_begin (dev);/* XXX: only needed for safe powerdown, not reset. */
@@ -216,7 +216,7 @@ v3d_clean_caches(struct v3d_dev *v3d)V3D_CORE_WRITE (core,V3D_CTL_L2TCACTL ,V3D_L2TCACTL_TMUWCF );if (wait_for (!(V3D_CORE_READ (core,V3D_CTL_L2TCACTL ) &V3D_L2TCACTL_TMUWCF ),100 )) { -DRM_ERROR ("Timeout waiting for TMU write combiner flush\n" ); +drm_err (dev,"Timeout waiting for TMU write combiner flush\n" ); }mutex_lock (&v3d->cache_clean_lock);
@@ -226,7 +226,7 @@ v3d_clean_caches(struct v3d_dev *v3d)if (wait_for (!(V3D_CORE_READ (core,V3D_CTL_L2TCACTL ) &V3D_L2TCACTL_L2TFLS ),100 )) { -DRM_ERROR ("Timeout waiting for L2T clean\n" ); +drm_err (dev,"Timeout waiting for L2T clean\n" ); }mutex_unlock (&v3d->cache_clean_lock);
drivers/gpu/drm/v3d/v3d_irq.c +4 -4
@@ -50,7 +50,7 @@ v3d_overflow_mem_work(struct work_struct *work)unsigned long irqflags;if (IS_ERR (bo)) { -DRM_ERROR ("Couldn't allocate binner overflow mem\n" ); +drm_err (dev,"Couldn't allocate binner overflow mem\n" );return ; } obj = &bo->base.base;
@@ -140,7 +140,7 @@ v3d_irq(int irq, void *arg)* always-allowed mode. */ if (v3d->ver <V3D_GEN_71 && (intsts &V3D_INT_GMPV )) -dev_err (v3d->drm.dev,"GMP violation\n" ); +drm_err (&v3d->drm,"GMP violation\n" );/* V3D 4.2 wires the hub and core IRQs together, so if we & * didn't see the common one then check hub for MMU IRQs.
@@ -226,7 +226,7 @@ v3d_hub_irq(int irq, void *arg) } } - dev_err(v3d->drm.dev, "MMU error from client %s (0x%x) at 0x%llx%s%s%s\n", + drm_dbg(&v3d->drm, "MMU error from client %s (0x%x) at 0x%llx%s%s%s\n", client, axi_id, (long long)vio_addr, ((intsts & V3D_HUB_INT_MMU_WRV) ? ", write violation" : ""),
@@ -238,7 +238,7 @@ v3d_hub_irq(int irq, void *arg) }if (v3d->ver >=V3D_GEN_71 && (intsts &V3D_V7_HUB_INT_GMPV )) { -dev_err (v3d->drm.dev,"GMP Violation\n" ); +drm_err (&v3d->drm,"GMP Violation\n" ); status =IRQ_HANDLED ; }
drivers/gpu/drm/v3d/v3d_mmu.c +4 -2
@@ -18,6 +18,8 @@* each client. This is not yet implemented. */ +#include <drm/drm_print.h> +#include "v3d_drv.h" #include "v3d_regs.h"
@@ -125,7 +127,7 @@ void v3d_mmu_insert_ptes(struct v3d_bo *bo) shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT);if (v3d_mmu_flush_all (v3d)) -dev_err (v3d->drm.dev,"MMU flush timeout\n" ); +drm_err (&v3d->drm,"MMU flush timeout\n" ); }void v3d_mmu_remove_ptes (struct v3d_bo *bo)
@@ -138,5 +140,5 @@ void v3d_mmu_remove_ptes(struct v3d_bo *bo) v3d->pt[page] =0 ;if (v3d_mmu_flush_all (v3d)) -dev_err (v3d->drm.dev,"MMU flush timeout\n" ); +drm_err (&v3d->drm,"MMU flush timeout\n" ); }
drivers/gpu/drm/v3d/v3d_sched.c +3 -3
@@ -585,7 +585,7 @@ v3d_reset_performance_queries(struct v3d_cpu_job *job) perfmon =v3d_perfmon_find (v3d_priv, performance_query->queries[i].kperfmon_ids[j]);if (!perfmon) { -DRM_DEBUG ("Failed to find perfmon." ); +drm_dbg (&v3d->drm,"Failed to find perfmon." );continue ; }
@@ -620,7 +620,7 @@ v3d_write_performance_query_result(struct v3d_cpu_job *job, void *data, perfmon =v3d_perfmon_find (v3d_priv, perf_query->kperfmon_ids[i]);if (!perfmon) { -DRM_DEBUG ("Failed to find perfmon." ); +drm_dbg (&v3d->drm,"Failed to find perfmon." );continue ; }
@@ -690,7 +690,7 @@ v3d_cpu_job_run(struct drm_sched_job *sched_job)struct v3d_dev *v3d = job->base.v3d;if (job->job_type >=ARRAY_SIZE (cpu_job_function)) { -DRM_DEBUG_DRIVER ("Unknown CPU job: %d\n" , job->job_type); +drm_dbg (&v3d->drm,"Unknown CPU job: %d\n" , job->job_type);return NULL ; }
drivers/gpu/drm/v3d/v3d_submit.c +36 -34
248 lines not on this page · raw message
Signature · 1 line
2.52.0
El vie, 09-01-2026 a las 15:35 -0300, Maíra Canal escribió:
(...)
Quoted 11 lines
drivers/gpu/drm/v3d/v3d_gem.c +0
-0@@ -126,9 +126,9 @@ v3d_reset(struct v3d_dev *v3d) { struct drm_device *dev = &v3d->drm;drivers/gpu/drm/v3d/v3d_gem.c +2
-3-DRM_DEV_ERROR (dev->dev,"Resetting GPU for hang.\n" ); -DRM_DEV_ERROR (dev->dev,"V3D_ERR_STAT: 0x%08x\n" , - V3D_CORE_READ(0, V3D_ERR_STAT)); +drm_warn (dev,"Resetting GPU for hang.\n" ); + drm_warn(dev, "V3D_ERR_STAT: 0x%08x\n", V3D_CORE_READ(0,
V3D_ERR_STAT));
+
These look like they should be drm_err, no?
(...)
drivers/gpu/drm/v3d/v3d_submit.c v3d_put_multisync_post_deps(struct v3d_submit_ext *se) · line 325
Quoted 3 lines
static int
drivers/gpu/drm/v3d/v3d_submit.c +1
-1-v3d_get_multisync_post_deps(struct drm_file *file_priv, +v3d_get_multisync_post_deps(struct v3d_dev *v3d,
Same comment as in the previous patch. Again, not necessarily against it.
Quoted 13 lines
(quoted diff) +1
-0+ struct drm_file *file_priv,struct
v3d_submit_ext*se, u32 count, u64 handles) {(quoted diff) +0
-0@@ -346,7 +347,7 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
if (copy_from_user(&out, post_deps++, sizeof(out))) {
ret =-EFAULT;(quoted diff) +0
-1- DRM_DEBUG("Failed to copy post dephandles\n");
(quoted diff) +1
-0+ drm_dbg(&v3d->drm, "Failed to copy post dep
Quoted 1 line
handles\n");
I think we have a lot of these kind of things as dbg that sould probably be err, no? Not sure if that is very relevant though, but we can fix that separately if we want to.
Iago
Quoted 3 lines
goto fail;
}
Maíra Canal
maintainerHi Iago,
Quoted 6 lines · Iago Toral
El vie, 09-01-2026 a las 15:35 -0300, Maíra Canal escribió:
(...)Quoted 4 lines
drivers/gpu/drm/v3d/v3d_gem.c +0
-0@@ -126,9 +126,9 @@ v3d_reset(struct v3d_dev *v3d) { struct drm_device *dev = &v3d->drm;
Quoted 9 lines
drivers/gpu/drm/v3d/v3d_gem.c v3d_reset(struct v3d_dev *v3d) · line 131
Quoted 7 lines
drivers/gpu/drm/v3d/v3d_gem.c +3
-3-DRM_DEV_ERROR (dev->dev,"Resetting GPU for hang.\n" ); -DRM_DEV_ERROR (dev->dev,"V3D_ERR_STAT: 0x%08x\n" , - V3D_CORE_READ(0, V3D_ERR_STAT)); +drm_warn (dev,"Resetting GPU for hang.\n" ); +drm_warn (dev,"V3D_ERR_STAT: 0x%08x\n" ,V3D_CORE_READ (0 ,V3D_ERR_STAT )); +These look like they should be
drm_err, no?
Actually, I decided to change to a warning as a GPU reset is not always an error. For example, we have the DRM_GPU_SCHED_STAT_NO_HANG scenario, in which the GPU isn't actually hung. Also, sometimes we have GPU resets that recover the GPU and the user doesn't see any disruption.
I believe a warning is a good compromise between an error and a debug message, but I'm fine with changing it back to an error if you believe it's more suitable.
Quoted 10 lines
(...)
drivers/gpu/drm/v3d/v3d_submit.c v3d_put_multisync_post_deps(struct v3d_submit_ext *se) · line 325
Quoted 3 lines
static int
drivers/gpu/drm/v3d/v3d_submit.c +1
-1-v3d_get_multisync_post_deps(struct drm_file *file_priv, +v3d_get_multisync_post_deps(struct v3d_dev *v3d,Same comment as in the previous patch. Again, not necessarily against it.
I'll address it in v2. Thanks!
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/v3d/v3d_submit.c +1
-0+ struct drm_file *file_priv, struct v3d_submit_ext *se, u32 count, u64 handles) {@@ -346,7 +347,7 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
Quoted 11 lines
Quoted 7 lines
(quoted diff) +1
-1if (copy_from_user(&out, post_deps++, sizeof(out))) { ret = -EFAULT; - DRM_DEBUG("Failed to copy post dep handles\n"); + drm_dbg(&v3d->drm, "Failed to copy post dephandles\n");
I think we have a lot of these kind of things as dbg that sould probably be err, no? Not sure if that is very relevant though, but we can fix that separately if we want to.
I have the impression that those messages are more useful for us, developers, than the end user. For such reason, I believe that a debug message is more suitable, as the userspace will (hopefully) handle the errno gracefully and in case of a bug, we can use ``drm.debug`` to investigate it without swamping the user's kernel log.
Best regards,
- Maíra
Quoted 6 lines
Iago
Quoted 3 lines
goto fail;
}
Quoted 19 lines · Maíra Canal
Hi Iago,
Quoted 15 lines · Iago Toral
El vie, 09-01-2026 a las 15:35 -0300, Maíra Canal escribió:
(...)Quoted 11 lines
drivers/gpu/drm/v3d/v3d_gem.c +0
-0@@ -126,9 +126,9 @@ v3d_reset(struct v3d_dev *v3d) { struct drm_device *dev = &v3d->drm;drivers/gpu/drm/v3d/v3d_gem.c +2
-3-DRM_DEV_ERROR (dev->dev,"Resetting GPU for hang.\n" ); -DRM_DEV_ERROR (dev->dev,"V3D_ERR_STAT: 0x%08x\n" , - V3D_CORE_READ(0, V3D_ERR_STAT)); +drm_warn (dev,"Resetting GPU for hang.\n" ); + drm_warn(dev, "V3D_ERR_STAT: 0x%08x\n", V3D_CORE_READ(0,
V3D_ERR_STAT));
+These look like they should be
drm_err, no?
Quoted 5 lines
Actually, I decided to change to a warning as a GPU reset is not always
an error. For example, we have theDRM_GPU_SCHED_STAT_NO_HANGscenario,
in which the GPU isn't actually hung.
But we only use that if we are not actually resetting the GPU, no? the messages above are for when we actually reset.
Quoted 3 lines
Also, sometimes we have GPU resets
that recover the GPU and the user doesn't see any disruption.
In the event of a reset there is always going to be at least a performance hiccup which would be noticeable by users, but more importantly, unless we are deciding to reset the GPU for some internal reason unrelated to the user (I don't think we ever do this?) it signs that something has gone really wrong, so making it an explicit error message makes more sense to me.
Quoted 42 lines
I believe a warning is a good compromise between an error and a debug message, but I'm fine with changing it back to an error if you believe
it's more suitable.Quoted 11 lines
(...)
drivers/gpu/drm/v3d/v3d_submit.c v3d_put_multisync_post_deps(struct v3d_submit_ext *se) · line 325
Quoted 3 lines
static int
drivers/gpu/drm/v3d/v3d_submit.c +1
-1-v3d_get_multisync_post_deps(struct drm_file *file_priv, +v3d_get_multisync_post_deps(struct v3d_dev *v3d,Same comment as in the previous patch. Again, not necessarily against
it.I'll address it in v2. Thanks!
Quoted 14 lines
Quoted 14 lines
(quoted diff) +1
-0+ struct drm_file *file_priv,struct
v3d_submit_ext*se, u32 count, u64 handles) {(quoted diff) +0
-0@@ -346,7 +347,7 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
if (copy_from_user(&out, post_deps++, sizeof(out)))
{
ret =-EFAULT;(quoted diff) +0
-1- DRM_DEBUG("Failed to copy post dephandles\n");
Quoted 8 lines
Quoted 3 lines
(quoted diff) +1
-0+ drm_dbg(&v3d->drm, "Failed to copy postdep
handles\n");I think we have a lot of these kind of things as dbg that sould probably be err, no? Not sure if that is very relevant though, but we
can fix that separately if we want to.
Quoted 7 lines
I have the impression that those messages are more useful for us, developers, than the end user. For such reason, I believe that a debug
message is more suitable, as the userspace will (hopefully) handle the
errno gracefully and in case of a bug, we can use ``drm.debug`` to investigate it without swamping the user's kernel log.
I think many of these would only happen in OOM scenarios, at which point swamping the user's kernel log is probably the least of their concerns... but in any case, I think these would be rare enough that is not a big deal if we dump them as debug or error messages, so I am okay with keeping this as-is.
Iago
Quoted 12 lines
Best regards,
- MaíraQuoted 6 lines
Iago
Quoted 3 lines
goto fail;
}