diff mbox series

[RFC,3/5] powerpc/64s: add CONFIG_PPC_NMMU for nest MMU support

Message ID 20201219234813.830747-4-npiggin@gmail.com
State New
Headers show
Series powerpc/64s/radix: Use non-atomic ops for PTE | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (3ae03872115a0a158508ee5a91337648aede547d)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (c1bea0a840ac75dca19bc6aa05575a33eb9fd058)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (467f8165a2b0e6accf3d0dd9c8089b1dbde29f7f)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (5eedf9fe8db23313df104576845cec5f481b9b60)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (0d52778b8710eb11cb616761a02aee0a7fd60425)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Nicholas Piggin Dec. 19, 2020, 11:48 p.m. UTC
This allows some nest MMU features to be compiled away if coprocessor
support is not selected.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Kconfig                          | 1 +
 arch/powerpc/include/asm/book3s/64/mmu.h      | 2 ++
 arch/powerpc/include/asm/book3s/64/tlbflush.h | 2 ++
 arch/powerpc/include/asm/mmu_context.h        | 5 +++--
 arch/powerpc/platforms/Kconfig                | 3 +++
 arch/powerpc/platforms/powernv/Kconfig        | 1 +
 6 files changed, 12 insertions(+), 2 deletions(-)

Comments

