aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-08-19 09:00:55 -0400
committerAlex Deucher <alexander.deucher@amd.com>2015-08-25 10:39:16 -0400
commitce882e6dc241ab8dded0eeeb33a86482d44a5689 (patch)
tree68d6186455e22e552efb3b5f46214e6d37540e07
parent4ce9891ee17c6e064cc334e3297f7e992d47f3a6 (diff)
drm/amdgpu: remove v_seq handling from the scheduler v2
Simply not used any more. Only keep 32bit atomic for fence sequence numbering. v2: trivial rebase Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1) Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com> (v1) Reviewed-by: Chunming Zhou <david1.zhou@amd.com> (v1)
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c20
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c1
-rw-r--r--drivers/gpu/drm/amd/scheduler/gpu_scheduler.c19
-rw-r--r--drivers/gpu/drm/amd/scheduler/gpu_scheduler.h7
-rw-r--r--drivers/gpu/drm/amd/scheduler/sched_fence.c13
9 files changed, 21 insertions, 57 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 80f2ceaf6af6..65e0e9406abb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1047,7 +1047,7 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx);
1047struct amdgpu_ctx *amdgpu_ctx_get_ref(struct amdgpu_ctx *ctx); 1047struct amdgpu_ctx *amdgpu_ctx_get_ref(struct amdgpu_ctx *ctx);
1048 1048
1049uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, 1049uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring,
1050 struct fence *fence, uint64_t queued_seq); 1050 struct fence *fence);
1051struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, 1051struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
1052 struct amdgpu_ring *ring, uint64_t seq); 1052 struct amdgpu_ring *ring, uint64_t seq);
1053 1053
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index dc8d2829c1e9..f91849b12a0f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -866,11 +866,9 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
866 kfree(job); 866 kfree(job);
867 goto out; 867 goto out;
868 } 868 }
869 job->ibs[parser->num_ibs - 1].sequence = 869 cs->out.handle =
870 amdgpu_ctx_add_fence(job->ctx, ring, 870 amdgpu_ctx_add_fence(job->ctx, ring,
871 &job->base.s_fence->base, 871 &job->base.s_fence->base);
872 job->base.s_fence->v_seq);
873 cs->out.handle = job->base.s_fence->v_seq;
874 list_sort(NULL, &parser->validated, cmp_size_smaller_first); 872 list_sort(NULL, &parser->validated, cmp_size_smaller_first);
875 ttm_eu_fence_buffer_objects(&parser->ticket, 873 ttm_eu_fence_buffer_objects(&parser->ticket,
876 &parser->validated, 874 &parser->validated,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 8660c0854a1e..f024effa60f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -236,17 +236,13 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx)
236} 236}
237 237
238uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, 238uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring,
239 struct fence *fence, uint64_t queued_seq) 239 struct fence *fence)
240{ 240{
241 struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx]; 241 struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx];
242 uint64_t seq = 0; 242 uint64_t seq = cring->sequence;
243 unsigned idx = 0; 243 unsigned idx = 0;
244 struct fence *other = NULL; 244 struct fence *other = NULL;
245 245
246 if (amdgpu_enable_scheduler)
247 seq = queued_seq;
248 else
249 seq = cring->sequence;
250 idx = seq % AMDGPU_CTX_MAX_CS_PENDING; 246 idx = seq % AMDGPU_CTX_MAX_CS_PENDING;
251 other = cring->fences[idx]; 247 other = cring->fences[idx];
252 if (other) { 248 if (other) {
@@ -260,8 +256,7 @@ uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring,
260 256
261 spin_lock(&ctx->ring_lock); 257 spin_lock(&ctx->ring_lock);
262 cring->fences[idx] = fence; 258 cring->fences[idx] = fence;
263 if (!amdgpu_enable_scheduler) 259 cring->sequence++;
264 cring->sequence++;
265 spin_unlock(&ctx->ring_lock); 260 spin_unlock(&ctx->ring_lock);
266 261
267 fence_put(other); 262 fence_put(other);
@@ -274,21 +269,16 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
274{ 269{
275 struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx]; 270 struct amdgpu_ctx_ring *cring = & ctx->rings[ring->idx];
276 struct fence *fence; 271 struct fence *fence;
277 uint64_t queued_seq;
278 272
279 spin_lock(&ctx->ring_lock); 273 spin_lock(&ctx->ring_lock);
280 if (amdgpu_enable_scheduler)
281 queued_seq = amd_sched_next_queued_seq(&cring->entity);
282 else
283 queued_seq = cring->sequence;
284 274
285 if (seq >= queued_seq) { 275 if (seq >= cring->sequence) {
286 spin_unlock(&ctx->ring_lock); 276 spin_unlock(&ctx->ring_lock);
287 return ERR_PTR(-EINVAL); 277 return ERR_PTR(-EINVAL);
288 } 278 }
289 279
290 280
291 if (seq + AMDGPU_CTX_MAX_CS_PENDING < queued_seq) { 281 if (seq + AMDGPU_CTX_MAX_CS_PENDING < cring->sequence) {
292 spin_unlock(&ctx->ring_lock); 282 spin_unlock(&ctx->ring_lock);
293 return NULL; 283 return NULL;
294 } 284 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index 13c5978ac69b..737c8e3e3a74 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -126,7 +126,6 @@ int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs,
126 struct amdgpu_ring *ring; 126 struct amdgpu_ring *ring;
127 struct amdgpu_ctx *ctx, *old_ctx; 127 struct amdgpu_ctx *ctx, *old_ctx;
128 struct amdgpu_vm *vm; 128 struct amdgpu_vm *vm;
129 uint64_t sequence;
130 unsigned i; 129 unsigned i;
131 int r = 0; 130 int r = 0;
132 131
@@ -199,12 +198,9 @@ int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs,
199 return r; 198 return r;
200 } 199 }
201 200
202 sequence = amdgpu_enable_scheduler ? ib->sequence : 0;
203
204 if (!amdgpu_enable_scheduler && ib->ctx) 201 if (!amdgpu_enable_scheduler && ib->ctx)
205 ib->sequence = amdgpu_ctx_add_fence(ib->ctx, ring, 202 ib->sequence = amdgpu_ctx_add_fence(ib->ctx, ring,
206 &ib->fence->base, 203 &ib->fence->base);
207 sequence);
208 204
209 /* wrap the last IB with fence */ 205 /* wrap the last IB with fence */
210 if (ib->user) { 206 if (ib->user) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
index b7cbaa9d532e..26b17939c9c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
@@ -435,8 +435,8 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
435 seq_printf(m, " protected by 0x%016llx on ring %d", 435 seq_printf(m, " protected by 0x%016llx on ring %d",
436 a_fence->seq, a_fence->ring->idx); 436 a_fence->seq, a_fence->ring->idx);
437 if (s_fence) 437 if (s_fence)
438 seq_printf(m, " protected by 0x%016llx on ring %d", 438 seq_printf(m, " protected by 0x%016x on ring %d",
439 s_fence->v_seq, 439 s_fence->base.seqno,
440 s_fence->entity->scheduler->ring_id); 440 s_fence->entity->scheduler->ring_id);
441 441
442 } 442 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
index 06d7bf51db9a..964b54381feb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
@@ -111,7 +111,6 @@ int amdgpu_sched_ib_submit_kernel_helper(struct amdgpu_device *adev,
111 kfree(job); 111 kfree(job);
112 return r; 112 return r;
113 } 113 }
114 ibs[num_ibs - 1].sequence = job->base.s_fence->v_seq;
115 *f = fence_get(&job->base.s_fence->base); 114 *f = fence_get(&job->base.s_fence->base);
116 mutex_unlock(&job->job_lock); 115 mutex_unlock(&job->job_lock);
117 } else { 116 } else {
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
index 1125aa2e2a9a..f8d46b0b4e3b 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@ -156,14 +156,12 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched,
156 struct amd_sched_rq *rq, 156 struct amd_sched_rq *rq,
157 uint32_t jobs) 157 uint32_t jobs)
158{ 158{
159 uint64_t seq_ring = 0;
160 char name[20]; 159 char name[20];
161 160
162 if (!(sched && entity && rq)) 161 if (!(sched && entity && rq))
163 return -EINVAL; 162 return -EINVAL;
164 163
165 memset(entity, 0, sizeof(struct amd_sched_entity)); 164 memset(entity, 0, sizeof(struct amd_sched_entity));
166 seq_ring = ((uint64_t)sched->ring_id) << 60;
167 spin_lock_init(&entity->lock); 165 spin_lock_init(&entity->lock);
168 entity->belongto_rq = rq; 166 entity->belongto_rq = rq;
169 entity->scheduler = sched; 167 entity->scheduler = sched;
@@ -179,8 +177,7 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched,
179 return -EINVAL; 177 return -EINVAL;
180 178
181 spin_lock_init(&entity->queue_lock); 179 spin_lock_init(&entity->queue_lock);
182 atomic64_set(&entity->last_queued_v_seq, seq_ring); 180 atomic_set(&entity->fence_seq, 0);
183 atomic64_set(&entity->last_signaled_v_seq, seq_ring);
184 181
185 /* Add the entity to the run queue */ 182 /* Add the entity to the run queue */
186 amd_sched_rq_add_entity(rq, entity); 183 amd_sched_rq_add_entity(rq, entity);
@@ -299,8 +296,6 @@ static void amd_sched_process_job(struct fence *f, struct fence_cb *cb)
299 unsigned long flags; 296 unsigned long flags;
300 297
301 sched = sched_job->sched; 298 sched = sched_job->sched;
302 atomic64_set(&sched_job->s_entity->last_signaled_v_seq,
303 sched_job->s_fence->v_seq);
304 amd_sched_fence_signal(sched_job->s_fence); 299 amd_sched_fence_signal(sched_job->s_fence);
305 spin_lock_irqsave(&sched->queue_lock, flags); 300 spin_lock_irqsave(&sched->queue_lock, flags);
306 list_del(&sched_job->list); 301 list_del(&sched_job->list);
@@ -421,15 +416,3 @@ int amd_sched_destroy(struct amd_gpu_scheduler *sched)
421 kfree(sched); 416 kfree(sched);
422 return 0; 417 return 0;
423} 418}
424
425/**
426 * Get next queued sequence number
427 *
428 * @entity The context entity
429 *
430 * return the next queued sequence number
431*/
432uint64_t amd_sched_next_queued_seq(struct amd_sched_entity *c_entity)
433{
434 return atomic64_read(&c_entity->last_queued_v_seq) + 1;
435}
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
index 6597d61266e7..d328e968beb3 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
@@ -42,9 +42,7 @@ struct amd_sched_entity {
42 struct list_head list; 42 struct list_head list;
43 struct amd_sched_rq *belongto_rq; 43 struct amd_sched_rq *belongto_rq;
44 spinlock_t lock; 44 spinlock_t lock;
45 /* the virtual_seq is unique per context per ring */ 45 atomic_t fence_seq;
46 atomic64_t last_queued_v_seq;
47 atomic64_t last_signaled_v_seq;
48 /* the job_queue maintains the jobs submitted by clients */ 46 /* the job_queue maintains the jobs submitted by clients */
49 struct kfifo job_queue; 47 struct kfifo job_queue;
50 spinlock_t queue_lock; 48 spinlock_t queue_lock;
@@ -72,7 +70,6 @@ struct amd_sched_fence {
72 struct fence base; 70 struct fence base;
73 struct fence_cb cb; 71 struct fence_cb cb;
74 struct amd_sched_entity *entity; 72 struct amd_sched_entity *entity;
75 uint64_t v_seq;
76 spinlock_t lock; 73 spinlock_t lock;
77}; 74};
78 75
@@ -148,8 +145,6 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched,
148int amd_sched_entity_fini(struct amd_gpu_scheduler *sched, 145int amd_sched_entity_fini(struct amd_gpu_scheduler *sched,
149 struct amd_sched_entity *entity); 146 struct amd_sched_entity *entity);
150 147
151uint64_t amd_sched_next_queued_seq(struct amd_sched_entity *c_entity);
152
153struct amd_sched_fence *amd_sched_fence_create( 148struct amd_sched_fence *amd_sched_fence_create(
154 struct amd_sched_entity *s_entity); 149 struct amd_sched_entity *s_entity);
155void amd_sched_fence_signal(struct amd_sched_fence *fence); 150void amd_sched_fence_signal(struct amd_sched_fence *fence);
diff --git a/drivers/gpu/drm/amd/scheduler/sched_fence.c b/drivers/gpu/drm/amd/scheduler/sched_fence.c
index a4751598c0b4..266ed7bbbc74 100644
--- a/drivers/gpu/drm/amd/scheduler/sched_fence.c
+++ b/drivers/gpu/drm/amd/scheduler/sched_fence.c
@@ -30,16 +30,19 @@
30struct amd_sched_fence *amd_sched_fence_create(struct amd_sched_entity *s_entity) 30struct amd_sched_fence *amd_sched_fence_create(struct amd_sched_entity *s_entity)
31{ 31{
32 struct amd_sched_fence *fence = NULL; 32 struct amd_sched_fence *fence = NULL;
33 unsigned seq;
34
33 fence = kzalloc(sizeof(struct amd_sched_fence), GFP_KERNEL); 35 fence = kzalloc(sizeof(struct amd_sched_fence), GFP_KERNEL);
34 if (fence == NULL) 36 if (fence == NULL)
35 return NULL; 37 return NULL;
36 fence->v_seq = atomic64_inc_return(&s_entity->last_queued_v_seq); 38
37 fence->entity = s_entity; 39 fence->entity = s_entity;
38 spin_lock_init(&fence->lock); 40 spin_lock_init(&fence->lock);
39 fence_init(&fence->base, &amd_sched_fence_ops, 41
40 &fence->lock, 42 seq = atomic_inc_return(&s_entity->fence_seq);
41 s_entity->fence_context, 43 fence_init(&fence->base, &amd_sched_fence_ops, &fence->lock,
42 fence->v_seq); 44 s_entity->fence_context, seq);
45
43 return fence; 46 return fence;
44} 47}
45 48