Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5d86257 authored by Anton Blanchard's avatar Anton Blanchard Committed by Benjamin Herrenschmidt
Browse files

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: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 223ca9d8
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,9 @@ struct machdep_calls {
	void		(*iommu_save)(void);
	void		(*iommu_save)(void);
	void		(*iommu_restore)(void);
	void		(*iommu_restore)(void);
#endif
#endif
#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
	unsigned long	(*memory_block_size)(void);
#endif
#endif /* CONFIG_PPC64 */
#endif /* CONFIG_PPC64 */


	void		(*pci_dma_dev_setup)(struct pci_dev *dev);
	void		(*pci_dma_dev_setup)(struct pci_dev *dev);
+10 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@
#include <linux/lockdep.h>
#include <linux/lockdep.h>
#include <linux/memblock.h>
#include <linux/memblock.h>
#include <linux/hugetlb.h>
#include <linux/hugetlb.h>
#include <linux/memory.h>


#include <asm/io.h>
#include <asm/io.h>
#include <asm/kdump.h>
#include <asm/kdump.h>
@@ -780,6 +781,15 @@ void __init setup_per_cpu_areas(void)
}
}
#endif
#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)
#if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
struct ppc_pci_io ppc_pci_io;
struct ppc_pci_io ppc_pci_io;
+3 −14
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@
#include <asm/prom.h>
#include <asm/prom.h>
#include <asm/sparsemem.h>
#include <asm/sparsemem.h>


static unsigned long get_memblock_size(void)
unsigned long pseries_memory_block_size(void)
{
{
	struct device_node *np;
	struct device_node *np;
	unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE;
	unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE;
@@ -64,17 +64,6 @@ static unsigned long get_memblock_size(void)
	return memblock_size;
	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
#ifdef CONFIG_MEMORY_HOTREMOVE
static int pseries_remove_memory(u64 start, u64 size)
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))
	if (!pfn_valid(start_pfn))
		goto out;
		goto out;


	block_sz = memory_block_size_bytes();
	block_sz = pseries_memory_block_size();
	sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
	sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
	nid = memory_add_physaddr_to_nid(base);
	nid = memory_add_physaddr_to_nid(base);


@@ -201,7 +190,7 @@ static int pseries_update_drconf_memory(struct of_prop_reconfig *pr)
	u32 *p;
	u32 *p;
	int i, rc = -EINVAL;
	int i, rc = -EINVAL;


	memblock_size = get_memblock_size();
	memblock_size = pseries_memory_block_size();
	if (!memblock_size)
	if (!memblock_size)
		return -EINVAL;
		return -EINVAL;


+2 −0
Original line number Original line Diff line number Diff line
@@ -64,4 +64,6 @@ extern int dlpar_detach_node(struct device_node *);
struct pci_host_bridge;
struct pci_host_bridge;
int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);


unsigned long pseries_memory_block_size(void);

#endif /* _PSERIES_PSERIES_H */
#endif /* _PSERIES_PSERIES_H */
+3 −0
Original line number Original line Diff line number Diff line
@@ -810,4 +810,7 @@ define_machine(pseries) {
#ifdef CONFIG_KEXEC
#ifdef CONFIG_KEXEC
	.machine_kexec          = pSeries_machine_kexec,
	.machine_kexec          = pSeries_machine_kexec,
#endif
#endif
#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
	.memory_block_size	= pseries_memory_block_size,
#endif
};
};