2023-07-10 14:08:27

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 0/9] Prefer using _OSC method over deprecated _PDC

ACPI 3.0 introduced a new Operating System Capabilities _OSC control
method. This method is similar to _PDC, which was marked as deprecated
in ACPI 3.0.

Prefer using _OSC method over deprecated _PDC in the acpi_bus_init(). In
case of the failure of the _OSC, try using _PDC as a fallback.

Testing done:
Tested on physical server with BIOS implementing _OSC methods. In this
case acpi_processor_osc() was executed for each CPU core. acpi_run_osc()
returned success indicating that _OSC method succeeded.

Tested on qemu VM to check whether the code would work on a SeaBios (the
default for qemu, doesn't support _OSC methods, or _PDC). This way I was
able to see how code behaves in case BIOS doesn't implement _OSC. In
that case the function
acpi_run_osc() returned failure, which propagated all the way up to
acpi_early_processor_osc(). The logic responsible for triggering _PDC
execution was triggered correctly.

Tested this using debug messages with printk.

v4:
- move setting processor capabilities bits into arch code
- move workaround for mwait to acpi/x86 directory
- rename ACPI_PDC* constants to more generic ACPI_PROC_CAP*
- introduce new function acpi_early_processor_control_setup()

v3:
- split into more commits to make review easier
- changed "_UID" to METHOD_NAME_UID
- changed hard-coded constant to ACPI_PDC_COLLAB_PROC_PERF
- added Suggested-by tags
- fixed style issues
- fixed whitespaces
- refactored code
v2:
- fixed compilation issues on ia64 and arm

Michal Wilczynski (9):
acpi: Move mwait quirk out of acpi_processor.c
acpi: Move processor_physically_present() to acpi_processor.c
acpi: Refactor arch_acpi_set_pdc_bits()
acpi: Rename ACPI_PDC constants
acpi: Clear C_C2C3_FFH and C_C1_FFH in arch_acpi_set_proc_cap_bits()
acpi: Move setting CAP_SMP_T_SWCOORD to arch_acpi_set_proc_cap_bits()
acpi: Introduce acpi_processor_osc()
acpi: Use _OSC method to convey processor OSPM capabilities
acpi: Remove acpi_hwp_native_thermal_lvt_osc()

arch/ia64/include/asm/acpi.h | 6 +-
arch/x86/include/asm/acpi.h | 24 ++++---
arch/x86/xen/enlighten_pv.c | 8 +--
drivers/acpi/acpi_processor.c | 121 +++++++++++++++++++++++++---------
drivers/acpi/bus.c | 5 +-
drivers/acpi/internal.h | 10 ++-
drivers/acpi/processor_pdc.c | 97 +--------------------------
drivers/acpi/x86/utils.c | 35 ++++++++++
include/acpi/pdc_intel.h | 36 ----------
include/acpi/proc_cap_intel.h | 40 +++++++++++
10 files changed, 194 insertions(+), 188 deletions(-)
delete mode 100644 include/acpi/pdc_intel.h
create mode 100644 include/acpi/proc_cap_intel.h

--
2.41.0



2023-07-10 14:09:05

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 3/9] acpi: Refactor arch_acpi_set_pdc_bits()

Capabilities buffer modified by the arch_acpi_set_pdc_bits() is not
_PDC specific, as it is used by _OSC method as well. Change function
name to better reflect it's independence from _PDC. Change function
expected argument to pass capability buffer directly without any
offset, as the offset differ among _OSC and _PDC methods.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
arch/ia64/include/asm/acpi.h | 4 ++--
arch/x86/include/asm/acpi.h | 10 +++++-----
drivers/acpi/processor_pdc.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index 87927eb824cc..43797cb44383 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -69,9 +69,9 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
#endif

static inline bool arch_has_acpi_pdc(void) { return true; }
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
+static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
{
- buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
+ *cap |= ACPI_PDC_EST_CAPABILITY_SMP;
}

#ifdef CONFIG_ACPI_NUMA
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 8eb74cf386db..6a498d1781e7 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -100,23 +100,23 @@ static inline bool arch_has_acpi_pdc(void)
c->x86_vendor == X86_VENDOR_CENTAUR);
}

-static inline void arch_acpi_set_pdc_bits(u32 *buf)
+static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
{
struct cpuinfo_x86 *c = &cpu_data(0);

- buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
+ *cap |= ACPI_PDC_C_CAPABILITY_SMP;

if (cpu_has(c, X86_FEATURE_EST))
- buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+ *cap |= ACPI_PDC_EST_CAPABILITY_SWSMP;

if (cpu_has(c, X86_FEATURE_ACPI))
- buf[2] |= ACPI_PDC_T_FFH;
+ *cap |= ACPI_PDC_T_FFH;

/*
* If mwait/monitor is unsupported, C2/C3_FFH will be disabled
*/
if (!cpu_has(c, X86_FEATURE_MWAIT))
- buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
+ *cap &= ~(ACPI_PDC_C_C2C3_FFH);
}

static inline bool acpi_has_cpu_in_madt(void)
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index 6d2d521a068d..b2c6f17fc87c 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -24,7 +24,7 @@ static void acpi_set_pdc_bits(u32 *buf)
buf[2] = ACPI_PDC_SMP_T_SWCOORD;

/* Twiddle arch-specific bits needed for _PDC */
- arch_acpi_set_pdc_bits(buf);
+ arch_acpi_set_proc_cap_bits(&buf[2]);
}

