LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] powerpc/mm: Add mask of always present MMU features
@ 2020-10-12 15:39 Christophe Leroy
  2020-10-21 10:32 ` Christophe Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy @ 2020-10-12 15:39 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, linux-kernel

On the same principle as commit 773edeadf672 ("powerpc/mm: Add mask
of possible MMU features"), add mask for MMU features that are
always there in order to optimise out dead branches.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v2: Features must be anded with MMU_FTRS_POSSIBLE instead of ~0, otherwise
    MMU_FTRS_ALWAYS is ~0 when no #ifdef matches.
---
 arch/powerpc/include/asm/mmu.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 255a1837e9f7..64e7e7f7cda9 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -201,8 +201,30 @@ enum {
 		0,
 };
 
+enum {
+	MMU_FTRS_ALWAYS =
+#ifdef CONFIG_PPC_8xx
+		MMU_FTR_TYPE_8xx &
+#endif
+#ifdef CONFIG_40x
+		MMU_FTR_TYPE_40x &
+#endif
+#ifdef CONFIG_PPC_47x
+		MMU_FTR_TYPE_47x &
+#elif defined(CONFIG_44x)
+		MMU_FTR_TYPE_44x &
+#endif
+#if defined(CONFIG_E200) || defined(CONFIG_E500)
+		MMU_FTR_TYPE_FSL_E &
+#endif
+		MMU_FTRS_POSSIBLE,
+};
+
 static inline bool early_mmu_has_feature(unsigned long feature)
 {
+	if (MMU_FTRS_ALWAYS & feature)
+		return true;
+
 	return !!(MMU_FTRS_POSSIBLE & cur_cpu_spec->mmu_features & feature);
 }
 
@@ -231,6 +253,9 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
 	}
 #endif
 
+	if (MMU_FTRS_ALWAYS & feature)
+		return true;
+
 	if (!(MMU_FTRS_POSSIBLE & feature))
 		return false;
 
-- 
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc/mm: Add mask of always present MMU features
  2020-10-12 15:39 [PATCH v2] powerpc/mm: Add mask of always present MMU features Christophe Leroy
@ 2020-10-21 10:32 ` Christophe Leroy
  2020-10-21 14:25   ` Aneesh Kumar K.V
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy @ 2020-10-21 10:32 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, linux-kernel



Le 12/10/2020 à 17:39, Christophe Leroy a écrit :
> On the same principle as commit 773edeadf672 ("powerpc/mm: Add mask
> of possible MMU features"), add mask for MMU features that are
> always there in order to optimise out dead branches.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> v2: Features must be anded with MMU_FTRS_POSSIBLE instead of ~0, otherwise
>      MMU_FTRS_ALWAYS is ~0 when no #ifdef matches.

This is still not enough. For BOOK3S/32, MMU_FTRS_POSSIBLE is still too much.
We need a #ifdef CONFIG_PPC_BOOK3S_32 with 0.

Christophe

> ---
>   arch/powerpc/include/asm/mmu.h | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
> index 255a1837e9f7..64e7e7f7cda9 100644
> --- a/arch/powerpc/include/asm/mmu.h
> +++ b/arch/powerpc/include/asm/mmu.h
> @@ -201,8 +201,30 @@ enum {
>   		0,
>   };
>   
> +enum {
> +	MMU_FTRS_ALWAYS =
> +#ifdef CONFIG_PPC_8xx
> +		MMU_FTR_TYPE_8xx &
> +#endif
> +#ifdef CONFIG_40x
> +		MMU_FTR_TYPE_40x &
> +#endif
> +#ifdef CONFIG_PPC_47x
> +		MMU_FTR_TYPE_47x &
> +#elif defined(CONFIG_44x)
> +		MMU_FTR_TYPE_44x &
> +#endif
> +#if defined(CONFIG_E200) || defined(CONFIG_E500)
> +		MMU_FTR_TYPE_FSL_E &
> +#endif
> +		MMU_FTRS_POSSIBLE,
> +};
> +
>   static inline bool early_mmu_has_feature(unsigned long feature)
>   {
> +	if (MMU_FTRS_ALWAYS & feature)
> +		return true;
> +
>   	return !!(MMU_FTRS_POSSIBLE & cur_cpu_spec->mmu_features & feature);
>   }
>   
> @@ -231,6 +253,9 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
>   	}
>   #endif
>   
> +	if (MMU_FTRS_ALWAYS & feature)
> +		return true;
> +
>   	if (!(MMU_FTRS_POSSIBLE & feature))
>   		return false;
>   
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc/mm: Add mask of always present MMU features
  2020-10-21 10:32 ` Christophe Leroy
@ 2020-10-21 14:25   ` Aneesh Kumar K.V
  2020-10-21 16:37     ` Christophe Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2020-10-21 14:25 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman
  Cc: linuxppc-dev, linux-kernel

Christophe Leroy <christophe.leroy@csgroup.eu> writes:

