From 0b5f9b86cc05d4a7a3703ab79526f3dc400d1e48 Mon Sep 17 00:00:00 2001 From: "Zikim,Wei" Date: Sun, 30 Oct 2016 17:26:46 +0800 Subject: [PATCH] vidro/rockchip: fix rga1 driver deadlock If rga get the mmu error, we must unlock the lock or it will lead the next frame timeout. Change-Id: I377217ea417de8e4d3f4ff63e478db1370951e62 Signed-off-by: Zikim,Wei (cherry picked from commit f453db8699919760a2297a7d2512f3c03c3edf25) --- drivers/video/rockchip/rga/rga_mmu_info.c | 44 +++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/video/rockchip/rga/rga_mmu_info.c b/drivers/video/rockchip/rga/rga_mmu_info.c index c0b999dd6bf6..ef53838058aa 100755 --- a/drivers/video/rockchip/rga/rga_mmu_info.c +++ b/drivers/video/rockchip/rga/rga_mmu_info.c @@ -36,25 +36,31 @@ static int rga_mmu_buf_get(struct rga_mmu_buf_t *t, uint32_t size) static int rga_mmu_buf_get_try(struct rga_mmu_buf_t *t, uint32_t size) { - mutex_lock(&rga_service.lock); - if((t->back - t->front) > t->size) { - if(t->front + size > t->back - t->size) - return -1; - } - else { - if((t->front + size) > t->back) - return -1; - - if(t->front + size > t->size) { - if (size > (t->back - t->size)) { - return -1; - } - t->front = 0; - } - } - mutex_unlock(&rga_service.lock); - - return 0; + int ret = 0; + + mutex_lock(&rga_service.lock); + if ((t->back - t->front) > t->size) { + if(t->front + size > t->back - t->size) { + ret = -ENOMEM; + goto out; + } + } else { + if ((t->front + size) > t->back) { + ret = -ENOMEM; + goto out; + } + if (t->front + size > t->size) { + if (size > (t->back - t->size)) { + ret = -ENOMEM; + goto out; + } + t->front = 0; + } + } + +out: + mutex_unlock(&rga_service.lock); + return ret; } static int rga_mem_size_cal(unsigned long Mem, uint32_t MemSize, unsigned long *StartAddr) -- 2.34.1