From f31e575ed6b048f2139eab0433cce7f18e670b28 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Fri, 19 Aug 2016 14:20:08 +0530 Subject: gpu: nvgpu: remove blocking wait for vidmem allocation We have blocking 1sec wait for vidmem allocation Remove this blocking wait and just return proper error code to the caller In case we have some buffers to be cleaned up in the list (clear_list_head), return EAGAIN so that caller can retry Otherwise return ENOMEM indicating that no memory is available right now Jira DNVGPU-84 Change-Id: Ife2b17c989fc80e568f03bb18ad75b93a25be962 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1204969 (cherry picked from commit 2bacdf0bc6d5b1cdcb8be37e574ca5f4f0663cae) Reviewed-on: http://git-master/r/1213451 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index e1f135e7..d26855f4 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -2981,7 +2981,7 @@ int gk20a_gmmu_alloc_attr_vid_at(struct gk20a *g, enum dma_attr attr, #if defined(CONFIG_GK20A_VIDMEM) u64 addr; int err; - unsigned long end_jiffies = jiffies + msecs_to_jiffies(1000); + bool clear_list_empty; struct gk20a_allocator *vidmem_alloc = g->mm.vidmem.cleared ? &g->mm.vidmem.allocator : &g->mm.vidmem.bootstrap_allocator; @@ -2995,16 +2995,17 @@ int gk20a_gmmu_alloc_attr_vid_at(struct gk20a *g, enum dma_attr attr, * are not done anyway */ WARN_ON(attr != 0 && attr != DMA_ATTR_NO_KERNEL_MAPPING); - do { - addr = __gk20a_gmmu_alloc(vidmem_alloc, at, size); - if (!addr) /* Possible OOM */ - usleep_range(100, 300); - else - break; - } while (time_before(jiffies, end_jiffies)); + addr = __gk20a_gmmu_alloc(vidmem_alloc, at, size); + if (!addr) { + mutex_lock(&g->mm.vidmem.clear_list_mutex); + clear_list_empty = list_empty(&g->mm.vidmem.clear_list_head); + mutex_unlock(&g->mm.vidmem.clear_list_mutex); - if (!addr) - return -ENOMEM; + if (clear_list_empty) + return -ENOMEM; + else + return -EAGAIN; + } if (at) mem->fixed = true; -- cgit v1.2.2