aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/lima/lima_sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/lima/lima_sched.c')
-rw-r--r--drivers/gpu/drm/lima/lima_sched.c66
1 files changed, 12 insertions, 54 deletions
diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
index 97bd9c1deb87..e253d031fb3d 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -3,6 +3,7 @@
3 3
4#include <linux/kthread.h> 4#include <linux/kthread.h>
5#include <linux/slab.h> 5#include <linux/slab.h>
6#include <linux/xarray.h>
6 7
7#include "lima_drv.h" 8#include "lima_drv.h"
8#include "lima_sched.h" 9#include "lima_sched.h"
@@ -126,19 +127,24 @@ int lima_sched_task_init(struct lima_sched_task *task,
126 127
127 task->num_bos = num_bos; 128 task->num_bos = num_bos;
128 task->vm = lima_vm_get(vm); 129 task->vm = lima_vm_get(vm);
130
131 xa_init_flags(&task->deps, XA_FLAGS_ALLOC);
132
129 return 0; 133 return 0;
130} 134}
131 135
132void lima_sched_task_fini(struct lima_sched_task *task) 136void lima_sched_task_fini(struct lima_sched_task *task)
133{ 137{
138 struct dma_fence *fence;
139 unsigned long index;
134 int i; 140 int i;
135 141
136 drm_sched_job_cleanup(&task->base); 142 drm_sched_job_cleanup(&task->base);
137 143
138 for (i = 0; i < task->num_dep; i++) 144 xa_for_each(&task->deps, index, fence) {
139 dma_fence_put(task->dep[i]); 145 dma_fence_put(fence);
140 146 }
141 kfree(task->dep); 147 xa_destroy(&task->deps);
142 148
143 if (task->bos) { 149 if (task->bos) {
144 for (i = 0; i < task->num_bos; i++) 150 for (i = 0; i < task->num_bos; i++)
@@ -149,42 +155,6 @@ void lima_sched_task_fini(struct lima_sched_task *task)
149 lima_vm_put(task->vm); 155 lima_vm_put(task->vm);
150} 156}
151 157
152int lima_sched_task_add_dep(struct lima_sched_task *task, struct dma_fence *fence)
153{
154 int i, new_dep = 4;
155
156 /* same context's fence is definitly earlier then this task */
157 if (fence->context == task->base.s_fence->finished.context) {
158 dma_fence_put(fence);
159 return 0;
160 }
161
162 if (task->dep && task->num_dep == task->max_dep)
163 new_dep = task->max_dep * 2;
164
165 if (task->max_dep < new_dep) {
166 void *dep = krealloc(task->dep, sizeof(*task->dep) * new_dep, GFP_KERNEL);
167
168 if (!dep)
169 return -ENOMEM;
170
171 task->max_dep = new_dep;
172 task->dep = dep;
173 }
174
175 for (i = 0; i < task->num_dep; i++) {
176 if (task->dep[i]->context == fence->context &&
177 dma_fence_is_later(fence, task->dep[i])) {
178 dma_fence_put(task->dep[i]);
179 task->dep[i] = fence;
180 return 0;
181 }
182 }
183
184 task->dep[task->num_dep++] = fence;
185 return 0;
186}
187
188int lima_sched_context_init(struct lima_sched_pipe *pipe, 158int lima_sched_context_init(struct lima_sched_pipe *pipe,
189 struct lima_sched_context *context, 159 struct lima_sched_context *context,
190 atomic_t *guilty) 160 atomic_t *guilty)
@@ -213,21 +183,9 @@ static struct dma_fence *lima_sched_dependency(struct drm_sched_job *job,
213 struct drm_sched_entity *entity) 183 struct drm_sched_entity *entity)
214{ 184{
215 struct lima_sched_task *task = to_lima_task(job); 185 struct lima_sched_task *task = to_lima_task(job);
216 int i;
217
218 for (i = 0; i < task->num_dep; i++) {
219 struct dma_fence *fence = task->dep[i];
220
221 if (!task->dep[i])
222 continue;
223
224 task->dep[i] = NULL;
225 186
226 if (!dma_fence_is_signaled(fence)) 187 if (!xa_empty(&task->deps))
227 return fence; 188 return xa_erase(&task->deps, task->last_dep++);
228
229 dma_fence_put(fence);
230 }
231 189
232 return NULL; 190 return NULL;
233} 191}