linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Miscellaneous kernel command line fixes
@ 2019-04-24  0:02 Atish Patra
  2019-04-24  0:02 ` [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Atish Patra @ 2019-04-24  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-riscv, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Christoph Hellwig

Assorted command line option fixes for RISC-V.

Changes from v2->v3.
1. Merged patch 1 & 2 into one patch.

Changes from v1->v2.
1. Update pr_err string in patch (4/4) as per review.

Atish Patra (3):
RISC-V: Add RISC-V specific arch_match_cpu_phys_id
RISC-V: Implement nosmp commandline option.
RISC-V: Support nr_cpus command line option.

arch/riscv/kernel/cpu.c     |  3 +--
arch/riscv/kernel/smp.c     |  5 +++++
arch/riscv/kernel/smpboot.  |  0
arch/riscv/kernel/smpboot.c | 22 ++++++++++++++++++++--
4 files changed, 26 insertions(+), 4 deletions(-)
create mode 100644 arch/riscv/kernel/smpboot.

--
2.21.0


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

* [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id
  2019-04-24  0:02 [PATCH v3 0/3] Miscellaneous kernel command line fixes Atish Patra
@ 2019-04-24  0:02 ` Atish Patra
  2019-04-24  6:21   ` Christoph Hellwig
  2019-04-24  9:07   ` Sudeep Holla
  2019-04-24  0:02 ` [PATCH v3 2/3] RISC-V: Implement nosmp commandline option Atish Patra
  2019-04-24  0:02 ` [PATCH v3 3/3] RISC-V: Support nr_cpus command line option Atish Patra
  2 siblings, 2 replies; 11+ messages in thread
From: Atish Patra @ 2019-04-24  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-riscv, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Christoph Hellwig

OF/DT core has a hook for architecture specific logical cpuid to hartid
mapping. By implementing this, we can pass the logical cpu id to cpu
node parsing functions.

Fix the instances where logical cpuid is expected as an argument in
of_get_cpu_node.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
 arch/riscv/kernel/cpu.c | 3 +--
 arch/riscv/kernel/smp.c | 5 +++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index cf2fca12414a..c8d2a3223099 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -136,8 +136,7 @@ static void c_stop(struct seq_file *m, void *v)
 static int c_show(struct seq_file *m, void *v)
 {
 	unsigned long cpu_id = (unsigned long)v - 1;
-	struct device_node *node = of_get_cpu_node(cpuid_to_hartid_map(cpu_id),
-						   NULL);
+	struct device_node *node = of_get_cpu_node(cpu_id, NULL);
 	const char *compat, *isa, *mmu;
 
 	seq_printf(m, "processor\t: %lu\n", cpu_id);
diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
index 0c41d07ec281..94db72662f60 100644
--- a/arch/riscv/kernel/smp.c
+++ b/arch/riscv/kernel/smp.c
@@ -70,6 +70,11 @@ void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out)
 	for_each_cpu(cpu, in)
 		cpumask_set_cpu(cpuid_to_hartid_map(cpu), out);
 }
