Skip to content

Commit

Permalink
drm/v3d: Refactor job management.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Acked-by: Rob Clark <[email protected]>
  • Loading branch information
anholt committed Apr 18, 2019
1 parent d4c3022 commit a783a09
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 329 deletions.
77 changes: 39 additions & 38 deletions drivers/gpu/drm/v3d/v3d_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ struct v3d_dev {

struct work_struct overflow_mem_work;

struct v3d_exec_info *bin_job;
struct v3d_exec_info *render_job;
struct v3d_bin_job *bin_job;
struct v3d_render_job *render_job;
struct v3d_tfu_job *tfu_job;

struct v3d_queue_state queue[V3D_MAX_QUEUES];
Expand Down Expand Up @@ -117,7 +117,7 @@ struct v3d_bo {
struct drm_mm_node node;

/* List entry for the BO's position in
* v3d_exec_info->unref_list
* v3d_render_job->unref_list
*/
struct list_head unref_head;
};
Expand Down Expand Up @@ -157,67 +157,69 @@ to_v3d_fence(struct dma_fence *fence)
struct v3d_job {
struct drm_sched_job base;

struct v3d_exec_info *exec;
struct kref refcount;

struct v3d_dev *v3d;

/* This is the array of BOs that were looked up at the start
* of submission.
*/
struct drm_gem_object **bo;
u32 bo_count;

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

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

/* scheduler fence for when the job is considered complete and
* the BO reservations can be released.
*/
struct dma_fence *done_fence;

/* Callback for the freeing of the job on refcount going to 0. */
void (*free)(struct kref *ref);
};

struct v3d_bin_job {
struct v3d_job base;

/* GPU virtual addresses of the start/end of the CL job. */
u32 start, end;

u32 timedout_ctca, timedout_ctra;
};

struct v3d_exec_info {
struct v3d_dev *v3d;
/* Corresponding render job, for attaching our overflow memory. */
struct v3d_render_job *render;

/* Submitted tile memory allocation start/size, tile state. */
u32 qma, qms, qts;
};

struct v3d_job bin, render;
struct v3d_render_job {
struct v3d_job base;

/* Fence for when the scheduler considers the binner to be
* done, for render to depend on.
/* Optional fence for the binner, to depend on before starting
* our job.
*/
struct dma_fence *bin_done_fence;

/* Fence for when the scheduler considers the render to be
* done, for when the BOs reservations should be complete.
*/
struct dma_fence *render_done_fence;

struct kref refcount;
/* GPU virtual addresses of the start/end of the CL job. */
u32 start, end;

/* This is the array of BOs that were looked up at the start of exec. */
struct drm_gem_object **bo;
u32 bo_count;
u32 timedout_ctca, timedout_ctra;

/* List of overflow BOs used in the job that need to be
* released once the job is complete.
*/
struct list_head unref_list;

/* Submitted tile memory allocation start/size, tile state. */
u32 qma, qms, qts;
};

struct v3d_tfu_job {
struct drm_sched_job base;
struct v3d_job base;

struct drm_v3d_submit_tfu args;

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

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

struct v3d_dev *v3d;

struct kref refcount;

/* This is the array of BOs that were looked up at the start of exec. */
struct drm_gem_object *bo[4];
};

/**
Expand Down Expand Up @@ -283,8 +285,7 @@ int v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void v3d_exec_put(struct v3d_exec_info *exec);
void v3d_tfu_job_put(struct v3d_tfu_job *exec);
void v3d_job_put(struct v3d_job *job);
void v3d_reset(struct v3d_dev *v3d);
void v3d_invalidate_caches(struct v3d_dev *v3d);

Expand Down
Loading

0 comments on commit a783a09

Please sign in to comment.