提交 98864ff5 编写于 作者: R Russell King

ARM: OMAP: Convert OMAPFB and VRAM SDRAM reservation to LMB

Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 8d717a52
...@@ -85,8 +85,8 @@ EXPORT_SYMBOL(omap_get_var_config); ...@@ -85,8 +85,8 @@ EXPORT_SYMBOL(omap_get_var_config);
void __init omap_reserve(void) void __init omap_reserve(void)
{ {
omapfb_reserve_sdram(); omapfb_reserve_sdram_memblock();
omap_vram_reserve_sdram(); omap_vram_reserve_sdram_memblock();
} }
/* /*
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/bootmem.h> #include <linux/memblock.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/omapfb.h> #include <linux/omapfb.h>
...@@ -173,25 +173,27 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg, ...@@ -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) static int valid_sdram(unsigned long addr, unsigned long size)
{ {
struct bootmem_data *bdata = NODE_DATA(0)->bdata; struct memblock_property res;
unsigned long sdram_start, sdram_end;
sdram_start = bdata->node_min_pfn << PAGE_SHIFT; res.base = addr;
sdram_end = bdata->node_low_pfn << PAGE_SHIFT; res.size = size;
return !memblock_find(&res) && res.base == addr && res.size == size;
return addr >= sdram_start && sdram_end - addr >= size;
} }
static int reserve_sdram(unsigned long addr, unsigned long 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 * 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. * 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; unsigned long reserved = 0;
int i; int i;
...@@ -386,7 +388,10 @@ static inline int omap_init_fb(void) ...@@ -386,7 +388,10 @@ static inline int omap_init_fb(void)
arch_initcall(omap_init_fb); 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 omapfb_reserve_sram(unsigned long sram_pstart,
unsigned long sram_vstart, unsigned long sram_vstart,
unsigned long sram_size, unsigned long sram_size,
...@@ -402,7 +407,10 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data) ...@@ -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 omapfb_reserve_sram(unsigned long sram_pstart,
unsigned long sram_vstart, unsigned long sram_vstart,
unsigned long sram_size, unsigned long sram_size,
......
...@@ -38,7 +38,7 @@ extern void omap_vram_get_info(unsigned long *vram, unsigned long *free_vram, ...@@ -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_sdram_vram(u32 size, u32 start);
extern void omap_vram_set_sram_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, extern unsigned long omap_vram_reserve_sram(unsigned long sram_pstart,
unsigned long sram_vstart, unsigned long sram_vstart,
unsigned long sram_size, unsigned long sram_size,
...@@ -48,7 +48,7 @@ extern unsigned long omap_vram_reserve_sram(unsigned long sram_pstart, ...@@ -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_sdram_vram(u32 size, u32 start) { }
static inline void omap_vram_set_sram_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, static inline unsigned long omap_vram_reserve_sram(unsigned long sram_pstart,
unsigned long sram_vstart, unsigned long sram_vstart,
unsigned long sram_size, unsigned long sram_size,
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/bootmem.h> #include <linux/memblock.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
...@@ -525,10 +525,8 @@ early_param("vram", omap_vram_early_vram); ...@@ -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 * 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. * 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 paddr;
u32 size = 0; u32 size = 0;
...@@ -555,29 +553,28 @@ void __init omap_vram_reserve_sdram(void) ...@@ -555,29 +553,28 @@ void __init omap_vram_reserve_sdram(void)
size = PAGE_ALIGN(size); 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) {
if ((paddr & ~PAGE_MASK) || paddr < sdram_start || struct memblock_property res;
paddr + size > sdram_start + sdram_size) {
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"); pr_err("Illegal SDRAM region for VRAM\n");
return; return;
} }
if (reserve_bootmem(paddr, size, BOOTMEM_EXCLUSIVE) < 0) { if (memblock_is_region_reserved(paddr, size)) {
pr_err("FB: failed to reserve VRAM\n"); pr_err("FB: failed to reserve VRAM - busy\n");
return; return;
} }
} else {
if (size > sdram_size) { if (memblock_reserve(paddr, size) < 0) {
pr_err("Illegal SDRAM size for VRAM\n"); pr_err("FB: failed to reserve VRAM - no memory\n");
return; return;
} }
} else {
paddr = virt_to_phys(alloc_bootmem_pages(size)); paddr = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_REAL_LIMIT);
BUG_ON(paddr & ~PAGE_MASK);
} }
omap_vram_add_region(paddr, size); omap_vram_add_region(paddr, size);
......
...@@ -253,7 +253,7 @@ struct omapfb_platform_data { ...@@ -253,7 +253,7 @@ struct omapfb_platform_data {
/* in arch/arm/plat-omap/fb.c */ /* in arch/arm/plat-omap/fb.c */
extern void omapfb_set_platform_data(struct omapfb_platform_data *data); extern void omapfb_set_platform_data(struct omapfb_platform_data *data);
extern void omapfb_set_ctrl_platform_data(void *pdata); extern void omapfb_set_ctrl_platform_data(void *pdata);
extern void omapfb_reserve_sdram(void); extern void omapfb_reserve_sdram_memblock(void);
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册