From 228fbc478e9344818cdf701b8425341e1a8e31e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E6=9D=9C=E5=9D=A4=E6=98=8E?= Date: Thu, 16 Dec 2010 14:21:01 +0800 Subject: [PATCH] Limit the gpu's dma mem of size --- drivers/staging/rk29/vivante/Makefile | 2 +- .../hal/os/linux/kernel/gc_hal_kernel_os.c | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rk29/vivante/Makefile b/drivers/staging/rk29/vivante/Makefile index e4171f01ac18..1bec4a3a706d 100644 --- a/drivers/staging/rk29/vivante/Makefile +++ b/drivers/staging/rk29/vivante/Makefile @@ -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 diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c index 7da7bec0e726..582cb7dd2e6d 100644 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c @@ -40,6 +40,12 @@ #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 { -- 2.34.1