static struct acpi_object_list *acpi_processor_alloc_pdc(void)
--
2.41.0


2023-07-10 14:09:42

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 5/9] acpi: Clear C_C2C3_FFH and C_C1_FFH in arch_acpi_set_proc_cap_bits()

Currently arch_acpi_set_proc_cap_bits() clears ACPI_PDC_C_C2C3_FFH bit in
case MWAIT instruction is not supported. It should also clear
ACPI_PDC_C_C1_FFH, as when MWAIT is not supported C1 is accomplished
with HALT instruction. Quote from documentation describing C_C1_FFH:
"If set, OSPM is capable of performing native C State instructions (beyond
halt) for the C1 handler in multi-processor configurations". As without
MWAIT there is no native C-state instructions beyond HALT, this bit
should be toggled off.

Clear ACPI_PDC_C_C1_FFH and ACPI_PDC_C_C2C3_FFH in
arch_acpi_set_proc_cap_bits() in case MWAIT is not supported or overridden.
Remove setting those bits in processor_pdc.c code.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
---
arch/x86/include/asm/acpi.h | 9 +++++----
drivers/acpi/processor_pdc.c | 14 --------------
2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index ce5ad6a496e6..d615238bcd78 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -113,11 +113,12 @@ static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
*cap |= ACPI_PROC_CAP_T_FFH;

/*
- * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
+ * If mwait/monitor is unsupported, C_C1_FFH and
+ * C2/C3_FFH will be disabled.
*/
- if (!cpu_has(c, X86_FEATURE_MWAIT))
- *cap &= ~(ACPI_PROC_CAP_C_C2C3_FFH);
-
+ if (!cpu_has(c, X86_FEATURE_MWAIT) ||
+ boot_option_idle_override == IDLE_NOMWAIT)
+ *cap &= ~(ACPI_PROC_CAP_C_C1_FFH | ACPI_PROC_CAP_C_C2C3_FFH);
}

static inline bool acpi_has_cpu_in_madt(void)
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index 77d3fe73047c..b4b906b70a0b 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -74,20 +74,6 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
{
acpi_status status = AE_OK;

- if (boot_option_idle_override == IDLE_NOMWAIT) {
- /*
- * If mwait is disabled for CPU C-states, the C2C3_FFH access
- * mode will be disabled in the parameter of _PDC object.
- * Of course C1_FFH access mode will also be disabled.
- */
- union acpi_object *obj;
- u32 *buffer = NULL;
-
- obj = pdc_in->pointer;
- buffer = (u32 *)(obj->buffer.pointer);
- buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
-
- }
status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);

if (ACPI_FAILURE(status))
--
2.41.0


2023-07-10 14:17:48

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 7/9] acpi: Introduce acpi_processor_osc()

