Skip to content

Commit f142475

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled
With CONFIG_SPARSEMEM disabled the below kernel build error is observed. arch/powerpc/mm/init_64.c:477:38: error: use of undeclared identifier 'SECTION_SIZE_BITS' CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM and it is more clear to describe the code dependency in terms of MEMORY_HOTPLUG. Outside memory hotplug the kernel uses memory_block_size for kernel directmap. Instead of depending on SECTION_SIZE_BITS to compute the direct map page size, add a new #define which defaults to 16M(same as existing SECTION_SIZE) Fixes: 4d15721 ("powerpc/mm: Cleanup memory block size probing") Signed-off-by: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> Closes: https://lore.kernel.org/oe-kbuild-all/202308251532.k9PpWEAD-lkp@intel.com/ Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230828074658.59553-1-aneesh.kumar@linux.ibm.com
1 parent c37b690 commit f142475

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

arch/powerpc/mm/init_64.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,23 @@ static int __init dt_scan_mmu_pid_width(unsigned long node,
472472
return 1;
473473
}
474474

475+
/*
476+
* Outside hotplug the kernel uses this value to map the kernel direct map
477+
* with radix. To be compatible with older kernels, let's keep this value
478+
* as 16M which is also SECTION_SIZE with SPARSEMEM. We can ideally map
479+
* things with 1GB size in the case where we don't support hotplug.
480+
*/
481+
#ifndef CONFIG_MEMORY_HOTPLUG
482+
#define DEFAULT_MEMORY_BLOCK_SIZE SZ_16M
483+
#else
484+
#define DEFAULT_MEMORY_BLOCK_SIZE MIN_MEMORY_BLOCK_SIZE
485+
#endif
486+
475487
static void update_memory_block_size(unsigned long *block_size, unsigned long mem_size)
476488
{
477-
unsigned long section_size = 1UL << SECTION_SIZE_BITS;
478-
479-
for (; *block_size > section_size; *block_size >>= 2) {
489+
unsigned long min_memory_block_size = DEFAULT_MEMORY_BLOCK_SIZE;
480490

491+
for (; *block_size > min_memory_block_size; *block_size >>= 2) {
481492
if ((mem_size & *block_size) == 0)
482493
break;
483494
}
@@ -507,7 +518,7 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
507518
/*
508519
* Nothing in the device tree
509520
*/
510-
*block_size = MIN_MEMORY_BLOCK_SIZE;
521+
*block_size = DEFAULT_MEMORY_BLOCK_SIZE;
511522
else
512523
*block_size = of_read_number(prop, dt_root_size_cells);
513524
/*

0 commit comments

Comments
 (0)