linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Paul Mackerras <paulus@samba.org>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/2] powerpc: cleanup hw_irq.h
Date: Tue, 27 Aug 2019 22:48:24 +1000	[thread overview]
Message-ID: <1566909844.x4jee1jjda.astroid@bobo.none> (raw)
In-Reply-To: <81f39fa06ae582f4a783d26abd2b310204eba8f4.1566893505.git.christophe.leroy@c-s.fr>

Christophe Leroy's on August 27, 2019 6:13 pm:
> SET_MSR_EE() is just use in this file and doesn't provide
> any added value compared to mtmsr(). Drop it.
> 
> Add macros to use wrtee/wrteei insn.
> 
> Replace #ifdefs by IS_ENABLED()
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/include/asm/hw_irq.h | 57 ++++++++++++++++++---------------------
>  arch/powerpc/include/asm/reg.h    |  2 ++
>  2 files changed, 28 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
> index 32a18f2f49bc..c25d57f25a8b 100644
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
> @@ -226,8 +226,8 @@ static inline bool arch_irqs_disabled(void)
>  #endif /* CONFIG_PPC_BOOK3S */
>  
>  #ifdef CONFIG_PPC_BOOK3E
> -#define __hard_irq_enable()	asm volatile("wrteei 1" : : : "memory")
> -#define __hard_irq_disable()	asm volatile("wrteei 0" : : : "memory")
> +#define __hard_irq_enable()	wrteei(1)
> +#define __hard_irq_disable()	wrteei(0)
>  #else
>  #define __hard_irq_enable()	__mtmsrd(MSR_EE|MSR_RI, 1)
>  #define __hard_irq_disable()	__mtmsrd(MSR_RI, 1)
> @@ -280,8 +280,6 @@ extern void force_external_irq_replay(void);
>  
>  #else /* CONFIG_PPC64 */
>  
> -#define SET_MSR_EE(x)	mtmsr(x)
> -
>  static inline unsigned long arch_local_save_flags(void)
>  {
>  	return mfmsr();
> @@ -289,47 +287,44 @@ static inline unsigned long arch_local_save_flags(void)
>  
>  static inline void arch_local_irq_restore(unsigned long flags)
>  {
> -#if defined(CONFIG_BOOKE)
> -	asm volatile("wrtee %0" : : "r" (flags) : "memory");
> -#else
> -	mtmsr(flags);
> -#endif
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrtee(flags);
> +	else
> +		mtmsr(flags);
>  }
>  
>  static inline unsigned long arch_local_irq_save(void)
>  {
>  	unsigned long flags = arch_local_save_flags();
> -#ifdef CONFIG_BOOKE
> -	asm volatile("wrteei 0" : : : "memory");
> -#elif defined(CONFIG_PPC_8xx)
> -	wrtspr(SPRN_EID);
> -#else
> -	SET_MSR_EE(flags & ~MSR_EE);
> -#endif
> +
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrteei(0);
> +	else if (IS_ENABLED(CONFIG_PPC_8xx))
> +		wrtspr(SPRN_EID);
> +	else
> +		mtmsr(flags & ~MSR_EE);
> +
>  	return flags;
>  }
>  
>  static inline void arch_local_irq_disable(void)
>  {
> -#ifdef CONFIG_BOOKE
> -	asm volatile("wrteei 0" : : : "memory");
> -#elif defined(CONFIG_PPC_8xx)
> -	wrtspr(SPRN_EID);
> -#else
> -	arch_local_irq_save();
> -#endif
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrteei(0);
> +	else if (IS_ENABLED(CONFIG_PPC_8xx))
> +		wrtspr(SPRN_EID);
> +	else
> +		mtmsr(mfmsr() & ~MSR_EE);
>  }
>  
>  static inline void arch_local_irq_enable(void)
>  {
> -#ifdef CONFIG_BOOKE
> -	asm volatile("wrteei 1" : : : "memory");
> -#elif defined(CONFIG_PPC_8xx)
> -	wrtspr(SPRN_EIE);
> -#else
> -	unsigned long msr = mfmsr();
> -	SET_MSR_EE(msr | MSR_EE);
> -#endif
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrteei(1);
> +	else if (IS_ENABLED(CONFIG_PPC_8xx))
> +		wrtspr(SPRN_EIE);
> +	else
> +		mtmsr(mfmsr() | MSR_EE);
>  }
>  
>  static inline bool arch_irqs_disabled_flags(unsigned long flags)
> diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
> index b17ee25df226..04896dd09455 100644
> --- a/arch/powerpc/include/asm/reg.h
> +++ b/arch/powerpc/include/asm/reg.h
> @@ -1361,6 +1361,8 @@ static inline void mtmsr_isync(unsigned long val)
>  #endif
>  #define wrtspr(rn)	asm volatile("mtspr " __stringify(rn) ",0" : \
>  				     : : "memory")
> +#define wrtee(val)	asm volatile("wrtee %0" : : "r" (val) : "memory")
> +#define wrteei(val)	asm volatile("wrteei %0" : : "i" (val) : "memory")

Can you implement just one macro that uses __builtin_constant_p to 
select between the imm and reg versions? I forgot if there's some
corner cases that prevent that working with inline asm i constraints.

Otherwise, looks like a nice cleanup.

Thanks,
Nick

  reply	other threads:[~2019-08-27 12:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27  8:13 [PATCH 1/2] powerpc: permanently include 8xx registers in reg.h Christophe Leroy
2019-08-27  8:13 ` [PATCH 2/2] powerpc: cleanup hw_irq.h Christophe Leroy
2019-08-27 12:48   ` Nicholas Piggin [this message]
2019-08-27 17:29     ` Segher Boessenkool
2019-08-27 17:36       ` Christophe Leroy
2019-08-27 18:26         ` Segher Boessenkool
2019-08-27 18:33           ` Christophe Leroy
2019-08-27 19:11             ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1566909844.x4jee1jjda.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).