linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Icenowy Zheng <icenowy@nucleisys.com>
To: Rob Herring <robh+dt@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org,
	linux-spi@vger.kernel.org, Icenowy Zheng <icenowy@nucleisys.com>
Subject: [PATCH 10/12] RISC-V: workaround Nuclei UX600 cores with broken SATP CSR
Date: Thu, 27 Jan 2022 23:16:45 +0800	[thread overview]
Message-ID: <20220127151647.2375449-11-icenowy@nucleisys.com> (raw)
In-Reply-To: <20220127151647.2375449-1-icenowy@nucleisys.com>

Current release of Nuclei UX600 CPU cores have two errata against RISC-V
Privledged Specification 1.10: one is left over mvendorid value (not the
JEDEC ID), the other, which is a more breaking one that needs to be
workaround in software, is that satp will accept written value with
MODE=9 (Sv48, which is not supported by UX600), and silently change it
to MODE=8 (Sv39). As current kernel MMU initialization code relies on
the behavior defined on the spec (reject write request with unsupported
MODE value and do not change the CSR's value at all) to detect the
existence of Sv48, the erratum breaks the Sv48 detection code.

As both two errata are to be fixed in the next revision, use the first
to detect the existence of the second at runtime, and force Sv39 when
these errata are detected.

Signed-off-by: Icenowy Zheng <icenowy@nucleisys.com>
---
 arch/riscv/include/asm/vendorid_list.h |  1 +
 arch/riscv/mm/init.c                   | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/arch/riscv/include/asm/vendorid_list.h b/arch/riscv/include/asm/vendorid_list.h
index 9d934215b3c8..47ff43795d70 100644
--- a/arch/riscv/include/asm/vendorid_list.h
+++ b/arch/riscv/include/asm/vendorid_list.h
@@ -6,5 +6,6 @@
 #define ASM_VENDOR_LIST_H
 
 #define SIFIVE_VENDOR_ID	0x489
+#define NUCLEI_OLD_VENDOR_ID	0x2d33
 
 #endif
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index cf4d018b7d66..0085b14ae265 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -28,6 +28,8 @@
 #include <asm/io.h>
 #include <asm/ptdump.h>
 #include <asm/numa.h>
+#include <asm/sbi.h>
+#include <asm/vendorid_list.h>
 
 #include "../kernel/head.h"
 
@@ -591,6 +593,21 @@ static __init void set_satp_mode(void)
 	u64 identity_satp, hw_satp;
 	uintptr_t set_satp_mode_pmd;
 
+	if (sbi_get_mvendorid() == NUCLEI_OLD_VENDOR_ID) {
+		/*
+		 * Old Nuclei UX600 processor releases have broken
+		 * implementation of SATP register which prevents
+		 * proper runtime detection of Sv48 existence. In
+		 * addition these processor releases have an old
+		 * vendor id instead of proper JEDEC ID.
+		 *
+		 * As these releases do not support Sv48 at all,
+		 * force Sv39 on them.
+		 */
+		disable_pgtable_l4();
+		return;
+	}
+
 	set_satp_mode_pmd = ((unsigned long)set_satp_mode) & PMD_MASK;
 	create_pgd_mapping(early_pg_dir,
 			   set_satp_mode_pmd, (uintptr_t)early_pud,
-- 
2.30.2


  parent reply	other threads:[~2022-01-27 15:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 15:16 [PATCH 00/12] Initial support for Nuclei DemoSoC w/ UX600 Icenowy Zheng
2022-01-27 15:16 ` [PATCH 01/12] dt-bindings: vendor-prefixes: add Nuclei Icenowy Zheng
2022-02-09  4:03   ` Rob Herring
2022-01-27 15:16 ` [PATCH 02/12] RISC-V: add Nuclei SoC Kconfig option Icenowy Zheng
2022-01-27 15:16 ` [PATCH 03/12] dt-bindings: riscv: add compatible strings for Nuclei UX600 series Icenowy Zheng
2022-02-09  4:05   ` Rob Herring
2022-01-27 15:16 ` [PATCH 04/12] dt-bindings: timer: add compatible for Nuclei UX600 CLINT-compat timer Icenowy Zheng
2022-02-09  4:05   ` Rob Herring
2022-01-27 15:16 ` [PATCH 05/12] dt-bindings: interrupt-controller: add compatible string for UX600 PLIC Icenowy Zheng
2022-02-09  4:05   ` Rob Herring
2022-01-27 15:16 ` [PATCH 06/12] dt-bindings: serial: add compatible string for Nuclei DemoSoC UART Icenowy Zheng
2022-02-09  4:06   ` Rob Herring
2022-01-27 15:16 ` [PATCH 07/12] dt-bindings: spi: add compatible string for Nuclei DemoSoC SPI Icenowy Zheng
2022-02-09  4:06   ` Rob Herring
2022-01-27 15:16 ` [PATCH 08/12] dt-bindings: riscv: add binding for Nuclei platform boards Icenowy Zheng
2022-02-09  4:07   ` Rob Herring
2022-01-27 15:16 ` [PATCH 09/12] riscv: dts: add device tree for Nuclei DemoSoC w/ UX600 on DDR200T Icenowy Zheng
2022-01-27 15:16 ` Icenowy Zheng [this message]
2022-01-27 15:16 ` [PATCH 11/12] MAINTAINERS: add myself as Nuclei SoCs/CPUs supporter Icenowy Zheng
2022-01-27 15:16 ` [PATCH 12/12] mailmap: add Icenowy Zheng's Nuclei mail addresses Icenowy Zheng
2022-02-19 14:45 ` [PATCH 00/12] Initial support for Nuclei DemoSoC w/ UX600 Icenowy Zheng
2022-02-22 16:56   ` Palmer Dabbelt
2022-03-22  0:05     ` Palmer Dabbelt
2022-04-13 21:52       ` Palmer Dabbelt

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=20220127151647.2375449-11-icenowy@nucleisys.com \
    --to=icenowy@nucleisys.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).