Skip to content

Commit 4b26d22

Browse files
avpatelpalmer-dabbelt
authored andcommitted
RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo
Currently, /proc/cpuinfo show logical CPU ID as Hart ID which is in-correct. This patch shows CPU ID and Hart ID separately in /proc/cpuinfo using cpuid_to_hardid_map(). With this patch, contents of /proc/cpuinfo looks as follows: processor : 0 hart : 1 isa : rv64imafdc mmu : sv48 processor : 1 hart : 0 isa : rv64imafdc mmu : sv48 processor : 2 hart : 2 isa : rv64imafdc mmu : sv48 processor : 3 hart : 3 isa : rv64imafdc mmu : sv48 Signed-off-by: Anup Patel <anup@brainfault.org> Signed-off-by: Atish Patra <atish.patra@wdc.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
1 parent f99fb60 commit 4b26d22

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/riscv/kernel/cpu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
8181
#endif
8282

8383
/* Print the base ISA, as we already know it's legal. */
84-
seq_puts(f, "isa\t: ");
84+
seq_puts(f, "isa\t\t: ");
8585
seq_write(f, isa, 5);
8686
isa += 5;
8787

@@ -96,6 +96,7 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
9696
isa++;
9797
}
9898
}
99+
seq_puts(f, "\n");
99100

100101
/*
101102
* If we were given an unsupported ISA in the device tree then print
@@ -116,7 +117,7 @@ static void print_mmu(struct seq_file *f, const char *mmu_type)
116117
return;
117118
#endif
118119

119-
seq_printf(f, "mmu\t: %s\n", mmu_type+6);
120+
seq_printf(f, "mmu\t\t: %s\n", mmu_type+6);
120121
}
121122

122123
static void *c_start(struct seq_file *m, loff_t *pos)
@@ -144,14 +145,15 @@ static int c_show(struct seq_file *m, void *v)
144145
NULL);
145146
const char *compat, *isa, *mmu;
146147

147-
seq_printf(m, "hart\t: %lu\n", cpu_id);
148+
seq_printf(m, "processor\t: %lu\n", cpu_id);
149+
seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id));
148150
if (!of_property_read_string(node, "riscv,isa", &isa))
149151
print_isa(m, isa);
150152
if (!of_property_read_string(node, "mmu-type", &mmu))
151153
print_mmu(m, mmu);
152154
if (!of_property_read_string(node, "compatible", &compat)
153155
&& strcmp(compat, "riscv"))
154-
seq_printf(m, "uarch\t: %s\n", compat);
156+
seq_printf(m, "uarch\t\t: %s\n", compat);
155157
seq_puts(m, "\n");
156158

157159
return 0;

0 commit comments

Comments
 (0)