Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4124212pxb; Mon, 8 Feb 2021 08:30:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0Sut8NrQHEGgPxBM03xNpRfYcd+MG6zr96GNm/454aPaXFUiPRALRY/ME6HJ0CXCBmi8x X-Received: by 2002:a17:906:4b42:: with SMTP id j2mr6792608ejv.544.1612801822571; Mon, 08 Feb 2021 08:30:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612801822; cv=none; d=google.com; s=arc-20160816; b=PKSQv0vYVSRSt6vx6LV0dUymdxlAa95vr9A4XSjUQQRCcvQGH74P1vqELOe9JWhnp4 j9EwiE10dyl+h01eGcamJgv/xH34igdF4ia/asirmXUkogWRuLFFxAOYQBET8CXMC2WP HS1fIK8ObWzk+U8U8M23TUhrblG8lV3cx2JQMil99IJpaTeP2Xdt5ddtdXF0lwqzF05D spUou8XBMyPUhzMnW6X/RbdRxjvZynzyn5s922yFUlHmebQ3x2p5jdbq/O7G/SAuQEzt kG0VyFKs6Jm2gIWXak9Bg+S+wspS9Mim3ACwB4AGNV/kPUBNHrc+370Vps42Wwlf5Vvk 5slw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:references:in-reply-to :message-id; bh=DsvSZtCtdKe9dC7aefdwA8au/t97ygrtd4VheClKUss=; b=kjl+BWXfjGgftIhvuf4zr/PGzLWFX+oUtUWhdr+RFqtJtLhcLL+oeHb6Q6xotoPDoB UlWdiXFYt0aWx6qqz7TP4bPZwmQc+JPK4Sqs1Nqjbdx6Zili5/e4EXvesxFkqjNAALEy 66p9khkualei5G+thkSO+BrxkS2mBbVjaDr8HZBbbkb/IYEz9gTyyPR5h1bkbSB+Bbn+ VrqUcG27sTmjetAVLN2U9kZrEyTeSAENkgiZccpIk2U9dJ0nOj3CNXeV0JTPSCnBVbHu H/HsZLvMOWqBw9jRJSJ5SCWtRLf47A1jTVtG0nGC7iXkyzTDKqevC4B0VPVFJ2CdvFpp Ty3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si11999094ejh.668.2021.02.08.08.29.56; Mon, 08 Feb 2021 08:30:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234337AbhBHQ1O (ORCPT + 99 others); Mon, 8 Feb 2021 11:27:14 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:17643 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233375AbhBHPM6 (ORCPT ); Mon, 8 Feb 2021 10:12:58 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4DZ8bJ6LVcz9tx8b; Mon, 8 Feb 2021 16:10:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id MZEqW3ISDnPO; Mon, 8 Feb 2021 16:10:20 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4DZ8bJ4lbmz9ttF8; Mon, 8 Feb 2021 16:10:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 13E0D8B7B3; Mon, 8 Feb 2021 16:10:26 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id kJ7uvk_1k7Rg; Mon, 8 Feb 2021 16:10:25 +0100 (CET) Received: from po16121vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9D9BF8B7B2; Mon, 8 Feb 2021 16:10:25 +0100 (CET) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 93BDC6733E; Mon, 8 Feb 2021 15:10:25 +0000 (UTC) Message-Id: <0e290372a0e7dc2ae657b4a01aec85f8de7fdf77.1612796617.git.christophe.leroy@csgroup.eu> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v5 06/22] powerpc/irq: Rework helpers that manipulate MSR[EE/RI] To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , npiggin@gmail.com, msuchanek@suse.de Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 8 Feb 2021 15:10:25 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation of porting PPC32 to C syscall entry/exit, rewrite the following helpers as static inline functions and add support for PPC32 in them: __hard_irq_enable() __hard_irq_disable() __hard_EE_RI_disable() __hard_RI_enable() Then use them in PPC32 version of arch_local_irq_disable() and arch_local_irq_enable() to avoid code duplication. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/hw_irq.h | 75 +++++++++++++++++++++---------- arch/powerpc/include/asm/reg.h | 1 + 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index ed0c3b049dfd..4739f61e632c 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -50,6 +50,55 @@ #ifndef __ASSEMBLY__ +static inline void __hard_irq_enable(void) +{ + if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x)) + wrtee(MSR_EE); + else if (IS_ENABLED(CONFIG_PPC_8xx)) + wrtspr(SPRN_EIE); + else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) + __mtmsrd(MSR_EE | MSR_RI, 1); + else + mtmsr(mfmsr() | MSR_EE); +} + +static inline void __hard_irq_disable(void) +{ + if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x)) + wrtee(0); + else if (IS_ENABLED(CONFIG_PPC_8xx)) + wrtspr(SPRN_EID); + else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) + __mtmsrd(MSR_RI, 1); + else + mtmsr(mfmsr() & ~MSR_EE); +} + +static inline void __hard_EE_RI_disable(void) +{ + if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x)) + wrtee(0); + else if (IS_ENABLED(CONFIG_PPC_8xx)) + wrtspr(SPRN_NRI); + else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) + __mtmsrd(0, 1); + else + mtmsr(mfmsr() & ~(MSR_EE | MSR_RI)); +} + +static inline void __hard_RI_enable(void) +{ + if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x)) + return; + + if (IS_ENABLED(CONFIG_PPC_8xx)) + wrtspr(SPRN_EID); + else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64)) + __mtmsrd(MSR_RI, 1); + else + mtmsr(mfmsr() | MSR_RI); +} + #ifdef CONFIG_PPC64 #include @@ -212,18 +261,6 @@ static inline bool arch_irqs_disabled(void) #endif /* CONFIG_PPC_BOOK3S */ -#ifdef CONFIG_PPC_BOOK3E -#define __hard_irq_enable() wrtee(MSR_EE) -#define __hard_irq_disable() wrtee(0) -#define __hard_EE_RI_disable() wrtee(0) -#define __hard_RI_enable() do { } while (0) -#else -#define __hard_irq_enable() __mtmsrd(MSR_EE|MSR_RI, 1) -#define __hard_irq_disable() __mtmsrd(MSR_RI, 1) -#define __hard_EE_RI_disable() __mtmsrd(0, 1) -#define __hard_RI_enable() __mtmsrd(MSR_RI, 1) -#endif - #define hard_irq_disable() do { \ unsigned long flags; \ __hard_irq_disable(); \ @@ -322,22 +359,12 @@ static inline unsigned long arch_local_irq_save(void) static inline void arch_local_irq_disable(void) { - if (IS_ENABLED(CONFIG_BOOKE)) - wrtee(0); - else if (IS_ENABLED(CONFIG_PPC_8xx)) - wrtspr(SPRN_EID); - else - mtmsr(mfmsr() & ~MSR_EE); + __hard_irq_disable(); } static inline void arch_local_irq_enable(void) { - if (IS_ENABLED(CONFIG_BOOKE)) - wrtee(MSR_EE); - else if (IS_ENABLED(CONFIG_PPC_8xx)) - wrtspr(SPRN_EIE); - else - mtmsr(mfmsr() | MSR_EE); + __hard_irq_enable(); } 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 c5a3e856191c..bc4305ba00d0 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1375,6 +1375,7 @@ #define mtmsr(v) asm volatile("mtmsr %0" : \ : "r" ((unsigned long)(v)) \ : "memory") +#define __mtmsrd(v, l) BUILD_BUG() #define __MTMSR "mtmsr" #endif -- 2.25.0