Currently in ACPI code _OSC method is already used for workaround
introduced in commit a21211672c9a ("ACPI / processor: Request native
thermal interrupt handling via _OSC"). Create new function, similar to
already existing acpi_hwp_native_thermal_lvt_osc(). Call new function
acpi_processor_osc(). Make this function fulfill the purpose previously
fulfilled by the workaround plus convey OSPM processor capabilities
with it by setting correct processor capabilities bits. Don't include
unnecessary acknowledgment present in
acpi_hwp_native_thermal_lvt_osc(). Set ACPI_PROC_CAP_COLLAB_PROC_PERF
in arch code for coherency.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
arch/x86/include/asm/acpi.h | 3 +++
drivers/acpi/acpi_processor.c | 29 ++++++++++++++++++++++++++++-
include/acpi/proc_cap_intel.h | 1 +
3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 6f6752a2ea36..6c3af9486153 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -115,6 +115,9 @@ static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
if (cpu_has(c, X86_FEATURE_ACPI))
*cap |= ACPI_PROC_CAP_T_FFH;

+ if (cpu_has(c, X86_FEATURE_HWP))
+ *cap |= ACPI_PROC_CAP_COLLAB_PROC_PERF;
+
/*
* If mwait/monitor is unsupported, C_C1_FFH and
* C2/C3_FFH will be disabled.
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index ebb4efd3d0aa..f3c41acdb8ae 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -559,13 +559,40 @@ bool __init processor_physically_present(acpi_handle handle)
return !invalid_logical_cpuid(cpuid);
}

+/* vendor specific UUID indicating an Intel platform */
+static u8 sb_uuid_str[] = "4077A616-290C-47BE-9EBD-D87058713953";
static bool acpi_hwp_native_thermal_lvt_set;
+static acpi_status __init acpi_processor_osc(acpi_handle handle, u32 lvl,
+ void *context, void **rv)
+{
+ u32 capbuf[2] = {};
+ acpi_status status;
+ struct acpi_osc_context osc_context = {
+ .uuid_str = sb_uuid_str,
+ .rev = 1,
+ .cap.length = 8,
+ .cap.pointer = capbuf,
+ };
+
+ if (!processor_physically_present(handle))
+ return AE_OK;
+
+ arch_acpi_set_proc_cap_bits(&capbuf[OSC_SUPPORT_DWORD]);
+
+ status = acpi_run_osc(handle, &osc_context);
+ if (ACPI_FAILURE(status))
+ return status;
+
+ kfree(osc_context.ret.pointer);
+
+ return AE_OK;
+}
+
static acpi_status __init acpi_hwp_native_thermal_lvt_osc(acpi_handle handle,
u32 lvl,
void *context,
void **rv)
{
- u8 sb_uuid_str[] = "4077A616-290C-47BE-9EBD-D87058713953";
u32 capbuf[2];
struct acpi_osc_context osc_context = {
.uuid_str = sb_uuid_str,
diff --git a/include/acpi/proc_cap_intel.h b/include/acpi/proc_cap_intel.h
index 57e5e2628abb..ddcdc41d6c3e 100644
--- a/include/acpi/proc_cap_intel.h
+++ b/include/acpi/proc_cap_intel.h
@@ -19,6 +19,7 @@
#define ACPI_PROC_CAP_C_C1_FFH (0x0100)
#define ACPI_PROC_CAP_C_C2C3_FFH (0x0200)
#define ACPI_PROC_CAP_SMP_P_HWCOORD (0x0800)
+#define ACPI_PROC_CAP_COLLAB_PROC_PERF (0x1000)

#define ACPI_PROC_CAP_EST_CAPABILITY_SMP (ACPI_PROC_CAP_SMP_C1PT | \
ACPI_PROC_CAP_C_C1_HALT | \
--
2.41.0


2023-07-10 14:18:02

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 4/9] acpi: Rename ACPI_PDC constants

ACPI_PDC constants prefix suggest that those constants are only relevant
in the context of the _PDC method. This is not true, as they can also be
used in _OSC context. Change prefix to more generic ACPI_PROC_CAP, that
better describe the purpose of those constants as they describe bits in
processor capabilities buffer. Rename pdc_intel.h to proc_cap_intel.h to
reflect the change in the prefix.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
---
arch/ia64/include/asm/acpi.h | 4 ++--
arch/x86/include/asm/acpi.h | 11 +++++-----
arch/x86/xen/enlighten_pv.c | 8 +++----
drivers/acpi/processor_pdc.c | 2 +-
include/acpi/pdc_intel.h | 36 --------------------------------
include/acpi/proc_cap_intel.h | 39 +++++++++++++++++++++++++++++++++++
6 files changed, 52 insertions(+), 48 deletions(-)
delete mode 100644 include/acpi/pdc_intel.h
create mode 100644 include/acpi/proc_cap_intel.h

diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index 43797cb44383..58500a964238 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -11,7 +11,7 @@

#ifdef __KERNEL__

-#include <acpi/pdc_intel.h>
+#include <acpi/proc_cap_intel.h>

#include <linux/init.h>
#include <linux/numa.h>
@@ -71,7 +71,7 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
static inline bool arch_has_acpi_pdc(void) { return true; }
static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
{
- *cap |= ACPI_PDC_EST_CAPABILITY_SMP;
+ *cap |= ACPI_PROC_CAP_EST_CAPABILITY_SMP;
}

#ifdef CONFIG_ACPI_NUMA
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 6a498d1781e7..ce5ad6a496e6 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -6,7 +6,7 @@
* Copyright (C) 2001 Paul Diefenbaugh <[email protected]>
* Copyright (C) 2001 Patrick Mochel <[email protected]>
*/
-#include <acpi/pdc_intel.h>
+#include <acpi/proc_cap_intel.h>

#include <asm/numa.h>
#include <asm/fixmap.h>
@@ -104,19 +104,20 @@ static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
{
struct cpuinfo_x86 *c = &cpu_data(0);

- *cap |= ACPI_PDC_C_CAPABILITY_SMP;
+ *cap |= ACPI_PROC_CAP_C_CAPABILITY_SMP;

if (cpu_has(c, X86_FEATURE_EST))
- *cap |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+ *cap |= ACPI_PROC_CAP_EST_CAPABILITY_SWSMP;

if (cpu_has(c, X86_FEATURE_ACPI))
- *cap |= ACPI_PDC_T_FFH;
+ *cap |= ACPI_PROC_CAP_T_FFH;

/*
* If mwait/monitor is unsupported, C2/C3_FFH will be disabled
*/
if (!cpu_has(c, X86_FEATURE_MWAIT))
- *cap &= ~(ACPI_PDC_C_C2C3_FFH);
+ *cap &= ~(ACPI_PROC_CAP_C_C2C3_FFH);
+
}

static inline bool acpi_has_cpu_in_madt(void)
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 93b658248d01..a3864e2167a8 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -79,7 +79,7 @@
#ifdef CONFIG_ACPI
#include <linux/acpi.h>
#include <asm/acpi.h>
-#include <acpi/pdc_intel.h>
+#include <acpi/proc_cap_intel.h>
#include <acpi/processor.h>
#include <xen/interface/platform.h>
#endif
@@ -288,17 +288,17 @@ static bool __init xen_check_mwait(void)

native_cpuid(&ax, &bx, &cx, &dx);

- /* Ask the Hypervisor whether to clear ACPI_PDC_C_C2C3_FFH. If so,
+ /* Ask the Hypervisor whether to clear ACPI_PROC_CAP_C_C2C3_FFH. If so,
* don't expose MWAIT_LEAF and let ACPI pick the IOPORT version of C3.
*/
buf[0] = ACPI_PDC_REVISION_ID;
buf[1] = 1;
- buf[2] = (ACPI_PDC_C_CAPABILITY_SMP | ACPI_PDC_EST_CAPABILITY_SWSMP);
+ buf[2] = (ACPI_PROC_CAP_C_CAPABILITY_SMP | ACPI_PROC_CAP_EST_CAPABILITY_SWSMP);

set_xen_guest_handle(op.u.set_pminfo.pdc, buf);

if ((HYPERVISOR_platform_op(&op) == 0) &&
- (buf[2] & (ACPI_PDC_C_C1_FFH | ACPI_PDC_C_C2C3_FFH))) {
+ (buf[2] & (ACPI_PROC_CAP_C_C1_FFH | ACPI_PROC_CAP_C_C2C3_FFH))) {
cpuid_leaf5_ecx_val = cx;
cpuid_leaf5_edx_val = dx;
}
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index b2c6f17fc87c..77d3fe73047c 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -21,7 +21,7 @@ static void acpi_set_pdc_bits(u32 *buf)
buf[1] = 1;

/* Enable coordination with firmware's _TSD info */
- buf[2] = ACPI_PDC_SMP_T_SWCOORD;
+ buf[2] = ACPI_PROC_CAP_SMP_T_SWCOORD;

/* Twiddle arch-specific bits needed for _PDC */
arch_acpi_set_proc_cap_bits(&buf[2]);
diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h
deleted file mode 100644
index 967c552d1cd3..000000000000
--- a/include/acpi/pdc_intel.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-/* _PDC bit definition for Intel processors */
-
-#ifndef __PDC_INTEL_H__
-#define __PDC_INTEL_H__
-
-#define ACPI_PDC_P_FFH (0x0001)
-#define ACPI_PDC_C_C1_HALT (0x0002)
-#define ACPI_PDC_T_FFH (0x0004)
-#define ACPI_PDC_SMP_C1PT (0x0008)
-#define ACPI_PDC_SMP_C2C3 (0x0010)
-#define ACPI_PDC_SMP_P_SWCOORD (0x0020)
-#define ACPI_PDC_SMP_C_SWCOORD (0x0040)
-#define ACPI_PDC_SMP_T_SWCOORD (0x0080)
-#define ACPI_PDC_C_C1_FFH (0x0100)
-#define ACPI_PDC_C_C2C3_FFH (0x0200)
-#define ACPI_PDC_SMP_P_HWCOORD (0x0800)
-
-#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \
- ACPI_PDC_C_C1_HALT | \
- ACPI_PDC_P_FFH)
-
-#define ACPI_PDC_EST_CAPABILITY_SWSMP (ACPI_PDC_SMP_C1PT | \
- ACPI_PDC_C_C1_HALT | \
- ACPI_PDC_SMP_P_SWCOORD | \
- ACPI_PDC_SMP_P_HWCOORD | \
- ACPI_PDC_P_FFH)
-
-#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \
- ACPI_PDC_SMP_C1PT | \
- ACPI_PDC_C_C1_HALT | \
- ACPI_PDC_C_C1_FFH | \
- ACPI_PDC_C_C2C3_FFH)
-
-#endif /* __PDC_INTEL_H__ */
diff --git a/include/acpi/proc_cap_intel.h b/include/acpi/proc_cap_intel.h
new file mode 100644
index 000000000000..57e5e2628abb
--- /dev/null
+++ b/include/acpi/proc_cap_intel.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/* Vendor specific processor capabilities bit definition
+ * for Intel processors. Those bits are used to convey OSPM
+ * power management capabilities to the platform.
+ */
+
+#ifndef __PROC_CAP_INTEL_H__
+#define __PROC_CAP_INTEL_H__
+
+#define ACPI_PROC_CAP_P_FFH (0x0001)
+#define ACPI_PROC_CAP_C_C1_HALT (0x0002)
+#define ACPI_PROC_CAP_T_FFH (0x0004)
+#define ACPI_PROC_CAP_SMP_C1PT (0x0008)
+#define ACPI_PROC_CAP_SMP_C2C3 (0x0010)
+#define ACPI_PROC_CAP_SMP_P_SWCOORD (0x0020)
+#define ACPI_PROC_CAP_SMP_C_SWCOORD (0x0040)
+#define ACPI_PROC_CAP_SMP_T_SWCOORD (0x0080)
+#define ACPI_PROC_CAP_C_C1_FFH (0x0100)
+#define ACPI_PROC_CAP_C_C2C3_FFH (0x0200)
+#define ACPI_PROC_CAP_SMP_P_HWCOORD (0x0800)
+
+#define ACPI_PROC_CAP_EST_CAPABILITY_SMP (ACPI_PROC_CAP_SMP_C1PT | \
+ ACPI_PROC_CAP_C_C1_HALT | \
+ ACPI_PROC_CAP_P_FFH)
+
+#define ACPI_PROC_CAP_EST_CAPABILITY_SWSMP (ACPI_PROC_CAP_SMP_C1PT | \
+ ACPI_PROC_CAP_C_C1_HALT | \
+ ACPI_PROC_CAP_SMP_P_SWCOORD | \
+ ACPI_PROC_CAP_SMP_P_HWCOORD | \
+ ACPI_PROC_CAP_P_FFH)
+
+#define ACPI_PROC_CAP_C_CAPABILITY_SMP (ACPI_PROC_CAP_SMP_C2C3 | \
+ ACPI_PROC_CAP_SMP_C1PT | \
+ ACPI_PROC_CAP_C_C1_HALT | \
+ ACPI_PROC_CAP_C_C1_FFH | \
+ ACPI_PROC_CAP_C_C2C3_FFH)
+
+#endif /* __PROC_CAP_INTEL_H__ */
--
2.41.0


