Skip to content

Commit a783a09

Browse files
committed
drm/v3d: Refactor job management.
The CL submission had two jobs embedded in an exec struct. When I added TFU support, I had to replicate some of the exec stuff and some of the job stuff. As I went to add CSD, it became clear that actually what was in exec should just be in the two CL jobs, and it would let us share a lot more code between the 4 queues. v2: Fix missing error path in TFU ioctl's bo[] allocation. Signed-off-by: Eric Anholt <eric@anholt.net> Link: https://patchwork.freedesktop.org/patch/msgid/20190416225856.20264-3-eric@anholt.net Acked-by: Rob Clark <robdclark@gmail.com>
1 parent d4c3022 commit a783a09

4 files changed

Lines changed: 380 additions & 329 deletions

File tree

‎drivers/gpu/drm/v3d/v3d_drv.h‎

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ struct v3d_dev {
6767

6868
struct work_struct overflow_mem_work;
6969

70-
struct v3d_exec_info *bin_job;
71-
struct v3d_exec_info *render_job;
70+
struct v3d_bin_job *bin_job;
71+
struct v3d_render_job *render_job;
7272
struct v3d_tfu_job *tfu_job;
7373

7474
struct v3d_queue_state queue[V3D_MAX_QUEUES];
@@ -117,7 +117,7 @@ struct v3d_bo {
117117
struct drm_mm_node node;
118118

119119
/* List entry for the BO's position in
120-
* v3d_exec_info->unref_list
120+
* v3d_render_job->unref_list
121121
*/
122122
struct list_head unref_head;
123123
};
@@ -157,67 +157,69 @@ to_v3d_fence(struct dma_fence *fence)
157157
struct v3d_job {
158158
struct drm_sched_job base;
159159

160-
struct v3d_exec_info *exec;
160+
struct kref refcount;
161+
162+
struct v3d_dev *v3d;
163+
164+
/* This is the array of BOs that were looked up at the start
165+
* of submission.
166+
*/
167+
struct drm_gem_object **bo;
168+
u32 bo_count;
161169

162170
/* An optional fence userspace can pass in for the job to depend on. */
163171
struct dma_fence *in_fence;
164172

165173
/* v3d fence to be signaled by IRQ handler when the job is complete. */
166174
struct dma_fence *irq_fence;
167175

176+
/* scheduler fence for when the job is considered complete and
177+
* the BO reservations can be released.
178+
*/
179+
struct dma_fence *done_fence;
180+
181+
/* Callback for the freeing of the job on refcount going to 0. */
182+
void (*free)(struct kref *ref);
183+
};
184+
185+
struct v3d_bin_job {
186+
struct v3d_job base;
187+
168188
/* GPU virtual addresses of the start/end of the CL job. */
169189
u32 start, end;
170190

171191
u32 timedout_ctca, timedout_ctra;
172-
};
173192

174-
struct v3d_exec_info {
175-
struct v3d_dev *v3d;
193+
/* Corresponding render job, for attaching our overflow memory. */
194+
struct v3d_render_job *render;
195+
196+
/* Submitted tile memory allocation start/size, tile state. */
197+
u32 qma, qms, qts;
198+
};
176199

177-
struct v3d_job bin, render;
200+
struct v3d_render_job {
201+
struct v3d_job base;
178202

179-
/* Fence for when the scheduler considers the binner to be
180-
* done, for render to depend on.
203+
/* Optional fence for the binner, to depend on before starting
204+
* our job.
181205
*/
182206
struct dma_fence *bin_done_fence;
183207

184-
/* Fence for when the scheduler considers the render to be
185-
* done, for when the BOs reservations should be complete.
186-
*/
187-
struct dma_fence *render_done_fence;
188-
189-
struct kref refcount;
208+
/* GPU virtual addresses of the start/end of the CL job. */
209+
u32 start, end;
190210

191-
/* This is the array of BOs that were looked up at the start of exec. */
192-
struct drm_gem_object **bo;
193-
u32 bo_count;
211+
u32 timedout_ctca, timedout_ctra;
194212

195213
/* List of overflow BOs used in the job that need to be
196214
* released once the job is complete.
197215
*/
198216
struct list_head unref_list;
199-
200-
/* Submitted tile memory allocation start/size, tile state. */
201-
u32 qma, qms, qts;
202217
};
203218

204219
struct v3d_tfu_job {
205-
struct drm_sched_job base;
220+
struct v3d_job base;
206221

207222
struct drm_v3d_submit_tfu args;
208-
209-
/* An optional fence userspace can pass in for the job to depend on. */
210-
struct dma_fence *in_fence;
211-
212-
/* v3d fence to be signaled by IRQ handler when the job is complete. */
213-
struct dma_fence *irq_fence;
214-
215-
struct v3d_dev *v3d;
216-
217-
struct kref refcount;
218-
219-
/* This is the array of BOs that were looked up at the start of exec. */
220-
struct drm_gem_object *bo[4];
221223
};
222224

223225
/**
@@ -283,8 +285,7 @@ int v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
283285
struct drm_file *file_priv);
284286
int v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
285287
struct drm_file *file_priv);
286-
void v3d_exec_put(struct v3d_exec_info *exec);
287-
void v3d_tfu_job_put(struct v3d_tfu_job *exec);
288+
void v3d_job_put(struct v3d_job *job);
288289
void v3d_reset(struct v3d_dev *v3d);
289290
void v3d_invalidate_caches(struct v3d_dev *v3d);
290291

0 commit comments

Comments
 (0)