[RFC v2 2/2] powerpc/mm: add radix__{create, remove}_section_mapping()

Reza Arbab arbab at linux.vnet.ibm.com
Thu Aug 18 01:51:23 AEST 2016


Add radix variants of the memory hotplug mapping functions.

Signed-off-by: Reza Arbab <arbab at linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/book3s/64/radix.h |  5 +++++
 arch/powerpc/include/asm/sparsemem.h       |  8 ++++++++
 arch/powerpc/mm/pgtable-radix.c            | 23 +++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
index df29422..97e71cb 100644
--- a/arch/powerpc/include/asm/book3s/64/radix.h
+++ b/arch/powerpc/include/asm/book3s/64/radix.h
@@ -229,6 +229,11 @@ extern void radix__vmemmap_remove_mapping(unsigned long start,
 extern int radix__map_kernel_page(unsigned long ea, unsigned long pa,
 				 pgprot_t flags, unsigned int psz);
 
+#ifdef CONFIG_MEMORY_HOTPLUG
+int radix__create_section_mapping(unsigned long start, unsigned long end);
+void radix__remove_section_mapping(unsigned long start, unsigned long end);
+#endif /* CONFIG_MEMORY_HOTPLUG */
+
 static inline unsigned long radix__get_tree_size(void)
 {
 	unsigned long rts_field;
diff --git a/arch/powerpc/include/asm/sparsemem.h b/arch/powerpc/include/asm/sparsemem.h
index 5014e0d..42fe87e 100644
--- a/arch/powerpc/include/asm/sparsemem.h
+++ b/arch/powerpc/include/asm/sparsemem.h
@@ -19,12 +19,20 @@
 static inline int create_section_mapping(unsigned long start,
 					 unsigned long end)
 {
+	if (radix_enabled())
+		return radix__create_section_mapping(start, end);
+
 	return hash__create_section_mapping(start, end);
 }
 
 static inline int remove_section_mapping(unsigned long start,
 					 unsigned long end)
 {
+	if (radix_enabled()) {
+		radix__remove_section_mapping(start, end);
+		return 0;
+	}
+
 	return hash__remove_section_mapping(start, end);
 }
 
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index af897d9..ee0286c 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -527,3 +527,26 @@ int radix__has_transparent_hugepage(void)
 	return 0;
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+
+#ifdef CONFIG_MEMORY_HOTPLUG
+int radix__create_section_mapping(unsigned long start, unsigned long end)
+{
+	unsigned long page_size = 1 << mmu_psize_defs[mmu_linear_psize].shift;
+
+	/* Align to the page size of the linear mapping. */
+	start = _ALIGN_DOWN(start, page_size);
+
+	for (; start < end; start += page_size) {
+		int rc = radix__map_kernel_page(start, __pa(start),
+						PAGE_KERNEL, page_size);
+	        if (rc)
+			return rc;
+	}
+
+	return 0;
+}
+
+void radix__remove_section_mapping(unsigned long start, unsigned long end)
+{
+}
+#endif /* CONFIG_MEMORY_HOTPLUG */
-- 
1.8.3.1



More information about the Linuxppc-dev mailing list