diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index a78b03f65c69..4309820658c4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -67,6 +67,8 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, | |||
67 | if (!ctx->fences) | 67 | if (!ctx->fences) |
68 | return -ENOMEM; | 68 | return -ENOMEM; |
69 | 69 | ||
70 | mutex_init(&ctx->lock); | ||
71 | |||
70 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 72 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
71 | ctx->rings[i].sequence = 1; | 73 | ctx->rings[i].sequence = 1; |
72 | ctx->rings[i].fences = &ctx->fences[amdgpu_sched_jobs * i]; | 74 | ctx->rings[i].fences = &ctx->fences[amdgpu_sched_jobs * i]; |
@@ -126,6 +128,8 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) | |||
126 | &ctx->rings[i].entity); | 128 | &ctx->rings[i].entity); |
127 | 129 | ||
128 | amdgpu_queue_mgr_fini(adev, &ctx->queue_mgr); | 130 | amdgpu_queue_mgr_fini(adev, &ctx->queue_mgr); |
131 | |||
132 | mutex_destroy(&ctx->lock); | ||
129 | } | 133 | } |
130 | 134 | ||
131 | static int amdgpu_ctx_alloc(struct amdgpu_device *adev, | 135 | static int amdgpu_ctx_alloc(struct amdgpu_device *adev, |
@@ -296,12 +300,8 @@ int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, | |||
296 | 300 | ||
297 | idx = seq & (amdgpu_sched_jobs - 1); | 301 | idx = seq & (amdgpu_sched_jobs - 1); |
298 | other = cring->fences[idx]; | 302 | other = cring->fences[idx]; |
299 | if (other) { | 303 | if (other) |
300 | signed long r; | 304 | BUG_ON(!dma_fence_is_signaled(other)); |
301 | r = dma_fence_wait_timeout(other, true, MAX_SCHEDULE_TIMEOUT); | ||
302 | if (r < 0) | ||
303 | return r; | ||
304 | } | ||
305 | 305 | ||
306 | dma_fence_get(fence); | 306 | dma_fence_get(fence); |
307 | 307 | ||
@@ -372,6 +372,24 @@ void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, | |||
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | int amdgpu_ctx_wait_prev_fence(struct amdgpu_ctx *ctx, unsigned ring_id) | ||
376 | { | ||
377 | struct amdgpu_ctx_ring *cring = &ctx->rings[ring_id]; | ||
378 | unsigned idx = cring->sequence & (amdgpu_sched_jobs - 1); | ||
379 | struct dma_fence *other = cring->fences[idx]; | ||
380 | |||
381 | if (other) { | ||
382 | signed long r; | ||
383 | r = dma_fence_wait_timeout(other, false, MAX_SCHEDULE_TIMEOUT); | ||
384 | if (r < 0) { | ||
385 | DRM_ERROR("Error (%ld) waiting for fence!\n", r); | ||
386 | return r; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | return 0; | ||
391 | } | ||
392 | |||
375 | void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr) | 393 | void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr) |
376 | { | 394 | { |
377 | mutex_init(&mgr->lock); | 395 | mutex_init(&mgr->lock); |