2023-07-10 14:19:50

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 6/9] acpi: Move setting CAP_SMP_T_SWCOORD to arch_acpi_set_proc_cap_bits()

Currently ACPI_PROC_CAP_SMP_T_SWCOORD is set in acpi_set_pdc_bits().
This doesn't make any sense, as it isn't _PDC specific. It should be
moved to arch code for coherency.

Move setting of ACPI_PROC_CAP_SMP_T_SWCOORD to
arch_acpi_set_proc_cap_bits().

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
---
arch/x86/include/asm/acpi.h | 3 +++
drivers/acpi/processor_pdc.c | 3 ---
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index d615238bcd78..6f6752a2ea36 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -106,6 +106,9 @@ static inline void arch_acpi_set_proc_cap_bits(u32 *cap)

*cap |= ACPI_PROC_CAP_C_CAPABILITY_SMP;

+ /* Enable coordination with firmware's _TSD info */
+ *cap |= ACPI_PROC_CAP_SMP_T_SWCOORD;
+
if (cpu_has(c, X86_FEATURE_EST))
*cap |= ACPI_PROC_CAP_EST_CAPABILITY_SWSMP;

diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index b4b906b70a0b..116b5abb60b3 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -20,9 +20,6 @@ static void acpi_set_pdc_bits(u32 *buf)
buf[0] = ACPI_PDC_REVISION_ID;
buf[1] = 1;