> Le 12/10/2020 à 17:39, Christophe Leroy a écrit :
>> On the same principle as commit 773edeadf672 ("powerpc/mm: Add mask
>> of possible MMU features"), add mask for MMU features that are
>> always there in order to optimise out dead branches.
>> 
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> v2: Features must be anded with MMU_FTRS_POSSIBLE instead of ~0, otherwise
>>      MMU_FTRS_ALWAYS is ~0 when no #ifdef matches.
>
> This is still not enough. For BOOK3S/32, MMU_FTRS_POSSIBLE is still too much.
> We need a #ifdef CONFIG_PPC_BOOK3S_32 with 0.
>
> Christophe
>
>> ---
>>   arch/powerpc/include/asm/mmu.h | 25 +++++++++++++++++++++++++
>>   1 file changed, 25 insertions(+)
>> 
>> diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
>> index 255a1837e9f7..64e7e7f7cda9 100644
>> --- a/arch/powerpc/include/asm/mmu.h
>> +++ b/arch/powerpc/include/asm/mmu.h
>> @@ -201,8 +201,30 @@ enum {
>>   		0,
>>   };
>>   
>> +enum {
>> +	MMU_FTRS_ALWAYS =
>> +#ifdef CONFIG_PPC_8xx
>> +		MMU_FTR_TYPE_8xx &
>> +#endif
>> +#ifdef CONFIG_40x
>> +		MMU_FTR_TYPE_40x &
>> +#endif
>> +#ifdef CONFIG_PPC_47x
>> +		MMU_FTR_TYPE_47x &
>> +#elif defined(CONFIG_44x)
>> +		MMU_FTR_TYPE_44x &
>> +#endif
>> +#if defined(CONFIG_E200) || defined(CONFIG_E500)
>> +		MMU_FTR_TYPE_FSL_E &
>> +#endif
>> +		MMU_FTRS_POSSIBLE,
>> +};

Will it be simpler if we make it a #define like below?

#ifdef CONFIG_PPC_8XX
#define MMU_FTR_ALWAYS  MMU_FTR_TYPE_8XX & MMU_FTR_POSSIBLE
#endif



>> +
>>   static inline bool early_mmu_has_feature(unsigned long feature)
>>   {
>> +	if (MMU_FTRS_ALWAYS & feature)
>> +		return true;
>> +
>>   	return !!(MMU_FTRS_POSSIBLE & cur_cpu_spec->mmu_features & feature);
>>   }
>>   
>> @@ -231,6 +253,9 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
>>   	}
>>   #endif
>>   
>> +	if (MMU_FTRS_ALWAYS & feature)
>> +		return true;
>> +
>>   	if (!(MMU_FTRS_POSSIBLE & feature))
>>   		return false;
>>   
>> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc/mm: Add mask of always present MMU features
  2020-10-21 14:25   ` Aneesh Kumar K.V
@ 2020-10-21 16:37     ` Christophe Leroy
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe Leroy @ 2020-10-21 16:37 UTC (permalink / raw)
  To: Aneesh Kumar K.V, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman
  Cc: linuxppc-dev, linux-kernel



Le 21/10/2020 à 16:25, Aneesh Kumar K.V a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> 
>> Le 12/10/2020 à 17:39, Christophe Leroy a écrit :
>>> On the same principle as commit 773edeadf672 ("powerpc/mm: Add mask
>>> of possible MMU features"), add mask for MMU features that are
>>> always there in order to optimise out dead branches.
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> ---
>>> v2: Features must be anded with MMU_FTRS_POSSIBLE instead of ~0, otherwise
>>>       MMU_FTRS_ALWAYS is ~0 when no #ifdef matches.
>>
>> This is still not enough. For BOOK3S/32, MMU_FTRS_POSSIBLE is still too much.
>> We need a #ifdef CONFIG_PPC_BOOK3S_32 with 0.
>>
>> Christophe
>>
>>> ---
>>>    arch/powerpc/include/asm/mmu.h | 25 +++++++++++++++++++++++++
>>>    1 file changed, 25 insertions(+)
>>>
>>> diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
>>> index 255a1837e9f7..64e7e7f7cda9 100644
>>> --- a/arch/powerpc/include/asm/mmu.h
>>> +++ b/arch/powerpc/include/asm/mmu.h
>>> @@ -201,8 +201,30 @@ enum {
>>>    		0,
>>>    };
>>>    
>>> +enum {
>>> +	MMU_FTRS_ALWAYS =
>>> +#ifdef CONFIG_PPC_8xx
>>> +		MMU_FTR_TYPE_8xx &
>>> +#endif
>>> +#ifdef CONFIG_40x
>>> +		MMU_FTR_TYPE_40x &
>>> +#endif
>>> +#ifdef CONFIG_PPC_47x
>>> +		MMU_FTR_TYPE_47x &
>>> +#elif defined(CONFIG_44x)
>>> +		MMU_FTR_TYPE_44x &
>>> +#endif
>>> +#if defined(CONFIG_E200) || defined(CONFIG_E500)
>>> +		MMU_FTR_TYPE_FSL_E &
>>> +#endif
>>> +		MMU_FTRS_POSSIBLE,
>>> +};
> 
> Will it be simpler if we make it a #define like below?
> 
> #ifdef CONFIG_PPC_8XX
> #define MMU_FTR_ALWAYS  MMU_FTR_TYPE_8XX & MMU_FTR_POSSIBLE
> #endif

Yes you are right, it will be simpler, and consistant with CPU_FTR_ALWAYS which is partly set with 
defines after all.

Christophe

> 
> 
> 
>>> +
>>>    static inline bool early_mmu_has_feature(unsigned long feature)
>>>    {
>>> +	if (MMU_FTRS_ALWAYS & feature)
>>> +		return true;
>>> +
>>>    	return !!(MMU_FTRS_POSSIBLE & cur_cpu_spec->mmu_features & feature);
>>>    }
>>>    
>>> @@ -231,6 +253,9 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
>>>    	}
>>>    #endif
>>>    
>>> +	if (MMU_FTRS_ALWAYS & feature)
>>> +		return true;
>>> +
>>>    	if (!(MMU_FTRS_POSSIBLE & feature))
>>>    		return false;
>>>    
>>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 15:39 [PATCH v2] powerpc/mm: Add mask of always present MMU features Christophe Leroy
2020-10-21 10:32 ` Christophe Leroy
2020-10-21 14:25   ` Aneesh Kumar K.V
2020-10-21 16:37     ` Christophe Leroy

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git