Skip to content

Commit

Permalink
Merge branch 'core-memblock-for-linus' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/tip/linux-2.6-tip

* 'core-memblock-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (74 commits)
  x86-64: Only set max_pfn_mapped to 512 MiB if we enter via head_64.S
  xen: Cope with unmapped pages when initializing kernel pagetable
  memblock, bootmem: Round pfn properly for memory and reserved regions
  memblock: Annotate memblock functions with __init_memblock
  memblock: Allow memblock_init to be called early
  memblock/arm: Fix memblock_region_is_memory() typo
  x86, memblock: Remove __memblock_x86_find_in_range_size()
  memblock: Fix wraparound in find_region()
  x86-32, memblock: Make add_highpages honor early reserved ranges
  x86, memblock: Fix crashkernel allocation
  arm, memblock: Fix the sparsemem build
  memblock: Fix section mismatch warnings
  powerpc, memblock: Fix memblock API change fallout
  memblock, microblaze: Fix memblock API change fallout
  x86: Remove old bootmem code
  x86, memblock: Use memblock_memory_size()/memblock_free_memory_size() to get correct dma_reserve
  x86: Remove not used early_res code
  x86, memblock: Replace e820_/_early string with memblock_
  x86: Use memblock to replace early_res
  x86, memblock: Use memblock_debug to control debug message print out
  ...

Fix up trivial conflicts in arch/x86/kernel/setup.c and kernel/Makefile
  • Loading branch information
