Skip to content

Commit 1c2f87c

Browse files
labbottRussell King
authored andcommitted
ARM: 8025/1: Get rid of meminfo
memblock is now fully integrated into the kernel and is the prefered method for tracking memory. Rather than reinvent the wheel with meminfo, migrate to using memblock directly instead of meminfo as an intermediate. Acked-by: Jason Cooper <[email protected]> Acked-by: Catalin Marinas <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Acked-by: Kukjin Kim <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Tested-by: Leif Lindholm <[email protected]> Signed-off-by: Laura Abbott <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 1c8c3cf commit 1c2f87c

36 files changed

+179
-333
lines changed

arch/arm/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,6 @@ source "arch/arm/firmware/Kconfig"
11011101

11021102
source arch/arm/mm/Kconfig
11031103

1104-
config ARM_NR_BANKS
1105-
int
1106-
default 16 if ARCH_EP93XX
1107-
default 8
1108-
11091104
config IWMMXT
11101105
bool "Enable iWMMXt support" if !CPU_PJ4
11111106
depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4

arch/arm/boot/compressed/atags_to_fdt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#define do_extend_cmdline 0
88
#endif
99

10+
#define NR_BANKS 16
11+
1012
static int node_offset(void *fdt, const char *node_path)
1113
{
1214
int offset = fdt_path_offset(fdt, node_path);

arch/arm/include/asm/mach/arch.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/reboot.h>
1515

1616
struct tag;
17-
struct meminfo;
1817
struct pt_regs;
1918
struct smp_operations;
2019
#ifdef CONFIG_SMP
@@ -47,8 +46,7 @@ struct machine_desc {
4746
enum reboot_mode reboot_mode; /* default restart mode */
4847
struct smp_operations *smp; /* SMP operations */
4948
bool (*smp_init)(void);
50-
void (*fixup)(struct tag *, char **,
51-
struct meminfo *);
49+
void (*fixup)(struct tag *, char **);
5250
void (*init_meminfo)(void);
5351
void (*reserve)(void);/* reserve mem blocks */
5452
void (*map_io)(void);/* IO mapping function */

arch/arm/include/asm/memblock.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#ifndef _ASM_ARM_MEMBLOCK_H
22
#define _ASM_ARM_MEMBLOCK_H
33

4-
struct meminfo;
54
struct machine_desc;
65

7-
void arm_memblock_init(struct meminfo *, const struct machine_desc *);
6+
void arm_memblock_init(const struct machine_desc *);
87
phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align);
98

109
#endif

arch/arm/include/asm/setup.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,6 @@
2121
#define __tagtable(tag, fn) \
2222
static const struct tagtable __tagtable_##fn __tag = { tag, fn }
2323

24-
/*
25-
* Memory map description
26-
*/
27-
#define NR_BANKS CONFIG_ARM_NR_BANKS
28-
29-
struct membank {
30-
phys_addr_t start;
31-
phys_addr_t size;
32-
unsigned int highmem;
33-
};
34-
35-
struct meminfo {
36-
int nr_banks;
37-
struct membank bank[NR_BANKS];
38-
};
39-
40-
extern struct meminfo meminfo;
41-
42-
#define for_each_bank(iter,mi) \
43-
for (iter = 0; iter < (mi)->nr_banks; iter++)
44-
45-
#define bank_pfn_start(bank) __phys_to_pfn((bank)->start)
46-
#define bank_pfn_end(bank) __phys_to_pfn((bank)->start + (bank)->size)
47-
#define bank_pfn_size(bank) ((bank)->size >> PAGE_SHIFT)
48-
#define bank_phys_start(bank) (bank)->start
49-
#define bank_phys_end(bank) ((bank)->start + (bank)->size)
50-
#define bank_phys_size(bank) (bank)->size
51-
5224
extern int arm_add_memory(u64 start, u64 size);
5325
extern void early_print(const char *str, ...);
5426
extern void dump_machine_table(void);

arch/arm/kernel/atags_parse.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/fs.h>
2323
#include <linux/root_dev.h>
2424
#include <linux/screen_info.h>
25+
#include <linux/memblock.h>
2526

2627
#include <asm/setup.h>
2728
#include <asm/system_info.h>
@@ -222,10 +223,10 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
222223
}
223224

