linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v1 PATCH 1/4] RISC-V: Add RISC-V specific arch_match_cpu_phys_id
@ 2019-03-19 22:20 Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 2/4] RISC-V: Fix of_get_cpu_node usage Atish Patra
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Atish Patra @ 2019-03-19 22:20 UTC (permalink / raw)
  To: linux-riscv
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-kernel, Palmer Dabbelt,
	Paul Walmsley, Damien Le Moal, Anup Patel

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.

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

diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
index 0c41d07e..94db7266 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] 7+ messages in thread

* [v1 PATCH 2/4] RISC-V: Fix of_get_cpu_node usage
  2019-03-19 22:20 [v1 PATCH 1/4] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
@ 2019-03-19 22:20 ` Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 3/4] RISC-V: Implement nosmp commandline option Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option Atish Patra
  2 siblings, 0 replies; 7+ messages in thread
From: Atish Patra @ 2019-03-19 22:20 UTC (permalink / raw)
  To: linux-riscv
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-kernel, Palmer Dabbelt,
	Paul Walmsley, Damien Le Moal, Anup Patel

of_get_cpu_node expects a logical cpu id not a hartid.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
 arch/riscv/kernel/cpu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index cf2fca12..c8d2a322 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);
-- 
2.21.0


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

* [v1 PATCH 3/4] RISC-V: Implement nosmp commandline option.
  2019-03-19 22:20 [v1 PATCH 1/4] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 2/4] RISC-V: Fix of_get_cpu_node usage Atish Patra
@ 2019-03-19 22:20 ` Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option Atish Patra
  2 siblings, 0 replies; 7+ messages in thread
From: Atish Patra @ 2019-03-19 22:20 UTC (permalink / raw)
  To: linux-riscv
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-kernel, Palmer Dabbelt,
	Paul Walmsley, Damien Le Moal, Anup Patel

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 df353199..609475c5 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -49,6 +49,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)
@@ -76,7 +87,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] 7+ messages in thread

* [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option.
  2019-03-19 22:20 [v1 PATCH 1/4] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 2/4] RISC-V: Fix of_get_cpu_node usage Atish Patra
  2019-03-19 22:20 ` [v1 PATCH 3/4] RISC-V: Implement nosmp commandline option Atish Patra
@ 2019-03-19 22:20 ` Atish Patra
  2019-03-19 23:56   ` Damien Le Moal
  2 siblings, 1 reply; 7+ messages in thread
From: Atish Patra @ 2019-03-19 22:20 UTC (permalink / raw)
  To: linux-riscv
  Cc: Atish Patra, Albert Ou, Andreas Schwab, Anup Patel,
	Dmitriy Cherkasov, Johan Hovold, linux-kernel, Palmer Dabbelt,
	Paul Walmsley, Damien Le Moal, Anup Patel

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 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 609475c5..a8fe590c 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -86,11 +86,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] are greater than configured via nr_cpus [%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] 7+ messages in thread

* Re: [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option.
  2019-03-19 22:20 ` [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option Atish Patra
@ 2019-03-19 23:56   ` Damien Le Moal
  2019-03-19 23:58     ` Damien Le Moal
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2019-03-19 23:56 UTC (permalink / raw)
  To: Atish Patra, linux-riscv
  Cc: Albert Ou, Andreas Schwab, Anup Patel, Dmitriy Cherkasov,
	Johan Hovold, linux-kernel, Palmer Dabbelt, Paul Walmsley,
	Anup Patel

On 2019/03/20 7:20, 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>
> ---
>  arch/riscv/kernel/smpboot.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
> index 609475c5..a8fe590c 100644
> --- a/arch/riscv/kernel/smpboot.c
> +++ b/arch/riscv/kernel/smpboot.c
> @@ -86,11 +86,19 @@ void __init setup_smp(void)
>  		}
>  
>  		cpuid_to_hartid_map(cpuid) = hart;
> -		set_cpu_possible(cpuid, true);

This looks weird: the code being changed does not match what patch 3/4 did.

>  		cpuid++;
>  	}
>  
>  	BUG_ON(!found_boot_cpu);
> +
> +	if (cpuid > nr_cpu_ids)
> +		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",

