Skip to content

Commit 8d06116

Browse files
Salil Mehtajongwu
Salil Mehta
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 initialize 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 6f70bd5 commit 8d06116

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

arch/arm64/kernel/smp.c

+15-24
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,16 @@ 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
return 0;
528+
out:
529+
__cpu_logical_map[cpu] = INVALID_HWID;
530+
return -ENODEV;
528531
}
529532

530533
static bool bootcpu_valid __initdata;
@@ -562,7 +565,8 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
562565
pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid);
563566
#else
564567
cpu_madt_gicc[total_cpu_count] = *processor;
565-
set_cpu_possible(total_cpu_count, true);
568+
if (!smp_cpu_setup(total_cpu_count))
569+
set_cpu_possible(total_cpu_count, true);
566570
disabled_cpu_count++;
567571
#endif
568572
return;
@@ -606,9 +610,10 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
606610
*/
607611
acpi_set_mailbox_entry(total_cpu_count, processor);
608612

609-
set_cpu_possible(total_cpu_count, true);
610-
set_cpu_present(total_cpu_count, true);
611-
613+
if (!smp_cpu_setup(total_cpu_count)) {
614+
set_cpu_possible(total_cpu_count, true);
615+
set_cpu_present(total_cpu_count, true);
616+
}
612617
cpu_count++;
613618
}
614619

@@ -716,9 +721,10 @@ static void __init of_parse_and_init_cpus(void)
716721
set_cpu_logical_map(cpu_count, hwid);
717722

718723
early_map_cpu_to_node(cpu_count, of_node_to_nid(dn));
719-
720-
set_cpu_possible(cpu_count, true);
721-
set_cpu_present(cpu_count, true);
724+
if (!smp_cpu_setup(cpu_count)) {
725+
set_cpu_possible(cpu_count, true);
726+
set_cpu_present(cpu_count, true);
727+
}
722728
next:
723729
cpu_count++;
724730
}
@@ -732,7 +738,6 @@ static void __init of_parse_and_init_cpus(void)
732738
void __init smp_init_cpus(void)
733739
{
734740
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
735-
int i;
736741

737742
if (acpi_disabled)
738743
of_parse_and_init_cpus();
@@ -747,20 +752,6 @@ void __init smp_init_cpus(void)
747752
pr_err("missing boot CPU MPIDR, not enabling secondaries\n");
748753
return;
749754
}
750-
751-
/*
752-
* We need to set the cpu_logical_map entries before enabling
753-
* the cpus so that cpu processor description entries (DT cpu nodes
754-
* and ACPI MADT entries) can be retrieved by matching the cpu hwid
755-
* with entries in cpu_logical_map while initializing the cpus.
756-
* If the cpu set-up fails, invalidate the cpu_logical_map entry.
757-
*/
758-
for (i = 1; i < nr_cpu_ids; i++) {
759-
if (cpu_logical_map(i) != INVALID_HWID) {
760-
if (smp_cpu_setup(i))
761-
set_cpu_logical_map(i, INVALID_HWID);
762-
}
763-
}
764755
}
765756

766757
void __init smp_prepare_cpus(unsigned int max_cpus)

0 commit comments

Comments
 (0)