diff mbox series

[v3,1/3] RISC-V: Add RISC-V specific arch_match_cpu_phys_id

Message ID 20190424000227.3085-2-atish.patra@wdc.com (mailing list archive)
State New, archived
Headers show
Series Miscellaneous kernel command line fixes | expand

Commit Message

Atish Patra April 24, 2019, 12:02 a.m. UTC
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(-)

Comments

Christoph Hellwig April 24, 2019, 6:21 a.m. UTC | #1
>  }
> +
> +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>
Sudeep Holla April 24, 2019, 9:07 a.m. UTC | #2
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
>
Atish Patra April 24, 2019, 4:50 p.m. UTC | #3
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
>>
>
Palmer Dabbelt April 30, 2019, 12:36 a.m. UTC | #4
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.
diff mbox series

Patch

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