powerpc: Allow ppc_md platform hook to override memory_block_size_bytes
authorAnton Blanchard <anton@au1.ibm.com>
Wed, 4 Jun 2014 07:50:47 +0000 (17:50 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 5 Jun 2014 03:20:39 +0000 (13:20 +1000)
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>
arch/powerpc/include/asm/machdep.h
arch/powerpc/kernel/setup_64.c
arch/powerpc/platforms/pseries/hotplug-memory.c
arch/powerpc/platforms/pseries/pseries.h
arch/powerpc/platforms/pseries/setup.c

index 374abc2e41d73131c114e8bfa4d2a9dcadd78614..f92b0b54e921a5e71684a96b2d92f88b290e2222 100644 (file)
@@ -98,6 +98,9 @@ struct machdep_calls {
        void            (*iommu_save)(void);
        void            (*iommu_restore)(void);
 #endif
+#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+       unsigned long   (*memory_block_size)(void);
+#endif
 #endif /* CONFIG_PPC64 */
 
        void            (*pci_dma_dev_setup)(struct pci_dev *dev);
index 90b532ace0d5802b860e2344333f3ec32de91ea8..ee082d771178d463ff259adef107de4845ed84f2 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/lockdep.h>
 #include <linux/memblock.h>
 #include <linux/hugetlb.h>
+#include <linux/memory.h>
 
 #include <asm/io.h>
 #include <asm/kdump.h>
@@ -780,6 +781,15 @@ void __init setup_per_cpu_areas(void)
 }
 #endif
 
+#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+unsigned long memory_block_size_bytes(void)
+{
+       if (ppc_md.memory_block_size)
+               return ppc_md.memory_block_size();
+
+       return MIN_MEMORY_BLOCK_SIZE;
+}
+#endif
 
 #if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
 struct ppc_pci_io ppc_pci_io;
index 7f75c94af822c40322d8a4a751e983ad0e2bcdae..7995135170a31a35a7824703f72fe26b93b145a7 100644 (file)
@@ -21,7 +21,7 @@
 #include <asm/prom.h>
 #include <asm/sparsemem.h>
 
-static unsigned long get_memblock_size(void)
+unsigned long pseries_memory_block_size(void)
 {
        struct device_node *np;
        unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE;
@@ -64,17 +64,6 @@ static unsigned long get_memblock_size(void)
        return memblock_size;
 }
 
-/* WARNING: This is going to override the generic definition whenever
- * pseries is built-in regardless of what platform is active at boot
- * time. This is fine for now as this is the only "option" and it
- * should work everywhere. If not, we'll have to turn this into a
- * ppc_md. callback
- */
-unsigned long memory_block_size_bytes(void)
-{
-       return get_memblock_size();
-}
-
 #ifdef CONFIG_MEMORY_HOTREMOVE
 static int pseries_remove_memory(u64 start, u64 size)
 {
@@ -105,7 +94,7 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
        if (!pfn_valid(start_pfn))
                goto out;
 
-       block_sz = memory_block_size_bytes();
+       block_sz = pseries_memory_block_size();
        sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
        nid = memory_add_physaddr_to_nid(base);
 
@@ -201,7 +190,7 @@ static int pseries_update_drconf_memory(struct of_prop_reconfig *pr)
        u32 *p;
        int i, rc = -EINVAL;
 
-       memblock_size = get_memblock_size();
+       memblock_size = pseries_memory_block_size();
        if (!memblock_size)
                return -EINVAL;
 
index 99219530ea4aaad0da768b72d84a4caa1f96fcb0..361add62abf1089d4cd65aa28c72264a040de635 100644 (file)
@@ -64,4 +64,6 @@ extern int dlpar_detach_node(struct device_node *);
 struct pci_host_bridge;
 int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
 
+unsigned long pseries_memory_block_size(void);
+
 #endif /* _PSERIES_PSERIES_H */
index 215c3c269617f308a633bdeb60db823d1f25cfaa..adc21a0e34104b6eff390eb9f582768bdb6ee295 100644 (file)
@@ -810,4 +810,7 @@ define_machine(pseries) {
 #ifdef CONFIG_KEXEC
        .machine_kexec          = pSeries_machine_kexec,
 #endif
+#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+       .memory_block_size      = pseries_memory_block_size,
+#endif
 };