+
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+	return phys_id == cpuid_to_hartid_map(cpu);
+}
 /* Unsupported */
 int setup_profiling_timer(unsigned int multiplier)
 {
-- 
2.21.0


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

* [PATCH v3 2/3] RISC-V: Implement nosmp commandline option.
  2019-04-24  0:02 [PATCH v3 0/3] Miscellaneous kernel command line fixes Atish Patra
  2019-04-24  0:02 ` [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
@ 2019-04-24  0:02 ` Atish Patra
  2019-04-24  6:21   ` Christoph Hellwig
  2019-04-29 23:50   ` Palmer Dabbelt
  2019-04-24  0:02 ` [PATCH v3 3/3] RISC-V: Support nr_cpus command line option Atish Patra
  2 siblings, 2 replies; 11+ messages in thread
From: Atish Patra @ 2019-04-24  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-riscv, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Christoph Hellwig

nosmp command line option sets max_cpus to zero. No secondary harts
will boot if this is enabled. But present cpu mask will still point to
all possible masks.

Fix present cpu mask for nosmp usecase.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
 arch/riscv/kernel/smpboot.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index eb533b5c2c8c..a8ad200581aa 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -47,6 +47,17 @@ void __init smp_prepare_boot_cpu(void)
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
+	int cpuid;
+
+	/* This covers non-smp usecase mandated by "nosmp" option */
+	if (max_cpus == 0)
+		return;
+
+	for_each_possible_cpu(cpuid) {
+		if (cpuid == smp_processor_id())
+			continue;
+		set_cpu_present(cpuid, true);
+	}
 }
 
 void __init setup_smp(void)
@@ -74,7 +85,6 @@ void __init setup_smp(void)
 
 		cpuid_to_hartid_map(cpuid) = hart;
 		set_cpu_possible(cpuid, true);
-		set_cpu_present(cpuid, true);
 		cpuid++;
 	}
 
-- 
2.21.0


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

* [PATCH v3 3/3] RISC-V: Support nr_cpus command line option.
  2019-04-24  0:02 [PATCH v3 0/3] Miscellaneous kernel command line fixes Atish Patra
  2019-04-24  0:02 ` [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
  2019-04-24  0:02 ` [PATCH v3 2/3] RISC-V: Implement nosmp commandline option Atish Patra
@ 2019-04-24  0:02 ` Atish Patra
  2019-04-24  6:22   ` Christoph Hellwig
  2 siblings, 1 reply; 11+ messages in thread
From: Atish Patra @ 2019-04-24  0:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-riscv, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Christoph Hellwig

If nr_cpus command line option is set, maximum possible cpu should be
set to that value.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
 arch/riscv/kernel/smpboot.c | 10 +++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/kernel/smpboot.

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index a8ad200581aa..7a0b62252524 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -84,11 +84,19 @@ void __init setup_smp(void)
 		}
 
 		cpuid_to_hartid_map(cpuid) = hart;
-		set_cpu_possible(cpuid, true);
 		cpuid++;
 	}
 
 	BUG_ON(!found_boot_cpu);
+
+	if (cpuid > nr_cpu_ids)
+		pr_warn("Total number of cpus [%d] is greater than nr_cpus option value [%d]\n",
+			cpuid, nr_cpu_ids);
+
+	for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
+		if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
+			set_cpu_possible(cpuid, true);
+	}
 }
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)
-- 
2.21.0


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

* Re: [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id
  2019-04-24  0:02 ` [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
@ 2019-04-24  6:21   ` Christoph Hellwig
  2019-04-30  0:36     ` Palmer Dabbelt
  2019-04-24  9:07   ` Sudeep Holla
  1 sibling, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2019-04-24  6:21 UTC (permalink / raw)
  To: Atish Patra
  Cc: linux-kernel, Albert Ou, Dmitriy Cherkasov, Anup Patel,
	Palmer Dabbelt, Johan Hovold, Christoph Hellwig, Paul Walmsley,
	Andreas Schwab, linux-riscv, Thomas Gleixner

>  }
> +
> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
> +{
> +	return phys_id == cpuid_to_hartid_map(cpu);
> +}
>  /* Unsupported */

Please keep an empty line after function bodys.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 2/3] RISC-V: Implement nosmp commandline option.
  2019-04-24  0:02 ` [PATCH v3 2/3] RISC-V: Implement nosmp commandline option Atish Patra
@ 2019-04-24  6:21   ` Christoph Hellwig
  2019-04-29 23:50   ` Palmer Dabbelt
  1 sibling, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2019-04-24  6:21 UTC (permalink / raw)
  To: Atish Patra
  Cc: linux-kernel, Albert Ou, Dmitriy Cherkasov, Anup Patel,
	Palmer Dabbelt, Johan Hovold, Christoph Hellwig, Paul Walmsley,
	Andreas Schwab, linux-riscv, Thomas Gleixner

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 3/3] RISC-V: Support nr_cpus command line option.
  2019-04-24  0:02 ` [PATCH v3 3/3] RISC-V: Support nr_cpus command line option Atish Patra
@ 2019-04-24  6:22   ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2019-04-24  6:22 UTC (permalink / raw)
  To: Atish Patra
  Cc: linux-kernel, Albert Ou, Dmitriy Cherkasov, Anup Patel,
	Palmer Dabbelt, Johan Hovold, Christoph Hellwig, Paul Walmsley,
	Andreas Schwab, linux-riscv, Thomas Gleixner

On Tue, Apr 23, 2019 at 05:02:27PM -0700, Atish Patra wrote:
> If nr_cpus command line option is set, maximum possible cpu should be
> set to that value.
> 
> Signed-off-by: Atish Patra <atish.patra@wdc.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id
  2019-04-24  0:02 ` [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
  2019-04-24  6:21   ` Christoph Hellwig
@ 2019-04-24  9:07   ` Sudeep Holla
  2019-04-24 16:50     ` Atish Patra
  1 sibling, 1 reply; 11+ messages in thread
From: Sudeep Holla @ 2019-04-24  9:07 UTC (permalink / raw)
  To: Atish Patra
  Cc: open list, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-riscv, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Christoph Hellwig, Sudeep Holla

On Wed, Apr 24, 2019 at 1:03 AM Atish Patra <atish.patra@wdc.com> wrote:
>
> OF/DT core has a hook for architecture specific logical cpuid to hartid
> mapping. By implementing this, we can pass the logical cpu id to cpu
> node parsing functions.
>
> Fix the instances where logical cpuid is expected as an argument in
> of_get_cpu_node.
>

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

> Signed-off-by: Atish Patra <atish.patra@wdc.com>
> ---
>  arch/riscv/kernel/cpu.c | 3 +--
>  arch/riscv/kernel/smp.c | 5 +++++
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> index cf2fca12414a..c8d2a3223099 100644
> --- a/arch/riscv/kernel/cpu.c
> +++ b/arch/riscv/kernel/cpu.c
> @@ -136,8 +136,7 @@ static void c_stop(struct seq_file *m, void *v)
>  static int c_show(struct seq_file *m, void *v)
>  {
>         unsigned long cpu_id = (unsigned long)v - 1;
> -       struct device_node *node = of_get_cpu_node(cpuid_to_hartid_map(cpu_id),
> -                                                  NULL);

I assume it work working just fine as you are doing cpu to hartid
conversion here and
weak implementation of arch_match_cpu_phys_id does direct match.

> +       struct device_node *node = of_get_cpu_node(cpu_id, NULL);
>         const char *compat, *isa, *mmu;
>
>         seq_printf(m, "processor\t: %lu\n", cpu_id);
> diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
> index 0c41d07ec281..94db72662f60 100644
> --- a/arch/riscv/kernel/smp.c
> +++ b/arch/riscv/kernel/smp.c
> @@ -70,6 +70,11 @@ void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out)
>         for_each_cpu(cpu, in)
>                 cpumask_set_cpu(cpuid_to_hartid_map(cpu), out);
>  }
> +
> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
> +{
> +       return phys_id == cpuid_to_hartid_map(cpu);
> +}
>  /* Unsupported */
>  int setup_profiling_timer(unsigned int multiplier)
>  {
> --
> 2.21.0
>

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

* Re: [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id
  2019-04-24  9:07   ` Sudeep Holla
@ 2019-04-24 16:50     ` Atish Patra
  0 siblings, 0 replies; 11+ messages in thread
From: Atish Patra @ 2019-04-24 16:50 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: open list, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-riscv, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Christoph Hellwig

On 4/24/19 2:07 AM, Sudeep Holla wrote:
> On Wed, Apr 24, 2019 at 1:03 AM Atish Patra <atish.patra@wdc.com> wrote:
>>
>> OF/DT core has a hook for architecture specific logical cpuid to hartid
>> mapping. By implementing this, we can pass the logical cpu id to cpu
>> node parsing functions.
>>
>> Fix the instances where logical cpuid is expected as an argument in
>> of_get_cpu_node.
>>
> 
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> 
>> Signed-off-by: Atish Patra <atish.patra@wdc.com>
>> ---
>>   arch/riscv/kernel/cpu.c | 3 +--
>>   arch/riscv/kernel/smp.c | 5 +++++
>>   2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
>> index cf2fca12414a..c8d2a3223099 100644
>> --- a/arch/riscv/kernel/cpu.c
>> +++ b/arch/riscv/kernel/cpu.c
>> @@ -136,8 +136,7 @@ static void c_stop(struct seq_file *m, void *v)
>>   static int c_show(struct seq_file *m, void *v)
>>   {
>>          unsigned long cpu_id = (unsigned long)v - 1;
>> -       struct device_node *node = of_get_cpu_node(cpuid_to_hartid_map(cpu_id),
>> -                                                  NULL);
> 
> I assume it work working just fine as you are doing cpu to hartid
> conversion here and
> weak implementation of arch_match_cpu_phys_id does direct match.
> 

Yup. That's correct.

Regards,
Atish
>> +       struct device_node *node = of_get_cpu_node(cpu_id, NULL);
>>          const char *compat, *isa, *mmu;
>>
>>          seq_printf(m, "processor\t: %lu\n", cpu_id);
>> diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
>> index 0c41d07ec281..94db72662f60 100644
>> --- a/arch/riscv/kernel/smp.c
>> +++ b/arch/riscv/kernel/smp.c
>> @@ -70,6 +70,11 @@ void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out)
>>          for_each_cpu(cpu, in)
>>                  cpumask_set_cpu(cpuid_to_hartid_map(cpu), out);
>>   }
>> +
>> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
>> +{
>> +       return phys_id == cpuid_to_hartid_map(cpu);
>> +}
>>   /* Unsupported */
>>   int setup_profiling_timer(unsigned int multiplier)
>>   {
>> --
>> 2.21.0
>>
> 


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

* Re: [PATCH v3 2/3] RISC-V: Implement nosmp commandline option.
  2019-04-24  0:02 ` [PATCH v3 2/3] RISC-V: Implement nosmp commandline option Atish Patra
  2019-04-24  6:21   ` Christoph Hellwig
@ 2019-04-29 23:50   ` Palmer Dabbelt
  1 sibling, 0 replies; 11+ messages in thread
From: Palmer Dabbelt @ 2019-04-29 23:50 UTC (permalink / raw)
  To: atish.patra
  Cc: linux-kernel, atish.patra, aou, schwab, anup, dmitriy, johan,
	linux-riscv, Paul Walmsley, tglx, Christoph Hellwig

On Tue, 23 Apr 2019 17:02:26 PDT (-0700), atish.patra@wdc.com wrote:
> nosmp command line option sets max_cpus to zero. No secondary harts
> will boot if this is enabled. But present cpu mask will still point to
> all possible masks.
>
> Fix present cpu mask for nosmp usecase.
>
> Signed-off-by: Atish Patra <atish.patra@wdc.com>
> ---
>  arch/riscv/kernel/smpboot.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
> index eb533b5c2c8c..a8ad200581aa 100644
> --- a/arch/riscv/kernel/smpboot.c
> +++ b/arch/riscv/kernel/smpboot.c
> @@ -47,6 +47,17 @@ void __init smp_prepare_boot_cpu(void)
>
>  void __init smp_prepare_cpus(unsigned int max_cpus)
>  {
> +	int cpuid;
> +
> +	/* This covers non-smp usecase mandated by "nosmp" option */
> +	if (max_cpus == 0)
> +		return;
> +
> +	for_each_possible_cpu(cpuid) {
> +		if (cpuid == smp_processor_id())
> +			continue;
> +		set_cpu_present(cpuid, true);
> +	}
>  }
>
>  void __init setup_smp(void)
> @@ -74,7 +85,6 @@ void __init setup_smp(void)
>
>  		cpuid_to_hartid_map(cpuid) = hart;
>  		set_cpu_possible(cpuid, true);
> -		set_cpu_present(cpuid, true);
>  		cpuid++;
>  	}

Thanks.  I've taken all three of these into for-next.

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

* Re: [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id
  2019-04-24  6:21   ` Christoph Hellwig
@ 2019-04-30  0:36     ` Palmer Dabbelt
  0 siblings, 0 replies; 11+ messages in thread
From: Palmer Dabbelt @ 2019-04-30  0:36 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: atish.patra, linux-kernel, aou, dmitriy, anup, johan,
	Christoph Hellwig, Paul Walmsley, schwab, linux-riscv, tglx

On Tue, 23 Apr 2019 23:21:00 PDT (-0700), Christoph Hellwig wrote:
>>  }
>> +
>> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
>> +{
>> +	return phys_id == cpuid_to_hartid_map(cpu);
>> +}
>>  /* Unsupported */
>
> Please keep an empty line after function bodys.
>
> Otherwise looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Oh, sorry, I missed this -- I just fixed up the patch and added your tag.

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

end of thread, other threads:[~2019-04-30  0:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24  0:02 [PATCH v3 0/3] Miscellaneous kernel command line fixes Atish Patra
2019-04-24  0:02 ` [PATCH v3 1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
2019-04-24  6:21   ` Christoph Hellwig
2019-04-30  0:36     ` Palmer Dabbelt
2019-04-24  9:07   ` Sudeep Holla
2019-04-24 16:50     ` Atish Patra
2019-04-24  0:02 ` [PATCH v3 2/3] RISC-V: Implement nosmp commandline option Atish Patra
2019-04-24  6:21   ` Christoph Hellwig
2019-04-29 23:50   ` Palmer Dabbelt
2019-04-24  0:02 ` [PATCH v3 3/3] RISC-V: Support nr_cpus command line option Atish Patra
2019-04-24  6:22   ` Christoph Hellwig

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).