gpu: fixed sync leak in AOSP common kernel or LTS kernel 4.10
authorJiyu Yang <Jiyu.Yang@amlogic.com>
Wed, 27 Sep 2017 11:42:17 +0000 (19:42 +0800)
committerJiyu Yang <Jiyu.Yang@amlogic.com>
Wed, 27 Sep 2017 11:42:42 +0000 (19:42 +0800)
PD#151104
Change-Id: I1d1b1481b4579be486525c44378205326c372dd4

mali/linux/mali_internal_sync.c
mali/linux/mali_sync.c

index 3a9f03aeed8c03c9f52199141a431422db5170a9..ea9557acb61f34b23eee5ed954ab1753b5759b5c 100755 (executable)
@@ -289,6 +289,10 @@ struct mali_internal_sync_fence *mali_internal_sync_fence_merge(
                return NULL;
        }
 
+       fence_remove_callback(new_sync_fence->cb[0].fence, &new_sync_fence->cb[0].cb);
+       new_sync_fence->num_fences = 0;
+       atomic_dec(&new_sync_fence->status);
+
        for (; i < num_fence1 && j < num_fence2;) {
                struct fence *fence1 = sync_fence1->cbs[i].fence;
                struct fence *fence2 = sync_fence2->cbs[j].fence;
@@ -468,7 +472,13 @@ struct mali_internal_sync_fence *mali_internal_sync_fence_merge(
                        MALI_PRINT_ERROR(("Mali internal sync:Failed to  create the mali internal sync fence when merging sync fence.\n"));
                        goto sync_fence_alloc_failed;
                }
-       
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
+               fence_put(fences[0]);
+#else
+               dma_fence_put(fences[0]);
+#endif
+
                if (mali_internal_sync_fence_set_fence_array(sync_fence, fences, real_num_fences) < 0) {
                        MALI_PRINT_ERROR(("Mali internal sync:Failed to  set fence for sync fence.\n"));
                        goto sync_fence_set_failed;
index 2bba43118cfff963fb578a4fb0817a0ddf894de3..1712cfdd40fdc071f543e49bab3d641b5b115d4d 100755 (executable)
@@ -613,6 +613,12 @@ struct mali_internal_sync_fence *mali_sync_flag_create_fence(struct mali_sync_fl
                return NULL;
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
+       fence_put(&sync_pt->base);
+#else
+       dma_fence_put(&sync_pt->base);
+#endif
+
        return sync_fence;
 }
 #endif