diff mbox series

target/loongarch: cpu: Implement get_arch_id callback

Message ID 20230822122634.1435006-1-maobibo@loongson.cn (mailing list archive)
State New, archived
Headers show
Series target/loongarch: cpu: Implement get_arch_id callback | expand

Commit Message

bibo mao Aug. 22, 2023, 12:26 p.m. UTC
Implement the callback for getting the architecture-dependent CPU
ID, the cpu ID is physical id described in ACPI MADT table, this
will be used for cpu hotplug.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Change-Id: I53bcfb9f4279e491f33e8b99a9102534ad53409e
---
 hw/loongarch/virt.c    | 2 ++
 target/loongarch/cpu.c | 8 ++++++++
 target/loongarch/cpu.h | 1 +
 3 files changed, 11 insertions(+)

Comments

gaosong Aug. 23, 2023, 1:14 a.m. UTC | #1
在 2023/8/22 下午8:26, Bibo Mao 写道:
> Implement the callback for getting the architecture-dependent CPU
> ID, the cpu ID is physical id described in ACPI MADT table, this
> will be used for cpu hotplug.
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> Change-Id: I53bcfb9f4279e491f33e8b99a9102534ad53409e
> ---

Drop Chang-Id.

Otherwise
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao

>   hw/loongarch/virt.c    | 2 ++
>   target/loongarch/cpu.c | 8 ++++++++
>   target/loongarch/cpu.h | 1 +
>   3 files changed, 11 insertions(+)
> 
> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
> index e19b042ce8..6f6b577749 100644
> --- a/hw/loongarch/virt.c
> +++ b/hw/loongarch/virt.c
> @@ -815,6 +815,8 @@ static void loongarch_init(MachineState *machine)
>           cpu = cpu_create(machine->cpu_type);
>           cpu->cpu_index = i;
>           machine->possible_cpus->cpus[i].cpu = OBJECT(cpu);
> +        lacpu = LOONGARCH_CPU(cpu);
> +        lacpu->phy_id = machine->possible_cpus->cpus[i].arch_id;
>       }
>       fdt_add_cpu_nodes(lams);
>   
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index ad93ecac92..7be3769672 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -690,6 +690,13 @@ static struct TCGCPUOps loongarch_tcg_ops = {
>   static const struct SysemuCPUOps loongarch_sysemu_ops = {
>       .get_phys_page_debug = loongarch_cpu_get_phys_page_debug,
>   };
> +
> +static int64_t loongarch_cpu_get_arch_id(CPUState *cs)
> +{
> +    LoongArchCPU *cpu = LOONGARCH_CPU(cs);
> +
> +    return cpu->phy_id;
> +}
>   #endif
>   
>   static gchar *loongarch_gdb_arch_name(CPUState *cs)
> @@ -715,6 +722,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)
>       cc->set_pc = loongarch_cpu_set_pc;
>       cc->get_pc = loongarch_cpu_get_pc;
>   #ifndef CONFIG_USER_ONLY
> +    cc->get_arch_id = loongarch_cpu_get_arch_id;
>       dc->vmsd = &vmstate_loongarch_cpu;
>       cc->sysemu_ops = &loongarch_sysemu_ops;
>   #endif
> diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
> index fa371ca8ba..033081593c 100644
> --- a/target/loongarch/cpu.h
> +++ b/target/loongarch/cpu.h
> @@ -371,6 +371,7 @@ struct ArchCPU {
>       CPUNegativeOffsetState neg;
>       CPULoongArchState env;
>       QEMUTimer timer;
> +    uint32_t  phy_id;
>   
>       /* 'compatible' string for this CPU for Linux device trees */
>       const char *dtb_compatible;
>
bibo mao Aug. 23, 2023, 1:34 a.m. UTC | #2
在 2023/8/23 09:14, gaosong 写道:
> 在 2023/8/22 下午8:26, Bibo Mao 写道:
>> Implement the callback for getting the architecture-dependent CPU
>> ID, the cpu ID is physical id described in ACPI MADT table, this
>> will be used for cpu hotplug.
>>
>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>> Change-Id: I53bcfb9f4279e491f33e8b99a9102534ad53409e
>> ---
> 
> Drop Chang-Id.
sure, will fix in next version.

Regards
Bibo Mao
> 
> Otherwise
> Reviewed-by: Song Gao <gaosong@loongson.cn>
> 
> Thanks.
> Song Gao
> 
>>   hw/loongarch/virt.c    | 2 ++
>>   target/loongarch/cpu.c | 8 ++++++++
>>   target/loongarch/cpu.h | 1 +
>>   3 files changed, 11 insertions(+)
>>
>> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
>> index e19b042ce8..6f6b577749 100644
>> --- a/hw/loongarch/virt.c
>> +++ b/hw/loongarch/virt.c
>> @@ -815,6 +815,8 @@ static void loongarch_init(MachineState *machine)
>>           cpu = cpu_create(machine->cpu_type);
>>           cpu->cpu_index = i;
>>           machine->possible_cpus->cpus[i].cpu = OBJECT(cpu);
>> +        lacpu = LOONGARCH_CPU(cpu);
>> +        lacpu->phy_id = machine->possible_cpus->cpus[i].arch_id;
>>       }
>>       fdt_add_cpu_nodes(lams);
>>   diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
>> index ad93ecac92..7be3769672 100644
>> --- a/target/loongarch/cpu.c
>> +++ b/target/loongarch/cpu.c
>> @@ -690,6 +690,13 @@ static struct TCGCPUOps loongarch_tcg_ops = {
>>   static const struct SysemuCPUOps loongarch_sysemu_ops = {
>>       .get_phys_page_debug = loongarch_cpu_get_phys_page_debug,
>>   };
>> +
>> +static int64_t loongarch_cpu_get_arch_id(CPUState *cs)
>> +{
>> +    LoongArchCPU *cpu = LOONGARCH_CPU(cs);
>> +
>> +    return cpu->phy_id;
>> +}
>>   #endif
>>     static gchar *loongarch_gdb_arch_name(CPUState *cs)
>> @@ -715,6 +722,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)
>>       cc->set_pc = loongarch_cpu_set_pc;
>>       cc->get_pc = loongarch_cpu_get_pc;
>>   #ifndef CONFIG_USER_ONLY
>> +    cc->get_arch_id = loongarch_cpu_get_arch_id;
>>       dc->vmsd = &vmstate_loongarch_cpu;
>>       cc->sysemu_ops = &loongarch_sysemu_ops;
>>   #endif
>> diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
>> index fa371ca8ba..033081593c 100644
>> --- a/target/loongarch/cpu.h
>> +++ b/target/loongarch/cpu.h
>> @@ -371,6 +371,7 @@ struct ArchCPU {
>>       CPUNegativeOffsetState neg;
>>       CPULoongArchState env;
>>       QEMUTimer timer;
>> +    uint32_t  phy_id;
>>         /* 'compatible' string for this CPU for Linux device trees */
>>       const char *dtb_compatible;
>>
>
diff mbox series

Patch

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index e19b042ce8..6f6b577749 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -815,6 +815,8 @@  static void loongarch_init(MachineState *machine)
         cpu = cpu_create(machine->cpu_type);
         cpu->cpu_index = i;
         machine->possible_cpus->cpus[i].cpu = OBJECT(cpu);
+        lacpu = LOONGARCH_CPU(cpu);
+        lacpu->phy_id = machine->possible_cpus->cpus[i].arch_id;
     }
     fdt_add_cpu_nodes(lams);
 
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index ad93ecac92..7be3769672 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -690,6 +690,13 @@  static struct TCGCPUOps loongarch_tcg_ops = {
 static const struct SysemuCPUOps loongarch_sysemu_ops = {
     .get_phys_page_debug = loongarch_cpu_get_phys_page_debug,
 };
+
+static int64_t loongarch_cpu_get_arch_id(CPUState *cs)
+{
+    LoongArchCPU *cpu = LOONGARCH_CPU(cs);
+
+    return cpu->phy_id;
+}
 #endif
 
 static gchar *loongarch_gdb_arch_name(CPUState *cs)
@@ -715,6 +722,7 @@  static void loongarch_cpu_class_init(ObjectClass *c, void *data)
     cc->set_pc = loongarch_cpu_set_pc;
     cc->get_pc = loongarch_cpu_get_pc;
 #ifndef CONFIG_USER_ONLY
+    cc->get_arch_id = loongarch_cpu_get_arch_id;
     dc->vmsd = &vmstate_loongarch_cpu;
     cc->sysemu_ops = &loongarch_sysemu_ops;
 #endif
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index fa371ca8ba..033081593c 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -371,6 +371,7 @@  struct ArchCPU {
     CPUNegativeOffsetState neg;
     CPULoongArchState env;
     QEMUTimer timer;
+    uint32_t  phy_id;
 
     /* 'compatible' string for this CPU for Linux device trees */
     const char *dtb_compatible;