- /* Enable coordination with firmware's _TSD info */
- buf[2] = ACPI_PROC_CAP_SMP_T_SWCOORD;
-
/* Twiddle arch-specific bits needed for _PDC */
arch_acpi_set_proc_cap_bits(&buf[2]);
}
--
2.41.0


2023-07-10 14:20:01

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 8/9] acpi: Use _OSC method to convey processor OSPM capabilities

Change acpi_early_processor_osc() to return value in case of the failure.
Make it more generic - previously it served only to execute workaround
for buggy BIOS in Skylake systems. Now it will walk through ACPI
namespace looking for processor objects and will convey OSPM processor
capabilities using _OSC method.

Introduce new function acpi_early_processor_control_setup(). Call it in
acpi_bus_init(). Make acpi_early_processor_control_setup() call _OSC
method first. In case of the failure of the _OSC, try using _PDC as a
fallback.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
drivers/acpi/acpi_processor.c | 34 +++++++++++++++++++++++++---------
drivers/acpi/bus.c | 5 +----
drivers/acpi/internal.h | 9 ++-------
3 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index f3c41acdb8ae..50c456dbecea 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -623,16 +623,32 @@ static acpi_status __init acpi_hwp_native_thermal_lvt_osc(acpi_handle handle,
return AE_OK;
}

-void __init acpi_early_processor_osc(void)
+acpi_status __init acpi_early_processor_osc(void)
{
- if (boot_cpu_has(X86_FEATURE_HWP)) {
- acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX,
- acpi_hwp_native_thermal_lvt_osc,
- NULL, NULL, NULL);
- acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID,
- acpi_hwp_native_thermal_lvt_osc,
- NULL, NULL);
+ acpi_status status;
+
+ acpi_proc_quirk_dmi_check();
+
+ status = acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, acpi_processor_osc, NULL,
+ NULL, NULL);
+ if (ACPI_FAILURE(status))
+ return status;
+
+ return acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_osc,
+ NULL, NULL);
+}
+
+void __init acpi_early_processor_control_setup(void)
+{
+ acpi_status status;
+
+ status = acpi_early_processor_osc();
+ if (ACPI_FAILURE(status)) {
+ pr_err("_OSC methods failed, trying _PDC\n");
+ acpi_early_processor_set_pdc();
+ } else {
+ pr_info("_OSC methods ran successfully\n");
}
}
#endif
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 2fc2b43a4ed3..a39f2f3a2cd6 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1296,9 +1296,6 @@ static int __init acpi_bus_init(void)
goto error1;
}

- /* Set capability bits for _OSC under processor scope */
- acpi_early_processor_osc();
-
/*
* _OSC method may exist in module level code,
* so it must be run after ACPI_FULL_INITIALIZATION
@@ -1314,7 +1311,7 @@ static int __init acpi_bus_init(void)

acpi_sysfs_init();

- acpi_early_processor_set_pdc();
+ acpi_early_processor_control_setup();

/*
* Maybe EC region is required at bus_scan/acpi_get_devices. So it
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 87c343f79900..ccffa04c7060 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -152,18 +152,13 @@ int acpi_wakeup_device_init(void);
Processor
-------------------------------------------------------------------------- */
#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
+void acpi_early_processor_control_setup(void);
void acpi_early_processor_set_pdc(void);

void acpi_proc_quirk_dmi_check(void);
bool processor_physically_present(acpi_handle handle);
#else
-static inline void acpi_early_processor_set_pdc(void) {}
-#endif
-
-#ifdef CONFIG_X86
-void acpi_early_processor_osc(void);
-#else
-static inline void acpi_early_processor_osc(void) {}
+void acpi_early_processor_control_setup(void) {}
#endif

