linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: mm: don't advertise 1 num_asid for 0 asid bits
@ 2021-09-07 20:02 Vineet Gupta
  2021-09-08  8:35 ` Anup Patel
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Gupta @ 2021-09-07 20:02 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel,
	Jisheng Zhang, Guo Ren, Kefeng Wang
  Cc: linux-riscv, linux-kernel, 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.

Signed-off-by: Vineet Gupta <vgupta@kernel.org>
---
 arch/riscv/mm/context.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
index ee3459cb6750..c8c6f8831a3b 100644
--- a/arch/riscv/mm/context.c
+++ b/arch/riscv/mm/context.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: mm: don't advertise 1 num_asid for 0 asid bits
  2021-09-07 20:02 [PATCH] riscv: mm: don't advertise 1 num_asid for 0 asid bits Vineet Gupta
@ 2021-09-08  8:35 ` Anup Patel
  2021-09-08 17:30   ` [PATCH v2] " Vineet Gupta
  0 siblings, 1 reply; 4+ messages in thread
From: Anup Patel @ 2021-09-08  8:35 UTC (permalink / raw)
  To: Vineet Gupta
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel,
	Jisheng Zhang, Guo Ren, Kefeng Wang, linux-riscv,
	linux-kernel@vger.kernel.org List

On Wed, Sep 8, 2021 at 1:33 AM Vineet Gupta <vgupta@kernel.org> 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
> a case.
>
> Also while here, print the number of asid bits discovered even for the
> disabled case.
>
> Verified this on Hifive Unmatched.
>
> Signed-off-by: Vineet Gupta <vgupta@kernel.org>
> ---
>  arch/riscv/mm/context.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
> index ee3459cb6750..c8c6f8831a3b 100644
> --- a/arch/riscv/mm/context.c
> +++ b/arch/riscv/mm/context.c
> @@ -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);

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.

Reviewed-by: Anup Patel <anup@brainfault.org>

>         }
>
>         return 0;
> --
> 2.30.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

Regards,
Anup

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] riscv: mm: don't advertise 1 num_asid for 0 asid bits
  2021-09-08  8:35 ` Anup Patel
@ 2021-09-08 17:30   ` Vineet Gupta
  2021-10-03 17:10     ` Palmer Dabbelt
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Gupta @ 2021-09-08 17:30 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel,
	Jisheng Zhang, Guo Ren, Kefeng Wang
  Cc: linux-riscv, linux-kernel, Vineet Gupta, Anup Patel

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 <anup@brainfault.org>
Signed-off-by: Vineet Gupta <vgupta@kernel.org>
---
 arch/riscv/mm/context.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
index ee3459cb6750..ea54cc0c9106 100644
--- a/arch/riscv/mm/context.c
+++ b/arch/riscv/mm/context.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] riscv: mm: don't advertise 1 num_asid for 0 asid bits
  2021-09-08 17:30   ` [PATCH v2] " Vineet Gupta
@ 2021-10-03 17:10     ` Palmer Dabbelt
  0 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2021-10-03 17:10 UTC (permalink / raw)
  To: vgupta
  Cc: Paul Walmsley, aou, Anup Patel, jszhang, guoren, wangkefeng.wang,
	linux-riscv, linux-kernel, vgupta, anup

On Wed, 08 Sep 2021 10:30:29 PDT (-0700), vgupta@kernel.org 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.
>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> Signed-off-by: Vineet Gupta <vgupta@kernel.org>
> ---
>  arch/riscv/mm/context.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c
> index ee3459cb6750..ea54cc0c9106 100644
> --- a/arch/riscv/mm/context.c
> +++ b/arch/riscv/mm/context.c
> @@ -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;

Thanks, this is on for-next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-03 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 20:02 [PATCH] riscv: mm: don't advertise 1 num_asid for 0 asid bits Vineet Gupta
2021-09-08  8:35 ` Anup Patel
2021-09-08 17:30   ` [PATCH v2] " Vineet Gupta
2021-10-03 17:10     ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).