MGS-3367 [#imx-809] fix cma_release dump with ctrl-c
authorXianzhong <xianzhong.li@nxp.com>
Tue, 14 Nov 2017 19:07:35 +0000 (03:07 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:46:57 +0000 (15:46 -0500)
need release user memory before close the drmfb handle,
there is no galcore kernel interface for immediate free.

add new interface to release the user memory by force,

[  112.487090] [<ffff0000081748c0>] free_contig_range+0xa0/0xc0
[  112.492757] [<ffff0000081d944c>] cma_release+0x94/0xc0
[  112.497900] [<ffff0000085e344c>]
dma_release_from_contiguous+0x2c/0x38
[  112.504432] [<ffff000008095ab8>]
__dma_free_coherent.isra.14+0x50/0xb8
[  112.510962] [<ffff000008095b7c>] __dma_free+0x5c/0x90
[  112.516022] [<ffff0000085c56b4>] drm_gem_cma_free_object+0xa4/0x130
[  112.522293] [<ffff0000085a6384>] drm_gem_object_free+0x1c/0x58
[  112.528130] [<ffff0000085a646c>]
drm_gem_object_unreference_unlocked+0x54/0x130
[  112.535445] [<ffff0000085a65c0>]
drm_gem_object_handle_unreference_unlocked+0x60/0xb0
[  112.543281] [<ffff0000085a6664>]
drm_gem_object_release_handle+0x54/0x90
[  112.549989] [<ffff0000083c085c>] idr_for_each+0xb4/0x118
[  112.555304] [<ffff0000085a73cc>] drm_gem_release+0x24/0x38
[  112.560794] [<ffff0000085a62dc>] drm_release+0x28c/0x318
[  112.566111] [<ffff0000081df344>] __fput+0x8c/0x1d0
[  112.570906] [<ffff0000081df4ec>] ____fput+0xc/0x18
[  112.575705] [<ffff0000080d7e84>] task_work_run+0xc4/0xe0
[  112.581020] [<ffff0000080c0770>] do_exit+0x2d0/0x970
[  112.585988] [<ffff0000080c0e78>] do_group_exit+0x38/0xa0
[  112.591306] [<ffff0000080caf8c>] get_signal+0x1f4/0x508
[  112.596536] [<ffff000008087970>] do_signal+0x70/0x550
[  112.601591] [<ffff000008088080>] do_notify_resume+0x90/0xb0
[  112.607168] [<ffff000008082ddc>] work_pending+0x8/0x10

Date: Nov 14, 2017
Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
Reviewed-by: Prabhu Sundararaj <prabhu.sundararaj@nxp.com>
Reviewed-by: Yuchou Gan <yuchou.gan@nxp.com>
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c
drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h

index 6726a88..9251dfa 100644 (file)
@@ -149,6 +149,7 @@ gctCONST_STRING _DispatchText[] =
     gcmDEFINE2TEXT(gcvHAL_GET_VIDEO_MEMORY_FD),
     gcmDEFINE2TEXT(gcvHAL_CONFIG_POWER_MANAGEMENT),
     gcmDEFINE2TEXT(gcvHAL_WRAP_USER_MEMORY),
+    gcmDEFINE2TEXT(gcvHAL_RELEASE_USER_MEMORY),
     gcmDEFINE2TEXT(gcvHAL_WAIT_FENCE),
 #if gcdDEC_ENABLE_AHB
     gcmDEFINE2TEXT(gcvHAL_DEC300_READ),
@@ -3199,6 +3200,33 @@ gckKERNEL_Dispatch(
                                    0));
         break;
 
+    case gcvHAL_RELEASE_USER_MEMORY:
+       {
+           gckVIDMEM_NODE nodeObject;
+           gctBOOL asynchronous = gcvFALSE;
+           gctUINT32 node = Interface->u.ReleaseUserMemory.node;
+
+           gcmkONERROR(gckKERNEL_RemoveProcessDB(Kernel,
+                                                 processID,
+                                                 gcvDB_VIDEO_MEMORY_LOCKED,
+                                                 gcmINT2PTR(node)));
+
+           gcmkONERROR(gckKERNEL_ReleaseVideoMemory( Kernel, processID, node));
+
+           gcmkONERROR(gckVIDMEM_HANDLE_Lookup(Kernel, processID, node, &nodeObject));
+
+           gcmkONERROR(gckVIDMEM_Unlock(Kernel, nodeObject, gcvSURF_BITMAP, &asynchronous));
+           if (gcvTRUE == asynchronous)
+           {
+               gcmkONERROR(gckCOMMAND_Stall(Kernel->command, gcvFALSE));
+               gcmkVERIFY_OK(gckVIDMEM_Unlock(Kernel, nodeObject, gcvSURF_BITMAP, gcvNULL));
+           }
+
+           gcmkONERROR(gckVIDMEM_NODE_Dereference(Kernel, nodeObject));
+       }
+
+       break;
+
     case gcvHAL_WAIT_FENCE:
         gcmkONERROR(gckKERNEL_WaitFence(
             Kernel,
index 7a41b0a..f2c5cb3 100644 (file)
@@ -235,6 +235,7 @@ typedef enum _gceHAL_COMMAND_CODES
 
     /* Wrap a user memory into a video memory node. */
     gcvHAL_WRAP_USER_MEMORY,
+    gcvHAL_RELEASE_USER_MEMORY,
 
     /* Wait until GPU finishes access to a resource. */
     gcvHAL_WAIT_FENCE,
@@ -1268,6 +1269,12 @@ typedef struct _gcsHAL_INTERFACE
         }
         WrapUserMemory;
 
+        struct _gcsHAL_RELEASE_USER_MEMORY
+        {
+            IN gctUINT32               node;
+        }
+        ReleaseUserMemory;
+
         struct _gcsHAL_WAIT_FENCE
         {
             IN gctUINT32                handle;