El sáb, 30-05-2026 a las 16:51 -0300, Maíra Canal escribió:
> A compute shader dispatch encodes its workgroup counts in the
> CFG0..CFG2
> registers. Kicking off a dispatch with a zero count in any of the
> three
> dimensions is invalid. First, the hardware will process 0 as 65536,
> causing an illegitimate submission. But over that, a submission with
> a
> zeroed workgroup dimension should be a no-op.
>
> These zeroed counts can reach the dispatch path through an indirect
> CSD
> job, whose workgroup counts are only known once the indirect buffer
> is
> read and may legitimately be zero, but such scenario should only
> result in
> a no-op.
>
> Don't submit the job to the hardware when any of the workgroup counts
> is
> zero, so the job completes immediately instead of running the shader.
>
> Cc: [email protected]
> Fixes: d223f98f0209 ("drm/v3d: Add support for compute shader
> dispatch.")
> Suggested-by: Jose Maria Casanova Crespo <[email protected]>
> Signed-off-by: Maíra Canal <[email protected]>
> ---
> drivers/gpu/drm/v3d/v3d_sched.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/v3d/v3d_sched.c
> b/drivers/gpu/drm/v3d/v3d_sched.c
> index 47f83936cd73..5476fcf43793 100644
> --- a/drivers/gpu/drm/v3d/v3d_sched.c
> +++ b/drivers/gpu/drm/v3d/v3d_sched.c
> @@ -352,6 +352,9 @@ v3d_csd_job_run(struct drm_sched_job *sched_job)
> return NULL;
> }
>
> + if (!job->args.cfg[0] || !job->args.cfg[1] || !job-
> >args.cfg[2])
> + return NULL;
I think this is not correct: cfg[0-2] have the actual dispatch sizes
encoded in the 16 MSB bits of these registers, allowing the lower 16-
bit to specify a base offset for the generated workgroup ids that may
not be zero. Therefore, I think we would want to rewrite this check as:
if ((job->args.cfg[0] & 0xffff0000u) == 0 ||
(job->args.cfg[1] & 0xffff0000u) == 0 ||
(job->args.cfg[2] & 0xffff0000u) == 0) {
return NULL;
}
Also, we probably want to add a comment here explaining that at the hw
level, 0 is interpreted as 65536 but the user-space driver only exposes
65535 as the maximum workgroup size allowed.
Iago
> +
> v3d->queue[V3D_CSD].active_job = &job->base;
>
> v3d_invalidate_caches(v3d);
>