diff options
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/cde_gk20a.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c index e6dbaea8..1c230be6 100644 --- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c | |||
@@ -589,6 +589,33 @@ static int gk20a_cde_execute_buffer(struct gk20a_cde_ctx *cde_ctx, | |||
589 | num_entries, flags, fence, fence_out); | 589 | num_entries, flags, fence, fence_out); |
590 | } | 590 | } |
591 | 591 | ||
592 | static struct gk20a_cde_ctx *gk20a_cde_get_context(struct gk20a_cde_app *cde_app) | ||
593 | { | ||
594 | struct gk20a_cde_ctx *cde_ctx = cde_app->cde_ctx; | ||
595 | int i; | ||
596 | |||
597 | /* try to find a jobless context */ | ||
598 | |||
599 | for (i = 0; i < ARRAY_SIZE(cde_app->cde_ctx); i++, cde_ctx++) { | ||
600 | struct channel_gk20a *ch = cde_ctx->ch; | ||
601 | bool empty; | ||
602 | |||
603 | mutex_lock(&ch->jobs_lock); | ||
604 | empty = list_empty(&ch->jobs); | ||
605 | mutex_unlock(&ch->jobs_lock); | ||
606 | |||
607 | if (empty) | ||
608 | return cde_ctx; | ||
609 | } | ||
610 | |||
611 | /* pick just the next cde context, hopefully somewhat in order */ | ||
612 | cde_ctx = cde_app->cde_ctx + cde_app->cde_ctx_ptr; | ||
613 | cde_app->cde_ctx_ptr = (cde_app->cde_ctx_ptr + 1) % | ||
614 | ARRAY_SIZE(cde_app->cde_ctx); | ||
615 | |||
616 | return cde_ctx; | ||
617 | } | ||
618 | |||
592 | int gk20a_cde_convert(struct gk20a *g, | 619 | int gk20a_cde_convert(struct gk20a *g, |
593 | struct dma_buf *dst, | 620 | struct dma_buf *dst, |
594 | s32 dst_kind, u64 dst_byte_offset, | 621 | s32 dst_kind, u64 dst_byte_offset, |
@@ -610,10 +637,7 @@ int gk20a_cde_convert(struct gk20a *g, | |||
610 | 637 | ||
611 | mutex_lock(&cde_app->mutex); | 638 | mutex_lock(&cde_app->mutex); |
612 | 639 | ||
613 | /* pick next free cde context */ | 640 | cde_ctx = gk20a_cde_get_context(cde_app); |
614 | cde_ctx = cde_app->cde_ctx + cde_app->cde_ctx_ptr; | ||
615 | cde_app->cde_ctx_ptr = (cde_app->cde_ctx_ptr + 1) % | ||
616 | ARRAY_SIZE(cde_app->cde_ctx); | ||
617 | 641 | ||
618 | /* First, map the buffers to local va */ | 642 | /* First, map the buffers to local va */ |
619 | 643 | ||