Skip to content

Commit 0867205

Browse files
Salil Mehtajongwu
authored andcommitted
arm64: kernel: Handle disabled[(+)present] cpus in MADT/GICC during init
With ACPI enabled, cpus get identified by the presence of the GICC entry in the MADT Table. Each GICC entry part of MADT presents cpu as enabled or disabled. As of now, the disabled cpus are skipped as physical cpu hotplug is not supported. These remain disabled even after the kernel has booted. To support virtual cpu hotplug(in which case disabled vcpus could be hotplugged even after kernel has booted), QEMU will populate MADT Table with appropriate details of GICC entry for each possible(present+disabled) vcpu. Now, during the init time vcpus will be identified as present or disabled. To achieve this, below changes have been made with respect to the present/possible vcpu handling along with the mentioned reasoning: 1. Identify all possible(present+disabled) vcpus at boot/init time and set their present mask and possible mask. In the existing code, cpus are being marked present quite late within smp_prepare_cpus() function, which gets called in context to the kernel thread. Since the cpu hotplug is not supported, present cpus are always equal to the possible cpus. But with cpu hotplug enabled, this assumption is not true. Hence, present cpus should be marked while MADT GICC entries are bring parsed for each vcpu. 2. Set possible cpus to include disabled. This needs to be done now while parsing MADT GICC entries corresponding to each vcpu as the disabled vcpu info is available only at this point as for hotplug case possible vcpus is not equal to present vcpus. 3. We will store the parsed madt/gicc entry even for the disabled vcpus during init time. This is needed as some modules like PMU registers IRQs for each possible vcpus during init time. Therefore, a valid entry of the MADT GICC should be present for all possible vcpus. 4. Refactoring related to DT/OF is also done to align it with the init changes to support vcpu hotplug. Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: Xiongfeng Wang <[email protected]>
1 parent 7d768fa commit 0867205

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

arch/arm64/kernel/smp.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,12 @@ static int __init smp_cpu_setup(int cpu)
524524
if (ops->cpu_init(cpu))
525525
return -ENODEV;
526526

527-
set_cpu_possible(cpu, true);
528-
529527
return 0;
530528
}
531529

532530
static bool bootcpu_valid __initdata;
533531
static unsigned int cpu_count = 1;
532+
static unsigned int disabled_cpu_count;
534533

535534
#ifdef CONFIG_ACPI
536535
static struct acpi_madt_generic_interrupt cpu_madt_gicc[NR_CPUS];
@@ -549,10 +548,17 @@ struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu)
549548
static void __init
550549
acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
551550
{
551+
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
552552
u64 hwid = processor->arm_mpidr;
553553

554554
if (!(processor->flags & ACPI_MADT_ENABLED)) {
555+
#ifndef CONFIG_ACPI_HOTPLUG_CPU
555556
pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid);
557+
#else
558+
cpu_madt_gicc[total_cpu_count] = *processor;
559+
set_cpu_possible(total_cpu_count, true);
560+
disabled_cpu_count++;
561+
#endif
556562
return;
557563
}
558564

@@ -561,7 +567,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
561567
return;
562568
}
563569

564-
if (is_mpidr_duplicate(cpu_count, hwid)) {
570+
if (is_mpidr_duplicate(total_cpu_count, hwid)) {
565571
pr_err("duplicate CPU MPIDR 0x%llx in MADT\n", hwid);
566572
return;
567573
}
@@ -582,9 +588,9 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
582588
return;
583589

584590
/* map the logical cpu id to cpu MPIDR */
585-
set_cpu_logical_map(cpu_count, hwid);
591+
set_cpu_logical_map(total_cpu_count, hwid);
586592

587-
cpu_madt_gicc[cpu_count] = *processor;
593+
cpu_madt_gicc[total_cpu_count] = *processor;
588594

589595
/*
590596
* Set-up the ACPI parking protocol cpu entries
@@ -595,7 +601,10 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
595601
* initialize the cpu if the parking protocol is
596602
* the only available enable method).
597603
*/
598-
acpi_set_mailbox_entry(cpu_count, processor);
604+
acpi_set_mailbox_entry(total_cpu_count, processor);
605+
606+
set_cpu_possible(total_cpu_count, true);
607+
set_cpu_present(total_cpu_count, true);
599608

600609
cpu_count++;
601610
}
@@ -629,6 +638,9 @@ static void __init acpi_parse_and_init_cpus(void)
629638
acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
630639
acpi_parse_gic_cpu_interface, 0);
631640

641+
pr_debug("possible cpus(%u) present cpus(%u) disabled cpus(%u)\n",
642+
cpu_count+disabled_cpu_count, cpu_count, disabled_cpu_count);
643+
632644
/*
633645
* In ACPI, SMP and CPU NUMA information is provided in separate
634646
* static tables, namely the MADT and the SRAT.
@@ -699,6 +711,9 @@ static void __init of_parse_and_init_cpus(void)
699711
set_cpu_logical_map(cpu_count, hwid);
700712

701713
early_map_cpu_to_node(cpu_count, of_node_to_nid(dn));
714+
715+
set_cpu_possible(cpu_count, true);
716+
set_cpu_present(cpu_count, true);
702717
next:
703718
cpu_count++;
704719
}
@@ -783,7 +798,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
783798
if (err)
784799
continue;
785800

786-
set_cpu_present(cpu, true);
787801
numa_store_cpu_info(cpu);
788802
}
789803
}

0 commit comments

Comments
 (0)