Christophe Leroy Dec. 20, 2020, 11:43 a.m. UTC | #1
Le 20/12/2020 à 00:48, Nicholas Piggin a écrit :
> This allows some nest MMU features to be compiled away if coprocessor
> support is not selected.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>   arch/powerpc/Kconfig                          | 1 +
>   arch/powerpc/include/asm/book3s/64/mmu.h      | 2 ++
>   arch/powerpc/include/asm/book3s/64/tlbflush.h | 2 ++
>   arch/powerpc/include/asm/mmu_context.h        | 5 +++--
>   arch/powerpc/platforms/Kconfig                | 3 +++
>   arch/powerpc/platforms/powernv/Kconfig        | 1 +
>   6 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index ae7391627054..4376bf4c53b4 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -888,6 +888,7 @@ config PPC_PROT_SAO_LPAR
>   
>   config PPC_COPRO_BASE
>   	bool
> +	select PPC_NMMU if PPC_BOOK3S_64
>   
>   config SCHED_SMT
>   	bool "SMT (Hyperthreading) scheduler support"
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
> index 995bbcdd0ef8..07850d68a624 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
> @@ -103,8 +103,10 @@ typedef struct {
>   	/* Number of bits in the mm_cpumask */
>   	atomic_t active_cpus;
>   
> +#ifdef CONFIG_PPC_NMMU
>   	/* Number of users of the external (Nest) MMU */
>   	atomic_t copros;
> +#endif
>   
>   	/* Number of user space windows opened in process mm_context */
>   	atomic_t vas_windows;
> diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h b/arch/powerpc/include/asm/book3s/64/tlbflush.h
> index 0a7431e954c6..c70a82851f78 100644
> --- a/arch/powerpc/include/asm/book3s/64/tlbflush.h
> +++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h
> @@ -16,8 +16,10 @@ enum {
>   
>   static inline bool mm_has_nmmu(struct mm_struct *mm)
>   {
> +#ifdef CONFIG_PPC_NMMU
>   	if (unlikely(atomic_read(&mm->context.copros) > 0))
>   		return true;
> +#endif
>   	return false;
>   }
>   
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> index d5821834dba9..53eac0cc4929 100644
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -143,6 +143,7 @@ static inline void dec_mm_active_cpus(struct mm_struct *mm)
>   	atomic_dec(&mm->context.active_cpus);
>   }
>   
> +#ifdef CONFIG_PPC_NMMU
>   static inline void mm_context_add_copro(struct mm_struct *mm)
>   {
>   	/*
> @@ -187,6 +188,7 @@ static inline void mm_context_remove_copro(struct mm_struct *mm)
>   			dec_mm_active_cpus(mm);
>   	}
>   }
> +#endif
>   
>   /*
>    * vas_windows counter shows number of open windows in the mm
> @@ -218,8 +220,7 @@ static inline void mm_context_remove_vas_window(struct mm_struct *mm)
>   #else
>   static inline void inc_mm_active_cpus(struct mm_struct *mm) { }
>   static inline void dec_mm_active_cpus(struct mm_struct *mm) { }
> -static inline void mm_context_add_copro(struct mm_struct *mm) { }
> -static inline void mm_context_remove_copro(struct mm_struct *mm) { }

Are you sure you can remove those ?
If so, I think it belongs to another patch, I can't see how the new PPC_NMMU would allow that by itself.

> +static inline bool mm_has_nmmu(struct mm_struct *mm) { return false; }
>   #endif
>   
>   
> diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
> index 7a5e8f4541e3..b4b04b3f98d1 100644
> --- a/arch/powerpc/platforms/Kconfig
> +++ b/arch/powerpc/platforms/Kconfig
> @@ -191,6 +191,9 @@ config PPC_INDIRECT_MMIO
>   config PPC_IO_WORKAROUNDS
>   	bool
>   
> +config PPC_NMMU
> +	bool
> +
>   source "drivers/cpufreq/Kconfig"
>   
>   menu "CPUIdle driver"
> diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
> index 619b093a0657..145009d74457 100644
> --- a/arch/powerpc/platforms/powernv/Kconfig
> +++ b/arch/powerpc/platforms/powernv/Kconfig
> @@ -36,6 +36,7 @@ config PPC_MEMTRACE
>   config PPC_VAS
>   	bool "IBM Virtual Accelerator Switchboard (VAS)"
>   	depends on PPC_POWERNV && PPC_64K_PAGES
> +	select PPC_NMMU
>   	default y
>   	help
>   	  This enables support for IBM Virtual Accelerator Switchboard (VAS).
>
Nicholas Piggin Dec. 22, 2020, 3:37 a.m. UTC | #2
Excerpts from Christophe Leroy's message of December 20, 2020 9:43 pm:
> 
> 
> Le 20/12/2020 à 00:48, Nicholas Piggin a écrit :
>> This allows some nest MMU features to be compiled away if coprocessor
>> support is not selected.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>   arch/powerpc/Kconfig                          | 1 +
>>   arch/powerpc/include/asm/book3s/64/mmu.h      | 2 ++
>>   arch/powerpc/include/asm/book3s/64/tlbflush.h | 2 ++
>>   arch/powerpc/include/asm/mmu_context.h        | 5 +++--
>>   arch/powerpc/platforms/Kconfig                | 3 +++
>>   arch/powerpc/platforms/powernv/Kconfig        | 1 +
>>   6 files changed, 12 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index ae7391627054..4376bf4c53b4 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -888,6 +888,7 @@ config PPC_PROT_SAO_LPAR
>>   
>>   config PPC_COPRO_BASE
>>   	bool
>> +	select PPC_NMMU if PPC_BOOK3S_64
>>   
>>   config SCHED_SMT
>>   	bool "SMT (Hyperthreading) scheduler support"
>> diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
>> index 995bbcdd0ef8..07850d68a624 100644
>> --- a/arch/powerpc/include/asm/book3s/64/mmu.h
>> +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
>> @@ -103,8 +103,10 @@ typedef struct {
>>   	/* Number of bits in the mm_cpumask */
>>   	atomic_t active_cpus;
>>   
>> +#ifdef CONFIG_PPC_NMMU
>>   	/* Number of users of the external (Nest) MMU */
>>   	atomic_t copros;
>> +#endif
>>   
>>   	/* Number of user space windows opened in process mm_context */
>>   	atomic_t vas_windows;
>> diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h b/arch/powerpc/include/asm/book3s/64/tlbflush.h
>> index 0a7431e954c6..c70a82851f78 100644
>> --- a/arch/powerpc/include/asm/book3s/64/tlbflush.h
>> +++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h
>> @@ -16,8 +16,10 @@ enum {
>>   
>>   static inline bool mm_has_nmmu(struct mm_struct *mm)
>>   {
>> +#ifdef CONFIG_PPC_NMMU
>>   	if (unlikely(atomic_read(&mm->context.copros) > 0))
>>   		return true;
>> +#endif
>>   	return false;
>>   }
>>   
>> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
>> index d5821834dba9..53eac0cc4929 100644
>> --- a/arch/powerpc/include/asm/mmu_context.h
>> +++ b/arch/powerpc/include/asm/mmu_context.h
>> @@ -143,6 +143,7 @@ static inline void dec_mm_active_cpus(struct mm_struct *mm)
>>   	atomic_dec(&mm->context.active_cpus);
>>   }
>>   
>> +#ifdef CONFIG_PPC_NMMU
>>   static inline void mm_context_add_copro(struct mm_struct *mm)
>>   {
>>   	/*
>> @@ -187,6 +188,7 @@ static inline void mm_context_remove_copro(struct mm_struct *mm)
>>   			dec_mm_active_cpus(mm);
>>   	}
>>   }
>> +#endif
>>   
>>   /*
>>    * vas_windows counter shows number of open windows in the mm
>> @@ -218,8 +220,7 @@ static inline void mm_context_remove_vas_window(struct mm_struct *mm)
>>   #else
>>   static inline void inc_mm_active_cpus(struct mm_struct *mm) { }
>>   static inline void dec_mm_active_cpus(struct mm_struct *mm) { }
>> -static inline void mm_context_add_copro(struct mm_struct *mm) { }
>> -static inline void mm_context_remove_copro(struct mm_struct *mm) { }
> 
> Are you sure you can remove those ?
> If so, I think it belongs to another patch, I can't see how the new PPC_NMMU would allow that by itself.

Yeah possibly a separate patch. Nothing except 64s should compile such
code though, I think?

Thanks,
Nick
diff mbox series

Patch

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ae7391627054..4376bf4c53b4 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -888,6 +888,7 @@  config PPC_PROT_SAO_LPAR
 
 config PPC_COPRO_BASE
 	bool
+	select PPC_NMMU if PPC_BOOK3S_64
 
 config SCHED_SMT
 	bool "SMT (Hyperthreading) scheduler support"
diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
index 995bbcdd0ef8..07850d68a624 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu.h
@@ -103,8 +103,10 @@  typedef struct {
 	/* Number of bits in the mm_cpumask */
 	atomic_t active_cpus;
 
+#ifdef CONFIG_PPC_NMMU
 	/* Number of users of the external (Nest) MMU */
 	atomic_t copros;
+#endif
 
 	/* Number of user space windows opened in process mm_context */
 	atomic_t vas_windows;
diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h b/arch/powerpc/include/asm/book3s/64/tlbflush.h
index 0a7431e954c6..c70a82851f78 100644
--- a/arch/powerpc/include/asm/book3s/64/tlbflush.h
+++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h
@@ -16,8 +16,10 @@  enum {
 
 static inline bool mm_has_nmmu(struct mm_struct *mm)
 {
+#ifdef CONFIG_PPC_NMMU
 	if (unlikely(atomic_read(&mm->context.copros) > 0))
 		return true;
+#endif
 	return false;
 }
 
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
index d5821834dba9..53eac0cc4929 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -143,6 +143,7 @@  static inline void dec_mm_active_cpus(struct mm_struct *mm)
 	atomic_dec(&mm->context.active_cpus);
 }
 
+#ifdef CONFIG_PPC_NMMU
 static inline void mm_context_add_copro(struct mm_struct *mm)
 {
 	/*
@@ -187,6 +188,7 @@  static inline void mm_context_remove_copro(struct mm_struct *mm)
 			dec_mm_active_cpus(mm);
 	}
 }
+#endif
 
 /*
  * vas_windows counter shows number of open windows in the mm
@@ -218,8 +220,7 @@  static inline void mm_context_remove_vas_window(struct mm_struct *mm)
 #else
 static inline void inc_mm_active_cpus(struct mm_struct *mm) { }
 static inline void dec_mm_active_cpus(struct mm_struct *mm) { }
-static inline void mm_context_add_copro(struct mm_struct *mm) { }
-static inline void mm_context_remove_copro(struct mm_struct *mm) { }
+static inline bool mm_has_nmmu(struct mm_struct *mm) { return false; }
 #endif
 
 
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 7a5e8f4541e3..b4b04b3f98d1 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -191,6 +191,9 @@  config PPC_INDIRECT_MMIO
 config PPC_IO_WORKAROUNDS
 	bool
 
+config PPC_NMMU
+	bool
+
 source "drivers/cpufreq/Kconfig"
 
 menu "CPUIdle driver"
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
index 619b093a0657..145009d74457 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -36,6 +36,7 @@  config PPC_MEMTRACE
 config PPC_VAS
 	bool "IBM Virtual Accelerator Switchboard (VAS)"
 	depends on PPC_POWERNV && PPC_64K_PAGES
+	select PPC_NMMU
 	default y
 	help
 	  This enables support for IBM Virtual Accelerator Switchboard (VAS).