Skip to content

Commit 3044100

Browse files
committed
Merge branch 'core-memblock-for-linus' of git://git.kernel.org/pub/scm/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
2 parents b515316 + 67e87f0 commit 3044100

69 files changed

Lines changed: 1639 additions & 1703 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/arm/mm/init.c‎

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static void __init find_limits(struct meminfo *mi,
150150
static void __init arm_bootmem_init(struct meminfo *mi,
151151
unsigned long start_pfn, unsigned long end_pfn)
152152
{
153+
struct memblock_region *reg;
153154
unsigned int boot_pages;
154155
phys_addr_t bitmap;
155156
pg_data_t *pgdat;
@@ -180,13 +181,13 @@ static void __init arm_bootmem_init(struct meminfo *mi,
180181
/*
181182
* Reserve the memblock reserved regions in bootmem.
182183
*/
183-
for (i = 0; i < memblock.reserved.cnt; i++) {
184-
phys_addr_t start = memblock_start_pfn(&memblock.reserved, i);
185-
if (start >= start_pfn &&
186-
memblock_end_pfn(&memblock.reserved, i) <= end_pfn)
184+
for_each_memblock(reserved, reg) {
185+
phys_addr_t start = memblock_region_reserved_base_pfn(reg);
186+
phys_addr_t end = memblock_region_reserved_end_pfn(reg);
187+
if (start >= start_pfn && end <= end_pfn)
187188
reserve_bootmem_node(pgdat, __pfn_to_phys(start),
188-
memblock_size_bytes(&memblock.reserved, i),
189-
BOOTMEM_DEFAULT);
189+
(end - start) << PAGE_SHIFT,
190+
BOOTMEM_DEFAULT);
190191
}
191192
}
192193

@@ -237,20 +238,7 @@ static void __init arm_bootmem_free(struct meminfo *mi, unsigned long min,
237238
#ifndef CONFIG_SPARSEMEM
238239
int pfn_valid(unsigned long pfn)
239240
{
240-
struct memblock_region *mem = &memblock.memory;
241-
unsigned int left = 0, right = mem->cnt;
242-
243-
do {
244-
unsigned int mid = (right + left) / 2;
245-
246-
if (pfn < memblock_start_pfn(mem, mid))
247-
right = mid;
248-
else if (pfn >= memblock_end_pfn(mem, mid))
249-
left = mid + 1;
250-
else
251-
return 1;
252-
} while (left < right);
253-
return 0;
241+
return memblock_is_memory(pfn << PAGE_SHIFT);
254242
}
255243
EXPORT_SYMBOL(pfn_valid);
256244

@@ -260,10 +248,11 @@ static void arm_memory_present(void)
260248
#else
261249
static void arm_memory_present(void)
262250
{
263-
int i;
264-
for (i = 0; i < memblock.memory.cnt; i++)
265-
memory_present(0, memblock_start_pfn(&memblock.memory, i),
266-
memblock_end_pfn(&memblock.memory, i));
251+
struct memblock_region *reg;
252+
253+
for_each_memblock(memory, reg)
254+
memory_present(0, memblock_region_memory_base_pfn(reg),
255+
memblock_region_memory_end_pfn(reg));
267256
}
268257
#endif
269258

‎arch/arm/plat-omap/fb.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg,
173173

174174
static int valid_sdram(unsigned long addr, unsigned long size)
175175
{
176-
struct memblock_property res;
177-
178-
res.base = addr;
179-
res.size = size;
180-
return !memblock_find(&res) && res.base == addr && res.size == size;
176+
return memblock_is_region_memory(addr, size);
181177
}
182178

183179
static int reserve_sdram(unsigned long addr, unsigned long size)

‎arch/microblaze/include/asm/memblock.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#ifndef _ASM_MICROBLAZE_MEMBLOCK_H
1010
#define _ASM_MICROBLAZE_MEMBLOCK_H
1111

12-
/* MEMBLOCK limit is OFF */
13-
#define MEMBLOCK_REAL_LIMIT 0xFFFFFFFF
14-
1512
#endif /* _ASM_MICROBLAZE_MEMBLOCK_H */
1613

1714

‎arch/microblaze/mm/init.c‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ static void __init paging_init(void)
7070

7171
void __init setup_memory(void)
7272
{
73-
int i;
7473
unsigned long map_size;
74+
struct memblock_region *reg;
75+
7576
#ifndef CONFIG_MMU
7677
u32 kernel_align_start, kernel_align_size;
7778

7879
/* Find main memory where is the kernel */
79-
for (i = 0; i < memblock.memory.cnt; i++) {
80-
memory_start = (u32) memblock.memory.region[i].base;
81-
memory_end = (u32) memblock.memory.region[i].base
82-
+ (u32) memblock.memory.region[i].size;
80+
for_each_memblock(memory, reg) {
81+
memory_start = (u32)reg->base;
82+
memory_end = (u32) reg->base + reg->size;
8383
if ((memory_start <= (u32)_text) &&
8484
((u32)_text <= memory_end)) {
8585
memory_size = memory_end - memory_start;
@@ -142,12 +142,10 @@ void __init setup_memory(void)
142142
free_bootmem(memory_start, memory_size);
143143

144144
/* reserve allocate blocks */
145-
for (i = 0; i < memblock.reserved.cnt; i++) {
146-
pr_debug("reserved %d - 0x%08x-0x%08x\n", i,
147-
(u32) memblock.reserved.region[i].base,
148-
(u32) memblock_size_bytes(&memblock.reserved, i));
149-
reserve_bootmem(memblock.reserved.region[i].base,
150-
memblock_size_bytes(&memblock.reserved, i) - 1, BOOTMEM_DEFAULT);
145+
for_each_memblock(reserved, reg) {
146+
pr_debug("reserved - 0x%08x-0x%08x\n",
147+
(u32) reg->base, (u32) reg->size);
148+
reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
151149
}
152150
#ifdef CONFIG_MMU
153151
init_bootmem_done = 1;
@@ -230,7 +228,7 @@ static void mm_cmdline_setup(void)
230228
if (maxmem && memory_size > maxmem) {
231229
memory_size = maxmem;
232230
memory_end = memory_start + memory_size;
233-
memblock.memory.region[0].size = memory_size;
231+
memblock.memory.regions[0].size = memory_size;
234232
}
235233
}
236234
}
@@ -273,14 +271,14 @@ asmlinkage void __init mmu_init(void)
273271
machine_restart(NULL);
274272
}
275273

276-
if ((u32) memblock.memory.region[0].size < 0x1000000) {
274+
if ((u32) memblock.memory.regions[0].size < 0x1000000) {
277275
printk(KERN_EMERG "Memory must be greater than 16MB\n");
278276
machine_restart(NULL);
279277
}
280278
/* Find main memory where the kernel is */
281-
memory_start = (u32) memblock.memory.region[0].base;
282-
memory_end = (u32) memblock.memory.region[0].base +
283-
(u32) memblock.memory.region[0].size;
279+
memory_start = (u32) memblock.memory.regions[0].base;
280+
memory_end = (u32) memblock.memory.regions[0].base +
281+
(u32) memblock.memory.regions[0].size;
284282
memory_size = memory_end - memory_start;
285283

286284
mm_cmdline_setup(); /* FIXME parse args from command line - not used */

‎arch/powerpc/include/asm/memblock.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,4 @@
55

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

8-
#ifdef CONFIG_PPC32
9-
extern phys_addr_t lowmem_end_addr;
10-
#define MEMBLOCK_REAL_LIMIT lowmem_end_addr
11-
#else
12-
#define MEMBLOCK_REAL_LIMIT 0
13-
#endif
14-
158
#endif /* _ASM_POWERPC_MEMBLOCK_H */

‎arch/powerpc/include/asm/mmu.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define _ASM_POWERPC_MMU_H_
33
#ifdef __KERNEL__
44

5+
#include <linux/types.h>
6+
57
#include <asm/asm-compat.h>
68
#include <asm/feature-fixups.h>
79

@@ -82,6 +84,16 @@ extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
8284
extern void early_init_mmu(void);
8385
extern void early_init_mmu_secondary(void);
8486

87+
extern void setup_initial_memory_limit(phys_addr_t first_memblock_base,
88+
phys_addr_t first_memblock_size);
89+
90+
#ifdef CONFIG_PPC64
91+
/* This is our real memory area size on ppc64 server, on embedded, we
92+
* make it match the size our of bolted TLB area
93+
*/
94+
extern u64 ppc64_rma_size;
95+
#endif /* CONFIG_PPC64 */
96+
8597
#endif /* !__ASSEMBLY__ */
8698

8799
/* The kernel use the constants below to index in the page sizes array.

‎arch/powerpc/kernel/head_40x.S‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -923,11 +923,7 @@ initial_mmu:
923923
mtspr SPRN_PID,r0
924924
sync
925925

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

‎arch/powerpc/kernel/paca.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void __init allocate_pacas(void)
127127
* the first segment. On iSeries they must be within the area mapped
128128
* by the HV, which is HvPagesToMap * HVPAGESIZE bytes.
129129
*/
130-
limit = min(0x10000000ULL, memblock.rmo_size);
130+
limit = min(0x10000000ULL, ppc64_rma_size);
131131
if (firmware_has_feature(FW_FEATURE_ISERIES))
132132
limit = min(limit, HvPagesToMap * HVPAGESIZE);
133133

‎arch/powerpc/kernel/prom.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
int __initdata iommu_is_off;
6767
int __initdata iommu_force_on;
6868
unsigned long tce_alloc_start, tce_alloc_end;
69+
u64 ppc64_rma_size;
6970
#endif
7071

7172
static int __init early_parse_mem(char *p)
@@ -98,7 +99,7 @@ static void __init move_device_tree(void)
9899

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

493494
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
494495
{
495-
#if defined(CONFIG_PPC64)
496+
#ifdef CONFIG_PPC64
496497
if (iommu_is_off) {
497498
if (base >= 0x80000000ul)
498499
return;
@@ -501,9 +502,13 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
501502
}
502503
#endif
503504

504-
memblock_add(base, size);
505-
505+
/* First MEMBLOCK added, do some special initializations */
506+
if (memstart_addr == ~(phys_addr_t)0)
507+
setup_initial_memory_limit(base, size);
506508
memstart_addr = min((u64)memstart_addr, base);
509+
510+
/* Add the chunk to the MEMBLOCK list */
511+
memblock_add(base, size);
507512
}
508513

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

658-
659663
void __init early_init_devtree(void *params)
660664
{
661665
phys_addr_t limit;
@@ -683,6 +687,7 @@ void __init early_init_devtree(void *params)
683687

684688
/* Scan memory nodes and rebuild MEMBLOCKs */
685689
memblock_init();
690+
686691
of_scan_flat_dt(early_init_dt_scan_root, NULL);
687692
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
688693

‎arch/powerpc/kernel/rtas.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ void __init rtas_initialize(void)
969969
*/
970970
#ifdef CONFIG_PPC64
971971
if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR)) {
972-
rtas_region = min(memblock.rmo_size, RTAS_INSTANTIATE_MAX);
972+
rtas_region = min(ppc64_rma_size, RTAS_INSTANTIATE_MAX);
973973
ibm_suspend_me_token = rtas_token("ibm,suspend-me");
974974
}
975975
#endif

0 commit comments

Comments
 (0)