diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-08-04 00:06:41 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-08-04 00:21:49 -0400 |
commit | e3239ff92a17976ac5d26fa0fe40ef3a9daf2523 (patch) | |
tree | da3c493196811ccae1b79c3c94234f5d481c8221 | |
parent | f1c2c19c498e27de48bf0dc4221e6e31b1823169 (diff) |
memblock: Rename memblock_region to memblock_type and memblock_property to memblock_region
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/arm/mm/init.c | 2 | ||||
-rw-r--r-- | arch/arm/plat-omap/fb.c | 2 | ||||
-rw-r--r-- | arch/microblaze/mm/init.c | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/hash_utils_64.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/mem.c | 26 | ||||
-rw-r--r-- | arch/powerpc/platforms/embedded6xx/wii.c | 2 | ||||
-rw-r--r-- | arch/sparc/mm/init_64.c | 6 | ||||
-rw-r--r-- | drivers/video/omap2/vram.c | 2 | ||||
-rw-r--r-- | include/linux/memblock.h | 24 | ||||
-rw-r--r-- | mm/memblock.c | 168 |
10 files changed, 118 insertions, 120 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 7185b00650fe..d1496e65dc2d 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -237,7 +237,7 @@ static void __init arm_bootmem_free(struct meminfo *mi, unsigned long min, | |||
237 | #ifndef CONFIG_SPARSEMEM | 237 | #ifndef CONFIG_SPARSEMEM |
238 | int pfn_valid(unsigned long pfn) | 238 | int pfn_valid(unsigned long pfn) |
239 | { | 239 | { |
240 | struct memblock_region *mem = &memblock.memory; | 240 | struct memblock_type *mem = &memblock.memory; |
241 | unsigned int left = 0, right = mem->cnt; | 241 | unsigned int left = 0, right = mem->cnt; |
242 | 242 | ||
243 | do { | 243 | do { |
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c index 0054b9501a53..05bf22827404 100644 --- a/arch/arm/plat-omap/fb.c +++ b/arch/arm/plat-omap/fb.c | |||
@@ -173,7 +173,7 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg, | |||
173 | 173 | ||
174 | static int valid_sdram(unsigned long addr, unsigned long size) | 174 | static int valid_sdram(unsigned long addr, unsigned long size) |
175 | { | 175 | { |
176 | struct memblock_property res; | 176 | struct memblock_region res; |
177 | 177 | ||
178 | res.base = addr; | 178 | res.base = addr; |
179 | res.size = size; | 179 | res.size = size; |
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index db5934989926..afd6494fbbc6 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c | |||
@@ -77,8 +77,8 @@ void __init setup_memory(void) | |||
77 | 77 | ||
78 | /* Find main memory where is the kernel */ | 78 | /* Find main memory where is the kernel */ |
79 | for (i = 0; i < memblock.memory.cnt; i++) { | 79 | for (i = 0; i < memblock.memory.cnt; i++) { |
80 | memory_start = (u32) memblock.memory.region[i].base; | 80 | memory_start = (u32) memblock.memory.regions[i].base; |
81 | memory_end = (u32) memblock.memory.region[i].base | 81 | memory_end = (u32) memblock.memory.regions[i].base |
82 | + (u32) memblock.memory.region[i].size; | 82 | + (u32) memblock.memory.region[i].size; |
83 | if ((memory_start <= (u32)_text) && | 83 | if ((memory_start <= (u32)_text) && |
84 | ((u32)_text <= memory_end)) { | 84 | ((u32)_text <= memory_end)) { |
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 09dffe6efa46..b1a3784744db 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c | |||
@@ -660,7 +660,7 @@ static void __init htab_initialize(void) | |||
660 | 660 | ||
661 | /* create bolted the linear mapping in the hash table */ | 661 | /* create bolted the linear mapping in the hash table */ |
662 | for (i=0; i < memblock.memory.cnt; i++) { | 662 | for (i=0; i < memblock.memory.cnt; i++) { |
663 | base = (unsigned long)__va(memblock.memory.region[i].base); | 663 | base = (unsigned long)__va(memblock.memory.regions[i].base); |
664 | size = memblock.memory.region[i].size; | 664 | size = memblock.memory.region[i].size; |
665 | 665 | ||
666 | DBG("creating mapping for region: %lx..%lx (prot: %lx)\n", | 666 | DBG("creating mapping for region: %lx..%lx (prot: %lx)\n", |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 1a84a8d00005..a33f5c186fb7 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -86,10 +86,10 @@ int page_is_ram(unsigned long pfn) | |||
86 | for (i=0; i < memblock.memory.cnt; i++) { | 86 | for (i=0; i < memblock.memory.cnt; i++) { |
87 | unsigned long base; | 87 | unsigned long base; |
88 | 88 | ||
89 | base = memblock.memory.region[i].base; | 89 | base = memblock.memory.regions[i].base; |
90 | 90 | ||
91 | if ((paddr >= base) && | 91 | if ((paddr >= base) && |
92 | (paddr < (base + memblock.memory.region[i].size))) { | 92 | (paddr < (base + memblock.memory.regions[i].size))) { |
93 | return 1; | 93 | return 1; |
94 | } | 94 | } |
95 | } | 95 | } |
@@ -149,7 +149,7 @@ int | |||
149 | walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | 149 | walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, |
150 | void *arg, int (*func)(unsigned long, unsigned long, void *)) | 150 | void *arg, int (*func)(unsigned long, unsigned long, void *)) |
151 | { | 151 | { |
152 | struct memblock_property res; | 152 | struct memblock_region res; |
153 | unsigned long pfn, len; | 153 | unsigned long pfn, len; |
154 | u64 end; | 154 | u64 end; |
155 | int ret = -1; | 155 | int ret = -1; |
@@ -206,7 +206,7 @@ void __init do_init_bootmem(void) | |||
206 | /* Add active regions with valid PFNs */ | 206 | /* Add active regions with valid PFNs */ |
207 | for (i = 0; i < memblock.memory.cnt; i++) { | 207 | for (i = 0; i < memblock.memory.cnt; i++) { |
208 | unsigned long start_pfn, end_pfn; | 208 | unsigned long start_pfn, end_pfn; |
209 | start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT; | 209 | start_pfn = memblock.memory.regions[i].base >> PAGE_SHIFT; |
210 | end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); | 210 | end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); |
211 | add_active_range(0, start_pfn, end_pfn); | 211 | add_active_range(0, start_pfn, end_pfn); |
212 | } | 212 | } |
@@ -219,16 +219,16 @@ void __init do_init_bootmem(void) | |||
219 | 219 | ||
220 | /* reserve the sections we're already using */ | 220 | /* reserve the sections we're already using */ |
221 | for (i = 0; i < memblock.reserved.cnt; i++) { | 221 | for (i = 0; i < memblock.reserved.cnt; i++) { |
222 | unsigned long addr = memblock.reserved.region[i].base + | 222 | unsigned long addr = memblock.reserved.regions[i].base + |
223 | memblock_size_bytes(&memblock.reserved, i) - 1; | 223 | memblock_size_bytes(&memblock.reserved, i) - 1; |
224 | if (addr < lowmem_end_addr) | 224 | if (addr < lowmem_end_addr) |
225 | reserve_bootmem(memblock.reserved.region[i].base, | 225 | reserve_bootmem(memblock.reserved.regions[i].base, |
226 | memblock_size_bytes(&memblock.reserved, i), | 226 | memblock_size_bytes(&memblock.reserved, i), |
227 | BOOTMEM_DEFAULT); | 227 | BOOTMEM_DEFAULT); |
228 | else if (memblock.reserved.region[i].base < lowmem_end_addr) { | 228 | else if (memblock.reserved.regions[i].base < lowmem_end_addr) { |
229 | unsigned long adjusted_size = lowmem_end_addr - | 229 | unsigned long adjusted_size = lowmem_end_addr - |
230 | memblock.reserved.region[i].base; | 230 | memblock.reserved.regions[i].base; |
231 | reserve_bootmem(memblock.reserved.region[i].base, | 231 | reserve_bootmem(memblock.reserved.regions[i].base, |
232 | adjusted_size, BOOTMEM_DEFAULT); | 232 | adjusted_size, BOOTMEM_DEFAULT); |
233 | } | 233 | } |
234 | } | 234 | } |
@@ -237,7 +237,7 @@ void __init do_init_bootmem(void) | |||
237 | 237 | ||
238 | /* reserve the sections we're already using */ | 238 | /* reserve the sections we're already using */ |
239 | for (i = 0; i < memblock.reserved.cnt; i++) | 239 | for (i = 0; i < memblock.reserved.cnt; i++) |
240 | reserve_bootmem(memblock.reserved.region[i].base, | 240 | reserve_bootmem(memblock.reserved.regions[i].base, |
241 | memblock_size_bytes(&memblock.reserved, i), | 241 | memblock_size_bytes(&memblock.reserved, i), |
242 | BOOTMEM_DEFAULT); | 242 | BOOTMEM_DEFAULT); |
243 | 243 | ||
@@ -257,10 +257,10 @@ static int __init mark_nonram_nosave(void) | |||
257 | 257 | ||
258 | for (i = 0; i < memblock.memory.cnt - 1; i++) { | 258 | for (i = 0; i < memblock.memory.cnt - 1; i++) { |
259 | memblock_region_max_pfn = | 259 | memblock_region_max_pfn = |
260 | (memblock.memory.region[i].base >> PAGE_SHIFT) + | 260 | (memblock.memory.regions[i].base >> PAGE_SHIFT) + |
261 | (memblock.memory.region[i].size >> PAGE_SHIFT); | 261 | (memblock.memory.regions[i].size >> PAGE_SHIFT); |
262 | memblock_next_region_start_pfn = | 262 | memblock_next_region_start_pfn = |
263 | memblock.memory.region[i+1].base >> PAGE_SHIFT; | 263 | memblock.memory.regions[i+1].base >> PAGE_SHIFT; |
264 | 264 | ||
265 | if (memblock_region_max_pfn < memblock_next_region_start_pfn) | 265 | if (memblock_region_max_pfn < memblock_next_region_start_pfn) |
266 | register_nosave_region(memblock_region_max_pfn, | 266 | register_nosave_region(memblock_region_max_pfn, |
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c index 5cdcc7c8d973..8450c29e9b2f 100644 --- a/arch/powerpc/platforms/embedded6xx/wii.c +++ b/arch/powerpc/platforms/embedded6xx/wii.c | |||
@@ -65,7 +65,7 @@ static int __init page_aligned(unsigned long x) | |||
65 | 65 | ||
66 | void __init wii_memory_fixups(void) | 66 | void __init wii_memory_fixups(void) |
67 | { | 67 | { |
68 | struct memblock_property *p = memblock.memory.region; | 68 | struct memblock_region *p = memblock.memory.region; |
69 | 69 | ||
70 | /* | 70 | /* |
71 | * This is part of a workaround to allow the use of two | 71 | * This is part of a workaround to allow the use of two |
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index f0434513df15..16d8bee889ba 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -978,7 +978,7 @@ static void __init add_node_ranges(void) | |||
978 | unsigned long size = memblock_size_bytes(&memblock.memory, i); | 978 | unsigned long size = memblock_size_bytes(&memblock.memory, i); |
979 | unsigned long start, end; | 979 | unsigned long start, end; |
980 | 980 | ||
981 | start = memblock.memory.region[i].base; | 981 | start = memblock.memory.regions[i].base; |
982 | end = start + size; | 982 | end = start + size; |
983 | while (start < end) { | 983 | while (start < end) { |
984 | unsigned long this_end; | 984 | unsigned long this_end; |
@@ -1299,7 +1299,7 @@ static void __init bootmem_init_nonnuma(void) | |||
1299 | if (!size) | 1299 | if (!size) |
1300 | continue; | 1300 | continue; |
1301 | 1301 | ||
1302 | start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT; | 1302 | start_pfn = memblock.memory.regions[i].base >> PAGE_SHIFT; |
1303 | end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); | 1303 | end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); |
1304 | add_active_range(0, start_pfn, end_pfn); | 1304 | add_active_range(0, start_pfn, end_pfn); |
1305 | } | 1305 | } |
@@ -1339,7 +1339,7 @@ static void __init trim_reserved_in_node(int nid) | |||
1339 | numadbg(" trim_reserved_in_node(%d)\n", nid); | 1339 | numadbg(" trim_reserved_in_node(%d)\n", nid); |
1340 | 1340 | ||
1341 | for (i = 0; i < memblock.reserved.cnt; i++) { | 1341 | for (i = 0; i < memblock.reserved.cnt; i++) { |
1342 | unsigned long start = memblock.reserved.region[i].base; | 1342 | unsigned long start = memblock.reserved.regions[i].base; |
1343 | unsigned long size = memblock_size_bytes(&memblock.reserved, i); | 1343 | unsigned long size = memblock_size_bytes(&memblock.reserved, i); |
1344 | unsigned long end = start + size; | 1344 | unsigned long end = start + size; |
1345 | 1345 | ||
diff --git a/drivers/video/omap2/vram.c b/drivers/video/omap2/vram.c index f6fdc2085f3e..0f2532bf0f04 100644 --- a/drivers/video/omap2/vram.c +++ b/drivers/video/omap2/vram.c | |||
@@ -554,7 +554,7 @@ void __init omap_vram_reserve_sdram_memblock(void) | |||
554 | size = PAGE_ALIGN(size); | 554 | size = PAGE_ALIGN(size); |
555 | 555 | ||
556 | if (paddr) { | 556 | if (paddr) { |
557 | struct memblock_property res; | 557 | struct memblock_region res; |
558 | 558 | ||
559 | res.base = paddr; | 559 | res.base = paddr; |
560 | res.size = size; | 560 | res.size = size; |
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index a59faf2b5edd..86e7daf742f2 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
@@ -18,22 +18,22 @@ | |||
18 | 18 | ||
19 | #define MAX_MEMBLOCK_REGIONS 128 | 19 | #define MAX_MEMBLOCK_REGIONS 128 |
20 | 20 | ||
21 | struct memblock_property { | 21 | struct memblock_region { |
22 | u64 base; | 22 | u64 base; |
23 | u64 size; | 23 | u64 size; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | struct memblock_region { | 26 | struct memblock_type { |
27 | unsigned long cnt; | 27 | unsigned long cnt; |
28 | u64 size; | 28 | u64 size; |
29 | struct memblock_property region[MAX_MEMBLOCK_REGIONS+1]; | 29 | struct memblock_region regions[MAX_MEMBLOCK_REGIONS+1]; |
30 | }; | 30 | }; |
31 | 31 | ||
32 | struct memblock { | 32 | struct memblock { |
33 | unsigned long debug; | 33 | unsigned long debug; |
34 | u64 rmo_size; | 34 | u64 rmo_size; |
35 | struct memblock_region memory; | 35 | struct memblock_type memory; |
36 | struct memblock_region reserved; | 36 | struct memblock_type reserved; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | extern struct memblock memblock; | 39 | extern struct memblock memblock; |
@@ -56,27 +56,27 @@ extern u64 memblock_end_of_DRAM(void); | |||
56 | extern void __init memblock_enforce_memory_limit(u64 memory_limit); | 56 | extern void __init memblock_enforce_memory_limit(u64 memory_limit); |
57 | extern int __init memblock_is_reserved(u64 addr); | 57 | extern int __init memblock_is_reserved(u64 addr); |
58 | extern int memblock_is_region_reserved(u64 base, u64 size); | 58 | extern int memblock_is_region_reserved(u64 base, u64 size); |
59 | extern int memblock_find(struct memblock_property *res); | 59 | extern int memblock_find(struct memblock_region *res); |
60 | 60 | ||
61 | extern void memblock_dump_all(void); | 61 | extern void memblock_dump_all(void); |
62 | 62 | ||
63 | static inline u64 | 63 | static inline u64 |
64 | memblock_size_bytes(struct memblock_region *type, unsigned long region_nr) | 64 | memblock_size_bytes(struct memblock_type *type, unsigned long region_nr) |
65 | { | 65 | { |
66 | return type->region[region_nr].size; | 66 | return type->regions[region_nr].size; |
67 | } | 67 | } |
68 | static inline u64 | 68 | static inline u64 |
69 | memblock_size_pages(struct memblock_region *type, unsigned long region_nr) | 69 | memblock_size_pages(struct memblock_type *type, unsigned long region_nr) |
70 | { | 70 | { |
71 | return memblock_size_bytes(type, region_nr) >> PAGE_SHIFT; | 71 | return memblock_size_bytes(type, region_nr) >> PAGE_SHIFT; |
72 | } | 72 | } |
73 | static inline u64 | 73 | static inline u64 |
74 | memblock_start_pfn(struct memblock_region *type, unsigned long region_nr) | 74 | memblock_start_pfn(struct memblock_type *type, unsigned long region_nr) |
75 | { | 75 | { |
76 | return type->region[region_nr].base >> PAGE_SHIFT; | 76 | return type->regions[region_nr].base >> PAGE_SHIFT; |
77 | } | 77 | } |
78 | static inline u64 | 78 | static inline u64 |
79 | memblock_end_pfn(struct memblock_region *type, unsigned long region_nr) | 79 | memblock_end_pfn(struct memblock_type *type, unsigned long region_nr) |
80 | { | 80 | { |
81 | return memblock_start_pfn(type, region_nr) + | 81 | return memblock_start_pfn(type, region_nr) + |
82 | memblock_size_pages(type, region_nr); | 82 | memblock_size_pages(type, region_nr); |
diff --git a/mm/memblock.c b/mm/memblock.c index 43840b305ecb..6f407ccf604e 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -29,7 +29,7 @@ static int __init early_memblock(char *p) | |||
29 | } | 29 | } |
30 | early_param("memblock", early_memblock); | 30 | early_param("memblock", early_memblock); |
31 | 31 | ||
32 | static void memblock_dump(struct memblock_region *region, char *name) | 32 | static void memblock_dump(struct memblock_type *region, char *name) |
33 | { | 33 | { |
34 | unsigned long long base, size; | 34 | unsigned long long base, size; |
35 | int i; | 35 | int i; |
@@ -37,8 +37,8 @@ static void memblock_dump(struct memblock_region *region, char *name) | |||
37 | pr_info(" %s.cnt = 0x%lx\n", name, region->cnt); | 37 | pr_info(" %s.cnt = 0x%lx\n", name, region->cnt); |
38 | 38 | ||
39 | for (i = 0; i < region->cnt; i++) { | 39 | for (i = 0; i < region->cnt; i++) { |
40 | base = region->region[i].base; | 40 | base = region->regions[i].base; |
41 | size = region->region[i].size; | 41 | size = region->regions[i].size; |
42 | 42 | ||
43 | pr_info(" %s[0x%x]\t0x%016llx - 0x%016llx, 0x%llx bytes\n", | 43 | pr_info(" %s[0x%x]\t0x%016llx - 0x%016llx, 0x%llx bytes\n", |
44 | name, i, base, base + size - 1, size); | 44 | name, i, base, base + size - 1, size); |
@@ -74,34 +74,34 @@ static long memblock_addrs_adjacent(u64 base1, u64 size1, u64 base2, u64 size2) | |||
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | static long memblock_regions_adjacent(struct memblock_region *rgn, | 77 | static long memblock_regions_adjacent(struct memblock_type *type, |
78 | unsigned long r1, unsigned long r2) | 78 | unsigned long r1, unsigned long r2) |
79 | { | 79 | { |
80 | u64 base1 = rgn->region[r1].base; | 80 | u64 base1 = type->regions[r1].base; |
81 | u64 size1 = rgn->region[r1].size; | 81 | u64 size1 = type->regions[r1].size; |
82 | u64 base2 = rgn->region[r2].base; | 82 | u64 base2 = type->regions[r2].base; |
83 | u64 size2 = rgn->region[r2].size; | 83 | u64 size2 = type->regions[r2].size; |
84 | 84 | ||
85 | return memblock_addrs_adjacent(base1, size1, base2, size2); | 85 | return memblock_addrs_adjacent(base1, size1, base2, size2); |
86 | } | 86 | } |
87 | 87 | ||
88 | static void memblock_remove_region(struct memblock_region *rgn, unsigned long r) | 88 | static void memblock_remove_region(struct memblock_type *type, unsigned long r) |
89 | { | 89 | { |
90 | unsigned long i; | 90 | unsigned long i; |
91 | 91 | ||
92 | for (i = r; i < rgn->cnt - 1; i++) { | 92 | for (i = r; i < type->cnt - 1; i++) { |
93 | rgn->region[i].base = rgn->region[i + 1].base; | 93 | type->regions[i].base = type->regions[i + 1].base; |
94 | rgn->region[i].size = rgn->region[i + 1].size; | 94 | type->regions[i].size = type->regions[i + 1].size; |
95 | } | 95 | } |
96 | rgn->cnt--; | 96 | type->cnt--; |
97 | } | 97 | } |
98 | 98 | ||
99 | /* Assumption: base addr of region 1 < base addr of region 2 */ | 99 | /* Assumption: base addr of region 1 < base addr of region 2 */ |
100 | static void memblock_coalesce_regions(struct memblock_region *rgn, | 100 | static void memblock_coalesce_regions(struct memblock_type *type, |
101 | unsigned long r1, unsigned long r2) | 101 | unsigned long r1, unsigned long r2) |
102 | { | 102 | { |
103 | rgn->region[r1].size += rgn->region[r2].size; | 103 | type->regions[r1].size += type->regions[r2].size; |
104 | memblock_remove_region(rgn, r2); | 104 | memblock_remove_region(type, r2); |
105 | } | 105 | } |
106 | 106 | ||
107 | void __init memblock_init(void) | 107 | void __init memblock_init(void) |
@@ -109,13 +109,13 @@ void __init memblock_init(void) | |||
109 | /* Create a dummy zero size MEMBLOCK which will get coalesced away later. | 109 | /* Create a dummy zero size MEMBLOCK which will get coalesced away later. |
110 | * This simplifies the memblock_add() code below... | 110 | * This simplifies the memblock_add() code below... |
111 | */ | 111 | */ |
112 | memblock.memory.region[0].base = 0; | 112 | memblock.memory.regions[0].base = 0; |
113 | memblock.memory.region[0].size = 0; | 113 | memblock.memory.regions[0].size = 0; |
114 | memblock.memory.cnt = 1; | 114 | memblock.memory.cnt = 1; |
115 | 115 | ||
116 | /* Ditto. */ | 116 | /* Ditto. */ |
117 | memblock.reserved.region[0].base = 0; | 117 | memblock.reserved.regions[0].base = 0; |
118 | memblock.reserved.region[0].size = 0; | 118 | memblock.reserved.regions[0].size = 0; |
119 | memblock.reserved.cnt = 1; | 119 | memblock.reserved.cnt = 1; |
120 | } | 120 | } |
121 | 121 | ||
@@ -126,24 +126,24 @@ void __init memblock_analyze(void) | |||
126 | memblock.memory.size = 0; | 126 | memblock.memory.size = 0; |
127 | 127 | ||
128 | for (i = 0; i < memblock.memory.cnt; i++) | 128 | for (i = 0; i < memblock.memory.cnt; i++) |
129 | memblock.memory.size += memblock.memory.region[i].size; | 129 | memblock.memory.size += memblock.memory.regions[i].size; |
130 | } | 130 | } |
131 | 131 | ||
132 | static long memblock_add_region(struct memblock_region *rgn, u64 base, u64 size) | 132 | static long memblock_add_region(struct memblock_type *type, u64 base, u64 size) |
133 | { | 133 | { |
134 | unsigned long coalesced = 0; | 134 | unsigned long coalesced = 0; |
135 | long adjacent, i; | 135 | long adjacent, i; |
136 | 136 | ||
137 | if ((rgn->cnt == 1) && (rgn->region[0].size == 0)) { | 137 | if ((type->cnt == 1) && (type->regions[0].size == 0)) { |
138 | rgn->region[0].base = base; | 138 | type->regions[0].base = base; |
139 | rgn->region[0].size = size; | 139 | type->regions[0].size = size; |
140 | return 0; | 140 | return 0; |
141 | } | 141 | } |
142 | 142 | ||
143 | /* First try and coalesce this MEMBLOCK with another. */ | 143 | /* First try and coalesce this MEMBLOCK with another. */ |
144 | for (i = 0; i < rgn->cnt; i++) { | 144 | for (i = 0; i < type->cnt; i++) { |
145 | u64 rgnbase = rgn->region[i].base; | 145 | u64 rgnbase = type->regions[i].base; |
146 | u64 rgnsize = rgn->region[i].size; | 146 | u64 rgnsize = type->regions[i].size; |
147 | 147 | ||
148 | if ((rgnbase == base) && (rgnsize == size)) | 148 | if ((rgnbase == base) && (rgnsize == size)) |
149 | /* Already have this region, so we're done */ | 149 | /* Already have this region, so we're done */ |
@@ -151,61 +151,59 @@ static long memblock_add_region(struct memblock_region *rgn, u64 base, u64 size) | |||
151 | 151 | ||
152 | adjacent = memblock_addrs_adjacent(base, size, rgnbase, rgnsize); | 152 | adjacent = memblock_addrs_adjacent(base, size, rgnbase, rgnsize); |
153 | if (adjacent > 0) { | 153 | if (adjacent > 0) { |
154 | rgn->region[i].base -= size; | 154 | type->regions[i].base -= size; |
155 | rgn->region[i].size += size; | 155 | type->regions[i].size += size; |
156 | coalesced++; | 156 | coalesced++; |
157 | break; | 157 | break; |
158 | } else if (adjacent < 0) { | 158 | } else if (adjacent < 0) { |
159 | rgn->region[i].size += size; | 159 | type->regions[i].size += size; |
160 | coalesced++; | 160 | coalesced++; |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | if ((i < rgn->cnt - 1) && memblock_regions_adjacent(rgn, i, i+1)) { | 165 | if ((i < type->cnt - 1) && memblock_regions_adjacent(type, i, i+1)) { |
166 | memblock_coalesce_regions(rgn, i, i+1); | 166 | memblock_coalesce_regions(type, i, i+1); |
167 | coalesced++; | 167 | coalesced++; |
168 | } | 168 | } |
169 | 169 | ||
170 | if (coalesced) | 170 | if (coalesced) |
171 | return coalesced; | 171 | return coalesced; |
172 | if (rgn->cnt >= MAX_MEMBLOCK_REGIONS) | 172 | if (type->cnt >= MAX_MEMBLOCK_REGIONS) |
173 | return -1; | 173 | return -1; |
174 | 174 | ||
175 | /* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */ | 175 | /* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */ |
176 | for (i = rgn->cnt - 1; i >= 0; i--) { | 176 | for (i = type->cnt - 1; i >= 0; i--) { |
177 | if (base < rgn->region[i].base) { | 177 | if (base < type->regions[i].base) { |
178 | rgn->region[i+1].base = rgn->region[i].base; | 178 | type->regions[i+1].base = type->regions[i].base; |
179 | rgn->region[i+1].size = rgn->region[i].size; | 179 | type->regions[i+1].size = type->regions[i].size; |
180 | } else { | 180 | } else { |
181 | rgn->region[i+1].base = base; | 181 | type->regions[i+1].base = base; |
182 | rgn->region[i+1].size = size; | 182 | type->regions[i+1].size = size; |
183 | break; | 183 | break; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | if (base < rgn->region[0].base) { | 187 | if (base < type->regions[0].base) { |
188 | rgn->region[0].base = base; | 188 | type->regions[0].base = base; |
189 | rgn->region[0].size = size; | 189 | type->regions[0].size = size; |
190 | } | 190 | } |
191 | rgn->cnt++; | 191 | type->cnt++; |
192 | 192 | ||
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
196 | long memblock_add(u64 base, u64 size) | 196 | long memblock_add(u64 base, u64 size) |
197 | { | 197 | { |
198 | struct memblock_region *_rgn = &memblock.memory; | ||
199 | |||
200 | /* On pSeries LPAR systems, the first MEMBLOCK is our RMO region. */ | 198 | /* On pSeries LPAR systems, the first MEMBLOCK is our RMO region. */ |
201 | if (base == 0) | 199 | if (base == 0) |
202 | memblock.rmo_size = size; | 200 | memblock.rmo_size = size; |
203 | 201 | ||
204 | return memblock_add_region(_rgn, base, size); | 202 | return memblock_add_region(&memblock.memory, base, size); |
205 | 203 | ||
206 | } | 204 | } |
207 | 205 | ||
208 | static long __memblock_remove(struct memblock_region *rgn, u64 base, u64 size) | 206 | static long __memblock_remove(struct memblock_type *type, u64 base, u64 size) |
209 | { | 207 | { |
210 | u64 rgnbegin, rgnend; | 208 | u64 rgnbegin, rgnend; |
211 | u64 end = base + size; | 209 | u64 end = base + size; |
@@ -214,34 +212,34 @@ static long __memblock_remove(struct memblock_region *rgn, u64 base, u64 size) | |||
214 | rgnbegin = rgnend = 0; /* supress gcc warnings */ | 212 | rgnbegin = rgnend = 0; /* supress gcc warnings */ |
215 | 213 | ||
216 | /* Find the region where (base, size) belongs to */ | 214 | /* Find the region where (base, size) belongs to */ |
217 | for (i=0; i < rgn->cnt; i++) { | 215 | for (i=0; i < type->cnt; i++) { |
218 | rgnbegin = rgn->region[i].base; | 216 | rgnbegin = type->regions[i].base; |
219 | rgnend = rgnbegin + rgn->region[i].size; | 217 | rgnend = rgnbegin + type->regions[i].size; |
220 | 218 | ||
221 | if ((rgnbegin <= base) && (end <= rgnend)) | 219 | if ((rgnbegin <= base) && (end <= rgnend)) |
222 | break; | 220 | break; |
223 | } | 221 | } |
224 | 222 | ||
225 | /* Didn't find the region */ | 223 | /* Didn't find the region */ |
226 | if (i == rgn->cnt) | 224 | if (i == type->cnt) |
227 | return -1; | 225 | return -1; |
228 | 226 | ||
229 | /* Check to see if we are removing entire region */ | 227 | /* Check to see if we are removing entire region */ |
230 | if ((rgnbegin == base) && (rgnend == end)) { | 228 | if ((rgnbegin == base) && (rgnend == end)) { |
231 | memblock_remove_region(rgn, i); | 229 | memblock_remove_region(type, i); |
232 | return 0; | 230 | return 0; |
233 | } | 231 | } |
234 | 232 | ||
235 | /* Check to see if region is matching at the front */ | 233 | /* Check to see if region is matching at the front */ |
236 | if (rgnbegin == base) { | 234 | if (rgnbegin == base) { |
237 | rgn->region[i].base = end; | 235 | type->regions[i].base = end; |
238 | rgn->region[i].size -= size; | 236 | type->regions[i].size -= size; |
239 | return 0; | 237 | return 0; |
240 | } | 238 | } |
241 | 239 | ||
242 | /* Check to see if the region is matching at the end */ | 240 | /* Check to see if the region is matching at the end */ |
243 | if (rgnend == end) { | 241 | if (rgnend == end) { |
244 | rgn->region[i].size -= size; | 242 | type->regions[i].size -= size; |
245 | return 0; | 243 | return 0; |
246 | } | 244 | } |
247 | 245 | ||
@@ -249,8 +247,8 @@ static long __memblock_remove(struct memblock_region *rgn, u64 base, u64 size) | |||
249 | * We need to split the entry - adjust the current one to the | 247 | * We need to split the entry - adjust the current one to the |
250 | * beginging of the hole and add the region after hole. | 248 | * beginging of the hole and add the region after hole. |
251 | */ | 249 | */ |
252 | rgn->region[i].size = base - rgn->region[i].base; | 250 | type->regions[i].size = base - type->regions[i].base; |
253 | return memblock_add_region(rgn, end, rgnend - end); | 251 | return memblock_add_region(type, end, rgnend - end); |
254 | } | 252 | } |
255 | 253 | ||
256 | long memblock_remove(u64 base, u64 size) | 254 | long memblock_remove(u64 base, u64 size) |
@@ -265,25 +263,25 @@ long __init memblock_free(u64 base, u64 size) | |||
265 | 263 | ||
266 | long __init memblock_reserve(u64 base, u64 size) | 264 | long __init memblock_reserve(u64 base, u64 size) |
267 | { | 265 | { |
268 | struct memblock_region *_rgn = &memblock.reserved; | 266 | struct memblock_type *_rgn = &memblock.reserved; |
269 | 267 | ||
270 | BUG_ON(0 == size); | 268 | BUG_ON(0 == size); |
271 | 269 | ||
272 | return memblock_add_region(_rgn, base, size); | 270 | return memblock_add_region(_rgn, base, size); |
273 | } | 271 | } |
274 | 272 | ||
275 | long memblock_overlaps_region(struct memblock_region *rgn, u64 base, u64 size) | 273 | long memblock_overlaps_region(struct memblock_type *type, u64 base, u64 size) |
276 | { | 274 | { |
277 | unsigned long i; | 275 | unsigned long i; |
278 | 276 | ||
279 | for (i = 0; i < rgn->cnt; i++) { | 277 | for (i = 0; i < type->cnt; i++) { |
280 | u64 rgnbase = rgn->region[i].base; | 278 | u64 rgnbase = type->regions[i].base; |
281 | u64 rgnsize = rgn->region[i].size; | 279 | u64 rgnsize = type->regions[i].size; |
282 | if (memblock_addrs_overlap(base, size, rgnbase, rgnsize)) | 280 | if (memblock_addrs_overlap(base, size, rgnbase, rgnsize)) |
283 | break; | 281 | break; |
284 | } | 282 | } |
285 | 283 | ||
286 | return (i < rgn->cnt) ? i : -1; | 284 | return (i < type->cnt) ? i : -1; |
287 | } | 285 | } |
288 | 286 | ||
289 | static u64 memblock_align_down(u64 addr, u64 size) | 287 | static u64 memblock_align_down(u64 addr, u64 size) |
@@ -311,7 +309,7 @@ static u64 __init memblock_alloc_nid_unreserved(u64 start, u64 end, | |||
311 | base = ~(u64)0; | 309 | base = ~(u64)0; |
312 | return base; | 310 | return base; |
313 | } | 311 | } |
314 | res_base = memblock.reserved.region[j].base; | 312 | res_base = memblock.reserved.regions[j].base; |
315 | if (res_base < size) | 313 | if (res_base < size) |
316 | break; | 314 | break; |
317 | base = memblock_align_down(res_base - size, align); | 315 | base = memblock_align_down(res_base - size, align); |
@@ -320,7 +318,7 @@ static u64 __init memblock_alloc_nid_unreserved(u64 start, u64 end, | |||
320 | return ~(u64)0; | 318 | return ~(u64)0; |
321 | } | 319 | } |
322 | 320 | ||
323 | static u64 __init memblock_alloc_nid_region(struct memblock_property *mp, | 321 | static u64 __init memblock_alloc_nid_region(struct memblock_region *mp, |
324 | u64 (*nid_range)(u64, u64, int *), | 322 | u64 (*nid_range)(u64, u64, int *), |
325 | u64 size, u64 align, int nid) | 323 | u64 size, u64 align, int nid) |
326 | { | 324 | { |
@@ -350,7 +348,7 @@ static u64 __init memblock_alloc_nid_region(struct memblock_property *mp, | |||
350 | u64 __init memblock_alloc_nid(u64 size, u64 align, int nid, | 348 | u64 __init memblock_alloc_nid(u64 size, u64 align, int nid, |
351 | u64 (*nid_range)(u64 start, u64 end, int *nid)) | 349 | u64 (*nid_range)(u64 start, u64 end, int *nid)) |
352 | { | 350 | { |
353 | struct memblock_region *mem = &memblock.memory; | 351 | struct memblock_type *mem = &memblock.memory; |
354 | int i; | 352 | int i; |
355 | 353 | ||
356 | BUG_ON(0 == size); | 354 | BUG_ON(0 == size); |
@@ -358,7 +356,7 @@ u64 __init memblock_alloc_nid(u64 size, u64 align, int nid, | |||
358 | size = memblock_align_up(size, align); | 356 | size = memblock_align_up(size, align); |
359 | 357 | ||
360 | for (i = 0; i < mem->cnt; i++) { | 358 | for (i = 0; i < mem->cnt; i++) { |
361 | u64 ret = memblock_alloc_nid_region(&mem->region[i], | 359 | u64 ret = memblock_alloc_nid_region(&mem->regions[i], |
362 | nid_range, | 360 | nid_range, |
363 | size, align, nid); | 361 | size, align, nid); |
364 | if (ret != ~(u64)0) | 362 | if (ret != ~(u64)0) |
@@ -402,8 +400,8 @@ u64 __init __memblock_alloc_base(u64 size, u64 align, u64 max_addr) | |||
402 | max_addr = MEMBLOCK_REAL_LIMIT; | 400 | max_addr = MEMBLOCK_REAL_LIMIT; |
403 | 401 | ||
404 | for (i = memblock.memory.cnt - 1; i >= 0; i--) { | 402 | for (i = memblock.memory.cnt - 1; i >= 0; i--) { |
405 | u64 memblockbase = memblock.memory.region[i].base; | 403 | u64 memblockbase = memblock.memory.regions[i].base; |
406 | u64 memblocksize = memblock.memory.region[i].size; | 404 | u64 memblocksize = memblock.memory.regions[i].size; |
407 | 405 | ||
408 | if (memblocksize < size) | 406 | if (memblocksize < size) |
409 | continue; | 407 | continue; |
@@ -423,7 +421,7 @@ u64 __init __memblock_alloc_base(u64 size, u64 align, u64 max_addr) | |||
423 | return 0; | 421 | return 0; |
424 | return base; | 422 | return base; |
425 | } | 423 | } |
426 | res_base = memblock.reserved.region[j].base; | 424 | res_base = memblock.reserved.regions[j].base; |
427 | if (res_base < size) | 425 | if (res_base < size) |
428 | break; | 426 | break; |
429 | base = memblock_align_down(res_base - size, align); | 427 | base = memblock_align_down(res_base - size, align); |
@@ -442,7 +440,7 @@ u64 memblock_end_of_DRAM(void) | |||
442 | { | 440 | { |
443 | int idx = memblock.memory.cnt - 1; | 441 | int idx = memblock.memory.cnt - 1; |
444 | 442 | ||
445 | return (memblock.memory.region[idx].base + memblock.memory.region[idx].size); | 443 | return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size); |
446 | } | 444 | } |
447 | 445 | ||
448 | /* You must call memblock_analyze() after this. */ | 446 | /* You must call memblock_analyze() after this. */ |
@@ -450,7 +448,7 @@ void __init memblock_enforce_memory_limit(u64 memory_limit) | |||
450 | { | 448 | { |
451 | unsigned long i; | 449 | unsigned long i; |
452 | u64 limit; | 450 | u64 limit; |
453 | struct memblock_property *p; | 451 | struct memblock_region *p; |
454 | 452 | ||
455 | if (!memory_limit) | 453 | if (!memory_limit) |
456 | return; | 454 | return; |
@@ -458,24 +456,24 @@ void __init memblock_enforce_memory_limit(u64 memory_limit) | |||
458 | /* Truncate the memblock regions to satisfy the memory limit. */ | 456 | /* Truncate the memblock regions to satisfy the memory limit. */ |
459 | limit = memory_limit; | 457 | limit = memory_limit; |
460 | for (i = 0; i < memblock.memory.cnt; i++) { | 458 | for (i = 0; i < memblock.memory.cnt; i++) { |
461 | if (limit > memblock.memory.region[i].size) { | 459 | if (limit > memblock.memory.regions[i].size) { |
462 | limit -= memblock.memory.region[i].size; | 460 | limit -= memblock.memory.regions[i].size; |
463 | continue; | 461 | continue; |
464 | } | 462 | } |
465 | 463 | ||
466 | memblock.memory.region[i].size = limit; | 464 | memblock.memory.regions[i].size = limit; |
467 | memblock.memory.cnt = i + 1; | 465 | memblock.memory.cnt = i + 1; |
468 | break; | 466 | break; |
469 | } | 467 | } |
470 | 468 | ||
471 | if (memblock.memory.region[0].size < memblock.rmo_size) | 469 | if (memblock.memory.regions[0].size < memblock.rmo_size) |
472 | memblock.rmo_size = memblock.memory.region[0].size; | 470 | memblock.rmo_size = memblock.memory.regions[0].size; |
473 | 471 | ||
474 | memory_limit = memblock_end_of_DRAM(); | 472 | memory_limit = memblock_end_of_DRAM(); |
475 | 473 | ||
476 | /* And truncate any reserves above the limit also. */ | 474 | /* And truncate any reserves above the limit also. */ |
477 | for (i = 0; i < memblock.reserved.cnt; i++) { | 475 | for (i = 0; i < memblock.reserved.cnt; i++) { |
478 | p = &memblock.reserved.region[i]; | 476 | p = &memblock.reserved.regions[i]; |
479 | 477 | ||
480 | if (p->base > memory_limit) | 478 | if (p->base > memory_limit) |
481 | p->size = 0; | 479 | p->size = 0; |
@@ -494,9 +492,9 @@ int __init memblock_is_reserved(u64 addr) | |||
494 | int i; | 492 | int i; |
495 | 493 | ||
496 | for (i = 0; i < memblock.reserved.cnt; i++) { | 494 | for (i = 0; i < memblock.reserved.cnt; i++) { |
497 | u64 upper = memblock.reserved.region[i].base + | 495 | u64 upper = memblock.reserved.regions[i].base + |
498 | memblock.reserved.region[i].size - 1; | 496 | memblock.reserved.regions[i].size - 1; |
499 | if ((addr >= memblock.reserved.region[i].base) && (addr <= upper)) | 497 | if ((addr >= memblock.reserved.regions[i].base) && (addr <= upper)) |
500 | return 1; | 498 | return 1; |
501 | } | 499 | } |
502 | return 0; | 500 | return 0; |
@@ -511,7 +509,7 @@ int memblock_is_region_reserved(u64 base, u64 size) | |||
511 | * Given a <base, len>, find which memory regions belong to this range. | 509 | * Given a <base, len>, find which memory regions belong to this range. |
512 | * Adjust the request and return a contiguous chunk. | 510 | * Adjust the request and return a contiguous chunk. |
513 | */ | 511 | */ |
514 | int memblock_find(struct memblock_property *res) | 512 | int memblock_find(struct memblock_region *res) |
515 | { | 513 | { |
516 | int i; | 514 | int i; |
517 | u64 rstart, rend; | 515 | u64 rstart, rend; |
@@ -520,8 +518,8 @@ int memblock_find(struct memblock_property *res) | |||
520 | rend = rstart + res->size - 1; | 518 | rend = rstart + res->size - 1; |
521 | 519 | ||
522 | for (i = 0; i < memblock.memory.cnt; i++) { | 520 | for (i = 0; i < memblock.memory.cnt; i++) { |
523 | u64 start = memblock.memory.region[i].base; | 521 | u64 start = memblock.memory.regions[i].base; |
524 | u64 end = start + memblock.memory.region[i].size - 1; | 522 | u64 end = start + memblock.memory.regions[i].size - 1; |
525 | 523 | ||
526 | if (start > rend) | 524 | if (start > rend) |
527 | return -1; | 525 | return -1; |