224225
if (mdesc->fixup)
225-
mdesc->fixup(tags, &from, &meminfo);
226+
mdesc->fixup(tags, &from);
226227

227228
if (tags->hdr.tag == ATAG_CORE) {
228-
if (meminfo.nr_banks != 0)
229+
if (memblock_phys_mem_size())
229230
squash_mem_tags(tags);
230231
save_atags(tags);
231232
parse_tags(tags);

arch/arm/kernel/devtree.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
#include <asm/mach/arch.h>
2828
#include <asm/mach-types.h>
2929

30-
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
31-
{
32-
arm_add_memory(base, size);
33-
}
34-
3530
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
3631
{
3732
return memblock_virt_alloc(size, align);

arch/arm/kernel/setup.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,8 @@ void __init dump_machine_table(void)
628628

629629
int __init arm_add_memory(u64 start, u64 size)
630630
{
631-
struct membank *bank = &meminfo.bank[meminfo.nr_banks];
632631
u64 aligned_start;
633632

634-
if (meminfo.nr_banks >= NR_BANKS) {
635-
pr_crit("NR_BANKS too low, ignoring memory at 0x%08llx\n",
636-
(long long)start);
637-
return -EINVAL;
638-
}
639-
640633
/*
641634
* Ensure that start/size are aligned to a page boundary.
642635
* Size is appropriately rounded down, start is rounded up.
@@ -677,24 +670,25 @@ int __init arm_add_memory(u64 start, u64 size)
677670
aligned_start = PHYS_OFFSET;
678671
}
679672

680-
bank->start = aligned_start;
681-
bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
673+
start = aligned_start;
674+
size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
682675

683676
/*
684677
* Check whether this memory region has non-zero size or
685678
* invalid node number.
686679
*/
687-
if (bank->size == 0)
680+
if (size == 0)
688681
return -EINVAL;
689682

690-
meminfo.nr_banks++;
683+
memblock_add(start, size);
691684
return 0;
692685
}
693686

694687
/*
695688
* Pick out the memory size. We look for mem=size@start,
696689
* where start and size are "size[KkMm]"
697690
*/
691+
698692
static int __init early_mem(char *p)
699693
{
700694
static int usermem __initdata = 0;
@@ -709,7 +703,8 @@ static int __init early_mem(char *p)
709703
*/
710704
if (usermem == 0) {
711705
usermem = 1;
712-
meminfo.nr_banks = 0;
706+
memblock_remove(memblock_start_of_DRAM(),
707+
memblock_end_of_DRAM() - memblock_start_of_DRAM());
713708
}
714709

715710
start = PHYS_OFFSET;
@@ -854,13 +849,6 @@ static void __init reserve_crashkernel(void)
854849
static inline void reserve_crashkernel(void) {}
855850
#endif /* CONFIG_KEXEC */
856851

857-
static int __init meminfo_cmp(const void *_a, const void *_b)
858-
{
859-
const struct membank *a = _a, *b = _b;
860-
long cmp = bank_pfn_start(a) - bank_pfn_start(b);
861-
return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
862-
}
863-
864852
void __init hyp_mode_check(void)
865853
{
866854
#ifdef CONFIG_ARM_VIRT_EXT
@@ -903,12 +891,10 @@ void __init setup_arch(char **cmdline_p)
903891

904892
parse_early_param();
905893

906-
sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
907-
908894
early_paging_init(mdesc, lookup_processor_type(read_cpuid_id()));
909895
setup_dma_zone(mdesc);
910896
sanity_check_meminfo();
911-
arm_memblock_init(&meminfo, mdesc);
897+
arm_memblock_init(mdesc);
912898

913899
paging_init(mdesc);
914900
request_standard_resources(mdesc);

arch/arm/mach-clps711x/board-clep7312.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/init.h>
1919
#include <linux/types.h>
2020
#include <linux/string.h>
21+
#include <linux/memblock.h>
2122

2223
#include <asm/setup.h>
2324
#include <asm/mach-types.h>
@@ -26,11 +27,9 @@
2627
#include "common.h"
2728

2829
static void __init
29-
fixup_clep7312(struct tag *tags, char **cmdline, struct meminfo *mi)
30+
fixup_clep7312(struct tag *tags, char **cmdline)
3031
{
31-
mi->nr_banks=1;
32-
mi->bank[0].start = 0xc0000000;
33-
mi->bank[0].size = 0x01000000;
32+
memblock_add(0xc0000000, 0x01000000);
3433
}
3534

3635
MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312")

arch/arm/mach-clps711x/board-edb7211.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/interrupt.h>
1717
#include <linux/backlight.h>
1818
#include <linux/platform_device.h>
19+
#include <linux/memblock.h>
1920

2021
#include <linux/mtd/physmap.h>
2122
#include <linux/mtd/partitions.h>
@@ -133,7 +134,7 @@ static void __init edb7211_reserve(void)
133134
}
134135

135136
static void __init
136-
fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi)
137+
fixup_edb7211(struct tag *tags, char **cmdline)
137138
{
138139
/*
139140
* Bank start addresses are not present in the information
@@ -143,11 +144,8 @@ fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi)
143144
* Banks sizes _are_ present in the param block, but we're
144145
* not using that information yet.
145146
*/
146-
mi->bank[0].start = 0xc0000000;
147-
mi->bank[0].size = SZ_8M;
148-
mi->bank[1].start = 0xc1000000;
149-
mi->bank[1].size = SZ_8M;
150-
mi->nr_banks = 2;
147+
memblock_add(0xc0000000, SZ_8M);
148+
memblock_add(0xc1000000, SZ_8M);
151149
}
152150

153151
static void __init edb7211_init(void)

arch/arm/mach-clps711x/board-p720t.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static struct generic_bl_info p720t_lcd_backlight_pdata = {
295295
};
296296

297297
static void __init
298-
fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi)
298+
fixup_p720t(struct tag *tag, char **cmdline)
299299
{
300300
/*
301301
* Our bootloader doesn't setup any tags (yet).

arch/arm/mach-footbridge/cats-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ __initcall(cats_hw_init);
7676
* hard reboots fail on early boards.
7777
*/
7878
static void __init
79-
fixup_cats(struct tag *tags, char **cmdline, struct meminfo *mi)
79+
fixup_cats(struct tag *tags, char **cmdline)
8080
{
8181
#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
8282
screen_info.orig_video_lines = 25;

arch/arm/mach-footbridge/netwinder-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ __initcall(nw_hw_init);
620620
* the parameter page.
621621
*/
622622
static void __init
623-
fixup_netwinder(struct tag *tags, char **cmdline, struct meminfo *mi)
623+
fixup_netwinder(struct tag *tags, char **cmdline)
624624
{
625625
#ifdef CONFIG_ISAPNP
626626
extern int isapnp_disable;

arch/arm/mach-msm/board-halibut.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ static void __init halibut_init(void)
8383
platform_add_devices(devices, ARRAY_SIZE(devices));
8484
}
8585

86-
static void __init halibut_fixup(struct tag *tags, char **cmdline,
87-
struct meminfo *mi)
88-
{
89-
}
90-
9186
static void __init halibut_map_io(void)
9287
{
9388
msm_map_common_io();
@@ -100,7 +95,6 @@ static void __init halibut_init_late(void)
10095

10196
MACHINE_START(HALIBUT, "Halibut Board (QCT SURF7200A)")
10297
.atag_offset = 0x100,
103-
.fixup = halibut_fixup,
10498
.map_io = halibut_map_io,
10599
.init_early = halibut_init_early,
106100
.init_irq = halibut_init_irq,

arch/arm/mach-msm/board-mahimahi.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/io.h>
2323
#include <linux/kernel.h>
2424
#include <linux/platform_device.h>
25+
#include <linux/memblock.h>
2526

2627
#include <asm/mach-types.h>
2728
#include <asm/mach/arch.h>
@@ -52,16 +53,10 @@ static void __init mahimahi_init(void)
5253
platform_add_devices(devices, ARRAY_SIZE(devices));
5354
}
5455

55-
static void __init mahimahi_fixup(struct tag *tags, char **cmdline,
56-
struct meminfo *mi)
56+
static void __init mahimahi_fixup(struct tag *tags, char **cmdline)
5757
{
58-
mi->nr_banks = 2;
59-
mi->bank[0].start = PHYS_OFFSET;
60-
mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET);
61-
mi->bank[0].size = (219*1024*1024);
62-
mi->bank[1].start = MSM_HIGHMEM_BASE;
63-
mi->bank[1].node = PHYS_TO_NID(MSM_HIGHMEM_BASE);
64-
mi->bank[1].size = MSM_HIGHMEM_SIZE;
58+
memblock_add(PHYS_OFFSET, 219*SZ_1M);
59+
memblock_add(MSM_HIGHMEM_BASE, MSM_HIGHMEM_SIZE);
6560
}
6661

6762
static void __init mahimahi_map_io(void)

arch/arm/mach-msm/board-msm7x30.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
#include "proc_comm.h"
4141
#include "common.h"
4242

43-
static void __init msm7x30_fixup(struct tag *tag, char **cmdline,
44-
struct meminfo *mi)
43+
static void __init msm7x30_fixup(struct tag *tag, char **cmdline)
4544
{
4645
for (; tag->hdr.size; tag = tag_next(tag))
4746
if (tag->hdr.tag == ATAG_MEM && tag->u.mem.start == 0x200000) {

arch/arm/mach-msm/board-sapphire.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <linux/mtd/nand.h>
3737
#include <linux/mtd/partitions.h>
38+
#include <linux/memblock.h>
3839

3940
#include "gpio_chip.h"
4041
#include "board-sapphire.h"
@@ -74,22 +75,18 @@ static struct map_desc sapphire_io_desc[] __initdata = {
7475
}
7576
};
7677

77-
static void __init sapphire_fixup(struct tag *tags, char **cmdline,
78-
struct meminfo *mi)
78+
static void __init sapphire_fixup(struct tag *tags, char **cmdline)
7979
{
8080
int smi_sz = parse_tag_smi((const struct tag *)tags);
8181

82-
mi->nr_banks = 1;
83-
mi->bank[0].start = PHYS_OFFSET;
84-
mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET);
8582
if (smi_sz == 32) {
86-
mi->bank[0].size = (84*1024*1024);
83+
memblock_add(PHYS_OFFSET, 84*SZ_1M);
8784
} else if (smi_sz == 64) {
88-
mi->bank[0].size = (101*1024*1024);
85+
memblock_add(PHYS_OFFSET, 101*SZ_1M);
8986
} else {
87+
memblock_add(PHYS_OFFSET, 101*SZ_1M);
9088
/* Give a default value when not get smi size */
9189
smi_sz = 64;
92-
mi->bank[0].size = (101*1024*1024);
9390
}
9491
}
9592

arch/arm/mach-msm/board-trout.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/init.h>
2020
#include <linux/platform_device.h>
2121
#include <linux/clkdev.h>
22+
#include <linux/memblock.h>
2223

2324
#include <asm/system_info.h>
2425
#include <asm/mach-types.h>
@@ -55,12 +56,9 @@ static void __init trout_init_irq(void)
5556
msm_init_irq();
5657
}
5758

58-
static void __init trout_fixup(struct tag *tags, char **cmdline,
59-
struct meminfo *mi)
59+
static void __init trout_fixup(struct tag *tags, char **cmdline)
6060
{
61-
mi->nr_banks = 1;
62-
mi->bank[0].start = PHYS_OFFSET;
63-
mi->bank[0].size = (101*1024*1024);
61+
memblock_add(PHYS_OFFSET, 101*SZ_1M);
6462
}
6563

6664
static void __init trout_init(void)

0 commit comments

Comments
 (0)