Skip to content

Commit 3272a4a

Browse files
mwilczyrafaeljw
authored andcommitted
ACPI: processor: Move processor_physically_present() to acpi_processor.c
Since _PDC method is deprecated and a preferred method of communicating OSPM processor power management capabilities is _OSC, there is a need to move function checking whether processor is present as this logic is not _PDC specific. Move processor_physically_present() to acpi_processor.c. No intentional functional impact. Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0a0e2ea commit 3272a4a

File tree

3 files changed

+52
-50
lines changed

3 files changed

+52
-50
lines changed

drivers/acpi/acpi_processor.c

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/acpi.h>
1414
#include <linux/device.h>
15+
#include <linux/dmi.h>
1516
#include <linux/kernel.h>
1617
#include <linux/module.h>
1718
#include <linux/pci.h>
@@ -21,6 +22,8 @@
2122

2223
#include <asm/cpu.h>
2324

25+
#include <xen/xen.h>
26+
2427
#include "internal.h"
2528

2629
DEFINE_PER_CPU(struct acpi_processor *, processors);
@@ -508,7 +511,54 @@ static void acpi_processor_remove(struct acpi_device *device)
508511
}
509512
#endif /* CONFIG_ACPI_HOTPLUG_CPU */
510513

511-
#ifdef CONFIG_X86
514+
#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
515+
bool __init processor_physically_present(acpi_handle handle)
516+
{
517+
int cpuid, type;
518+
u32 acpi_id;
519+
acpi_status status;
520+
acpi_object_type acpi_type;
521+
unsigned long long tmp;
522+
union acpi_object object = {};
523+
struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
524+
525+
status = acpi_get_type(handle, &acpi_type);
526+
if (ACPI_FAILURE(status))
527+
return false;
528+
529+
switch (acpi_type) {
530+
case ACPI_TYPE_PROCESSOR:
531+
status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
532+
if (ACPI_FAILURE(status))
533+
return false;
534+
acpi_id = object.processor.proc_id;
535+
break;
536+
case ACPI_TYPE_DEVICE:
537+
status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
538+
NULL, &tmp);
539+
if (ACPI_FAILURE(status))
540+
return false;
541+
acpi_id = tmp;
542+
break;
543+
default:
544+
return false;
545+
}
546+
547+
if (xen_initial_domain())
548+
/*
549+
* When running as a Xen dom0 the number of processors Linux
550+
* sees can be different from the real number of processors on
551+
* the system, and we still need to execute _PDC or _OSC for
552+
* all of them.
553+
*/
554+
return xen_processor_present(acpi_id);
555+
556+
type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
557+
cpuid = acpi_get_cpuid(handle, type, acpi_id);
558+
559+
return !invalid_logical_cpuid(cpuid);
560+
}
561+
512562
static bool acpi_hwp_native_thermal_lvt_set;
513563
static acpi_status __init acpi_hwp_native_thermal_lvt_osc(acpi_handle handle,
514564
u32 lvl,

drivers/acpi/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ int acpi_wakeup_device_init(void);
155155
void acpi_early_processor_set_pdc(void);
156156

157157
void acpi_proc_quirk_mwait_check(void);
158+
bool processor_physically_present(acpi_handle handle);
158159
#else
159160
static inline void acpi_early_processor_set_pdc(void) {}
160161
#endif

drivers/acpi/processor_pdc.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,12 @@
99

1010
#define pr_fmt(fmt) "ACPI: " fmt
1111

12-
#include <linux/dmi.h>
1312
#include <linux/slab.h>
1413
#include <linux/acpi.h>
1514
#include <acpi/processor.h>
1615

17-
#include <xen/xen.h>
18-
1916
#include "internal.h"
2017

21-
static bool __init processor_physically_present(acpi_handle handle)
22-
{
23-
int cpuid, type;
24-
u32 acpi_id;
25-
acpi_status status;
26-
acpi_object_type acpi_type;
27-
unsigned long long tmp;
28-
union acpi_object object = { 0 };
29-
struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
30-
31-
status = acpi_get_type(handle, &acpi_type);
32-
if (ACPI_FAILURE(status))
33-
return false;
34-
35-
switch (acpi_type) {
36-
case ACPI_TYPE_PROCESSOR:
37-
status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
38-
if (ACPI_FAILURE(status))
39-
return false;
40-
acpi_id = object.processor.proc_id;
41-
break;
42-
case ACPI_TYPE_DEVICE:
43-
status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp);
44-
if (ACPI_FAILURE(status))
45-
return false;
46-
acpi_id = tmp;
47-
break;
48-
default:
49-
return false;
50-
}
51-
52-
if (xen_initial_domain())
53-
/*
54-
* When running as a Xen dom0 the number of processors Linux
55-
* sees can be different from the real number of processors on
56-
* the system, and we still need to execute _PDC for all of
57-
* them.
58-
*/
59-
return xen_processor_present(acpi_id);
60-
61-
type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
62-
cpuid = acpi_get_cpuid(handle, type, acpi_id);
63-
64-
return !invalid_logical_cpuid(cpuid);
65-
}
66-
6718
static void acpi_set_pdc_bits(u32 *buf)
6819
{
6920
buf[0] = ACPI_PDC_REVISION_ID;

0 commit comments

Comments
 (0)