Skip to content

Commit 73c7c8f

Browse files
AlexGhitipalmer-dabbelt
authored andcommitted
riscv: Use pgtable_l4_enabled to output mmu_type in cpuinfo
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent e8a62cc commit 73c7c8f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

arch/riscv/kernel/cpu.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/seq_file.h>
88
#include <linux/of.h>
99
#include <asm/smp.h>
10+
#include <asm/pgtable.h>
1011

1112
/*
1213
* Returns the hart ID of the given device tree node, or -ENODEV if the node
@@ -71,18 +72,19 @@ static void print_isa(struct seq_file *f, const char *isa)
7172
seq_puts(f, "\n");
7273
}
7374

74-
static void print_mmu(struct seq_file *f, const char *mmu_type)
75+
static void print_mmu(struct seq_file *f)
7576
{
77+
char sv_type[16];
78+
7679
#if defined(CONFIG_32BIT)
77-
if (strcmp(mmu_type, "riscv,sv32") != 0)
78-
return;
80+
strncpy(sv_type, "sv32", 5);
7981
#elif defined(CONFIG_64BIT)
80-
if (strcmp(mmu_type, "riscv,sv39") != 0 &&
81-
strcmp(mmu_type, "riscv,sv48") != 0)
82-
return;
82+
if (pgtable_l4_enabled)
83+
strncpy(sv_type, "sv48", 5);
84+
else
85+
strncpy(sv_type, "sv39", 5);
8386
#endif
84-
85-
seq_printf(f, "mmu\t\t: %s\n", mmu_type+6);
87+
seq_printf(f, "mmu\t\t: %s\n", sv_type);
8688
}
8789

8890
static void *c_start(struct seq_file *m, loff_t *pos)
@@ -107,14 +109,13 @@ static int c_show(struct seq_file *m, void *v)
107109
{
108110
unsigned long cpu_id = (unsigned long)v - 1;
109111
struct device_node *node = of_get_cpu_node(cpu_id, NULL);
110-
const char *compat, *isa, *mmu;
112+
const char *compat, *isa;
111113

112114
seq_printf(m, "processor\t: %lu\n", cpu_id);
113115
seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id));
114116
if (!of_property_read_string(node, "riscv,isa", &isa))
115117
print_isa(m, isa);
116-
if (!of_property_read_string(node, "mmu-type", &mmu))
117-
print_mmu(m, mmu);
118+
print_mmu(m);
118119
if (!of_property_read_string(node, "compatible", &compat)
119120
&& strcmp(compat, "riscv"))
120121
seq_printf(m, "uarch\t\t: %s\n", compat);

0 commit comments

Comments
 (0)