/* --------------------------------------------------------------------------
--
2.41.0


2023-07-10 14:20:08

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 9/9] acpi: Remove acpi_hwp_native_thermal_lvt_osc()

Workaround for buggy skylake BIOS is implemented in acpi_processor_osc()
and acpi_hwp_native_thermal_lvt_osc() function is not called anywhere.
Remove it.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
drivers/acpi/acpi_processor.c | 36 -----------------------------------
1 file changed, 36 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 50c456dbecea..a1815155543a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -561,7 +561,6 @@ bool __init processor_physically_present(acpi_handle handle)

/* vendor specific UUID indicating an Intel platform */
static u8 sb_uuid_str[] = "4077A616-290C-47BE-9EBD-D87058713953";
-static bool acpi_hwp_native_thermal_lvt_set;
static acpi_status __init acpi_processor_osc(acpi_handle handle, u32 lvl,
void *context, void **rv)
{
@@ -588,41 +587,6 @@ static acpi_status __init acpi_processor_osc(acpi_handle handle, u32 lvl,
return AE_OK;
}

-static acpi_status __init acpi_hwp_native_thermal_lvt_osc(acpi_handle handle,
- u32 lvl,
- void *context,
- void **rv)
-{
- u32 capbuf[2];
- struct acpi_osc_context osc_context = {
- .uuid_str = sb_uuid_str,
- .rev = 1,
- .cap.length = 8,
- .cap.pointer = capbuf,
- };
-
- if (acpi_hwp_native_thermal_lvt_set)
- return AE_CTRL_TERMINATE;
-
- capbuf[0] = 0x0000;
- capbuf[1] = 0x1000; /* set bit 12 */
-
- if (ACPI_SUCCESS(acpi_run_osc(handle, &osc_context))) {
- if (osc_context.ret.pointer && osc_context.ret.length > 1) {
- u32 *capbuf_ret = osc_context.ret.pointer;
-
- if (capbuf_ret[1] & 0x1000) {
- acpi_handle_info(handle,
- "_OSC native thermal LVT Acked\n");
- acpi_hwp_native_thermal_lvt_set = true;
- }
- }
- kfree(osc_context.ret.pointer);
- }
-
- return AE_OK;
-}
-
acpi_status __init acpi_early_processor_osc(void)
{
acpi_status status;
--
2.41.0


2023-07-10 14:20:52

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 1/9] acpi: Move mwait quirk out of acpi_processor.c

Commit 2a2a64714d9c ("ACPI: Disable MWAIT via DMI on broken Compal board")
introduced a workaround for mwait for a specific x86 system. Move the
code outside of acpi_processor.c to acpi/x86 directory for better
coherency. Rename functions to start with acpi_proc_quirk to make the
goal obvious.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
---
drivers/acpi/internal.h | 2 ++
drivers/acpi/processor_pdc.c | 29 +----------------------------
drivers/acpi/x86/utils.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index f4148dc50b9c..90d199ab271c 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -153,6 +153,8 @@ int acpi_wakeup_device_init(void);
-------------------------------------------------------------------------- */
#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
void acpi_early_processor_set_pdc(void);
+
+void acpi_proc_quirk_dmi_check(void);
#else
static inline void acpi_early_processor_set_pdc(void) {}
#endif
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index 18fb04523f93..34bb06de2afb 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -174,36 +174,9 @@ early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK;
}

