| 1 |
|
| 2 |
|
| 3 |
|
| 4 | #ifndef PVR_QUEUE_H
|
| 5 | #define PVR_QUEUE_H
|
| 6 |
|
| 7 | #include <drm/gpu_scheduler.h>
|
| 8 | #include <linux/workqueue.h>
|
| 9 |
|
| 10 | #include "pvr_cccb.h"
|
| 11 | #include "pvr_device.h"
|
| 12 |
|
| 13 | struct pvr_context;
|
| 14 | struct pvr_queue;
|
| 15 |
|
| 16 | |
| 17 | * struct pvr_queue_fence_ctx - Queue fence context
|
| 18 | *
|
| 19 | * Used to implement dma_fence_ops for pvr_job::{done,cccb}_fence.
|
| 20 |
|
| 21 | struct pvr_queue_fence_ctx {
|
| 22 |
|
| 23 | u64 id;
|
| 24 |
|
| 25 |
|
| 26 | atomic_t seqno;
|
| 27 |
|
| 28 |
|
| 29 | spinlock_t lock;
|
| 30 | };
|
| 31 |
|
| 32 | |
| 33 | * struct pvr_queue_cccb_fence_ctx - CCCB fence context
|
| 34 | *
|
| 35 | * Context used to manage fences controlling access to the CCCB. No fences are
|
| 36 | * issued if there's enough space in the CCCB to push job commands.
|
| 37 |
|
| 38 | struct pvr_queue_cccb_fence_ctx {
|
| 39 |
|
| 40 | struct pvr_queue_fence_ctx base;
|
| 41 |
|
| 42 | |
| 43 | * @job: Job waiting for CCCB space.
|
| 44 | *
|
| 45 | * Thanks to the serializationg done at the drm_sched_entity level,
|
| 46 | * there's no more than one job waiting for CCCB at a given time.
|
| 47 | *
|
| 48 | * This field is NULL if no jobs are currently waiting for CCCB space.
|
| 49 | *
|
| 50 | * Must be accessed with @job_lock held.
|
| 51 |
|
| 52 | struct pvr_job *job;
|
| 53 |
|
| 54 |
|
| 55 | struct mutex job_lock;
|
| 56 | };
|
| 57 |
|
| 58 | |
| 59 | * struct pvr_queue_fence - Queue fence object
|
| 60 |
|
| 61 | struct pvr_queue_fence {
|
| 62 |
|
| 63 | struct dma_fence base;
|
| 64 |
|
| 65 |
|
| 66 | struct pvr_queue *queue;
|
| 67 |
|
| 68 |
|
| 69 | struct work_struct release_work;
|
| 70 | };
|
| 71 |
|
| 72 | |
| 73 | * struct pvr_queue - Job queue
|
| 74 | *
|
| 75 | * Used to queue and track execution of pvr_job objects.
|
| 76 |
|
| 77 | struct pvr_queue {
|
| 78 |
|
| 79 | struct drm_gpu_scheduler scheduler;
|
| 80 |
|
| 81 |
|
| 82 | struct drm_sched_entity entity;
|
| 83 |
|
| 84 |
|
| 85 | enum drm_pvr_job_type type;
|
| 86 |
|
| 87 |
|
| 88 | struct pvr_context *ctx;
|
| 89 |
|
| 90 |
|
| 91 | struct list_head node;
|
| 92 |
|
| 93 | |
| 94 | * @in_flight_job_count: Number of jobs submitted to the CCCB that
|
| 95 | * have not been processed yet.
|
| 96 |
|
| 97 | atomic_t in_flight_job_count;
|
| 98 |
|
| 99 | |
| 100 | * @cccb_fence_ctx: CCCB fence context.
|
| 101 | *
|
| 102 | * Used to control access to the CCCB is full, such that we don't
|
| 103 | * end up trying to push commands to the CCCB if there's not enough
|
| 104 | * space to receive all commands needed for a job to complete.
|
| 105 |
|
| 106 | struct pvr_queue_cccb_fence_ctx cccb_fence_ctx;
|
| 107 |
|
| 108 |
|
| 109 | struct pvr_queue_fence_ctx job_fence_ctx;
|
| 110 |
|
| 111 |
|
| 112 | struct {
|
| 113 |
|
| 114 | struct pvr_fw_object *fw_obj;
|
| 115 |
|
| 116 |
|
| 117 | u32 *value;
|
| 118 | } timeline_ufo;
|
| 119 |
|
| 120 | |
| 121 | * @last_queued_job_scheduled_fence: The scheduled fence of the last
|
| 122 | * job queued to this queue.
|
| 123 | *
|
| 124 | * We use it to insert frag -> geom dependencies when issuing combined
|
| 125 | * geom+frag jobs, to guarantee that the fragment job that's part of
|
| 126 | * the combined operation comes after all fragment jobs that were queued
|
| 127 | * before it.
|
| 128 |
|
| 129 | struct dma_fence *last_queued_job_scheduled_fence;
|
| 130 |
|
| 131 |
|
| 132 | struct pvr_cccb cccb;
|
| 133 |
|
| 134 |
|
| 135 | struct pvr_fw_object *reg_state_obj;
|
| 136 |
|
| 137 |
|
| 138 | u32 ctx_offset;
|
| 139 |
|
| 140 |
|
| 141 | u64 callstack_addr;
|
| 142 | };
|
| 143 |
|
| 144 | bool pvr_queue_fence_is_native(struct dma_fence *f);
|
| 145 |
|
| 146 | int pvr_queue_job_init(struct pvr_job *job, u64 drm_client_id);
|
| 147 |
|
| 148 | void pvr_queue_job_cleanup(struct pvr_job *job);
|
| 149 |
|
| 150 | void pvr_queue_job_push(struct pvr_job *job);
|
| 151 |
|
| 152 | struct dma_fence *pvr_queue_job_arm(struct pvr_job *job);
|
| 153 |
|
| 154 | struct pvr_queue *pvr_queue_create(struct pvr_context *ctx,
|
| 155 | enum drm_pvr_job_type type,
|
| 156 | struct drm_pvr_ioctl_create_context_args *args,
|
| 157 | void *fw_ctx_map);
|
| 158 |
|
| 159 | void pvr_queue_kill(struct pvr_queue *queue);
|
| 160 |
|
| 161 | void pvr_queue_destroy(struct pvr_queue *queue, bool cleanup_queue_entity);
|
| 162 |
|
| 163 | void pvr_queue_process(struct pvr_queue *queue);
|
| 164 |
|
| 165 | void pvr_queue_device_pre_reset(struct pvr_device *pvr_dev);
|
| 166 |
|
| 167 | void pvr_queue_device_post_reset(struct pvr_device *pvr_dev);
|
| 168 |
|
| 169 | int pvr_queue_device_init(struct pvr_device *pvr_dev);
|
| 170 |
|
| 171 | void pvr_queue_device_fini(struct pvr_device *pvr_dev);
|
| 172 |
|
| 173 | #endif
|