Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp317175ybg; Wed, 3 Jun 2020 01:22:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRRoosmWwxA8S9FkpkV6Yd5WG88RBa+k2XzaFzWFfcxV1wuTwzZO+FSVa50uEfwsh4J1c7 X-Received: by 2002:a17:906:77c4:: with SMTP id m4mr17506781ejn.246.1591172558422; Wed, 03 Jun 2020 01:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591172558; cv=none; d=google.com; s=arc-20160816; b=W6vxZxKZ1G1+AXd78CTvG87nHps4XueewJGavQwddvmHsPvxbZmaD3pf495ylpW+jt 3WYNL5EqOTDPg3m7gZ4/6dStFt1PB6ynKb5ciCLIUykKd5WAKyrny8wBG+7GjfPxBOu3 8wZmMazwgOVIeTVo8vgrVXTEGBYf8vDGXcFKErmbRkBiDHOP0/LXx8ZGgmuTwqvx14eZ 1nheRwznkvFZl7CWRKM+Sk7mTJ30k3QZfJYIDzgzsHJDzCkLxUa1LqAFyY4qkjnaFy7d JixxnruhivgOqsXR/x2I4z05IxXN+gJo6VOfZwZKorPao5RW9M9lsnboaUiatLkQVKKY 5t9g== 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=RDf40XEhncdas4l7T+aTtnhyN5xDSbYeO07ZjuqIneU=; b=KQbXNqjqJVvR6y6IfHAJo2gyfdxCIGAsghDpyPzM3Fx1m5DtQ2CtnnuWQ1QGzz2wRI 6hLRe4Viy0RrA42uoNhVpviPb40TNVA3wSBzSYNLwv53H3EWbG/kJMKML/iTcJT9WRr9 pmmO9VoJyMKEtEQZ3xm4u5Laj3O+F66SOTvQ6w/HT8VTTlGTA5VhOxcRKH48GnsCHkkJ fY9PTn04ES77QAcFtMGuQJqcsX7/FzH6DRczor3uPlP5syBzz0vaNHbC+ZojAq1agS5V ZUF4PFcWkexzxl+xvBiiHJa9ihsGhgKrJwbS1RioU89RZVg4iID47miCItXChHZkfigQ +iHw== 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 i4si699445edq.200.2020.06.03.01.22.15; Wed, 03 Jun 2020 01:22:38 -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 S1726229AbgFCIS2 (ORCPT + 99 others); Wed, 3 Jun 2020 04:18:28 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:59417 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgFCIS2 (ORCPT ); Wed, 3 Jun 2020 04:18:28 -0400 X-Originating-IP: 90.112.45.105 Received: from debian.home (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 8235120006; Wed, 3 Jun 2020 08:18:24 +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 v2 7/8] riscv: Use pgtable_l4_enabled to output mmu type in cpuinfo Date: Wed, 3 Jun 2020 04:11:03 -0400 Message-Id: <20200603081104.14004-8-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200603081104.14004-1-alex@ghiti.fr> References: <20200603081104.14004-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/include/asm/pgtable.h | 1 + arch/riscv/kernel/cpu.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index b4b532525fee..cb8c6863266b 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -507,6 +507,7 @@ static inline void __kernel_map_pages(struct page *page, int numpages, int enabl extern char _start[]; extern void *dtb_early_va; extern u64 satp_mode; +extern bool pgtable_l4_enabled; void setup_bootmem(void); void paging_init(void); diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 40a3c442ac5f..4661b6669edb 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -7,6 +7,7 @@ #include #include #include +#include /* * Returns the hart ID of the given device tree node, or -ENODEV if the node @@ -54,18 +55,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 +92,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