Restructure the CPU ioctl so that all job types, including indirect CSD,
use a single struct v3d_submit chain and a single DRM exec context.
Currently, v3d_get_cpu_indirect_csd_params(), which is the indirect CSD
parser, not only parses the ioctl arguments, but also creates the jobs
and
locks the BOs during extension parsing. This breaks the default
submission
flow and creates a nested job submission.
This refactoring turns v3d_get_cpu_indirect_csd_params() into a pure
parser. Now, job creation and BO locking happen in the ioctl function,
which appends the indirect CSD and CLEAN_CACHE jobs to the same struct
v3d_submit and locks the union of all jobs' BOs under one drm_exec. This
eliminates the second drm_exec, the nested submission, and the
conditional
two-pass fence attachment that the CPU ioctl previously required for the
indirect CSD path.
For the refactoring, change the functions v3d_lock_bo_reservations(),
v3d_lookup_bos(), v3d_setup_csd_jobs_and_bos() and
v3d_attach_fences_and_unlock_reservation() to take struct v3d_submit
instead of individual arguments. The BO locking helper now iterates over
all jobs in the submission and locks the union, instead of only handling
the last job of the chain.
Signed-off-by: Maíra Canal <[email protected]>
---
drivers/gpu/drm/v3d/v3d_drv.h | 9 +-
drivers/gpu/drm/v3d/v3d_submit.c | 341 +++++++++++++
+-------------------------
2 files changed, 121 insertions(+), 229 deletions(-)
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/
v3d_drv.h
index fc12e5215fb0..071d919fe860 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -422,8 +422,10 @@ struct v3d_indirect_csd_info {
/* Indirect CSD */
struct v3d_csd_job *job;
- /* 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;
@@ -438,9 +440,6 @@ struct v3d_indirect_csd_info {
/* Indirect BO */
struct drm_gem_object *indirect;
-
- /* Context of the Indirect CSD job */
- struct drm_exec exec;
};
struct v3d_timestamp_query_info {
diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/
v3d_submit.c
index 5b519a892985..36402fc25c10 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -20,28 +20,42 @@
* to v3d, so we don't attach dma-buf fences to them.
*/
static int
-v3d_lock_bo_reservations(struct v3d_job *job, struct drm_exec *exec)
+v3d_lock_bo_reservations(struct v3d_submit *submit)
{
- int i, ret;
+ int i, j, ret;
- drm_exec_init(exec, DRM_EXEC_INTERRUPTIBLE_WAIT, job->bo_count);
- drm_exec_until_all_locked(exec) {
- ret = drm_exec_prepare_array(exec, job->bo, job->bo_count, 1);
+ drm_exec_init(&submit->exec,
+ DRM_EXEC_INTERRUPTIBLE_WAIT |
DRM_EXEC_IGNORE_DUPLICATES, 0);
+ drm_exec_until_all_locked(&submit->exec) {
+ for (i = 0; i < submit->job_count; i++) {
+ struct v3d_job *job = submit->jobs[i];