Linus Torvalds committed Oct 22, 2010
2 parents b515316 + 67e87f0 commit 3044100
Show file tree
Hide file tree
Showing 69 changed files with 1,639 additions and 1,703 deletions.
37 changes: 13 additions & 24 deletions arch/arm/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ static void __init find_limits(struct meminfo *mi,
static void __init arm_bootmem_init(struct meminfo *mi,
unsigned long start_pfn, unsigned long end_pfn)
{
struct memblock_region *reg;
unsigned int boot_pages;
phys_addr_t bitmap;
pg_data_t *pgdat;
Expand Down Expand Up @@ -180,13 +181,13 @@ static void __init arm_bootmem_init(struct meminfo *mi,
/*
* Reserve the memblock reserved regions in bootmem.
*/
for (i = 0; i < memblock.reserved.cnt; i++) {
phys_addr_t start = memblock_start_pfn(&memblock.reserved, i);
if (start >= start_pfn &&
memblock_end_pfn(&memblock.reserved, i) <= end_pfn)
for_each_memblock(reserved, reg) {
phys_addr_t start = memblock_region_reserved_base_pfn(reg);
phys_addr_t end = memblock_region_reserved_end_pfn(reg);
if (start >= start_pfn && end <= end_pfn)
reserve_bootmem_node(pgdat, __pfn_to_phys(start),
memblock_size_bytes(&memblock.reserved, i),
BOOTMEM_DEFAULT);
(end - start) << PAGE_SHIFT,
BOOTMEM_DEFAULT);
}
}

Expand Down Expand Up @@ -237,20 +238,7 @@ static void __init arm_bootmem_free(struct meminfo *mi, unsigned long min,
#ifndef CONFIG_SPARSEMEM
int pfn_valid(unsigned long pfn)
{
struct memblock_region *mem = &memblock.memory;
unsigned int left = 0, right = mem->cnt;

do {
unsigned int mid = (right + left) / 2;

if (pfn < memblock_start_pfn(mem, mid))
right = mid;
else if (pfn >= memblock_end_pfn(mem, mid))
left = mid + 1;
else
return 1;
} while (left < right);
return 0;
return memblock_is_memory(pfn << PAGE_SHIFT);
}
EXPORT_SYMBOL(pfn_valid);

Expand All @@ -260,10 +248,11 @@ static void arm_memory_present(void)
#else
static void arm_memory_present(void)
{
int i;
for (i = 0; i < memblock.memory.cnt; i++)
memory_present(0, memblock_start_pfn(&memblock.memory, i),
memblock_end_pfn(&memblock.memory, i));
struct memblock_region *reg;

for_each_memblock(memory, reg)
memory_present(0, memblock_region_memory_base_pfn(reg),
memblock_region_memory_end_pfn(reg));
}
#endif

Expand Down
6 changes: 1 addition & 5 deletions arch/arm/plat-omap/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg,

static int valid_sdram(unsigned long addr, unsigned long size)
{
struct memblock_property res;

res.base = addr;
res.size = size;
return !memblock_find(&res) && res.base == addr && res.size == size;
return memblock_is_region_memory(addr, size);
}

static int reserve_sdram(unsigned long addr, unsigned long size)
Expand Down
3 changes: 0 additions & 3 deletions arch/microblaze/include/asm/memblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#ifndef _ASM_MICROBLAZE_MEMBLOCK_H
#define _ASM_MICROBLAZE_MEMBLOCK_H

/* MEMBLOCK limit is OFF */
#define MEMBLOCK_REAL_LIMIT 0xFFFFFFFF

#endif /* _ASM_MICROBLAZE_MEMBLOCK_H */


30 changes: 14 additions & 16 deletions arch/microblaze/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ static void __init paging_init(void)

void __init setup_memory(void)
{
int i;
unsigned long map_size;
struct memblock_region *reg;

#ifndef CONFIG_MMU
u32 kernel_align_start, kernel_align_size;

/* Find main memory where is the kernel */
for (i = 0; i < memblock.memory.cnt; i++) {
memory_start = (u32) memblock.memory.region[i].base;
memory_end = (u32) memblock.memory.region[i].base
+ (u32) memblock.memory.region[i].size;
for_each_memblock(memory, reg) {
memory_start = (u32)reg->base;
memory_end = (u32) reg->base + reg->size;
if ((memory_start <= (u32)_text) &&
((u32)_text <= memory_end)) {
memory_size = memory_end - memory_start;
Expand Down Expand Up @@ -142,12 +142,10 @@ void __init setup_memory(void)
free_bootmem(memory_start, memory_size);

/* reserve allocate blocks */
for (i = 0; i < memblock.reserved.cnt; i++) {
pr_debug("reserved %d - 0x%08x-0x%08x\n", i,
(u32) memblock.reserved.region[i].base,
(u32) memblock_size_bytes(&memblock.reserved, i));
reserve_bootmem(memblock.reserved.region[i].base,
memblock_size_bytes(&memblock.reserved, i) - 1, BOOTMEM_DEFAULT);
for_each_memblock(reserved, reg) {
pr_debug("reserved - 0x%08x-0x%08x\n",
(u32) reg->base, (u32) reg->size);
reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
}
#ifdef CONFIG_MMU
init_bootmem_done = 1;
Expand Down Expand Up @@ -230,7 +228,7 @@ static void mm_cmdline_setup(void)
if (maxmem && memory_size > maxmem) {
memory_size = maxmem;
memory_end = memory_start + memory_size;
memblock.memory.region[0].size = memory_size;
memblock.memory.regions[0].size = memory_size;
}
}
}
Expand Down Expand Up @@ -273,14 +271,14 @@ asmlinkage void __init mmu_init(void)
machine_restart(NULL);
}

if ((u32) memblock.memory.region[0].size < 0x1000000) {
if ((u32) memblock.memory.regions[0].size < 0x1000000) {
printk(KERN_EMERG "Memory must be greater than 16MB\n");
machine_restart(NULL);
}
/* Find main memory where the kernel is */
memory_start = (u32) memblock.memory.region[0].base;
memory_end = (u32) memblock.memory.region[0].base +
(u32) memblock.memory.region[0].size;
memory_start = (u32) memblock.memory.regions[0].base;
memory_end = (u32) memblock.memory.regions[0].base +
(u32) memblock.memory.regions[0].size;
memory_size = memory_end - memory_start;

mm_cmdline_setup(); /* FIXME parse args from command line - not used */
Expand Down
7 changes: 0 additions & 7 deletions arch/powerpc/include/asm/memblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,4 @@

#define MEMBLOCK_DBG(fmt...) udbg_printf(fmt)

#ifdef CONFIG_PPC32
extern phys_addr_t lowmem_end_addr;
#define MEMBLOCK_REAL_LIMIT lowmem_end_addr
#else
#define MEMBLOCK_REAL_LIMIT 0
#endif

#endif /* _ASM_POWERPC_MEMBLOCK_H */
12 changes: 12 additions & 0 deletions arch/powerpc/include/asm/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define _ASM_POWERPC_MMU_H_
#ifdef __KERNEL__

#include <linux/types.h>

#include <asm/asm-compat.h>
#include <asm/feature-fixups.h>

Expand Down Expand Up @@ -82,6 +84,16 @@ extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
extern void early_init_mmu(void);
extern void early_init_mmu_secondary(void);

extern void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size);

#ifdef CONFIG_PPC64
/* This is our real memory area size on ppc64 server, on embedded, we
* make it match the size our of bolted TLB area
*/
extern u64 ppc64_rma_size;
#endif /* CONFIG_PPC64 */

#endif /* !__ASSEMBLY__ */

/* The kernel use the constants below to index in the page sizes array.
Expand Down
6 changes: 1 addition & 5 deletions arch/powerpc/kernel/head_40x.S
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,7 @@ initial_mmu:
mtspr SPRN_PID,r0
sync

/* Configure and load two entries into TLB slots 62 and 63.
* In case we are pinning TLBs, these are reserved in by the
* other TLB functions. If not reserving, then it doesn't
* matter where they are loaded.
*/
/* Configure and load one entry into TLB slots 63 */
clrrwi r4,r4,10 /* Mask off the real page number */
ori r4,r4,(TLB_WR | TLB_EX) /* Set the write and execute bits */

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/paca.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void __init allocate_pacas(void)
* the first segment. On iSeries they must be within the area mapped
* by the HV, which is HvPagesToMap * HVPAGESIZE bytes.
*/
limit = min(0x10000000ULL, memblock.rmo_size);
limit = min(0x10000000ULL, ppc64_rma_size);
if (firmware_has_feature(FW_FEATURE_ISERIES))
limit = min(limit, HvPagesToMap * HVPAGESIZE);

Expand Down
15 changes: 10 additions & 5 deletions arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
int __initdata iommu_is_off;
int __initdata iommu_force_on;
unsigned long tce_alloc_start, tce_alloc_end;
u64 ppc64_rma_size;
#endif

static int __init early_parse_mem(char *p)
Expand Down Expand Up @@ -98,7 +99,7 @@ static void __init move_device_tree(void)

if ((memory_limit && (start + size) > memory_limit) ||
overlaps_crashkernel(start, size)) {
p = __va(memblock_alloc_base(size, PAGE_SIZE, memblock.rmo_size));
p = __va(memblock_alloc(size, PAGE_SIZE));
memcpy(p, initial_boot_params, size);
initial_boot_params = (struct boot_param_header *)p;
DBG("Moved device tree to 0x%p\n", p);
Expand Down Expand Up @@ -492,7 +493,7 @@ static int __init early_init_dt_scan_memory_ppc(unsigned long node,

void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
#if defined(CONFIG_PPC64)
#ifdef CONFIG_PPC64
if (iommu_is_off) {
if (base >= 0x80000000ul)
return;
Expand All @@ -501,9 +502,13 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
}
#endif

memblock_add(base, size);

/* First MEMBLOCK added, do some special initializations */
if (memstart_addr == ~(phys_addr_t)0)
setup_initial_memory_limit(base, size);
memstart_addr = min((u64)memstart_addr, base);

/* Add the chunk to the MEMBLOCK list */
memblock_add(base, size);
}

u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
Expand Down Expand Up @@ -655,7 +660,6 @@ static void __init phyp_dump_reserve_mem(void)
static inline void __init phyp_dump_reserve_mem(void) {}
#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */


void __init early_init_devtree(void *params)
{
phys_addr_t limit;
Expand Down Expand Up @@ -683,6 +687,7 @@ void __init early_init_devtree(void *params)

/* Scan memory nodes and rebuild MEMBLOCKs */
memblock_init();

of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/rtas.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void __init rtas_initialize(void)
*/
#ifdef CONFIG_PPC64
if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR)) {
rtas_region = min(memblock.rmo_size, RTAS_INSTANTIATE_MAX);
rtas_region = min(ppc64_rma_size, RTAS_INSTANTIATE_MAX);
ibm_suspend_me_token = rtas_token("ibm,suspend-me");
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/setup_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static void __init irqstack_early_init(void)
unsigned int i;

/* interrupt stacks must be in lowmem, we get that for free on ppc32
* as the memblock is limited to lowmem by MEMBLOCK_REAL_LIMIT */
* as the memblock is limited to lowmem by default */
for_each_possible_cpu(i) {
softirq_ctx[i] = (struct thread_info *)
__va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/setup_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ static void __init emergency_stack_init(void)
* bringup, we need to get at them in real mode. This means they
* must also be within the RMO region.
*/
limit = min(slb0_limit(), memblock.rmo_size);
limit = min(slb0_limit(), ppc64_rma_size);

for_each_possible_cpu(i) {
unsigned long sp;
Expand Down
17 changes: 15 additions & 2 deletions arch/powerpc/mm/40x_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/highmem.h>
#include <linux/memblock.h>

#include <asm/pgalloc.h>
#include <asm/prom.h>
Expand All @@ -47,6 +48,7 @@
#include <asm/bootx.h>
#include <asm/machdep.h>
#include <asm/setup.h>

#include "mmu_decl.h"

extern int __map_without_ltlbs;
Expand Down Expand Up @@ -139,8 +141,19 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
* coverage with normal-sized pages (or other reasons) do not
* attempt to allocate outside the allowed range.
*/

__initial_memory_limit_addr = memstart_addr + mapped;
memblock_set_current_limit(mapped);

return mapped;
}

void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
{
/* We don't currently support the first MEMBLOCK not mapping 0
* physical on those processors
*/
BUG_ON(first_memblock_base != 0);

/* 40x can only access 16MB at the moment (see head_40x.S) */
memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000));
}
14 changes: 14 additions & 0 deletions arch/powerpc/mm/44x_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/

#include <linux/init.h>
#include <linux/memblock.h>

#include <asm/mmu.h>
#include <asm/system.h>
#include <asm/page.h>
Expand Down Expand Up @@ -213,6 +215,18 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
return total_lowmem;
}

void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
{
/* We don't currently support the first MEMBLOCK not mapping 0
* physical on those processors
*/
BUG_ON(first_memblock_base != 0);

/* 44x has a 256M TLB entry pinned at boot */
memblock_set_current_limit(min_t(u64, first_memblock_size, PPC_PIN_SIZE));
}

#ifdef CONFIG_SMP
void __cpuinit mmu_init_secondary(int cpu)
{
Expand Down
12 changes: 11 additions & 1 deletion arch/powerpc/mm/fsl_booke_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/highmem.h>
#include <linux/memblock.h>

#include <asm/pgalloc.h>
#include <asm/prom.h>
Expand Down Expand Up @@ -213,5 +214,14 @@ void __init adjust_total_lowmem(void)
pr_cont("%lu Mb, residual: %dMb\n", tlbcam_sz(tlbcam_index - 1) >> 20,
(unsigned int)((total_lowmem - __max_low_memory) >> 20));

__initial_memory_limit_addr = memstart_addr + __max_low_memory;
memblock_set_current_limit(memstart_addr + __max_low_memory);
}

void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
{
phys_addr_t limit = first_memblock_base + first_memblock_size;

/* 64M mapped initially according to head_fsl_booke.S */
memblock_set_current_limit(min_t(u64, limit, 0x04000000));
}
Loading

0 comments on commit 3044100

Please sign in to comment.