MGS-4338-2 [#imx-1223] GPU memory optimization for page fault
authorXianzhong <xianzhong.li@nxp.com>
Mon, 22 Oct 2018 11:13:15 +0000 (19:13 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
GPU memory initialization will cause large boot time with 40ms.

If GPU memory is allocated from CMA, memset in cma kernel driver,
It is not necessary to add duplicated memset in GPU kernel driver.

Only GFP allocator need trigger a page fault with a simple write.

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c

index 937c752..71a867c 100644 (file)
@@ -926,6 +926,12 @@ _GFPMapKernel(
 
     addr = vmap(pages, numPages, 0, pgprot_writecombine(PAGE_KERNEL));
 
+    /* Trigger a page fault. */
+    for (i = 0; i < numPages; i++)
+    {
+        *(gctINT *)(addr + PAGE_SIZE * i) = 0;
+    }
+
     if (free)
     {
         kfree(pages);
index bc316b3..7be6e79 100644 (file)
@@ -1345,9 +1345,6 @@ gckOS_AllocateNonPagedMemory(
 
     gcmkONERROR(allocator->ops->MapKernel(allocator, mdl, &addr));
 
-    /* Trigger a page fault. */
-    memset(addr, 0, numPages * PAGE_SIZE);
-
     mdl->addr = addr;
 
     if (InUserSpace)