Skip to content

Commit 21ccdcc

Browse files
vineetgarcpalmer-dabbelt
authored andcommitted
riscv: mm: don't advertise 1 num_asid for 0 asid bits
Even if mmu doesn't support ASID, current code calculates @num_asids=1 which is misleading, so avoid setting any asid related variables in such case. Also while here, print the number of asid bits discovered even for the disabled case. Verified this on Hifive Unmatched. Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Vineet Gupta <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent f2928e2 commit 21ccdcc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/riscv/mm/context.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ static int __init asids_init(void)
233233
local_flush_tlb_all();
234234

235235
/* Pre-compute ASID details */
236-
num_asids = 1 << asid_bits;
237-
asid_mask = num_asids - 1;
236+
if (asid_bits) {
237+
num_asids = 1 << asid_bits;
238+
asid_mask = num_asids - 1;
239+
}
238240

239241
/*
240242
* Use ASID allocator only if number of HW ASIDs are
@@ -255,7 +257,7 @@ static int __init asids_init(void)
255257
pr_info("ASID allocator using %lu bits (%lu entries)\n",
256258
asid_bits, num_asids);
257259
} else {
258-
pr_info("ASID allocator disabled\n");
260+
pr_info("ASID allocator disabled (%lu bits)\n", asid_bits);
259261
}
260262

261263
return 0;

0 commit comments

Comments
 (0)