-static int __init set_no_mwait(const struct dmi_system_id *id)
-{
- pr_notice("%s detected - disabling mwait for CPU C-states\n",
- id->ident);
- boot_option_idle_override = IDLE_NOMWAIT;
- return 0;
-}
-
-static const struct dmi_system_id processor_idle_dmi_table[] __initconst = {
- {
- set_no_mwait, "Extensa 5220", {
- DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
- DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
- DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
- DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
- {},
-};
-
-static void __init processor_dmi_check(void)
-{
- /*
- * Check whether the system is DMI table. If yes, OSPM
- * should not use mwait for CPU-states.
- */
- dmi_check_system(processor_idle_dmi_table);
-}
-
void __init acpi_early_processor_set_pdc(void)
{
- processor_dmi_check();
+ acpi_proc_quirk_dmi_check();

acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
index c2b925f8cd4e..5903cd7c8404 100644
--- a/drivers/acpi/x86/utils.c
+++ b/drivers/acpi/x86/utils.c
@@ -518,3 +518,38 @@ bool acpi_quirk_skip_acpi_ac_and_battery(void)
return false;
}
EXPORT_SYMBOL_GPL(acpi_quirk_skip_acpi_ac_and_battery);
+
+/* This section provides a workaround for a specific x86 system
+ * which requires disabling of mwait to work correctly.
+ */
+static int __init acpi_proc_quirk_set_no_mwait(const struct dmi_system_id *id)
+{
+ pr_notice("%s detected - disabling mwait for CPU C-states\n",
+ id->ident);
+ boot_option_idle_override = IDLE_NOMWAIT;
+ return 0;
+}
+
+static const struct dmi_system_id acpi_proc_quirk_idle_dmi_table[] __initconst = {
+ {
+ .callback = acpi_proc_quirk_set_no_mwait,
+ .ident = "Extensa 5220",
+ .matches = {
+ DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
+ DMI_MATCH(DMI_BOARD_NAME, "Columbia"),
+ },
+ .driver_data = NULL,
+ },
+ {}
+};
+
+void __init acpi_proc_quirk_dmi_check(void)
+{
+ /*
+ * Check whether the system is DMI table. If yes, OSPM
+ * should not use mwait for CPU-states.
+ */
+ dmi_check_system(acpi_proc_quirk_idle_dmi_table);
+}
--
2.41.0


2023-07-10 14:43:14

by Wilczynski, Michal

[permalink] [raw]
Subject: [PATCH v4 2/9] acpi: 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.

Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Michal Wilczynski <[email protected]>
---
drivers/acpi/acpi_processor.c | 52 ++++++++++++++++++++++++++++++++++-
drivers/acpi/internal.h | 1 +
drivers/acpi/processor_pdc.c | 49 ---------------------------------
3 files changed, 52 insertions(+), 50 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index f9aa02cac6d1..ebb4efd3d0aa 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -12,6 +12,7 @@

#include <linux/acpi.h>
#include <linux/device.h>
+#include <linux/dmi.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -21,6 +22,8 @@

#include <asm/cpu.h>

+#include <xen/xen.h>
+
#include "internal.h"

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

-#ifdef CONFIG_X86
+#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
+bool __init processor_physically_present(acpi_handle handle)
+{
+ int cpuid, type;
+ u32 acpi_id;
+ acpi_status status;
+ acpi_object_type acpi_type;
+ unsigned long long tmp;
+ union acpi_object object = {};
+ struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
+
+ status = acpi_get_type(handle, &acpi_type);
+ if (ACPI_FAILURE(status))
+ return false;
+
+ switch (acpi_type) {
+ case ACPI_TYPE_PROCESSOR:
+ status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
+ if (ACPI_FAILURE(status))
+ return false;
+ acpi_id = object.processor.proc_id;
+ break;
+ case ACPI_TYPE_DEVICE:
+ status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
+ NULL, &tmp);
+ if (ACPI_FAILURE(status))
+ return false;
+ acpi_id = tmp;
+ break;
+ default:
+ return false;
+ }
+
+ if (xen_initial_domain())
+ /*
+ * When running as a Xen dom0 the number of processors Linux
+ * sees can be different from the real number of processors on
+ * the system, and we still need to execute _PDC or _OSC for
+ * all of them.
+ */
+ return xen_processor_present(acpi_id);
+
+ type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
+ cpuid = acpi_get_cpuid(handle, type, acpi_id);
+
+ return !invalid_logical_cpuid(cpuid);
+}
+
static bool acpi_hwp_native_thermal_lvt_set;
static acpi_status __init acpi_hwp_native_thermal_lvt_osc(acpi_handle handle,
u32 lvl,
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 90d199ab271c..87c343f79900 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -155,6 +155,7 @@ int acpi_wakeup_device_init(void);
void acpi_early_processor_set_pdc(void);

void acpi_proc_quirk_dmi_check(void);
+bool processor_physically_present(acpi_handle handle);
#else
static inline void acpi_early_processor_set_pdc(void) {}
#endif
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index 34bb06de2afb..6d2d521a068d 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -9,61 +9,12 @@

#define pr_fmt(fmt) "ACPI: " fmt

-#include <linux/dmi.h>
#include <linux/slab.h>
#include <linux/acpi.h>
#include <acpi/processor.h>

-#include <xen/xen.h>
-
#include "internal.h"

-static bool __init processor_physically_present(acpi_handle handle)
-{
- int cpuid, type;
- u32 acpi_id;
- acpi_status status;
- acpi_object_type acpi_type;
- unsigned long long tmp;
- union acpi_object object = { 0 };
- struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
-
- status = acpi_get_type(handle, &acpi_type);
- if (ACPI_FAILURE(status))
- return false;
-
- switch (acpi_type) {
- case ACPI_TYPE_PROCESSOR:
- status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
- if (ACPI_FAILURE(status))
- return false;
- acpi_id = object.processor.proc_id;
- break;
- case ACPI_TYPE_DEVICE:
- status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp);
- if (ACPI_FAILURE(status))
- return false;
- acpi_id = tmp;
- break;
- default:
- return false;
- }
-
- if (xen_initial_domain())
- /*
- * When running as a Xen dom0 the number of processors Linux
- * sees can be different from the real number of processors on
- * the system, and we still need to execute _PDC for all of
- * them.
- */
- return xen_processor_present(acpi_id);
-
- type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
- cpuid = acpi_get_cpuid(handle, type, acpi_id);
-
- return !invalid_logical_cpuid(cpuid);
-}
-
static void acpi_set_pdc_bits(u32 *buf)
{
buf[0] = ACPI_PDC_REVISION_ID;
--
2.41.0


2023-07-10 14:44:02

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v4 4/9] acpi: Rename ACPI_PDC constants

On Mon, Jul 10, 2023 at 05:03:32PM +0300, Michal Wilczynski wrote:
> ACPI_PDC constants prefix suggest that those constants are only relevant
> in the context of the _PDC method. This is not true, as they can also be
> used in _OSC context. Change prefix to more generic ACPI_PROC_CAP, that
> better describe the purpose of those constants as they describe bits in
> processor capabilities buffer. Rename pdc_intel.h to proc_cap_intel.h to
> reflect the change in the prefix.

...

> - /* Ask the Hypervisor whether to clear ACPI_PDC_C_C2C3_FFH. If so,
> + /* Ask the Hypervisor whether to clear ACPI_PROC_CAP_C_C2C3_FFH. If so,
> * don't expose MWAIT_LEAF and let ACPI pick the IOPORT version of C3.
> */

/*
* While at it, you can fix multi-line
* comment style. It supposed to be
* like in this example.
*/

I don't know if resend is required, I would wait for Rafael to comment on this.

--
With Best Regards,
Andy Shevchenko



2023-07-14 16:48:28

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v4 0/9] Prefer using _OSC method over deprecated _PDC

