Message ID | 20230519164753.72065-2-jiaxun.yang@flygoat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1374524vqo; Fri, 19 May 2023 09:50:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DiIHMop2xPVKfGfTxgG8iyAv1FrsX75qdz/WAMsomHSpV2C4fx/1hMNEsuLhXI32YXtG8 X-Received: by 2002:a05:6a00:2e98:b0:64d:3e99:83a5 with SMTP id fd24-20020a056a002e9800b0064d3e9983a5mr1881294pfb.26.1684515004580; Fri, 19 May 2023 09:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684515004; cv=none; d=google.com; s=arc-20160816; b=ib6w84OMQpg1c7Lamms51asmNF0j1544laqkq8S4HJiZCt+No7FX8NRZ6IMj/RT4Lo ctc/ZiVnHdPsGmplmCqqgwNPlFTc1E7kSUAqQt7hqqEFXu02gnFsNJ5iR1NMKusF95xF qiHcPQxnhZWd5FgOMhi9DNUhA2byETNmQgTK+ahGdBBX/sXoKp7v8uu4tJw7n6AMWTsW saP3PPvISWHrp5K8PgzICGWoTjmK+/bKhKMWv9qjrPw2YYosnuLxJDzbyMWD42huYIEc 99Bwgtwo8mwN4iZXF/WxVxx1iL/WVy2CnevcbWQ7EtNxb4vsvRwbIK8I3aSTXGDGlR56 q0MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=F3XQUAgQCOlN5uBkLtjyaKBz6CFsqhjFQGgXG6jbvic=; b=RCBEwq32A4CAaTe8L8ar85bhM3R2rOEp8SC91D/Q6a2fe6RpBdK8sILmt6/DhjYsaA r5c4/wbeXDmbOe1S5O3v8l+cZYOMyP2BlGzeYYQK2dzCddrxKX88wZmJqbnMgrG6wemI F88kR1i63HThNT5YjqYdLTDiINYXNP7fr308z3IHUWF5zeF0QfC6dhUY34jUKcnRwFHd 3hM3RjhMTz7RvTcOIr9jY1d7+LxDIp3FwS72hUzfu4Pgi4ltpmnVdmhmfOIwDmIskjkl IQhLEgXXilhcnXomQglAAOaSLNhhbQsdwxU8wKiRlZJl7HNhJnDpZVMCFtweHxP1hTUb prxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm2 header.b=Kc8WU7T8; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Harxxgnx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y81-20020a626454000000b00647e5f1d563si2738518pfb.387.2023.05.19.09.49.49; Fri, 19 May 2023 09:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm2 header.b=Kc8WU7T8; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Harxxgnx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbjESQtD (ORCPT <rfc822;wlfightup@gmail.com> + 99 others); Fri, 19 May 2023 12:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjESQsp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 19 May 2023 12:48:45 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D475E10FA; Fri, 19 May 2023 09:48:16 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 9B3C43200935; Fri, 19 May 2023 12:48:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 19 May 2023 12:48:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1684514893; x= 1684601293; bh=F3XQUAgQCOlN5uBkLtjyaKBz6CFsqhjFQGgXG6jbvic=; b=K c8WU7T8IkBvsJCSF/9uQ7LT/WB532t+YlDO+jchAXzlyhtdz8C3tQwubUgF+StP2 Cu95oiJfD7CO8oUELxmprroaS1CokTggSdw8/4UREl0R1R9Bq+dCCZGXYhbjIve6 BHJyzXj7kx7efUbZNtHnD3sB9XqpZg7U0ADrJI0jXMfoFfQNjXkA+JZ/+U3NibGl V2i+JelcxBQ0ehS1eqxugCR4MpFhet2Q9oLmwNLuISyQgn+WXp8gRCE2Nu5SCIwX o1vNZwQPdeNZ4Zn3YamanLYFaQAFsrWeISVqRA57FwGHPv8X8md7BmdI1jBLBqe2 gprhxBDAVTdr2Ft55NJyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1684514893; x= 1684601293; bh=F3XQUAgQCOlN5uBkLtjyaKBz6CFsqhjFQGgXG6jbvic=; b=H arxxgnxMHSrlbj9no4qixqDtlz+Er+fOSZuO0UcSue2pLGf96sEQhympqL8zZBb3 4iVpqbVEwP+EYUzDs0HZglndCIW5QuazTgFAwBt0/e9h+4MDy4ooIDRNxPrhe4QA qOLLf5IR+4pnoNQf2yEJUlsDhEaByt33u/V5+kgd/jNm57Ugv7ml8lb39py1TJsb hyfanwD8xzMXh6GqTt9QMoJkol+XkuZAbJeiAQbN/XtNdIgZ0U9Lc2JZBp4Prxwp kvAqr+pPtCDfoXmm/6D/L7y9aC/+eLUBsvBEV6fxRyqkZOc5FW+nOJnBLl7xeM+g YnJ7dpWUOCvjiYi8cF+oA== X-ME-Sender: <xms:TahnZCmNDv65y6eHYahQkXZydy60Eskxl7ElsTvT5-95EwAiYVomkw> <xme:TahnZJ0MxzaTFgf9y-5IjPqMHT3dOYXfzHH-kbWHm0Ig6eeL5LHbF0wawcoPoz_6U BX8Q9TJ7S-r6cVq0Sc> X-ME-Received: <xmr:TahnZArFMeavcUb-xecYHwDP9DKzVmJGj5Mhh-NqM86b6ZDYkcwRV-exUipt> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeihedguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestd ekredtredttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigr nhhgsehflhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefledufeehgedvue dvvdegkefgvddttedtleeiiefhgeetudegkefhvdfhjeeftdenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflh ihghhorghtrdgtohhm X-ME-Proxy: <xmx:TahnZGlNU1CRXCqo2zEcE_V-O-0NRybvYjY-X61tXCPAkb89OvGkyw> <xmx:TahnZA0QFLJOzNZOf_QgR8JJ_e3HaeRDPfM7dce1IW2d6i1yD3RWgA> <xmx:TahnZNsf2WvqTwXiH1L8dGSyX2LBR-bBfpi86ov-1WLqakvLWe3FYA> <xmx:TahnZOAxOozfzEv86nu-Yh_A3ew_z9V8Wdw4Z6Pl_Zwau0W8uHjYBA> Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 19 May 2023 12:48:12 -0400 (EDT) From: Jiaxun Yang <jiaxun.yang@flygoat.com> To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, Jiaxun Yang <jiaxun.yang@flygoat.com> Subject: [PATCH 1/3] MIPS: Introduce WAR_4KC_LLSC config option Date: Fri, 19 May 2023 17:47:51 +0100 Message-Id: <20230519164753.72065-2-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230519164753.72065-1-jiaxun.yang@flygoat.com> References: <20230519164753.72065-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766342005335904345?= X-GMAIL-MSGID: =?utf-8?q?1766342005335904345?= |
Series |
MIPS: Enable ARCH_SUPPORTS_ATOMIC_RMW
|
|
Commit Message
Jiaxun Yang
May 19, 2023, 4:47 p.m. UTC
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>
---
arch/mips/Kconfig | 6 ++++++
arch/mips/include/asm/cpu.h | 1 +
arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h | 2 +-
arch/mips/kernel/cpu-probe.c | 7 +++++++
4 files changed, 15 insertions(+), 1 deletion(-)
Comments
On Fri, 19 May 2023, Jiaxun Yang wrote: > diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c > index 6d15a398d389..fd452e68cd90 100644 > --- a/arch/mips/kernel/cpu-probe.c > +++ b/arch/mips/kernel/cpu-probe.c > @@ -152,6 +152,13 @@ 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 (!IS_ENABLED(CONFIG_WAR_4K_LLSC)) > + pr_err("CPU have LLSC errata, please enable CONFIG_WAR_4K_LLSC"); Given the circumstances I think this should be `panic'. You don't want to continue with a system that can randomly lock up. Also "CPU has LLSC erratum, [...]" as both are singular. Maciej
> 2023年5月19日 21:23,Maciej W. Rozycki <macro@orcam.me.uk> 写道: > > On Fri, 19 May 2023, Jiaxun Yang wrote: > >> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c >> index 6d15a398d389..fd452e68cd90 100644 >> --- a/arch/mips/kernel/cpu-probe.c >> +++ b/arch/mips/kernel/cpu-probe.c >> @@ -152,6 +152,13 @@ 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 (!IS_ENABLED(CONFIG_WAR_4K_LLSC)) >> + pr_err("CPU have LLSC errata, please enable CONFIG_WAR_4K_LLSC"); > > Given the circumstances I think this should be `panic'. You don't want > to continue with a system that can randomly lock up. I just checked how other architectures handle such situation, it seems like TAINT_CPU_OUT_OF_SPEC is a better option. Panic in cpu_probe can be frustrating for users as it is earlier than initialisation of consoles so the panic message can never be read by users. > > Also "CPU has LLSC erratum, [...]" as both are singular. Thanks for the tip :-) - Jiaxun > > Maciej
On Fri, 19 May 2023, Jiaxun Yang wrote: > > Given the circumstances I think this should be `panic'. You don't want > > to continue with a system that can randomly lock up. > > I just checked how other architectures handle such situation, it seems like > TAINT_CPU_OUT_OF_SPEC is a better option. That can be easily missed, just as a random message in the kernel log, even at a high priority, and LOGLEVEL_ERR is not particularly high even. For a system configuration that qualifies as not usable for any practical purpose I find this approach leaving something to desire. > Panic in cpu_probe can be frustrating for users as it is earlier than initialisation > of consoles so the panic message can never be read by users. Is there no early console support for the systems affected? Maciej
Hi, On Fri, 19 May 2023 at 18:49, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote: > > 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> > --- > arch/mips/Kconfig | 6 ++++++ > arch/mips/include/asm/cpu.h | 1 + > arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h | 2 +- > arch/mips/kernel/cpu-probe.c | 7 +++++++ > 4 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig > index 30e90a2d53f4..354d033364ad 100644 > --- a/arch/mips/Kconfig > +++ b/arch/mips/Kconfig > @@ -230,6 +230,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 Shouldn't this be "if SOC_AR5312"? Though since you are adding runtime detection/correction below, I wonder if this would be really needed as an extra symbol, and rather use the later introduced (CPU_MAY_HAVE_LLSC) directly. Or rather have select "CPU_HAS_LLSC if !SOC_AR5312" in that case. > help > Support for Atheros AR231x and Atheros AR531x based boards > > @@ -2544,6 +2545,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..5df292b1ff04 100644 > --- a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h > +++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h > @@ -24,7 +24,7 @@ > #define cpu_has_counter 1 > #define cpu_has_ejtag 1 > > -#if !defined(CONFIG_SOC_AR5312) > +#if !defined(WAR_4KC_LLSC) > # define cpu_has_llsc 1 since the #else path defines cpu_has_llsc as 0, it means that kernels targeting both SoCs would force llsc to be unavailable (not introduced by you). So this probably should be rather this: #if !defined(CONFIG_SOC_AR5312) #define cpu_has_llsc 1 #else if !defined(CONFIG_SOC_AR5312) #define cpu_has_llsc 0 #endif (so if only one is enabled, set it accordingly, else let runtime detection handle it). > #else > /* > diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c > index 6d15a398d389..fd452e68cd90 100644 > --- a/arch/mips/kernel/cpu-probe.c > +++ b/arch/mips/kernel/cpu-probe.c > @@ -152,6 +152,13 @@ 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 (!IS_ENABLED(CONFIG_WAR_4K_LLSC)) > + pr_err("CPU have LLSC errata, please enable CONFIG_WAR_4K_LLSC"); > + } And then you don't need this error message at all, since then cpu_has_llsc is 0 or follows MIPS_CPU_LLSC, unless you disabled support for the relevant SoC, and then you'll have bigger problems anyway. Regards, Jonas
> 2023年5月22日 19:40,Jonas Gorski <jonas.gorski@gmail.com> 写道: > > Hi, > > On Fri, 19 May 2023 at 18:49, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote: >> >> 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> >> --- >> arch/mips/Kconfig | 6 ++++++ >> arch/mips/include/asm/cpu.h | 1 + >> arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h | 2 +- >> arch/mips/kernel/cpu-probe.c | 7 +++++++ >> 4 files changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig >> index 30e90a2d53f4..354d033364ad 100644 >> --- a/arch/mips/Kconfig >> +++ b/arch/mips/Kconfig >> @@ -230,6 +230,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 > > Shouldn't this be "if SOC_AR5312"? Ah sorry, I misread the original code. > > Though since you are adding runtime detection/correction below, I > wonder if this would be really needed as an extra symbol, and rather > use the later introduced (CPU_MAY_HAVE_LLSC) directly. I bet it’s better to have a symbol just for tracking errata. So we can easily know if SoC is affected by a errata and have some extra documentation. > > Or rather have select "CPU_HAS_LLSC if !SOC_AR5312" in that case. > >> help >> Support for Atheros AR231x and Atheros AR531x based boards >> >> @@ -2544,6 +2545,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..5df292b1ff04 100644 >> --- a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h >> +++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h >> @@ -24,7 +24,7 @@ >> #define cpu_has_counter 1 >> #define cpu_has_ejtag 1 >> >> -#if !defined(CONFIG_SOC_AR5312) >> +#if !defined(WAR_4KC_LLSC) >> # define cpu_has_llsc 1 > > since the #else path defines cpu_has_llsc as 0, it means that kernels > targeting both SoCs would force llsc to be unavailable (not introduced > by you). I’m a little bit confused. The logic seems very clear to me: If a SoC is not affected by WAR_4KC_LLSC, then wire cpu_has_llsc to 1, else wire it to 0. It matches my intention. > > So this probably should be rather this: > > #if !defined(CONFIG_SOC_AR5312) > #define cpu_has_llsc 1 > #else if !defined(CONFIG_SOC_AR5312) > #define cpu_has_llsc 0 > #endif The condition on if leg seems same to the else leg, I’m not sure if it can ever work. > > (so if only one is enabled, set it accordingly, else let runtime > detection handle it). > >> #else >> /* >> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c >> index 6d15a398d389..fd452e68cd90 100644 >> --- a/arch/mips/kernel/cpu-probe.c >> +++ b/arch/mips/kernel/cpu-probe.c >> @@ -152,6 +152,13 @@ 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 (!IS_ENABLED(CONFIG_WAR_4K_LLSC)) >> + pr_err("CPU have LLSC errata, please enable CONFIG_WAR_4K_LLSC"); >> + } > > And then you don't need this error message at all, since then > cpu_has_llsc is 0 or follows MIPS_CPU_LLSC, unless you disabled > support for the relevant SoC, and then you'll have bigger problems > anyway. The problem is as per MIPS the affected IP core was shipped to multiple customers This error message can cover other SoCs that potentially using this core. Thanks - Jiaxun > > Regards, > Jonas
> 2023年5月19日 23:51,Maciej W. Rozycki <macro@orcam.me.uk> 写道: > > On Fri, 19 May 2023, Jiaxun Yang wrote: > >>> Given the circumstances I think this should be `panic'. You don't want >>> to continue with a system that can randomly lock up. >> >> I just checked how other architectures handle such situation, it seems like >> TAINT_CPU_OUT_OF_SPEC is a better option. > > That can be easily missed, just as a random message in the kernel log, > even at a high priority, and LOGLEVEL_ERR is not particularly high even. > For a system configuration that qualifies as not usable for any practical > purpose I find this approach leaving something to desire. Just found another reason that not to panic in such situation when I’m playing around QEMU. Emulation software like QEMU, mipssim, OVPSim, IASIM tends use base PRID of a core. It can be more than annoying for people to find kernel suddenly won’t boot on their simulator. > >> Panic in cpu_probe can be frustrating for users as it is earlier than initialisation >> of consoles so the panic message can never be read by users. > > Is there no early console support for the systems affected? For routers it’s very common that serial port available to user is not the same one as we hooked for earlyprintk. For QEMU users potentially using graphic interface, initialisation of DRM/FBDEV comes very later. Thanks - Jiaxun > > Maciej
On Mon, 22 May 2023 at 22:38, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote: > > > > > 2023年5月22日 19:40,Jonas Gorski <jonas.gorski@gmail.com> 写道: > > > > Hi, > > > > On Fri, 19 May 2023 at 18:49, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote: > >> > >> 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> > >> --- > >> arch/mips/Kconfig | 6 ++++++ > >> arch/mips/include/asm/cpu.h | 1 + > >> arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h | 2 +- > >> arch/mips/kernel/cpu-probe.c | 7 +++++++ > >> 4 files changed, 15 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig > >> index 30e90a2d53f4..354d033364ad 100644 > >> --- a/arch/mips/Kconfig > >> +++ b/arch/mips/Kconfig > >> @@ -230,6 +230,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 > > > > Shouldn't this be "if SOC_AR5312"? > > Ah sorry, I misread the original code. > > > > > Though since you are adding runtime detection/correction below, I > > wonder if this would be really needed as an extra symbol, and rather > > use the later introduced (CPU_MAY_HAVE_LLSC) directly. > > I bet it’s better to have a symbol just for tracking errata. So we can easily know > if SoC is affected by a errata and have some extra documentation. > > > > > Or rather have select "CPU_HAS_LLSC if !SOC_AR5312" in that case. > > > >> help > >> Support for Atheros AR231x and Atheros AR531x based boards > >> > >> @@ -2544,6 +2545,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..5df292b1ff04 100644 > >> --- a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h > >> +++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h > >> @@ -24,7 +24,7 @@ > >> #define cpu_has_counter 1 > >> #define cpu_has_ejtag 1 > >> > >> -#if !defined(CONFIG_SOC_AR5312) > >> +#if !defined(WAR_4KC_LLSC) > >> # define cpu_has_llsc 1 > > > > since the #else path defines cpu_has_llsc as 0, it means that kernels > > targeting both SoCs would force llsc to be unavailable (not introduced > > by you). > > I’m a little bit confused. > The logic seems very clear to me: If a SoC is not affected by WAR_4KC_LLSC, > then wire cpu_has_llsc to 1, else wire it to 0. ATH25 allows you building for multiple SoCs at the same time, and if you do so, you don't know in advance on which SoC you boot. So you need to have third path here where cpu_has_llsc isn't wired to anything. This is wrong in the current code already, so should be fixed there. > > It matches my intention. > > > > > So this probably should be rather this: > > > > #if !defined(CONFIG_SOC_AR5312) > > #define cpu_has_llsc 1 > > #else if !defined(CONFIG_SOC_AR5312) > > #define cpu_has_llsc 0 > > #endif > > The condition on if leg seems same to the else leg, I’m not sure if it can ever work. Sorry, I typo'd. I wanted to write #if !defined(CONFIG_SOC_AR5312) #define cpu_has_llsc 1 #else if !defined(CONFIG_SOC_AR2315) #define cpu_has_llsc 0 (#else /* don't define it */) #endif Only SOC_AR2315 selected => cpu_has_llsc = 1 Only SOC_AR5312 selected => cpu_has_llsc = 0 both selected => cpu_has_llsc will need to be determined at runtime (don't set it to anything) > > > > > (so if only one is enabled, set it accordingly, else let runtime > > detection handle it). > > > >> #else > >> /* > >> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c > >> index 6d15a398d389..fd452e68cd90 100644 > >> --- a/arch/mips/kernel/cpu-probe.c > >> +++ b/arch/mips/kernel/cpu-probe.c > >> @@ -152,6 +152,13 @@ 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 (!IS_ENABLED(CONFIG_WAR_4K_LLSC)) > >> + pr_err("CPU have LLSC errata, please enable CONFIG_WAR_4K_LLSC"); > >> + } > > > > And then you don't need this error message at all, since then > > cpu_has_llsc is 0 or follows MIPS_CPU_LLSC, unless you disabled > > support for the relevant SoC, and then you'll have bigger problems > > anyway. > > The problem is as per MIPS the affected IP core was shipped to multiple customers > This error message can cover other SoCs that potentially using this core. AFAICT the core issue is if the platform hardcodes cpu_has_llsc to 1. So the error/warning this should be then something like this if ((c->processor_id & PRID_REV_MASK) < PRID_REV_4KC_V1_0) { c->options &= ~MIPS_CPU_LLSC; if (cpu_has_llsc) { // <- should now be false, unless the platform defines it as 1 pr_err("CPU has LLSC erratum, but cpu_has_llsc is force enabled!\n"); } because clearing MIPS_CPU_LLSC does nothing if cpu_has_llsc is #defined as 1, regardless if it selected WAR_4K_LLSC or not. (also your error print is missing a \n at the end) Regards, Jonas
> 2023年5月22日 23:03,Jonas Gorski <jonas.gorski@gmail.com> 写道: > > On Mon, 22 May 2023 at 22:38, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote: >> >> >> >>> 2023年5月22日 19:40,Jonas Gorski <jonas.gorski@gmail.com> 写道: >>> >>> Hi, >>> >>> On Fri, 19 May 2023 at 18:49, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote: >>>> >>>> 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> >>>> --- >>>> arch/mips/Kconfig | 6 ++++++ >>>> arch/mips/include/asm/cpu.h | 1 + >>>> arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h | 2 +- >>>> arch/mips/kernel/cpu-probe.c | 7 +++++++ >>>> 4 files changed, 15 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig >>>> index 30e90a2d53f4..354d033364ad 100644 >>>> --- a/arch/mips/Kconfig >>>> +++ b/arch/mips/Kconfig >>>> @@ -230,6 +230,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 >>> >>> Shouldn't this be "if SOC_AR5312"? >> >> Ah sorry, I misread the original code. >> >>> >>> Though since you are adding runtime detection/correction below, I >>> wonder if this would be really needed as an extra symbol, and rather >>> use the later introduced (CPU_MAY_HAVE_LLSC) directly. >> >> I bet it’s better to have a symbol just for tracking errata. So we can easily know >> if SoC is affected by a errata and have some extra documentation. >> >>> >>> Or rather have select "CPU_HAS_LLSC if !SOC_AR5312" in that case. >>> >>>> help >>>> Support for Atheros AR231x and Atheros AR531x based boards >>>> >>>> @@ -2544,6 +2545,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..5df292b1ff04 100644 >>>> --- a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h >>>> +++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h >>>> @@ -24,7 +24,7 @@ >>>> #define cpu_has_counter 1 >>>> #define cpu_has_ejtag 1 >>>> >>>> -#if !defined(CONFIG_SOC_AR5312) >>>> +#if !defined(WAR_4KC_LLSC) >>>> # define cpu_has_llsc 1 >>> >>> since the #else path defines cpu_has_llsc as 0, it means that kernels >>> targeting both SoCs would force llsc to be unavailable (not introduced >>> by you). >> >> I’m a little bit confused. >> The logic seems very clear to me: If a SoC is not affected by WAR_4KC_LLSC, >> then wire cpu_has_llsc to 1, else wire it to 0. > > ATH25 allows you building for multiple SoCs at the same time, and if > you do so, you don't know in advance on which SoC you boot. So you > need to have third path here where cpu_has_llsc isn't wired to > anything. Thanks for pointing out the missing piece, I thought ATH25 can only be built for a single SoC :-) > > This is wrong in the current code already, so should be fixed there. > [...] > AFAICT the core issue is if the platform hardcodes cpu_has_llsc to 1. > > So the error/warning this should be then something like this > > if ((c->processor_id & PRID_REV_MASK) < PRID_REV_4KC_V1_0) { > c->options &= ~MIPS_CPU_LLSC; > if (cpu_has_llsc) { // <- should now be false, unless the platform > defines it as 1 > pr_err("CPU has LLSC erratum, but cpu_has_llsc is force enabled!\n"); > } > > because clearing MIPS_CPU_LLSC does nothing if cpu_has_llsc is > #defined as 1, regardless if it selected WAR_4K_LLSC or not. > > (also your error print is missing a \n at the end) Ah, thanks. I’m planning to replace this pr_err with WARN_TAINT_ONCE. Thanks - Jiaxun > > Regards, > Jonas
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 30e90a2d53f4..354d033364ad 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -230,6 +230,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 @@ -2544,6 +2545,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..5df292b1ff04 100644 --- a/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h +++ b/arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h @@ -24,7 +24,7 @@ #define cpu_has_counter 1 #define cpu_has_ejtag 1 -#if !defined(CONFIG_SOC_AR5312) +#if !defined(WAR_4KC_LLSC) # define cpu_has_llsc 1 #else /* diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index 6d15a398d389..fd452e68cd90 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -152,6 +152,13 @@ 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 (!IS_ENABLED(CONFIG_WAR_4K_LLSC)) + pr_err("CPU have LLSC errata, please enable CONFIG_WAR_4K_LLSC"); + } + break; case CPU_34K: /* * Erratum "RPS May Cause Incorrect Instruction Execution"