From 946eb774e95cdc2f2fa5cdc24aa69229f82814b8 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 16 Apr 2009 17:56:00 +0300 Subject: [PATCH 34/69] DSS2: VRAM: improve omap_vram_add_region() Combine postponed and non-posponed versions of omap_vram_add_region. Make the func non-static, so it can be called from board files. --- arch/arm/plat-omap/include/mach/vram.h | 1 + arch/arm/plat-omap/vram.c | 54 +++++++++++++------------------ 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/arch/arm/plat-omap/include/mach/vram.h b/arch/arm/plat-omap/include/mach/vram.h index f176562..8639e08 100644 --- a/arch/arm/plat-omap/include/mach/vram.h +++ b/arch/arm/plat-omap/include/mach/vram.h @@ -24,6 +24,7 @@ #include +extern int omap_vram_add_region(unsigned long paddr, size_t size); extern int omap_vram_free(unsigned long paddr, size_t size); extern int omap_vram_alloc(int mtype, size_t size, unsigned long *paddr); extern int omap_vram_reserve(unsigned long paddr, size_t size); diff --git a/arch/arm/plat-omap/vram.c b/arch/arm/plat-omap/vram.c index 520f260..8e9fe77 100644 --- a/arch/arm/plat-omap/vram.c +++ b/arch/arm/plat-omap/vram.c @@ -60,6 +60,7 @@ * time when we cannot yet allocate the region list */ #define MAX_POSTPONED_REGIONS 10 +static bool vram_initialized; static int postponed_cnt __initdata; static struct { unsigned long paddr; @@ -145,39 +146,32 @@ static void omap_vram_free_allocation(struct vram_alloc *va) kfree(va); } -static __init int omap_vram_add_region_postponed(unsigned long paddr, - size_t size) -{ - if (postponed_cnt == MAX_POSTPONED_REGIONS) - return -ENOMEM; - - postponed_regions[postponed_cnt].paddr = paddr; - postponed_regions[postponed_cnt].size = size; - - ++postponed_cnt; - - return 0; -} - -/* add/remove_region can be exported if there's need to add/remove regions - * runtime */ -static int omap_vram_add_region(unsigned long paddr, size_t size) +int omap_vram_add_region(unsigned long paddr, size_t size) { struct vram_region *rm; unsigned pages; - DBG("adding region paddr %08lx size %d\n", - paddr, size); + if (vram_initialized) { + DBG("adding region paddr %08lx size %d\n", + paddr, size); - size &= PAGE_MASK; - pages = size >> PAGE_SHIFT; + size &= PAGE_MASK; + pages = size >> PAGE_SHIFT; - rm = omap_vram_create_region(paddr, pages); - if (rm == NULL) - return -ENOMEM; + rm = omap_vram_create_region(paddr, pages); + if (rm == NULL) + return -ENOMEM; + + list_add(&rm->list, ®ion_list); + } else { + if (postponed_cnt == MAX_POSTPONED_REGIONS) + return -ENOMEM; - list_add(&rm->list, ®ion_list); + postponed_regions[postponed_cnt].paddr = paddr; + postponed_regions[postponed_cnt].size = size; + ++postponed_cnt; + } return 0; } @@ -438,6 +432,8 @@ static __init int omap_vram_init(void) { int i, r; + vram_initialized = 1; + for (i = 0; i < postponed_cnt; i++) omap_vram_add_region(postponed_regions[i].paddr, postponed_regions[i].size); @@ -472,10 +468,6 @@ static void __init omapfb_early_vram(char **p) omapfb_def_sdram_vram_size = memparse(*p, p); if (**p == ',') omapfb_def_sdram_vram_start = simple_strtoul((*p) + 1, p, 16); - - printk("omapfb_early_vram, %d, 0x%x\n", - omapfb_def_sdram_vram_size, - omapfb_def_sdram_vram_start); } __early_param("vram=", omapfb_early_vram); @@ -538,7 +530,7 @@ void __init omapfb_reserve_sdram(void) BUG_ON(paddr & ~PAGE_MASK); } - omap_vram_add_region_postponed(paddr, size); + omap_vram_add_region(paddr, size); pr_info("Reserving %u bytes SDRAM for VRAM\n", size); } @@ -594,7 +586,7 @@ unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart, reserved = pend_avail - paddr; size_avail = pend_avail - reserved - pstart_avail; - omap_vram_add_region_postponed(paddr, size); + omap_vram_add_region(paddr, size); if (reserved) pr_info("Reserving %lu bytes SRAM for VRAM\n", reserved); -- 1.6.2.4