powerpc/64s: Get LPID bit width from device tree
Nicholas Piggin
reviewerPATCH v3 1/1 powerpc/64s: Get LPID bit width from device tree
Allow the LPID bit width and partition table size to be set at runtime from the device tree.
Move the PID bit width detection into the same place.
KVM does not support using the extra bits yet, this is mainly required to get the PTCR register values correct (so KVM will run but it will not allocate > 4096 LPIDs).
OPAL firmware provides this property for POWER10 CPUs since skiboot commit 9b85f7d961f2 ("hdata: add mmu-pid-bits and mmu-lpid-bits for POWER10 CPUs").
---
Since v2: fixed compile bug, added skiboot commit hash in changelog.
arch/powerpc/include/asm/book3s/64/mmu.h | 9 ++--- arch/powerpc/mm/book3s64/pgtable.c | 5 --- arch/powerpc/mm/book3s64/radix_pgtable.c | 13 +------ arch/powerpc/mm/init_64.c | 46 +++++++++++++++++++++++- 4 files changed, 51 insertions(+), 22 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +5 -4
@@ -62,6 +62,9 @@ extern struct patb_entry *partition_tb;#define PRTS_MASK 0x1f/* process table size field */ #define PRTB_MASK 0x0ffffffffffff000UL +/* Number of supported LPID bits */ +extern unsigned int mmu_lpid_bits; +/* Number of supported PID bits */ extern unsigned int mmu_pid_bits;
@@ -76,10 +79,8 @@ 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) -/* -* Power9 currently only support 64K partition table size. -*/ -#define PATB_SIZE_SHIFT 16 +#define PATB_SIZE_SHIFT (mmu_lpid_bits + 4) +#define PATB_ENTRIES (1ul << mmu_lpid_bits)typedef unsigned long mm_context_id_t ;struct spinlock ;
arch/powerpc/mm/book3s64/pgtable.c +0 -5
@@ -207,17 +207,12 @@ void __init mmu_partition_table_init(void)unsigned long patb_size =1UL <<PATB_SIZE_SHIFT ;unsigned long ptcr; -BUILD_BUG_ON_MSG ((PATB_SIZE_SHIFT >36 ),"Partition table size too large." );/* Initialize the Partition Table with no entries */ partition_tb =memblock_alloc (patb_size, patb_size);if (!partition_tb)panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , __func__, patb_size, patb_size); -/* -* update partition table control register, -* 64 K size. -*/ ptcr =__pa (partition_tb) | (PATB_SIZE_SHIFT -12 );set_ptcr_when_no_uv (ptcr);powernv_set_nmmu_ptcr (ptcr);
arch/powerpc/mm/book3s64/radix_pgtable.c +1 -12
@@ -33,7 +33,6 @@#include <trace/events/thp.h> -unsigned int mmu_pid_bits;unsigned int mmu_base_pid;unsigned long radix_mem_block_size__ro_after_init ;
@@ -357,18 +356,13 @@ static void __init radix_init_pgtable(void) -1, PAGE_KERNEL)); } -/* Find out how many PID bits are supported */ if (!cpu_has_feature (CPU_FTR_HVMODE ) &&cpu_has_feature (CPU_FTR_P9_RADIX_PREFETCH_BUG )) {/* * Older versions of KVM on these machines perfer if the * guest only uses the low 19 PID bits. */ -if (!mmu_pid_bits) - mmu_pid_bits =19 ; - }else { -if (!mmu_pid_bits) - mmu_pid_bits =20 ; + mmu_pid_bits =19 ; } mmu_base_pid =1 ;
@@ -449,11 +443,6 @@ static int __init radix_dt_scan_page_sizes(unsigned long node,if (type ==NULL ||strcmp (type,"cpu" ) !=0 )return 0 ; -/* Find MMU PID size */ - prop =of_get_flat_dt_prop (node,"ibm,mmu-pid-bits" , &size); -if (prop && size ==4 ) - mmu_pid_bits =be32_to_cpup (prop); -/* Grab page size encodings */ prop =of_get_flat_dt_prop (node,"ibm,processor-radix-AP-encodings" , &size);if (!prop)
arch/powerpc/mm/init_64.c +45 -1
70 lines not on this page · raw message
Signature · 1 line
2.23.0
Michael Ellerman
AppliedQuoted 10 lines · Nicholas Piggin
Allow the LPID bit width and partition table size to be set at runtime from the device tree.
Move the PID bit width detection into the same place.
KVM does not support using the extra bits yet, this is mainly required to get the PTCR register values correct (so KVM will run but it will not allocate > 4096 LPIDs).
[...]
Applied to powerpc/next.
[1/1] powerpc/64s: Get LPID bit width from device tree
https://git.kernel.org/powerpc/c/5402e239d09feea482d25d60df9b908cfaf9ec3c
cheers