mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: find unused cde context instead of lru
When preparing a new job, loop initially through the small number of preallocated contexts and try to find one that is already finished, instead of blindly getting the next slot in lru order. If all have work to do, select next in lru order. This reduces the possibility of a deadlock between cde tasks. Bug 200040211 Change-Id: Ib695c0a8e1bcec095d50ec4f2522f3aad39ce97b Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/552035 GVS: Gerrit_Virtual_Submit Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
This commit is contained in:
committed by
Dan Willemsen
parent
492b60fa2e
commit
5ce4438380
@@ -589,6 +589,33 @@ static int gk20a_cde_execute_buffer(struct gk20a_cde_ctx *cde_ctx,
|
|||||||
num_entries, flags, fence, fence_out);
|
num_entries, flags, fence, fence_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct gk20a_cde_ctx *gk20a_cde_get_context(struct gk20a_cde_app *cde_app)
|
||||||
|
{
|
||||||
|
struct gk20a_cde_ctx *cde_ctx = cde_app->cde_ctx;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* try to find a jobless context */
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(cde_app->cde_ctx); i++, cde_ctx++) {
|
||||||
|
struct channel_gk20a *ch = cde_ctx->ch;
|
||||||
|
bool empty;
|
||||||
|
|
||||||
|
mutex_lock(&ch->jobs_lock);
|
||||||
|
empty = list_empty(&ch->jobs);
|
||||||
|
mutex_unlock(&ch->jobs_lock);
|
||||||
|
|
||||||
|
if (empty)
|
||||||
|
return cde_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pick just the next cde context, hopefully somewhat in order */
|
||||||
|
cde_ctx = cde_app->cde_ctx + cde_app->cde_ctx_ptr;
|
||||||
|
cde_app->cde_ctx_ptr = (cde_app->cde_ctx_ptr + 1) %
|
||||||
|
ARRAY_SIZE(cde_app->cde_ctx);
|
||||||
|
|
||||||
|
return cde_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
int gk20a_cde_convert(struct gk20a *g,
|
int gk20a_cde_convert(struct gk20a *g,
|
||||||
struct dma_buf *dst,
|
struct dma_buf *dst,
|
||||||
s32 dst_kind, u64 dst_byte_offset,
|
s32 dst_kind, u64 dst_byte_offset,
|
||||||
@@ -610,10 +637,7 @@ int gk20a_cde_convert(struct gk20a *g,
|
|||||||
|
|
||||||
mutex_lock(&cde_app->mutex);
|
mutex_lock(&cde_app->mutex);
|
||||||
|
|
||||||
/* pick next free cde context */
|
cde_ctx = gk20a_cde_get_context(cde_app);
|
||||||
cde_ctx = cde_app->cde_ctx + cde_app->cde_ctx_ptr;
|
|
||||||
cde_app->cde_ctx_ptr = (cde_app->cde_ctx_ptr + 1) %
|
|
||||||
ARRAY_SIZE(cde_app->cde_ctx);
|
|
||||||
|
|
||||||
/* First, map the buffers to local va */
|
/* First, map the buffers to local va */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user