[Top] [All Lists]

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

Subject: [PATCH 2/2] MIPS: mipsregs.h: Make read_c0_prid use const accessor
From: James Hogan <>
Date: Mon, 11 Dec 2017 16:13:15 +0000
Authentication-results:; dmarc=none (p=none dis=none)
Authentication-results:; spf=none
Cc: James Hogan <>, Ralf Baechle <>, "Maciej W . Rozycki" <>
Dmarc-filter: OpenDMARC Filter v1.3.2 084B02192C
In-reply-to: <>
In-reply-to: <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
References: <>
References: <>
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 <>
Signed-off-by: James Hogan <>
Cc: Ralf Baechle <>
Cc: Maciej W. Rozycki <>
 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>