Skip to content

Commit a4166ae

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Deduplicate code in setup_smp()
Both the ACPI and DT implementations contain some of the same code. Move it to the calling function so it is not duplicated. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20231121234736.3489608-2-samuel.holland@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent b85ea95 commit a4166ae

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

arch/riscv/kernel/smpboot.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,7 @@ static int __init acpi_parse_rintc(union acpi_subtable_headers *header, const un
125125

126126
static void __init acpi_parse_and_init_cpus(void)
127127
{
128-
int cpuid;
129-
130-
cpu_set_ops(0);
131-
132128
acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, acpi_parse_rintc, 0);
133-
134-
for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
135-
if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) {
136-
cpu_set_ops(cpuid);
137-
set_cpu_possible(cpuid, true);
138-
}
139-
}
140129
}
141130
#else
142131
#define acpi_parse_and_init_cpus(...) do { } while (0)
@@ -150,8 +139,6 @@ static void __init of_parse_and_init_cpus(void)
150139
int cpuid = 1;
151140
int rc;
152141

153-
cpu_set_ops(0);
154-
155142
for_each_of_cpu_node(dn) {
156143
rc = riscv_early_of_processor_hartid(dn, &hart);
157144
if (rc < 0)
@@ -179,21 +166,25 @@ static void __init of_parse_and_init_cpus(void)
179166
if (cpuid > nr_cpu_ids)
180167
pr_warn("Total number of cpus [%d] is greater than nr_cpus option value [%d]\n",
181168
cpuid, nr_cpu_ids);
182-
183-
for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
184-
if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) {
185-
cpu_set_ops(cpuid);
186-
set_cpu_possible(cpuid, true);
187-
}
188-
}
189169
}
190170

191171
void __init setup_smp(void)
192172
{
173+
int cpuid;
174+
175+
cpu_set_ops(0);
176+
193177
if (acpi_disabled)
194178
of_parse_and_init_cpus();
195179
else
196180
acpi_parse_and_init_cpus();
181+
182+
for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) {
183+
if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) {
184+
cpu_set_ops(cpuid);
185+
set_cpu_possible(cpuid, true);
186+
}
187+
}
197188
}
198189

199190
static int start_secondary_cpu(int cpu, struct task_struct *tidle)

0 commit comments

Comments
 (0)