Skip to contentSkip to conversation

powerpc/book3s64/mm: Remove radix_mem_block_size

PATCH New Aneesh Kumar K.V 1 participant 2 messages Jun 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc/book3s64/mm: Remove radix_mem_block_size

Simplify powernv memory_block_size call back by directly using 1G value instead of using radix_mem_block_size. Also, remove the variable and use memory_block_size_bytes() in the kernel mapping function. This gets called in radix__early_init_mmu() which is called after probe_machine is called and correct machine-specific callback is assigned.

No functional change in this patch.

---
 arch/powerpc/include/asm/book3s/64/mmu.h |  5 --
 arch/powerpc/mm/book3s64/radix_pgtable.c | 64 +-----------------------
 arch/powerpc/platforms/powernv/setup.c   |  4 +-
 3 files changed, 3 insertions(+), 70 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +0 -5
index 570a4960cf17..7b7643f32e0e 100644
@@ -71,11 +71,6 @@ extern unsigned int mmu_pid_bits;
 /* Base PID to allocate from */
 extern unsigned int mmu_base_pid;
 
-/*
- * memory block size used with radix translation.
- */
-extern unsigned long __ro_after_init radix_mem_block_size;
-
 #define PRTB_SIZE_SHIFT	(mmu_pid_bits + 4)
 #define PRTB_ENTRIES	(1ul << mmu_pid_bits)
 
arch/powerpc/mm/book3s64/radix_pgtable.c +1 -63

88 lines not on this page · raw message

arch/powerpc/platforms/powernv/setup.c +2 -2
index 5e9c6b55809f..29f855c66ad3 100644
@@ -488,9 +488,9 @@ static unsigned long pnv_memory_block_size(void)
 	 * this size.
 	 */
 	if (radix_enabled())
-		return radix_mem_block_size;
+		return 1UL << 30;
 	else
-		return 256UL * 1024 * 1024;
+		return 256UL << 20;
 }
 #endif
 
Signature · 1 line
2.40.1
#1 lore raw

PATCH 2/2 powerpc/mm: Add memory_block_size as a kernel parameter

Certain devices can possess non-standard memory capacities, not constrained to multiples of 1GB. Provide a kernel parameter so that we can map the device memory completely on memory hotplug.

Restrict memory_block_size value to a power of 2 value similar to LMB size. The memory block size should also be more than the section size.

---
 .../admin-guide/kernel-parameters.txt         |  3 +++
 arch/powerpc/kernel/setup_64.c                | 27 +++++++++++++++++++
 2 files changed, 30 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index 9e5bab29685f..833b8c5b4b4c 100644
@@ -3190,6 +3190,9 @@
 			Note that even when enabled, there are a few cases where
 			the feature is not effective.
 
+	memory_block_size=size [PPC]
+			 Use this parameter to configure the memory block size value.
+
 	memtest=	[KNL,X86,ARM,M68K,PPC,RISCV] Enable memtest
 			Format: <integer>
 			default : 0 <disable>
arch/powerpc/kernel/setup_64.c +27 -0
index 246201d0d879..54ce748a340d 100644
@@ -885,13 +885,40 @@ void __init setup_per_cpu_areas(void)
 #endif
 
 #ifdef CONFIG_MEMORY_HOTPLUG
+static unsigned long set_mem_block_size;
 unsigned long memory_block_size_bytes(void)
 {
+	if (set_mem_block_size)
+		return set_mem_block_size;
+
 	if (ppc_md.memory_block_size)
 		return ppc_md.memory_block_size();
 
 	return MIN_MEMORY_BLOCK_SIZE;
 }
+
+/*
+ * Restrict to a power of 2 value for memblock which is larger than
+ * section size
+ */
+static int __init parse_mem_block_size(char *ptr)
+{
+	unsigned int order;
+	unsigned long size = memparse(ptr, NULL);
+
+	order = fls64(size);
+	if (!order)
+		return 0;
+
+	order--;
+	if (order < SECTION_SIZE_BITS)
+		return 0;
+
+	set_mem_block_size = 1UL << order;
+
+	return 0;
+}
+early_param("memory_block_size", parse_mem_block_size);
 #endif
 
 #if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
Signature · 1 line
2.40.1