Skip to content

Commit 932df74

Browse files
Lin Minglenb
authored andcommitted
ACPI: processor: fix processor_physically_present in UP kernel
Usually, there are multiple processors defined in ACPI table, for example Scope (_PR) { Processor (CPU0, 0x00, 0x00000410, 0x06) {} Processor (CPU1, 0x01, 0x00000410, 0x06) {} Processor (CPU2, 0x02, 0x00000410, 0x06) {} Processor (CPU3, 0x03, 0x00000410, 0x06) {} } processor_physically_present(...) will be called to check whether those processors are physically present. Currently we have below codes in processor_physically_present, cpuid = acpi_get_cpuid(...); if ((cpuid == -1) && (num_possible_cpus() > 1)) return false; return true; In UP kernel, acpi_get_cpuid(...) always return -1 and num_possible_cpus() always return 1, so processor_physically_present(...) always returns true for all passed in processor handles. This is wrong for UP processor or SMP processor running UP kernel. This patch removes the !SMP version of acpi_get_cpuid(), so both UP and SMP kernel use the same acpi_get_cpuid function. And for UP kernel, only processor 0 is valid. https://bugzilla.kernel.org/show_bug.cgi?id=16548 https://bugzilla.kernel.org/show_bug.cgi?id=16357 Tested-by: Anton Kochkov <anton.kochkov@gmail.com> Tested-by: Ambroz Bizjak <ambrop7@gmail.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 61c4f2c commit 932df74

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎drivers/acpi/processor_core.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static struct dmi_system_id __initdata processor_idle_dmi_table[] = {
3737
{},
3838
};
3939

40-
#ifdef CONFIG_SMP
4140
static int map_lapic_id(struct acpi_subtable_header *entry,
4241
u32 acpi_id, int *apic_id)
4342
{
@@ -165,7 +164,9 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
165164

166165
int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
167166
{
167+
#ifdef CONFIG_SMP
168168
int i;
169+
#endif
169170
int apic_id = -1;
170171

171172
apic_id = map_mat_entry(handle, type, acpi_id);
@@ -174,14 +175,19 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
174175
if (apic_id == -1)
175176
return apic_id;
176177

178+
#ifdef CONFIG_SMP
177179
for_each_possible_cpu(i) {
178180
if (cpu_physical_id(i) == apic_id)
179181
return i;
180182
}
183+
#else
184+
/* In UP kernel, only processor 0 is valid */
185+
if (apic_id == 0)
186+
return apic_id;
187+
#endif
181188
return -1;
182189
}
183190
EXPORT_SYMBOL_GPL(acpi_get_cpuid);
184-
#endif
185191

186192
static bool __init processor_physically_present(acpi_handle handle)
187193
{
@@ -217,7 +223,7 @@ static bool __init processor_physically_present(acpi_handle handle)
217223
type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
218224
cpuid = acpi_get_cpuid(handle, type, acpi_id);
219225

220-
if ((cpuid == -1) && (num_possible_cpus() > 1))
226+
if (cpuid == -1)
221227
return false;
222228

223229
return true;

‎include/acpi/processor.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,7 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
310310

311311
/* in processor_core.c */
312312
void acpi_processor_set_pdc(acpi_handle handle);
313-
#ifdef CONFIG_SMP
314313
int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
315-
#else
316-
static inline int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
317-
{
318-
return -1;
319-
}
320-
#endif
321314

322315
/* in processor_throttling.c */
323316
int acpi_processor_tstate_has_changed(struct acpi_processor *pr);

0 commit comments

Comments
 (0)