Skip to content

Commit cc3595c

Browse files
Salil Mehtajongwu
authored andcommitted
arm64: kernel: Init cpu operations for all possible vcpus
Currently, cpu-operations are only initialized for the cpus which already have logical cpuid to hwid assoication established. And this only happens for the cpus which are present during boot time. To support virtual cpu hotplug, we shall initialze the cpu-operations for all possible(present+disabled) vcpus. This means logical cpuid to hwid/mpidr association might not exists(i.e. might be INVALID_HWID) during init. Later, when the vcpu is actually hotplugged logical cpuid is allocated and associated with the hwid/mpidr. This patch does some refactoring to support above change. Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: Xiongfeng Wang <[email protected]>
1 parent 5492bf5 commit cc3595c

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

arch/arm64/kernel/smp.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,18 @@ static int __init smp_cpu_setup(int cpu)
518518
const struct cpu_operations *ops;
519519

520520
if (init_cpu_ops(cpu))
521-
return -ENODEV;
521+
goto out;
522522

523523
ops = get_cpu_ops(cpu);
524524
if (ops->cpu_init(cpu))
525-
return -ENODEV;
525+
goto out;
526526

527527
// set_cpu_possible(cpu, true);
528528

529529
return 0;
530+
out:
531+
__cpu_logical_map[cpu] = INVALID_HWID;
532+
return -ENODEV;
530533
}
531534

532535
static bool bootcpu_valid __initdata;
@@ -564,7 +567,8 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
564567
pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid);
565568
#else
566569
cpu_madt_gicc[total_cpu_count] = *processor;
567-
set_cpu_possible(total_cpu_count, true);
570+
if (!smp_cpu_setup(total_cpu_count))
571+
set_cpu_possible(total_cpu_count, true);
568572
disabled_cpu_count++;
569573
#endif
570574
return;
@@ -611,9 +615,10 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
611615
*/
612616
acpi_set_mailbox_entry(total_cpu_count, processor);
613617

614-
set_cpu_possible(total_cpu_count, true);
615-
set_cpu_present(total_cpu_count, true);
616-
618+
if (!smp_cpu_setup(total_cpu_count)) {
619+
set_cpu_possible(total_cpu_count, true);
620+
set_cpu_present(total_cpu_count, true);
621+
}
617622
cpu_count++;
618623
}
619624

@@ -721,9 +726,10 @@ static void __init of_parse_and_init_cpus(void)
721726
set_cpu_logical_map(cpu_count, hwid);
722727

723728
early_map_cpu_to_node(cpu_count, of_node_to_nid(dn));
724-
725-
set_cpu_possible(cpu_count, true);
726-
set_cpu_present(cpu_count, true);
729+
if (!smp_cpu_setup(cpu_count)) {
730+
set_cpu_possible(cpu_count, true);
731+
set_cpu_present(cpu_count, true);
732+
}
727733
next:
728734
cpu_count++;
729735
}
@@ -737,7 +743,6 @@ static void __init of_parse_and_init_cpus(void)
737743
void __init smp_init_cpus(void)
738744
{
739745
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
740-
int i;
741746

742747
if (acpi_disabled)
743748
of_parse_and_init_cpus();
@@ -760,12 +765,12 @@ void __init smp_init_cpus(void)
760765
* with entries in cpu_logical_map while initializing the cpus.
761766
* If the cpu set-up fails, invalidate the cpu_logical_map entry.
762767
*/
763-
for (i = 1; i < nr_cpu_ids; i++) {
768+
/* for (i = 1; i < nr_cpu_ids; i++) {
764769
if (cpu_logical_map(i) != INVALID_HWID) {
765770
if (smp_cpu_setup(i))
766771
set_cpu_logical_map(i, INVALID_HWID);
767772
}
768-
}
773+
}*/
769774
}
770775

771776
void __init smp_prepare_cpus(unsigned int max_cpus)

0 commit comments

Comments
 (0)