Skip to contentSkip to conversation

riscv: mm: don't advertise 1 num_asid for 0 asid bits

PATCH Superseded Vineet Gupta 3 participants 4 messages Sep 7, 2021 – Oct 3, 2021 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 a case.

Also while here, print the number of asid bits discovered even for the disabled case.

Verified this on Hifive Unmatched.

---
 arch/riscv/mm/context.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/riscv/mm/context.c +5 -3
index ee3459cb6750..c8c6f8831a3b 100644
@@ -233,8 +233,10 @@ static int __init asids_init(void)
 	local_flush_tlb_all();
 
 	/* Pre-compute ASID details */
-	num_asids = 1 << asid_bits;
-	asid_mask = num_asids - 1;
+	if (asid_bits) {
+		num_asids = 1 << asid_bits;
+		asid_mask = num_asids - 1;
+	}
 
 	/*
 	 * Use ASID allocator only if number of HW ASIDs are
@@ -255,7 +257,7 @@ static int __init asids_init(void)
 		pr_info("ASID allocator using %lu bits (%lu entries)\n",
 			asid_bits, num_asids);
 	} else {
-		pr_info("ASID allocator disabled\n");
+		pr_info("ASID allocator disabled: %lu bits\n", asid_bits);
 	}
 
 	return 0;
Signature · 7 lines
2.30.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v1 1/1
#1 lore raw
Quoted 33 lines · Vineet Gupta

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 a case.

Also while here, print the number of asid bits discovered even for the disabled case.

Verified this on Hifive Unmatched.

---
 arch/riscv/mm/context.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/riscv/mm/context.c +4 -2
index ee3459cb6750..c8c6f8831a3b 100644
@@ -233,8 +233,10 @@ static int __init asids_init(void)
        local_flush_tlb_all();
 
        /* Pre-compute ASID details */
-       num_asids = 1 << asid_bits;
-       asid_mask = num_asids - 1;
+       if (asid_bits) {
+               num_asids = 1 << asid_bits;
+               asid_mask = num_asids - 1;
+       }
 
        /*
         * Use ASID allocator only if number of HW ASIDs are

arch/riscv/mm/context.c static int __init asids_init(void) · line 260

Quoted 5 lines
arch/riscv/mm/context.c +1 -1
@@ -255,7 +257,7 @@ static int __init asids_init(void)
                pr_info("ASID allocator using %lu bits (%lu entries)\n",
                        asid_bits, num_asids);
        } else {
-               pr_info("ASID allocator disabled\n");
+               pr_info("ASID allocator disabled: %lu bits\n", asid_bits);

May be use:

pr_info("ASID allocator disabled (%lu bits)\n", asid_bits);

for consistency with the ASID enabled case.

Otherwise, it looks good to me.

Quoted 11 lines
arch/riscv/mm/context.c +0 -1
        }
 
        return 0;
--

2.30.2

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

Regards,
Anup

#2 lore raw

PATCH v2 1/1 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.

---
 arch/riscv/mm/context.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/riscv/mm/context.c +5 -3
index ee3459cb6750..ea54cc0c9106 100644
@@ -233,8 +233,10 @@ static int __init asids_init(void)
 	local_flush_tlb_all();
 
 	/* Pre-compute ASID details */
-	num_asids = 1 << asid_bits;
-	asid_mask = num_asids - 1;
+	if (asid_bits) {
+		num_asids = 1 << asid_bits;
+		asid_mask = num_asids - 1;
+	}
 
 	/*
 	 * Use ASID allocator only if number of HW ASIDs are
@@ -255,7 +257,7 @@ static int __init asids_init(void)
 		pr_info("ASID allocator using %lu bits (%lu entries)\n",
 			asid_bits, num_asids);
 	} else {
-		pr_info("ASID allocator disabled\n");
+		pr_info("ASID allocator disabled (%lu bits)\n", asid_bits);
 	}
 
 	return 0;
Signature · 1 line
2.30.2
maintainer
#3 lore raw
Quoted 33 lines · On Wed, 08 Sep 2021 10:30:29 PDT (-0700), [email protected] wrote:

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.

---
 arch/riscv/mm/context.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/riscv/mm/context.c +4 -2
index ee3459cb6750..ea54cc0c9106 100644
@@ -233,8 +233,10 @@ static int __init asids_init(void)
 	local_flush_tlb_all();
 
 	/* Pre-compute ASID details */
-	num_asids = 1 << asid_bits;
-	asid_mask = num_asids - 1;
+	if (asid_bits) {
+		num_asids = 1 << asid_bits;
+		asid_mask = num_asids - 1;
+	}
 
 	/*
 	 * Use ASID allocator only if number of HW ASIDs are

arch/riscv/mm/context.c static int __init asids_init(void) · line 263

Quoted 8 lines
arch/riscv/mm/context.c +1 -1
@@ -255,7 +257,7 @@ static int __init asids_init(void)
 		pr_info("ASID allocator using %lu bits (%lu entries)\n",
 			asid_bits, num_asids);
 	} else {
-		pr_info("ASID allocator disabled\n");
+		pr_info("ASID allocator disabled (%lu bits)\n", asid_bits);
 	}
 
 	return 0;

Thanks, this is on for-next.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv