diff options
author | Wu Guoxing <b02248@freescale.com> | 2010-04-09 16:57:55 +0800 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2010-05-25 11:20:23 +0200 |
commit | 87c17002508c548d2aeb308eb3d9536ac78927c0 (patch) | |
tree | 4c2fa8f2fd428f274ed023e403b66031b93d489a /arch/arm | |
parent | 157f4e812d6a7ee38de3c47fd0df346ce3e4c2f4 (diff) |
ENGR00122151 reserve gpu memory in kernel
add a new kernel command "gpu_memory" to reserve gpu memory in kernel
Signed-off-by:Wu Guoxing <b02248@freescale.com>
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-mx5/devices.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-mx5/mx51_babbage.c | 68 | ||||
-rw-r--r-- | arch/arm/mach-mx5/mx53_evk.c | 75 |
3 files changed, 111 insertions, 38 deletions
diff --git a/arch/arm/mach-mx5/devices.c b/arch/arm/mach-mx5/devices.c index 84133a95002b..df433a8f5417 100644 --- a/arch/arm/mach-mx5/devices.c +++ b/arch/arm/mach-mx5/devices.c @@ -930,6 +930,12 @@ static struct resource mxc_gpu_resources[] = { .name = "gpu_graphics_mem", .flags = IORESOURCE_MEM, }, + { + .start = 0, + .end = 0, + .name = "gpu_reserved_mem", + .flags = IORESOURCE_MEM, + }, }; struct platform_device gpu_device = { diff --git a/arch/arm/mach-mx5/mx51_babbage.c b/arch/arm/mach-mx5/mx51_babbage.c index 2e558307d9e3..4a962ab6f647 100644 --- a/arch/arm/mach-mx5/mx51_babbage.c +++ b/arch/arm/mach-mx5/mx51_babbage.c @@ -798,36 +798,72 @@ static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { char *str; - int size = SZ_512M - SZ_32M; struct tag *t; + struct tag *mem_tag = 0; + int total_mem = SZ_512M; + int left_mem = 0; + int gpu_mem = SZ_64M; + int fb_mem = SZ_32M; mxc_set_cpu_type(MXC_CPU_MX51); get_cpu_wp = mx51_babbage_get_cpu_wp; set_num_cpu_wp = mx51_babbage_set_num_cpu_wp; - for_each_tag(t, tags) { - if (t->hdr.tag != ATAG_CMDLINE) - continue; - str = t->u.cmdline.cmdline; - str = strstr(str, "mem="); - if (str != NULL) { - str += 4; - size = memparse(str, &str); - if (size == 0 || size == SZ_512M) - return; + for_each_tag(mem_tag, tags) { + if (mem_tag->hdr.tag == ATAG_MEM) { + total_mem = mem_tag->u.mem.size; + left_mem = total_mem - gpu_mem - fb_mem; + break; } } for_each_tag(t, tags) { - if (t->hdr.tag != ATAG_MEM) - continue; + if (t->hdr.tag == ATAG_CMDLINE) { + str = t->u.cmdline.cmdline; + str = strstr(str, "mem="); + if (str != NULL) { + str += 4; + left_mem = memparse(str, &str); + if (left_mem == 0 || left_mem > total_mem) + left_mem = total_mem - gpu_mem - fb_mem; + } + + str = t->u.cmdline.cmdline; + str = strstr(str, "gpu_memory="); + if (str != NULL) { + str += 11; + gpu_mem = memparse(str, &str); + } + + break; + } + } - t->u.mem.size = size; + if (mem_tag) { + fb_mem = total_mem - left_mem - gpu_mem; + if (fb_mem < 0) { + gpu_mem = total_mem - left_mem; + fb_mem = 0; + } + mem_tag->u.mem.size = left_mem; + + /*reserve memory for gpu*/ + gpu_device.resource[5].start = + mem_tag->u.mem.start + left_mem; + gpu_device.resource[5].end = + gpu_device.resource[5].start + gpu_mem - 1; #if defined(CONFIG_FB_MXC_SYNC_PANEL) || \ defined(CONFIG_FB_MXC_SYNC_PANEL_MODULE) - mxcfb_resources[0].start = t->u.mem.start + size; - mxcfb_resources[0].end = t->u.mem.start + SZ_512M - 1; + if (fb_mem) { + mxcfb_resources[0].start = + gpu_device.resource[5].end + 1; + mxcfb_resources[0].end = + mxcfb_resources[0].start + fb_mem - 1; + } else { + mxcfb_resources[0].start = 0; + mxcfb_resources[0].end = 0; + } #endif } } diff --git a/arch/arm/mach-mx5/mx53_evk.c b/arch/arm/mach-mx5/mx53_evk.c index 7cb9830daaff..1064f11908c6 100644 --- a/arch/arm/mach-mx5/mx53_evk.c +++ b/arch/arm/mach-mx5/mx53_evk.c @@ -473,42 +473,73 @@ static struct platform_device mxc_sgtl5000_device = { static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { - char *str; - int size = 0; - unsigned long orig_size; struct tag *t; + struct tag *mem_tag = 0; + int total_mem = SZ_1G; + int left_mem = 0; + int gpu_mem = SZ_128M; + int fb_mem = SZ_32M; + char *str; mxc_set_cpu_type(MXC_CPU_MX53); get_cpu_wp = mx53_evk_get_cpu_wp; set_num_cpu_wp = mx53_evk_set_num_cpu_wp; - for_each_tag(t, tags) { - if (t->hdr.tag != ATAG_CMDLINE) - continue; - str = t->u.cmdline.cmdline; - str = strstr(str, "mem="); - if (str != NULL) { - str += 4; - size = memparse(str, &str); - if (size == 0 || size == SZ_512M) - return; + for_each_tag(mem_tag, tags) { + if (mem_tag->hdr.tag == ATAG_MEM) { + total_mem = mem_tag->u.mem.size; + left_mem = total_mem - gpu_mem - fb_mem; + break; } } for_each_tag(t, tags) { - if (t->hdr.tag != ATAG_MEM) - continue; + if (t->hdr.tag == ATAG_CMDLINE) { + str = t->u.cmdline.cmdline; + str = strstr(str, "mem="); + if (str != NULL) { + str += 4; + left_mem = memparse(str, &str); + if (left_mem == 0 || left_mem > total_mem) + left_mem = total_mem - gpu_mem - fb_mem; + } + + str = t->u.cmdline.cmdline; + str = strstr(str, "gpu_memory="); + if (str != NULL) { + str += 11; + gpu_mem = memparse(str, &str); + } - orig_size = t->u.mem.size; - if (!size) - size = t->u.mem.size - SZ_32M; - t->u.mem.size = size; + break; + } + } + + if (mem_tag) { + fb_mem = total_mem - left_mem - gpu_mem; + if (fb_mem < 0) { + gpu_mem = total_mem - left_mem; + fb_mem = 0; + } + mem_tag->u.mem.size = left_mem; + + /*reserve memory for gpu*/ + gpu_device.resource[5].start = + mem_tag->u.mem.start + left_mem; + gpu_device.resource[5].end = + gpu_device.resource[5].start + gpu_mem - 1; #if defined(CONFIG_FB_MXC_SYNC_PANEL) || \ defined(CONFIG_FB_MXC_SYNC_PANEL_MODULE) - mxcfb_resources[0].start = t->u.mem.start + size; - mxcfb_resources[0].end = t->u.mem.start + orig_size - 1; - break; + if (fb_mem) { + mxcfb_resources[0].start = + gpu_device.resource[5].end + 1; + mxcfb_resources[0].end = + mxcfb_resources[0].start + fb_mem - 1; + } else { + mxcfb_resources[0].start = 0; + mxcfb_resources[0].end = 0; + } #endif } } |