MGS-4376 [#imx-1238] fix low performance with CMA allocator
authorXianzhong <xianzhong.li@nxp.com>
Fri, 9 Nov 2018 18:37:56 +0000 (02:37 +0800)
committerXianzhong <xianzhong.li@nxp.com>
Tue, 29 Oct 2019 15:31:27 +0000 (23:31 +0800)
there are lots of PFNs busy message when run GPU tests:
 [  622.370671] alloc_contig_range: [4ea70, 4ea7c) PFNs busy
 [  626.518072] alloc_contig_range: [4ea90, 4ea9c) PFNs busy

this problem is related with CMA migration for fragments,

move CMA allocator after GFP to avoid memory migration,
also fix CMA preempt for contiguous memory request.

can improve CTS and gpubench benchmarks on M850D.

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
(cherry picked from commit ad77ed61b72c8362b04361acd2deb685fee15436)

drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_array.h
drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c

index 0f734d8..ab28fa8 100644 (file)
@@ -106,13 +106,13 @@ _DmaAlloctorInit(
 
 gcsALLOCATOR_DESC allocatorArray[] =
 {
+    /* GFP allocator. */
+    gcmkDEFINE_ALLOCATOR_DESC("gfp", _GFPAlloctorInit),
+
 #if LINUX_CMA_FSL
     gcmkDEFINE_ALLOCATOR_DESC("cmafsl", _CMAFSLAlloctorInit),
 #endif
 
-    /* GFP allocator. */
-    gcmkDEFINE_ALLOCATOR_DESC("gfp", _GFPAlloctorInit),
-
     /* User memory importer. */
     gcmkDEFINE_ALLOCATOR_DESC("user", _UserMemoryAlloctorInit),
 
index 5b157d5..b03c044 100644 (file)
@@ -147,9 +147,9 @@ _CMAFSLAlloc(
 
     gcmkHEADER_ARG("Mdl=%p NumPages=0x%zx", Mdl, NumPages);
 
-    if (os->allocatorLimitMarker)
+    if (os->allocatorLimitMarker && !(Flags & gcvALLOC_FLAG_CMA_PREEMPT))
     {
-        if ((Flags & gcvALLOC_FLAG_CMA_LIMIT) && !(Flags & gcvALLOC_FLAG_CMA_PREEMPT))
+        if (Flags & gcvALLOC_FLAG_CMA_LIMIT)
         {
             priv->cmaLimitRequest = gcvTRUE;
         }
@@ -593,9 +593,10 @@ _CMAFSLAlloctorInit(
     if (Os->allocatorLimitMarker)
     {
         allocator->capability |= gcvALLOC_FLAG_CMA_LIMIT;
-        allocator->capability |= gcvALLOC_FLAG_CMA_PREEMPT;
     }
 
+    allocator->capability |= gcvALLOC_FLAG_CMA_PREEMPT;
+
     *Allocator = allocator;
 
     return gcvSTATUS_OK;
index 17211a0..4b7f4e4 100644 (file)
@@ -1374,14 +1374,11 @@ gckOS_AllocateNonPagedMemory(
 
     gcmkASSERT(Flag & gcvALLOC_FLAG_CONTIGUOUS);
 
-    if (Os->allocatorLimitMarker)
-    {
-        Flag |= gcvALLOC_FLAG_CMA_LIMIT;
-        Flag |= gcvALLOC_FLAG_CMA_PREEMPT;
 #if gcdENABLE_CACHEABLE_COMMAND_BUFFER
-        Flag &= ~gcvALLOC_FLAG_CACHEABLE;
+    Flag &= ~gcvALLOC_FLAG_CACHEABLE;
 #endif
-    }
+
+    Flag |= gcvALLOC_FLAG_CMA_PREEMPT;
 
     /* Walk all allocators. */
     list_for_each_entry(allocator, &Os->allocatorList, link)