summaryrefslogtreecommitdiff
path: root/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
diff options
context:
space:
mode:
authorRichard Liu <xuegang.liu@nxp.com>2019-04-19 01:12:52 +0800
committerXianzhong <xianzhong.li@nxp.com>2019-08-30 03:50:28 +0800
commit6996fc5e086656bbe4478694f9207d1263f26770 (patch)
tree423205d38c95614006f07ac41340af6ccd1affdb /drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
parent5a0e323efcd6b08152fe70ac7d424117aaf07f3e (diff)
MA-14512-1 [#imx-1412] Use __GFP_DMA32 to replace CMA LIMIT when CONFIG_ZONE_DMA32 enable
When CONFIG_ZONE_DMA32 kernel configure enabled, use __GFP_DMA32 to ensure allocated memory within 4GB, then dma, cma and gfp allocators all can be used. Previous CMA LIMIT solution has limitation, only CMA allocator can ensure the allocated memory within 4GB and only with CMA LIMIT flag can use CMA allocator, some memory allocate fail due to no CMA limit flag but CMA still has much memory. This patch will back compatible, if enable CONFIG_ZONE_DMA32 use __GFP_DMA32, else keep previous CMA LIMIT logic. 4.19 kernel default enable CONFIG_ZONE_DMA32 by commit "ad67f5a6545f7fda8e", this enable CONFIG_ZONE_DMA32 patch can be cherry-picked to 4.14 kernel. Memory allocate fail cases due to without CMA LIMIT flag (can't use CMA memory) and _GFPAlloc fail due to system does not have enough continue memory: [ 3199.603326] gckOS_AllocatePagedMemoryEx(3171) cmafsl 7ea flag = 13 allocator->capability = c000011 [ 3199.612463] gckOS_AllocatePagedMemoryEx(3171) gfp 7ea flag = 13 allocator->capability = 300001b [ 3199.644893] _GFPAlloc fail, 375, Allocator=ffff80083af76980 Mdl=ffff80082171a000 NumPages=2026 Flags=0x13 [ 3199.712954] gckOS_AllocatePagedMemoryEx(3171) cmafsl 7f8 flag = 1 allocator->capability = c000011 [ 3199.721925] gckOS_AllocatePagedMemoryEx(3171) gfp 7f8 flag = 1 allocator->capability = 300001b [ 3199.735073] _GFPAlloc fail, 375, Allocator=ffff80083af76980 Mdl=ffff80006f6aff00 NumPages=2040 Flags=0x1 Change-Id: I56b93bfa06590bea1e0707c41b40009bd133fecb Signed-off-by: Richard Liu <xuegang.liu@nxp.com>
Diffstat (limited to 'drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c')
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
index 0d06fc1022a9..dd88062de771 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
@@ -1344,7 +1344,9 @@ gckOS_AllocateNonPagedMemory(
gcmkASSERT(Flag & gcvALLOC_FLAG_CONTIGUOUS);
+#ifndef CONFIG_ZONE_DMA32
Flag |= gcvALLOC_FLAG_CMA_PREEMPT;
+#endif
/* Walk all allocators. */
list_for_each_entry(allocator, &Os->allocatorList, link)
@@ -3147,6 +3149,15 @@ gckOS_AllocatePagedMemoryEx(
gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
}
+#if defined(CONFIG_ZONE_DMA32) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+ /* redirect DMA32 pool for CMA LIMIT request */
+ if (Flag & gcvALLOC_FLAG_CMA_LIMIT)
+ {
+ Flag &= ~gcvALLOC_FLAG_CMA_LIMIT;
+ Flag |= gcvALLOC_FLAG_4GB_ADDR;
+ }
+#endif
+
if (Os->allocatorLimitMarker && (Flag & gcvALLOC_FLAG_CMA_LIMIT))
{
Flag &= ~gcvALLOC_FLAG_CACHEABLE;