ARM: OMAP: Convert OMAPFB and VRAM SDRAM reservation to LMB
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 22 May 2010 22:59:11 +0000 (23:59 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 27 Jul 2010 07:48:23 +0000 (08:48 +0100)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/plat-omap/common.c
arch/arm/plat-omap/fb.c
arch/arm/plat-omap/include/plat/vram.h
drivers/video/omap2/vram.c
include/linux/omapfb.h

index 9f6bbc1..ebed826 100644 (file)
@@ -85,8 +85,8 @@ EXPORT_SYMBOL(omap_get_var_config);
 
 void __init omap_reserve(void)
 {
-       omapfb_reserve_sdram();
-       omap_vram_reserve_sdram();
+       omapfb_reserve_sdram_memblock();
+       omap_vram_reserve_sdram_memblock();
 }
 
 /*
index 97db493..0054b95 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/io.h>
 #include <linux/omapfb.h>
 
@@ -173,25 +173,27 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg,
 
 static int valid_sdram(unsigned long addr, unsigned long size)
 {
-       struct bootmem_data *bdata = NODE_DATA(0)->bdata;
-       unsigned long sdram_start, sdram_end;
+       struct memblock_property res;
 
-       sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
-       sdram_end = bdata->node_low_pfn << PAGE_SHIFT;
-
-       return addr >= sdram_start && sdram_end - addr >= size;
+       res.base = addr;
+       res.size = size;
+       return !memblock_find(&res) && res.base == addr && res.size == size;
 }
 
 static int reserve_sdram(unsigned long addr, unsigned long size)
 {
-       return reserve_bootmem(addr, size, BOOTMEM_EXCLUSIVE);
+       if (memblock_is_region_reserved(addr, size))
+               return -EBUSY;
+       if (memblock_reserve(addr, size))
+               return -ENOMEM;
+       return 0;
 }
 
 /*
  * Called from map_io. We need to call to this early enough so that we
  * can reserve the fixed SDRAM regions before VM could get hold of them.
  */
-void __init omapfb_reserve_sdram(void)
+void __init omapfb_reserve_sdram_memblock(void)
 {
        unsigned long reserved = 0;
        int i;
@@ -386,7 +388,10 @@ static inline int omap_init_fb(void)
 
 arch_initcall(omap_init_fb);
 
-void omapfb_reserve_sdram(void) {}
+void omapfb_reserve_sdram_memblock(void)
+{
+}
+
 unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
                                  unsigned long sram_vstart,
                                  unsigned long sram_size,
@@ -402,7 +407,10 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data)
 {
 }
 
-void omapfb_reserve_sdram(void) {}
+void omapfb_reserve_sdram_memblock(void)
+{
+}
+
 unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
                                  unsigned long sram_vstart,
                                  unsigned long sram_size,
index edd4987..0aa4ecd 100644 (file)
@@ -38,7 +38,7 @@ extern void omap_vram_get_info(unsigned long *vram, unsigned long *free_vram,
 extern void omap_vram_set_sdram_vram(u32 size, u32 start);
 extern void omap_vram_set_sram_vram(u32 size, u32 start);
 
-extern void omap_vram_reserve_sdram(void);
+extern void omap_vram_reserve_sdram_memblock(void);
 extern unsigned long omap_vram_reserve_sram(unsigned long sram_pstart,
                                            unsigned long sram_vstart,
                                            unsigned long sram_size,
@@ -48,7 +48,7 @@ extern unsigned long omap_vram_reserve_sram(unsigned long sram_pstart,
 static inline void omap_vram_set_sdram_vram(u32 size, u32 start) { }
 static inline void omap_vram_set_sram_vram(u32 size, u32 start) { }
 
-static inline void omap_vram_reserve_sdram(void) { }
+static inline void omap_vram_reserve_sdram_memblock(void) { }
 static inline unsigned long omap_vram_reserve_sram(unsigned long sram_pstart,
                                            unsigned long sram_vstart,
                                            unsigned long sram_size,
index 3b1237a..f6fdc20 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/completion.h>
 #include <linux/debugfs.h>
 #include <linux/jiffies.h>
@@ -525,10 +525,8 @@ early_param("vram", omap_vram_early_vram);
  * Called from map_io. We need to call to this early enough so that we
  * can reserve the fixed SDRAM regions before VM could get hold of them.
  */
-void __init omap_vram_reserve_sdram(void)
+void __init omap_vram_reserve_sdram_memblock(void)
 {
-       struct bootmem_data     *bdata;
-       unsigned long           sdram_start, sdram_size;
        u32 paddr;
        u32 size = 0;
 
@@ -555,29 +553,28 @@ void __init omap_vram_reserve_sdram(void)
 
        size = PAGE_ALIGN(size);
 
-       bdata = NODE_DATA(0)->bdata;
-       sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
-       sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start;
-
        if (paddr) {
-               if ((paddr & ~PAGE_MASK) || paddr < sdram_start ||
-                               paddr + size > sdram_start + sdram_size) {
+               struct memblock_property res;
+
+               res.base = paddr;
+               res.size = size;
+               if ((paddr & ~PAGE_MASK) || memblock_find(&res) ||
+                   res.base != paddr || res.size != size) {
                        pr_err("Illegal SDRAM region for VRAM\n");
                        return;
                }
 
-               if (reserve_bootmem(paddr, size, BOOTMEM_EXCLUSIVE) < 0) {
-                       pr_err("FB: failed to reserve VRAM\n");
+               if (memblock_is_region_reserved(paddr, size)) {
+                       pr_err("FB: failed to reserve VRAM - busy\n");
                        return;
                }
-       } else {
-               if (size > sdram_size) {
-                       pr_err("Illegal SDRAM size for VRAM\n");
+
+               if (memblock_reserve(paddr, size) < 0) {
+                       pr_err("FB: failed to reserve VRAM - no memory\n");
                        return;
                }
-
-               paddr = virt_to_phys(alloc_bootmem_pages(size));
-               BUG_ON(paddr & ~PAGE_MASK);
+       } else {
+               paddr = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_REAL_LIMIT);
        }
 
        omap_vram_add_region(paddr, size);
index 9bdd914..7e4cd61 100644 (file)
@@ -253,7 +253,7 @@ struct omapfb_platform_data {
 /* in arch/arm/plat-omap/fb.c */
 extern void omapfb_set_platform_data(struct omapfb_platform_data *data);
 extern void omapfb_set_ctrl_platform_data(void *pdata);
-extern void omapfb_reserve_sdram(void);
+extern void omapfb_reserve_sdram_memblock(void);
 
 #endif