From: Zikim,Wei Date: Sun, 30 Oct 2016 09:26:46 +0000 (+0800) Subject: vidro/rockchip: fix rga1 driver deadlock X-Git-Tag: firefly_0821_release~1281 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=firefly-linux-kernel-4.4.55.git;a=commitdiff_plain;h=0b5f9b86cc05d4a7a3703ab79526f3dc400d1e48 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) --- 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)