vidro/rockchip: fix rga1 driver deadlock
authorZikim,Wei <wzq@rock-chips.com>
Sun, 30 Oct 2016 09:26:46 +0000 (17:26 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 11 Nov 2016 11:46:23 +0000 (19:46 +0800)
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 <wzq@rock-chips.com>
(cherry picked from commit f453db8699919760a2297a7d2512f3c03c3edf25)

drivers/video/rockchip/rga/rga_mmu_info.c

index c0b999dd6bf68d18e8185e6066ecc25450f07cdb..ef53838058aafdd0fd31f69984ba7f06bf4763c4 100755 (executable)
@@ -36,25 +36,31 @@ static int rga_mmu_buf_get(struct rga_mmu_buf_t *t, uint32_t size)
 \r
 static int rga_mmu_buf_get_try(struct rga_mmu_buf_t *t, uint32_t size)\r
 {\r
 \r
 static int rga_mmu_buf_get_try(struct rga_mmu_buf_t *t, uint32_t size)\r
 {\r
-    mutex_lock(&rga_service.lock);\r
-    if((t->back - t->front) > t->size) {\r
-        if(t->front + size > t->back - t->size)\r
-            return -1;\r
-    }\r
-    else {\r
-        if((t->front + size) > t->back)\r
-            return -1;\r
-\r
-        if(t->front + size > t->size) {\r
-            if (size > (t->back - t->size)) {\r
-                return -1;\r
-            }\r
-            t->front = 0;\r
-        }\r
-    }\r
-    mutex_unlock(&rga_service.lock);\r
-\r
-    return 0;\r
+       int ret = 0;\r
+\r
+       mutex_lock(&rga_service.lock);\r
+       if ((t->back - t->front) > t->size) {\r
+               if(t->front + size > t->back - t->size) {\r
+                       ret = -ENOMEM;\r
+                       goto out;\r
+               }\r
+       } else {\r
+               if ((t->front + size) > t->back) {\r
+                       ret = -ENOMEM;\r
+                       goto out;\r
+               }\r
+               if (t->front + size > t->size) {\r
+                       if (size > (t->back - t->size)) {\r
+                               ret = -ENOMEM;\r
+                               goto out;\r
+                       }\r
+                       t->front = 0;\r
+               }\r
+       }\r
+\r
+out:\r
+       mutex_unlock(&rga_service.lock);\r
+       return ret;\r
 }\r
 \r
 static int rga_mem_size_cal(unsigned long Mem, uint32_t MemSize, unsigned long *StartAddr)\r
 }\r
 \r
 static int rga_mem_size_cal(unsigned long Mem, uint32_t MemSize, unsigned long *StartAddr)\r