aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Blanchard <anton@au1.ibm.com>2014-06-04 03:50:47 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-06-04 23:20:39 -0400
commita5d862576a64cb3e0c22dc9cc2170e4d750714f9 (patch)
treefcbe4063edf1c207af6bcde00506cb763d1db589
parent223ca9d855ce32a4cc2d2b961e6e9d1fb36872ba (diff)
powerpc: Allow ppc_md platform hook to override memory_block_size_bytes
The pseries platform code unconditionally overrides memory_block_size_bytes regardless of the running platform. Create a ppc_md hook that so each platform can choose to do what it wants. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/include/asm/machdep.h3
-rw-r--r--arch/powerpc/kernel/setup_64.c10
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c17
-rw-r--r--arch/powerpc/platforms/pseries/pseries.h2
-rw-r--r--arch/powerpc/platforms/pseries/setup.c3
5 files changed, 21 insertions, 14 deletions
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 374abc2e41d7..f92b0b54e921 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -98,6 +98,9 @@ struct machdep_calls {
98 void (*iommu_save)(void); 98 void (*iommu_save)(void);
99 void (*iommu_restore)(void); 99 void (*iommu_restore)(void);
100#endif 100#endif
101#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
102 unsigned long (*memory_block_size)(void);
103#endif
101#endif /* CONFIG_PPC64 */ 104#endif /* CONFIG_PPC64 */
102 105
103 void (*pci_dma_dev_setup)(struct pci_dev *dev); 106 void (*pci_dma_dev_setup)(struct pci_dev *dev);
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 90b532ace0d5..ee082d771178 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -36,6 +36,7 @@
36#include <linux/lockdep.h> 36#include <linux/lockdep.h>
37#include <linux/memblock.h> 37#include <linux/memblock.h>
38#include <linux/hugetlb.h> 38#include <linux/hugetlb.h>
39#include <linux/memory.h>
39 40
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/kdump.h> 42#include <asm/kdump.h>
@@ -780,6 +781,15 @@ void __init setup_per_cpu_areas(void)
780} 781}
781#endif 782#endif
782 783
784#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
785unsigned long memory_block_size_bytes(void)
786{
787 if (ppc_md.memory_block_size)
788 return ppc_md.memory_block_size();
789
790 return MIN_MEMORY_BLOCK_SIZE;
791}
792#endif
783 793
784#if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO) 794#if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
785struct ppc_pci_io ppc_pci_io; 795struct ppc_pci_io ppc_pci_io;
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 7f75c94af822..7995135170a3 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -21,7 +21,7 @@
21#include <asm/prom.h> 21#include <asm/prom.h>
22#include <asm/sparsemem.h> 22#include <asm/sparsemem.h>
23 23
24static unsigned long get_memblock_size(void) 24unsigned long pseries_memory_block_size(void)
25{ 25{
26 struct device_node *np; 26 struct device_node *np;
27 unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE; 27 unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE;
@@ -64,17 +64,6 @@ static unsigned long get_memblock_size(void)
64 return memblock_size; 64 return memblock_size;
65} 65}
66 66
67/* WARNING: This is going to override the generic definition whenever
68 * pseries is built-in regardless of what platform is active at boot
69 * time. This is fine for now as this is the only "option" and it
70 * should work everywhere. If not, we'll have to turn this into a
71 * ppc_md. callback
72 */
73unsigned long memory_block_size_bytes(void)
74{
75 return get_memblock_size();
76}
77
78#ifdef CONFIG_MEMORY_HOTREMOVE 67#ifdef CONFIG_MEMORY_HOTREMOVE
79static int pseries_remove_memory(u64 start, u64 size) 68static int pseries_remove_memory(u64 start, u64 size)
80{ 69{
@@ -105,7 +94,7 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
105 if (!pfn_valid(start_pfn)) 94 if (!pfn_valid(start_pfn))
106 goto out; 95 goto out;
107 96
108 block_sz = memory_block_size_bytes(); 97 block_sz = pseries_memory_block_size();
109 sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE; 98 sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
110 nid = memory_add_physaddr_to_nid(base); 99 nid = memory_add_physaddr_to_nid(base);
111 100
@@ -201,7 +190,7 @@ static int pseries_update_drconf_memory(struct of_prop_reconfig *pr)
201 u32 *p; 190 u32 *p;
202 int i, rc = -EINVAL; 191 int i, rc = -EINVAL;
203 192
204 memblock_size = get_memblock_size(); 193 memblock_size = pseries_memory_block_size();
205 if (!memblock_size) 194 if (!memblock_size)
206 return -EINVAL; 195 return -EINVAL;
207 196
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 99219530ea4a..361add62abf1 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -64,4 +64,6 @@ extern int dlpar_detach_node(struct device_node *);
64struct pci_host_bridge; 64struct pci_host_bridge;
65int pseries_root_bridge_prepare(struct pci_host_bridge *bridge); 65int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
66 66
67unsigned long pseries_memory_block_size(void);
68
67#endif /* _PSERIES_PSERIES_H */ 69#endif /* _PSERIES_PSERIES_H */
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 215c3c269617..adc21a0e3410 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -810,4 +810,7 @@ define_machine(pseries) {
810#ifdef CONFIG_KEXEC 810#ifdef CONFIG_KEXEC
811 .machine_kexec = pSeries_machine_kexec, 811 .machine_kexec = pSeries_machine_kexec,
812#endif 812#endif
813#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
814 .memory_block_size = pseries_memory_block_size,
815#endif
813}; 816};