Skip to content

Commit

Permalink
From patchwork series 358597
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Jun 7, 2023
1 parent a87fe4b commit 246414e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 70 deletions.
3 changes: 3 additions & 0 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,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>
Expand Down
5 changes: 0 additions & 5 deletions arch/powerpc/include/asm/book3s/64/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 27 additions & 0 deletions arch/powerpc/kernel/setup_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
64 changes: 1 addition & 63 deletions arch/powerpc/mm/book3s64/radix_pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <mm/mmu_decl.h>

unsigned int mmu_base_pid;
unsigned long radix_mem_block_size __ro_after_init;

static __ref void *early_alloc_pgtable(unsigned long size, int nid,
unsigned long region_start, unsigned long region_end)
Expand Down Expand Up @@ -300,7 +299,7 @@ static int __meminit create_physical_mapping(unsigned long start,
bool prev_exec, exec = false;
pgprot_t prot;
int psize;
unsigned long max_mapping_size = radix_mem_block_size;
unsigned long max_mapping_size = memory_block_size_bytes();

if (debug_pagealloc_enabled_or_kfence())
max_mapping_size = PAGE_SIZE;
Expand Down Expand Up @@ -502,58 +501,6 @@ static int __init radix_dt_scan_page_sizes(unsigned long node,
return 1;
}

#ifdef CONFIG_MEMORY_HOTPLUG
static int __init probe_memory_block_size(unsigned long node, const char *uname, int
depth, void *data)
{
unsigned long *mem_block_size = (unsigned long *)data;
const __be32 *prop;
int len;

if (depth != 1)
return 0;

if (strcmp(uname, "ibm,dynamic-reconfiguration-memory"))
return 0;

prop = of_get_flat_dt_prop(node, "ibm,lmb-size", &len);

if (!prop || len < dt_root_size_cells * sizeof(__be32))
/*
* Nothing in the device tree
*/
*mem_block_size = MIN_MEMORY_BLOCK_SIZE;
else
*mem_block_size = of_read_number(prop, dt_root_size_cells);
return 1;
}

static unsigned long __init radix_memory_block_size(void)
{
unsigned long mem_block_size = MIN_MEMORY_BLOCK_SIZE;

/*
* OPAL firmware feature is set by now. Hence we are ok
* to test OPAL feature.
*/
if (firmware_has_feature(FW_FEATURE_OPAL))
mem_block_size = 1UL * 1024 * 1024 * 1024;
else
of_scan_flat_dt(probe_memory_block_size, &mem_block_size);

return mem_block_size;
}

#else /* CONFIG_MEMORY_HOTPLUG */

static unsigned long __init radix_memory_block_size(void)
{
return 1UL * 1024 * 1024 * 1024;
}

#endif /* CONFIG_MEMORY_HOTPLUG */


void __init radix__early_init_devtree(void)
{
int rc;
Expand All @@ -578,15 +525,6 @@ void __init radix__early_init_devtree(void)
psize_to_rpti_pgsize(MMU_PAGE_64K);
}

/*
* Max mapping size used when mapping pages. We don't use
* ppc_md.memory_block_size() here because this get called
* early and we don't have machine probe called yet. Also
* the pseries implementation only check for ibm,lmb-size.
* All hypervisor supporting radix do expose that device
* tree node.
*/
radix_mem_block_size = radix_memory_block_size();
return;
}

Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/powernv/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 246414e

Please sign in to comment.