v3d_get_cpu_indirect_csd_params() currently does double duty: it parses
the indirect CSD extension and, while still inside the extension parser,
also creates the CSD/clean jobs and locks their BOs through a separate
DRM exec context. This nested submission deviates from the standard flow
and makes it hard to fold the indirect CSD path into the unified submit
chain.

Stash the parsed drm_v3d_submit_csd args in struct v3d_indirect_csd_info
and have the parser only fill in the parameters. Then, move job creation
(v3d_setup_csd_jobs_and_bos()) into v3d_submit_cpu_ioctl(), where is the
proper place to create jobs.

No functional change, but prepares to move the CPU ioctl into the
unified submission chain.

Signed-off-by: Maíra Canal <[email protected]>
---
 drivers/gpu/drm/v3d/v3d_drv.h    |  5 +++++
 drivers/gpu/drm/v3d/v3d_submit.c | 16 +++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index fc12e5215fb0..ec01668bacb6 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -425,6 +425,11 @@ struct v3d_indirect_csd_info {
        /* Clean cache job associated to the Indirect CSD job */
        struct v3d_job *clean_job;
 
+       /* Indirect CSD args, stashed by the extension parser and later used
+        * to create the CSD job from them.
+        */
+       struct drm_v3d_submit_csd args;
+
        /* Offset within the BO where the workgroup counts are stored */
        u32 offset;
 
diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
index c51474403d2d..ef003ca6b42a 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -600,6 +600,7 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,
        }
 
        job->job_type = V3D_CPU_JOB_TYPE_INDIRECT_CSD;
+       info->args = indirect_csd.submit;
        info->offset = indirect_csd.offset;
        info->wg_size = indirect_csd.wg_size;
        memcpy(&info->wg_uniform_offsets, &indirect_csd.wg_uniform_offsets,
@@ -607,9 +608,7 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv,
 
        info->indirect = drm_gem_object_lookup(file_priv, 
indirect_csd.indirect);
 
-       return v3d_setup_csd_jobs_and_bos(file_priv, v3d, &indirect_csd.submit,
-                                         &info->job, &info->clean_job,
-                                         NULL, &info->exec);
+       return 0;
 }
 
 /* Get data for the query timestamp job submission. */
@@ -1370,6 +1369,17 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,
                goto fail;
        }
 
+       if (cpu_job->job_type == V3D_CPU_JOB_TYPE_INDIRECT_CSD) {
+               ret = v3d_setup_csd_jobs_and_bos(file_priv, v3d,
+                                                &cpu_job->indirect_csd.args,
+                                                &cpu_job->indirect_csd.job,
+                                                
&cpu_job->indirect_csd.clean_job,
+                                                NULL,
+                                                &cpu_job->indirect_csd.exec);
+               if (ret)
+                       goto fail;
+       }
+
        clean_job = cpu_job->indirect_csd.clean_job;
        csd_job = cpu_job->indirect_csd.job;
 

-- 
2.54.0

Reply via email to