On Mon, Jul 10, 2023 at 4:06 PM Michal Wilczynski
<[email protected]> wrote:
>
> ACPI 3.0 introduced a new Operating System Capabilities _OSC control
> method. This method is similar to _PDC, which was marked as deprecated
> in ACPI 3.0.
>
> Prefer using _OSC method over deprecated _PDC in the acpi_bus_init(). In
> case of the failure of the _OSC, try using _PDC as a fallback.
>
> Testing done:
> Tested on physical server with BIOS implementing _OSC methods. In this
> case acpi_processor_osc() was executed for each CPU core. acpi_run_osc()
> returned success indicating that _OSC method succeeded.
>
> Tested on qemu VM to check whether the code would work on a SeaBios (the
> default for qemu, doesn't support _OSC methods, or _PDC). This way I was
> able to see how code behaves in case BIOS doesn't implement _OSC. In
> that case the function
> acpi_run_osc() returned failure, which propagated all the way up to
> acpi_early_processor_osc(). The logic responsible for triggering _PDC
> execution was triggered correctly.
>
> Tested this using debug messages with printk.
>
> v4:
> - move setting processor capabilities bits into arch code
> - move workaround for mwait to acpi/x86 directory
> - rename ACPI_PDC* constants to more generic ACPI_PROC_CAP*
> - introduce new function acpi_early_processor_control_setup()
>
> v3:
> - split into more commits to make review easier
> - changed "_UID" to METHOD_NAME_UID
> - changed hard-coded constant to ACPI_PDC_COLLAB_PROC_PERF
> - added Suggested-by tags
> - fixed style issues
> - fixed whitespaces
> - refactored code
> v2:
> - fixed compilation issues on ia64 and arm
>
> Michal Wilczynski (9):
> acpi: Move mwait quirk out of acpi_processor.c
> acpi: Move processor_physically_present() to acpi_processor.c
> acpi: Refactor arch_acpi_set_pdc_bits()
> acpi: Rename ACPI_PDC constants
> acpi: Clear C_C2C3_FFH and C_C1_FFH in arch_acpi_set_proc_cap_bits()
> acpi: Move setting CAP_SMP_T_SWCOORD to arch_acpi_set_proc_cap_bits()
> acpi: Introduce acpi_processor_osc()
> acpi: Use _OSC method to convey processor OSPM capabilities
> acpi: Remove acpi_hwp_native_thermal_lvt_osc()

I have made a number of changes to the patches (edited subjects,
rewrote changelogs, fixed up whitespace in a few places, changed the
return value of acpi_early_processor_osc() to bool and made it static
etc.) and tentatively queued them up for 6.6. Please see the
bleeding-edge branch of linux-pm.git.

I have made sure that the series will still compile at least on
x86-64, but testing it again would be appreciated.

Thanks!

2023-07-17 11:07:37

by Wilczynski, Michal

[permalink] [raw]
Subject: Re: [PATCH v4 0/9] Prefer using _OSC method over deprecated _PDC



On 7/14/2023 6:12 PM, Rafael J. Wysocki wrote:
> On Mon, Jul 10, 2023 at 4:06 PM Michal Wilczynski
> <[email protected]> wrote:
>> ACPI 3.0 introduced a new Operating System Capabilities _OSC control
>> method. This method is similar to _PDC, which was marked as deprecated
>> in ACPI 3.0.
>>
>> Prefer using _OSC method over deprecated _PDC in the acpi_bus_init(). In
>> case of the failure of the _OSC, try using _PDC as a fallback.
>>
>> Testing done:
>> Tested on physical server with BIOS implementing _OSC methods. In this
>> case acpi_processor_osc() was executed for each CPU core. acpi_run_osc()
>> returned success indicating that _OSC method succeeded.
>>
>> Tested on qemu VM to check whether the code would work on a SeaBios (the
>> default for qemu, doesn't support _OSC methods, or _PDC). This way I was
>> able to see how code behaves in case BIOS doesn't implement _OSC. In
>> that case the function
>> acpi_run_osc() returned failure, which propagated all the way up to
>> acpi_early_processor_osc(). The logic responsible for triggering _PDC
>> execution was triggered correctly.
>>
>> Tested this using debug messages with printk.
>>
>> v4:
>> - move setting processor capabilities bits into arch code
>> - move workaround for mwait to acpi/x86 directory
>> - rename ACPI_PDC* constants to more generic ACPI_PROC_CAP*
>> - introduce new function acpi_early_processor_control_setup()
>>
>> v3:
>> - split into more commits to make review easier
>> - changed "_UID" to METHOD_NAME_UID
>> - changed hard-coded constant to ACPI_PDC_COLLAB_PROC_PERF
>> - added Suggested-by tags
>> - fixed style issues
>> - fixed whitespaces
>> - refactored code
>> v2:
>> - fixed compilation issues on ia64 and arm
>>
>> Michal Wilczynski (9):
>> acpi: Move mwait quirk out of acpi_processor.c
>> acpi: Move processor_physically_present() to acpi_processor.c
>> acpi: Refactor arch_acpi_set_pdc_bits()
>> acpi: Rename ACPI_PDC constants
>> acpi: Clear C_C2C3_FFH and C_C1_FFH in arch_acpi_set_proc_cap_bits()
>> acpi: Move setting CAP_SMP_T_SWCOORD to arch_acpi_set_proc_cap_bits()
>> acpi: Introduce acpi_processor_osc()
>> acpi: Use _OSC method to convey processor OSPM capabilities
>> acpi: Remove acpi_hwp_native_thermal_lvt_osc()
> I have made a number of changes to the patches (edited subjects,
> rewrote changelogs, fixed up whitespace in a few places, changed the
> return value of acpi_early_processor_osc() to bool and made it static
> etc.) and tentatively queued them up for 6.6. Please see the
> bleeding-edge branch of linux-pm.git.
>
> I have made sure that the series will still compile at least on
> x86-64, but testing it again would be appreciated.
>
> Thanks!

Thanks, will re-test on linux-pm