Limit the gpu's dma mem of size
author杜坤明 <dkm@rock-chips.com>
Thu, 16 Dec 2010 06:21:01 +0000 (14:21 +0800)
committer杜坤明 <dkm@rock-chips.com>
Thu, 16 Dec 2010 06:21:01 +0000 (14:21 +0800)
drivers/staging/rk29/vivante/Makefile
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c

index e4171f01ac18394942f2b07db1fa94ae7f732b69..1bec4a3a706d30e518e8da7816f4817c01c330f6 100644 (file)
@@ -72,7 +72,7 @@ SDK_DIR               ?= $(AQROOT)/build/sdk
 USE_3D_VG      = 1
 
 DEBUG       = 0
-gcdkREPORT_VIDMEM_USAGE = 1
+gcdkREPORT_VIDMEM_USAGE = 0
 
 #DRIVER_OUT_DIR = hal/driver
 #KERNEL_DIR ?= $(TOOL_DIR)/kernel
index 7da7bec0e7262bd8e604c69ddfad89843a7e1a55..582cb7dd2e6dd45eee3dab51c33bec709c183dc0 100644 (file)
 
 #define _GC_OBJ_ZONE    gcvZONE_OS
 
+#define PAGE_ALLOC_LIMIT        1   // ÏÞÖÆPageÉêÇëÊý
+
+#if PAGE_ALLOC_LIMIT
+int g_pages_alloced = 0;
+#endif
+
 #define MEMORY_LOCK(os) \
     gcmkVERIFY_OK(gckOS_AcquireMutex( \
                                 (os), \
@@ -2656,7 +2662,20 @@ gceSTATUS gckOS_AllocatePagedMemoryEx(
 
     if (Contiguous)
     {
+#if PAGE_ALLOC_LIMIT
+        if((g_pages_alloced + numPages) > 256*32) {
+            //printk("full %d! \n", g_pages_alloced);
+            addr = NULL;
+        } else {
+            addr = (char *)__get_free_pages(GFP_ATOMIC | GFP_DMA, GetOrder(numPages));
+            if(addr) {
+                g_pages_alloced += numPages;
+                //printk("alloc %d / %d \n", numPages, g_pages_alloced);
+            }
+        }
+#else
         addr = (char *)__get_free_pages(GFP_ATOMIC | GFP_DMA, GetOrder(numPages));
+#endif
     }
     else
     {
@@ -2809,6 +2828,11 @@ gceSTATUS gckOS_FreePagedMemory(
     if (mdl->contiguous)
     {
         free_pages((unsigned long)mdl->addr, GetOrder(mdl->numPages));
+#if PAGE_ALLOC_LIMIT
+        g_pages_alloced -= mdl->numPages;
+        //printk("free %d / %d \n", mdl->numPages, g_pages_alloced);
+        if(g_pages_alloced<0)    g_pages_alloced = 0;
+#endif
     }
     else
     {