Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp192625ybs; Sun, 24 May 2020 02:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9HRcvg3ag12p/6F5tQ1vW93qSCjrHi0BUlA9cUL3L+R/bjp+h3ETvA+y8xly9qJVg3G/0 X-Received: by 2002:a05:6402:128f:: with SMTP id w15mr10369672edv.203.1590312016573; Sun, 24 May 2020 02:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590312016; cv=none; d=google.com; s=arc-20160816; b=RwUs5j7MTIN5X9ojDCuxvq46wkhGsl/KRgrYQT5BUjia+0TRqEv8M8hJYn+7jYosaj gu8PKqs54qUdx0emAgmcP+XOnSDFzCH5T8d76CdVTzAZgVlVRYcKZtlgwr0fnB1/Z4ZS mQHR4diDHeeWbQ9Qv2Un+z4Uy0X1rQdLv8qCRzj74QPtj+pM7Q6BGxByv2S/eu3j3n2s OyD+bMpu6lGHC138cz4feVpmypNQXxntJ4VeG5H46YkdgKc61cxXVqGKbsYERHdO6s+Q WxAnsyQAnHPAAcaVDr6+VKW3xmkqFaNqKq1QhTJroBk4Dins/d3+3/hjlLXc43HBiBtN GkTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Pepvf3DKSpWwjQ3vsJA2b6JEfWhAXzrXL6m+STj7xDI=; b=d4sli9/GayxjNSFxUEVuFuoFxjWRLqcb2eduh3qOCreAfdeElZ4Xv5YjGb9xOpNju8 pBvHhjEHEz3nFZEws9PwAuCJzFpnHg1q2zbebpyUUnKgiNKtpVgpAcVU6WZWKuVbS+iz sSs5lhfd/DPziOIq+LoNofk9p9H0T+N/k3PB6ODxytAqcLEEVFPQNyCqr8p5z26JAiqD lW5BJxFc/YwzOtqM8qZ22qkdo4y6FisCOtoWWr5Z1XN5D1cKosHMZxJOIGOOxqFg/rgz XPZiZwzKBrHV5kYuNchxAtpVj1RcrtmDhvcDHVp90hlL+otO6WAAprsrn78N7i+YIIVT la0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si7686529ejf.753.2020.05.24.02.19.54; Sun, 24 May 2020 02:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728959AbgEXJR1 (ORCPT + 99 others); Sun, 24 May 2020 05:17:27 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:50789 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727848AbgEXJR0 (ORCPT ); Sun, 24 May 2020 05:17:26 -0400 Received: from localhost.localdomain (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 7D2AA200007; Sun, 24 May 2020 09:17:23 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Zong Li , Anup Patel , Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , Palmer Dabbelt Subject: [PATCH 7/8] riscv: Use pgtable_l4_enabled to output mmu type in cpuinfo Date: Sun, 24 May 2020 05:10:07 -0400 Message-Id: <20200524091008.25587-8-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200524091008.25587-1-alex@ghiti.fr> References: <20200524091008.25587-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the mmu type is determined at runtime using SATP characteristic, use the global variable pgtable_l4_enabled to output mmu type of the processor through /proc/cpuinfo instead of relying on device tree infos. Signed-off-by: Alexandre Ghiti Reviewed-by: Anup Patel Reviewed-by: Palmer Dabbelt --- arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 4 ---- arch/riscv/kernel/cpu.c | 24 ++++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi index 7db861053483..6138590a2229 100644 --- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi +++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi @@ -50,7 +50,6 @@ i-cache-size = <32768>; i-tlb-sets = <1>; i-tlb-size = <32>; - mmu-type = "riscv,sv39"; reg = <1>; riscv,isa = "rv64imafdc"; tlb-split; @@ -74,7 +73,6 @@ i-cache-size = <32768>; i-tlb-sets = <1>; i-tlb-size = <32>; - mmu-type = "riscv,sv39"; reg = <2>; riscv,isa = "rv64imafdc"; tlb-split; @@ -98,7 +96,6 @@ i-cache-size = <32768>; i-tlb-sets = <1>; i-tlb-size = <32>; - mmu-type = "riscv,sv39"; reg = <3>; riscv,isa = "rv64imafdc"; tlb-split; @@ -122,7 +119,6 @@ i-cache-size = <32768>; i-tlb-sets = <1>; i-tlb-size = <32>; - mmu-type = "riscv,sv39"; reg = <4>; riscv,isa = "rv64imafdc"; tlb-split; diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 40a3c442ac5f..38a699b997a8 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -8,6 +8,8 @@ #include #include +extern bool pgtable_l4_enabled; + /* * Returns the hart ID of the given device tree node, or -ENODEV if the node * isn't an enabled and valid RISC-V hart node. @@ -54,18 +56,19 @@ static void print_isa(struct seq_file *f, const char *isa) seq_puts(f, "\n"); } -static void print_mmu(struct seq_file *f, const char *mmu_type) +static void print_mmu(struct seq_file *f) { + char sv_type[16]; + #if defined(CONFIG_32BIT) - if (strcmp(mmu_type, "riscv,sv32") != 0) - return; + strncpy(sv_type, "sv32", 5); #elif defined(CONFIG_64BIT) - if (strcmp(mmu_type, "riscv,sv39") != 0 && - strcmp(mmu_type, "riscv,sv48") != 0) - return; + if (pgtable_l4_enabled) + strncpy(sv_type, "sv48", 5); + else + strncpy(sv_type, "sv39", 5); #endif - - seq_printf(f, "mmu\t\t: %s\n", mmu_type+6); + seq_printf(f, "mmu\t\t: %s\n", sv_type); } static void *c_start(struct seq_file *m, loff_t *pos) @@ -90,14 +93,13 @@ static int c_show(struct seq_file *m, void *v) { unsigned long cpu_id = (unsigned long)v - 1; struct device_node *node = of_get_cpu_node(cpu_id, NULL); - const char *compat, *isa, *mmu; + const char *compat, *isa; seq_printf(m, "processor\t: %lu\n", cpu_id); seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); if (!of_property_read_string(node, "riscv,isa", &isa)) print_isa(m, isa); - if (!of_property_read_string(node, "mmu-type", &mmu)) - print_mmu(m, mmu); + print_mmu(m); if (!of_property_read_string(node, "compatible", &compat) && strcmp(compat, "riscv")) seq_printf(m, "uarch\t\t: %s\n", compat); -- 2.20.1