From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Jonas Gorski <jonas.gorski@gmail.com>,
"Maciej W. Rozycki" <macro@orcam.me.uk>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH v2 1/4] MIPS: Introduce WAR_4KC_LLSC config option
Date: Wed, 12 Jun 2024 10:53:29 +0100 [thread overview]
Message-ID: <20240612-mips-llsc-v2-1-a42bd5562bdb@flygoat.com> (raw)
In-Reply-To: <20240612-mips-llsc-v2-0-a42bd5562bdb@flygoat.com>
WAR_4KC_LLSC is used to control workaround of 4KC LLSC issue
that affects 4Kc up to version 0.9.
Early ath25 chips are known to be affected.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
v2:
- Improve error message, taint kernel on error
- Don't override cpu_has_llsc if WAR_4KC_LLSC is not selected,
cpu-probe logic can handle it, there is no need to mess around
ifdef as suggested in previous review comments as WAR_4KC_LLSC
is gated by SOC_AR5312.
---
arch/mips/Kconfig | 6 ++++++
arch/mips/include/asm/cpu.h | 1 +
arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h | 6 ++----
arch/mips/kernel/cpu-probe.c | 9 +++++++++
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1236ea122061..8ac467c1f9c8 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -221,6 +221,7 @@ config ATH25
select SYS_SUPPORTS_BIG_ENDIAN
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_HAS_EARLY_PRINTK
+ select WAR_4KC_LLSC if SOC_AR5312
help
Support for Atheros AR231x and Atheros AR531x based boards
@@ -2543,6 +2544,11 @@ config WAR_ICACHE_REFILLS
config WAR_R10000_LLSC
bool
+# On 4Kc up to version 0.9 (PRID_REV < 1) there is a bug that may cause llsc
+# sequences to deadlock.
+config WAR_4KC_LLSC
+ bool
+
# 34K core erratum: "Problems Executing the TLBR Instruction"
config WAR_MIPS34K_MISSED_ITLB
bool
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index ecb9854cb432..84bb1931a8b4 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -247,6 +247,7 @@
#define PRID_REV_VR4122 0x0070
#define PRID_REV_VR4181A 0x0070 /* Same as VR4122 */
#define PRID_REV_VR4130 0x0080
+#define PRID_REV_4KC_V1_0 0x0001
#define PRID_REV_34K_V1_0_2 0x0022
#define PRID_REV_LOONGSON1B 0x0020
#define PRID_REV_LOONGSON1C 0x0020 /* Same as Loongson-1B */
diff --git a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h
index ec3604c44ef2..4cf3d1ffba1a 100644
--- a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h
@@ -24,14 +24,12 @@
#define cpu_has_counter 1
#define cpu_has_ejtag 1
-#if !defined(CONFIG_SOC_AR5312)
-# define cpu_has_llsc 1
-#else
/*
* The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the
* ll/sc instructions.
*/
-# define cpu_has_llsc 0
+#if !defined(WAR_4KC_LLSC)
+# define cpu_has_llsc 1
#endif
#define cpu_has_mips16 0
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index bda7f193baab..ff2905f59f2a 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -152,6 +152,15 @@ static inline void check_errata(void)
struct cpuinfo_mips *c = ¤t_cpu_data;
switch (current_cpu_type()) {
+ case CPU_4KC:
+ if ((c->processor_id & PRID_REV_MASK) < PRID_REV_4KC_V1_0) {
+ c->options &= ~MIPS_CPU_LLSC;
+ if (cpu_has_llsc) {
+ pr_crit("CPU has LLSC erratum, but cpu_has_llsc is force enabled!\n");
+ add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
+ }
+ }
+ break;
case CPU_34K:
/*
* Erratum "RPS May Cause Incorrect Instruction Execution"
--
2.43.0
next prev parent reply other threads:[~2024-06-12 9:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 9:53 [PATCH v2 0/4] MIPS: Enable ARCH_SUPPORTS_ATOMIC_RMW Jiaxun Yang
2024-06-12 9:53 ` Jiaxun Yang [this message]
2024-06-12 9:53 ` [PATCH v2 2/4] MIPS: Introduce config options for LLSC availability Jiaxun Yang
2024-06-20 16:06 ` Thomas Bogendoerfer
2024-06-20 16:30 ` Jiaxun Yang
2024-06-20 17:41 ` Thomas Bogendoerfer
2024-06-21 0:00 ` Maciej W. Rozycki
2024-06-21 10:45 ` Jiaxun Yang
2024-06-21 13:57 ` Maciej W. Rozycki
2024-06-21 15:21 ` Jiaxun Yang
2024-06-21 17:40 ` Maciej W. Rozycki
2024-06-21 20:31 ` Thomas Bogendoerfer
2024-06-12 9:53 ` [PATCH v2 3/4] MIPS: Select ARCH_SUPPORTS_ATOMIC_RMW when possible Jiaxun Yang
2024-06-12 9:53 ` [PATCH v2 4/4] MIPS: Select ARCH_HAVE_NMI_SAFE_CMPXCHG " Jiaxun Yang
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=20240612-mips-llsc-v2-1-a42bd5562bdb@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=jonas.gorski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=tsbogend@alpha.franken.de \
/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