[PATCH v6 17/18] powerpc/64s: Move hash MMU support code under CONFIG_PPC_64S_HASH_MMU

Nicholas Piggin npiggin at gmail.com
Thu Dec 9 19:30:48 AEDT 2021


Excerpts from Michael Ellerman's message of December 7, 2021 11:00 pm:
> Nicholas Piggin <npiggin at gmail.com> writes:
>>  34 files changed, 173 insertions(+), 52 deletions(-)
> 
> 
> I was able to clean up some of the ifdefs a little with the changes
> below. I'll run these through some test builds and then squash them in.

Looks good to me.

Thanks,
Nick

> 
> cheers
> 
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> index 3004f3323144..21f780942911 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
> @@ -523,8 +523,14 @@ void slb_save_contents(struct slb_entry *slb_ptr);
>  void slb_dump_contents(struct slb_entry *slb_ptr);
>  
>  extern void slb_vmalloc_update(void);
> -extern void slb_set_size(u16 size);
>  void preload_new_slb_context(unsigned long start, unsigned long sp);
> +
> +#ifdef CONFIG_PPC_64S_HASH_MMU
> +void slb_set_size(u16 size);
> +#else
> +static inline void slb_set_size(u16 size) { }
> +#endif
> +
>  #endif /* __ASSEMBLY__ */
>  
>  /*
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 2197404cdcc4..75678ff04dd7 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -231,10 +231,9 @@ static void __init check_cpu_pa_features(unsigned long node)
>  		      ibm_pa_features, ARRAY_SIZE(ibm_pa_features));
>  }
>  
> -#ifdef CONFIG_PPC_BOOK3S_64
> +#ifdef CONFIG_PPC_64S_HASH_MMU
>  static void __init init_mmu_slb_size(unsigned long node)
>  {
> -#ifdef CONFIG_PPC_64S_HASH_MMU
>  	const __be32 *slb_size_ptr;
>  
>  	slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL) ? :
> @@ -242,7 +241,6 @@ static void __init init_mmu_slb_size(unsigned long node)
>  
>  	if (slb_size_ptr)
>  		mmu_slb_size = be32_to_cpup(slb_size_ptr);
> -#endif
>  }
>  #else
>  #define init_mmu_slb_size(node) do { } while(0)
> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
> index 22647bb82198..703a2e6ab08d 100644
> --- a/arch/powerpc/kernel/setup_64.c
> +++ b/arch/powerpc/kernel/setup_64.c
> @@ -886,9 +886,7 @@ void __init setup_per_cpu_areas(void)
>  		atom_size = SZ_1M;
>  	} else if (radix_enabled()) {
>  		atom_size = PAGE_SIZE;
> -	} else {
> -#ifdef CONFIG_PPC_64S_HASH_MMU
> -
> +	} else if (IS_ENABLED(CONFIG_PPC_64S_HASH_MMU)) {
>  		/*
>  		 * Linear mapping is one of 4K, 1M and 16M.  For 4K, no need
>  		 * to group units.  For larger mappings, use 1M atom which
> @@ -898,9 +896,6 @@ void __init setup_per_cpu_areas(void)
>  			atom_size = PAGE_SIZE;
>  		else
>  			atom_size = SZ_1M;
> -#else
> -		BUILD_BUG(); // radix_enabled() should be constant true
> -#endif
>  	}
>  
>  	if (pcpu_chosen_fc != PCPU_FC_PAGE) {
> diff --git a/arch/powerpc/kexec/ranges.c b/arch/powerpc/kexec/ranges.c
> index 92d831621fa0..563e9989a5bf 100644
> --- a/arch/powerpc/kexec/ranges.c
> +++ b/arch/powerpc/kexec/ranges.c
> @@ -296,7 +296,7 @@ int add_initrd_mem_range(struct crash_mem **mem_ranges)
>  	return ret;
>  }
>  
> -#ifdef CONFIG_PPC_BOOK3S_64
> +#ifdef CONFIG_PPC_64S_HASH_MMU
>  /**
>   * add_htab_mem_range - Adds htab range to the given memory ranges list,
>   *                      if it exists
> @@ -306,14 +306,10 @@ int add_initrd_mem_range(struct crash_mem **mem_ranges)
>   */
>  int add_htab_mem_range(struct crash_mem **mem_ranges)
>  {
> -#ifdef CONFIG_PPC_64S_HASH_MMU
>  	if (!htab_address)
>  		return 0;
>  
>  	return add_mem_range(mem_ranges, __pa(htab_address), htab_size_bytes);
> -#else
> -	return 0;
> -#endif
>  }
>  #endif
>  
> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
> index 5f8cbeca8080..3c4f0ebe5df8 100644
> --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
> +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
> @@ -333,10 +333,8 @@ static void __init radix_init_pgtable(void)
>  	phys_addr_t start, end;
>  	u64 i;
>  
> -#ifdef CONFIG_PPC_64S_HASH_MMU
>  	/* We don't support slb for radix */
> -	mmu_slb_size = 0;
> -#endif
> +	slb_set_size(0);
>  
>  	/*
>  	 * Create the linear mapping
> diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
> index 21b706bcea76..85033f392c78 100644
> --- a/arch/powerpc/platforms/pseries/mobility.c
> +++ b/arch/powerpc/platforms/pseries/mobility.c
> @@ -484,9 +484,7 @@ static int do_suspend(void)
>  	ret = rtas_ibm_suspend_me(&status);
>  	if (ret != 0) {
>  		pr_err("ibm,suspend-me error: %d\n", status);
> -#ifdef CONFIG_PPC_64S_HASH_MMU
>  		slb_set_size(saved_slb_size);
> -#endif
>  	}
>  
>  	return ret;
> diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
> index 3544778e06d0..b4c63c481f33 100644
> --- a/arch/powerpc/platforms/pseries/pseries.h
> +++ b/arch/powerpc/platforms/pseries/pseries.h
> @@ -113,6 +113,11 @@ int dlpar_workqueue_init(void);
>  
>  extern u32 pseries_security_flavor;
>  void pseries_setup_security_mitigations(void);
> +
> +#ifdef CONFIG_PPC_64S_HASH_MMU
>  void pseries_lpar_read_hblkrm_characteristics(void);
> +#else
> +static inline void pseries_lpar_read_hblkrm_characteristics(void) { }
> +#endif
>  
>  #endif /* _PSERIES_PSERIES_H */
> diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
> index 80dae18d6621..7f7369fec46b 100644
> --- a/arch/powerpc/platforms/pseries/reconfig.c
> +++ b/arch/powerpc/platforms/pseries/reconfig.c
> @@ -337,10 +337,8 @@ static int do_update_property(char *buf, size_t bufsize)
>  	if (!newprop)
>  		return -ENOMEM;
>  
> -#ifdef CONFIG_PPC_64S_HASH_MMU
>  	if (!strcmp(name, "slb-size") || !strcmp(name, "ibm,slb-size"))
>  		slb_set_size(*(int *)value);
> -#endif
>  
>  	return of_update_property(np, newprop);
>  }
> 


More information about the Linuxppc-dev mailing list