Skip to content

Commit

Permalink
x86: Use __memblock_alloc_base() in early_reserve_e820()
Browse files Browse the repository at this point in the history
early_reserve_e820() implements its own ad-hoc early allocator using
memblock_x86_find_in_range_size().  Use __memblock_alloc_base()
instead and remove the unnecessary @startt parameter (it's top-down
allocation anyway).

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-6-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Tejun Heo authored and H. Peter Anvin committed Jul 14, 2011
1 parent 0608f70 commit ab5d140
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
2 changes: 1 addition & 1 deletion arch/x86/include/asm/e820.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static inline void early_memtest(unsigned long start, unsigned long end)

extern unsigned long e820_end_of_ram_pfn(void);
extern unsigned long e820_end_of_low_ram_pfn(void);
extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
extern u64 early_reserve_e820(u64 sizet, u64 align);

void memblock_x86_fill(void);
void memblock_find_dma_reserve(void);
Expand Down
30 changes: 6 additions & 24 deletions arch/x86/kernel/e820.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,35 +737,17 @@ core_initcall(e820_mark_nvs_memory);
/*
* pre allocated 4k and reserved it in memblock and e820_saved
*/
u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
u64 __init early_reserve_e820(u64 size, u64 align)
{
u64 size = 0;
u64 addr;
u64 start;

for (start = startt; ; start += size) {
start = memblock_x86_find_in_range_size(start, &size, align);
if (!start)
return 0;
if (size >= sizet)
break;
addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
if (addr) {
e820_update_range_saved(addr, size, E820_RAM, E820_RESERVED);
printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
update_e820_saved();
}

#ifdef CONFIG_X86_32
if (start >= MAXMEM)
return 0;
if (start + size > MAXMEM)
size = MAXMEM - start;
#endif

addr = round_down(start + size - sizet, align);
if (addr < start)
return 0;
memblock_x86_reserve_range(addr, addr + sizet, "new next");
e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED);
printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
update_e820_saved();

return addr;
}

Expand Down
6 changes: 2 additions & 4 deletions arch/x86/kernel/mpparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,8 @@ early_param("alloc_mptable", parse_alloc_mptable_opt);

void __init early_reserve_e820_mpc_new(void)
{
if (enable_update_mptable && alloc_mptable) {
u64 startt = 0;
mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4);
}
if (enable_update_mptable && alloc_mptable)
mpc_new_phys = early_reserve_e820(mpc_new_length, 4);
}

static int __init update_mp_table(void)
Expand Down

0 comments on commit ab5d140

Please sign in to comment.