diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-06-13 20:57:51 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-07-11 21:16:45 -0400 |
commit | 770e1ac5f29003fca18af4e67eb5a05ddb5b1491 (patch) | |
tree | 71a5f1e9efb001a4f46bc077c024dedd1f94a835 /arch/powerpc/platforms | |
parent | a63fdc5156f2ef5690b6cf03d72b0c4917efbba7 (diff) |
powerpc/mm: Fix memory_block_size_bytes() for non-pseries
Just compiling pseries in the kernel causes it to override
memory_block_size_bytes() regardless of what is the runtime
platform.
This cleans up the implementation of that function, fixing
a bug or two while at it, so that it's harmless (and potentially
useful) for other platforms. Without this, bugs in that code
would trigger a WARN_ON() in drivers/base/memory.c when
booting some different platforms.
If/when we have another platform supporting memory hotplug we
might want to either move that out to a generic place or
make it a ppc_md. callback.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/pseries/hotplug-memory.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 33867ec4a234..9d6a8effeda2 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c | |||
@@ -12,6 +12,8 @@ | |||
12 | #include <linux/of.h> | 12 | #include <linux/of.h> |
13 | #include <linux/memblock.h> | 13 | #include <linux/memblock.h> |
14 | #include <linux/vmalloc.h> | 14 | #include <linux/vmalloc.h> |
15 | #include <linux/memory.h> | ||
16 | |||
15 | #include <asm/firmware.h> | 17 | #include <asm/firmware.h> |
16 | #include <asm/machdep.h> | 18 | #include <asm/machdep.h> |
17 | #include <asm/pSeries_reconfig.h> | 19 | #include <asm/pSeries_reconfig.h> |
@@ -20,24 +22,25 @@ | |||
20 | static unsigned long get_memblock_size(void) | 22 | static unsigned long get_memblock_size(void) |
21 | { | 23 | { |
22 | struct device_node *np; | 24 | struct device_node *np; |
23 | unsigned int memblock_size = 0; | 25 | unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE; |
26 | struct resource r; | ||
24 | 27 | ||
25 | np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); | 28 | np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); |
26 | if (np) { | 29 | if (np) { |
27 | const unsigned long *size; | 30 | const __be64 *size; |
28 | 31 | ||
29 | size = of_get_property(np, "ibm,lmb-size", NULL); | 32 | size = of_get_property(np, "ibm,lmb-size", NULL); |
30 | memblock_size = size ? *size : 0; | 33 | if (size) |
31 | 34 | memblock_size = be64_to_cpup(size); | |
32 | of_node_put(np); | 35 | of_node_put(np); |
33 | } else { | 36 | } else if (machine_is(pseries)) { |
37 | /* This fallback really only applies to pseries */ | ||
34 | unsigned int memzero_size = 0; | 38 | unsigned int memzero_size = 0; |
35 | const unsigned int *regs; | ||
36 | 39 | ||
37 | np = of_find_node_by_path("/memory@0"); | 40 | np = of_find_node_by_path("/memory@0"); |
38 | if (np) { | 41 | if (np) { |
39 | regs = of_get_property(np, "reg", NULL); | 42 | if (!of_address_to_resource(np, 0, &r)) |
40 | memzero_size = regs ? regs[3] : 0; | 43 | memzero_size = resource_size(&r); |
41 | of_node_put(np); | 44 | of_node_put(np); |
42 | } | 45 | } |
43 | 46 | ||
@@ -50,16 +53,21 @@ static unsigned long get_memblock_size(void) | |||
50 | sprintf(buf, "/memory@%x", memzero_size); | 53 | sprintf(buf, "/memory@%x", memzero_size); |
51 | np = of_find_node_by_path(buf); | 54 | np = of_find_node_by_path(buf); |
52 | if (np) { | 55 | if (np) { |
53 | regs = of_get_property(np, "reg", NULL); | 56 | if (!of_address_to_resource(np, 0, &r)) |
54 | memblock_size = regs ? regs[3] : 0; | 57 | memblock_size = resource_size(&r); |
55 | of_node_put(np); | 58 | of_node_put(np); |
56 | } | 59 | } |
57 | } | 60 | } |
58 | } | 61 | } |
59 | |||
60 | return memblock_size; | 62 | return memblock_size; |
61 | } | 63 | } |
62 | 64 | ||
65 | /* WARNING: This is going to override the generic definition whenever | ||
66 | * pseries is built-in regardless of what platform is active at boot | ||
67 | * time. This is fine for now as this is the only "option" and it | ||
68 | * should work everywhere. If not, we'll have to turn this into a | ||
69 | * ppc_md. callback | ||
70 | */ | ||
63 | unsigned long memory_block_size_bytes(void) | 71 | unsigned long memory_block_size_bytes(void) |
64 | { | 72 | { |
65 | return get_memblock_size(); | 73 | return get_memblock_size(); |