linux-mips
[Top] [All Lists]

[PATCH 2/2] MIPS: mipsregs.h: Make read_c0_prid use const accessor

To: linux-mips@linux-mips.org
Subject: [PATCH 2/2] MIPS: mipsregs.h: Make read_c0_prid use const accessor
From: James Hogan <jhogan@kernel.org>
Date: Mon, 11 Dec 2017 16:13:15 +0000
Authentication-results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org
Authentication-results: mail.kernel.org; spf=none smtp.mailfrom=jhogan@kernel.org
Cc: James Hogan <jhogan@kernel.org>, Ralf Baechle <ralf@linux-mips.org>, "Maciej W . Rozycki" <macro@mips.com>
Dmarc-filter: OpenDMARC Filter v1.3.2 mail.kernel.org 084B02192C
In-reply-to: <cover.a0a46ee9377083562543020efa89accdc3760bbe.1513004494.git-series.jhogan@kernel.org>
In-reply-to: <cover.a0a46ee9377083562543020efa89accdc3760bbe.1513004494.git-series.jhogan@kernel.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.a0a46ee9377083562543020efa89accdc3760bbe.1513004494.git-series.jhogan@kernel.org>
References: <cover.a0a46ee9377083562543020efa89accdc3760bbe.1513004494.git-series.jhogan@kernel.org>
Sender: linux-mips-bounce@linux-mips.org
Make read_c0_prid() use the new constant accessor macros so that it can
potentially be optimised or removed by the compiler. This is
particularly important under virtualisation, where even with hardware
assisted virtualisation (VZ), access to the PRid register may need to be
emulated by the hypervisor.

In particular this helps eliminate the read of the PRid register in the
rather frequently called add_interrupt_randomness() (which calls into
arch/mips/include/asm/timex.h) when the prid is unused but the read
can't be removed due to the inline asm being marked __volatile__.

Reported-by: Yann LeDu <Yann.LeDu@imgtec.com>
Signed-off-by: James Hogan <jhogan@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Maciej W. Rozycki <macro@mips.com>
Cc: linux-mips@linux-mips.org
---
 arch/mips/include/asm/mipsregs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 74c931104714..aa6e36259297 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -1558,7 +1558,7 @@ do {                                                      
                \
 #define read_c0_epc()          __read_ulong_c0_register($14, 0)
 #define write_c0_epc(val)      __write_ulong_c0_register($14, 0, val)
 
-#define read_c0_prid()         __read_32bit_c0_register($15, 0)
+#define read_c0_prid()         __read_const_32bit_c0_register($15, 0)
 
 #define read_c0_cmgcrbase()    __read_ulong_c0_register($15, 3)
 
-- 
git-series 0.9.1

<Prev in Thread] Current Thread [Next in Thread>