"The 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)
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option.
  2019-03-19 23:56   ` Damien Le Moal
@ 2019-03-19 23:58     ` Damien Le Moal
  2019-03-20  1:29       ` Atish Patra
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2019-03-19 23:58 UTC (permalink / raw)
  To: Atish Patra, linux-riscv
  Cc: Albert Ou, Andreas Schwab, Anup Patel, Dmitriy Cherkasov,
	Johan Hovold, linux-kernel, Palmer Dabbelt, Paul Walmsley,
	Anup Patel

On 2019/03/20 8:56, Damien Le Moal wrote:
> On 2019/03/20 7:20, 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>
>> ---
>>  arch/riscv/kernel/smpboot.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
>> index 609475c5..a8fe590c 100644
>> --- a/arch/riscv/kernel/smpboot.c
>> +++ b/arch/riscv/kernel/smpboot.c
>> @@ -86,11 +86,19 @@ void __init setup_smp(void)
>>  		}
>>  
>>  		cpuid_to_hartid_map(cpuid) = hart;
>> -		set_cpu_possible(cpuid, true);
> 
> This looks weird: the code being changed does not match what patch 3/4 did.

Arg... Ignore this one. My bad. Morning here, I need more coffee :)

> 
>>  		cpuid++;
>>  	}
>>  
>>  	BUG_ON(!found_boot_cpu);
>> +
>> +	if (cpuid > nr_cpu_ids)
>> +		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",
> 
> "The 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)
>>
> 
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option.
  2019-03-19 23:58     ` Damien Le Moal
@ 2019-03-20  1:29       ` Atish Patra
  0 siblings, 0 replies; 7+ messages in thread
From: Atish Patra @ 2019-03-20  1:29 UTC (permalink / raw)
  To: Damien Le Moal, linux-riscv
  Cc: Albert Ou, Andreas Schwab, Anup Patel, Dmitriy Cherkasov,
	Johan Hovold, linux-kernel, Palmer Dabbelt, Paul Walmsley,
	Anup Patel

On 3/19/19 4:58 PM, Damien Le Moal wrote:
> On 2019/03/20 8:56, Damien Le Moal wrote:
>> On 2019/03/20 7:20, 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>
>>> ---
>>>   arch/riscv/kernel/smpboot.c | 10 +++++++++-
>>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
>>> index 609475c5..a8fe590c 100644
>>> --- a/arch/riscv/kernel/smpboot.c
>>> +++ b/arch/riscv/kernel/smpboot.c
>>> @@ -86,11 +86,19 @@ void __init setup_smp(void)
>>>   		}
>>>   
>>>   		cpuid_to_hartid_map(cpuid) = hart;
>>> -		set_cpu_possible(cpuid, true);
>>
>> This looks weird: the code being changed does not match what patch 3/4 did.
> 
> Arg... Ignore this one. My bad. Morning here, I need more coffee :)
> 
:).

>>
>>>   		cpuid++;
>>>   	}
>>>   
>>>   	BUG_ON(!found_boot_cpu);
>>> +
>>> +	if (cpuid > nr_cpu_ids)
>>> +		pr_warn("Total number of cpus [%d] are greater than configured via nr_cpus [%d]\n",
>>
>> "The total number of cpus [%d] is greater than nr_cpus option value [%d]\n"
>>

ok. I will fix it in v2.

Regards,
Atish
>>> +			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)
>>>
>>
>>
> 
> 


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

end of thread, other threads:[~2019-03-20  1:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 22:20 [v1 PATCH 1/4] RISC-V: Add RISC-V specific arch_match_cpu_phys_id Atish Patra
2019-03-19 22:20 ` [v1 PATCH 2/4] RISC-V: Fix of_get_cpu_node usage Atish Patra
2019-03-19 22:20 ` [v1 PATCH 3/4] RISC-V: Implement nosmp commandline option Atish Patra
2019-03-19 22:20 ` [v1 PATCH 4/4] RISC-V: Support nr_cpus command line option Atish Patra
2019-03-19 23:56   ` Damien Le Moal
2019-03-19 23:58     ` Damien Le Moal
2019-03-20  1:29       ` Atish Patra

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