From: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Cc: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>,
Antoine Sidem <sidemantoine@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org (open list:ACPI),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v3] ACPI: processor: Use Apple-specific methods for P/C-states
Date: Sat, 21 Nov 2026 16:58:38 -0500 [thread overview]
Message-ID: <20261121215841.1286-1-atharvatiwarilinuxdev@gmail.com> (raw)
Use APSS and ACST instead of _PSS and _CST when available on Intel Macs
as they include better P/C-States.
These methods are used in macOS (X86PlatformPlugin.kext),
and when not found we fallback to generic _PSS and _CST methods.
Changes in v3:
- Used method variable instead of using_
- Used bool instead of int for functions
Changes in v2:
- Improved description of the patch
- Replaced goto's and if statement's with new functions
- Added support to differentiate _PSS and APSS in debug info/error info
- Added support to differentiate _CST and ACST in debug info/error info
- Used Package instead of variable for ACST description
Link to v2:
https://lore.kernel.org/all/20261113131243.28214-1-atharvatiwarilinuxdev@gmail.com/
Link to v1:
https://lore.kernel.org/all/20261015204450.1270-1-atharvatiwarilinuxdev@gmail.com/
Tested-by: Antoine Sidem <sidemantoine@gmail.com>
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
---
drivers/acpi/acpi_processor.c | 79 +++++++++++++++++++++-----------
drivers/acpi/processor_perflib.c | 43 +++++++++++++----
2 files changed, 85 insertions(+), 37 deletions(-)
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 5fbab5417..65e52cd52 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -18,6 +18,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/platform_data/x86/apple.h>
#include <linux/platform_device.h>
#include <acpi/processor.h>
@@ -815,6 +816,22 @@ bool acpi_processor_claim_cst_control(void)
}
EXPORT_SYMBOL_NS_GPL(acpi_processor_claim_cst_control, "ACPI_PROCESSOR_IDLE");
+static bool acpi_processor_apple_acst(acpi_handle handle, struct acpi_buffer *buffer)
+{
+ acpi_status status;
+
+ if (!x86_apple_machine)
+ return false;
+
+ status = acpi_evaluate_object(handle, "ACST", NULL, buffer);
+ if (ACPI_FAILURE(status)) {
+ buffer->length = ACPI_ALLOCATE_BUFFER;
+ buffer->pointer = NULL;
+ return false;
+ }
+
+ return true;
+}
/**
* acpi_processor_evaluate_cst - Evaluate the processor _CST control method.
* @handle: ACPI handle of the processor object containing the _CST.
@@ -837,28 +854,34 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
acpi_status status;
u64 count;
int last_index = 0;
- int i, ret = 0;
+ int i, ret = 0, base = 0;
+ const char *method = "_CST";
- status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(handle, "No _CST\n");
- return -ENODEV;
+ if (acpi_processor_apple_acst(handle, &buffer)) {
+ base = 1; /* ACST is a 4 field package we need to skip the first field */
+ method = "ACST";
+ } else {
+ status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_debug(handle, "No _CST\n");
+ return -ENODEV;
+ }
}
cst = buffer.pointer;
- /* There must be at least 2 elements. */
- if (!cst || cst->type != ACPI_TYPE_PACKAGE || cst->package.count < 2) {
- acpi_handle_warn(handle, "Invalid _CST output\n");
+ /* There must be at least 2 elements for _CST and at least 3 elements for ACST. */
+ if (!cst || cst->type != ACPI_TYPE_PACKAGE || cst->package.count < base + 2) {
+ acpi_handle_warn(handle, "Invalid %s output\n", method);
ret = -EFAULT;
goto end;
}
- count = cst->package.elements[0].integer.value;
+ count = cst->package.elements[base].integer.value;
/* Validate the number of C-states. */
- if (count < 1 || count != cst->package.count - 1) {
- acpi_handle_warn(handle, "Inconsistent _CST data\n");
+ if (count < 1 || count != cst->package.count - 1 - base) {
+ acpi_handle_warn(handle, "Inconsistent %s data\n", method);
ret = -EFAULT;
goto end;
}
@@ -882,24 +905,24 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
memset(&cx, 0, sizeof(cx));
- element = &cst->package.elements[i];
+ element = &cst->package.elements[base + i];
if (element->type != ACPI_TYPE_PACKAGE) {
- acpi_handle_info(handle, "_CST C%d type(%x) is not package, skip...\n",
- i, element->type);
+ acpi_handle_info(handle, "%s C%d type(%x) is not package, skip...\n",
+ method, i, element->type);
continue;
}
if (element->package.count != 4) {
- acpi_handle_info(handle, "_CST C%d package count(%d) is not 4, skip...\n",
- i, element->package.count);
+ acpi_handle_info(handle, "%s C%d package count(%d) is not 4, skip...\n",
+ method, i, element->package.count);
continue;
}
obj = &element->package.elements[0];
if (obj->type != ACPI_TYPE_BUFFER) {
- acpi_handle_info(handle, "_CST C%d package element[0] type(%x) is not buffer, skip...\n",
- i, obj->type);
+ acpi_handle_info(handle, "%s C%d package element[0] type(%x) is not buffer, skip...\n",
+ method, i, obj->type);
continue;
}
@@ -907,8 +930,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
obj = &element->package.elements[1];
if (obj->type != ACPI_TYPE_INTEGER) {
- acpi_handle_info(handle, "_CST C[%d] package element[1] type(%x) is not integer, skip...\n",
- i, obj->type);
+ acpi_handle_info(handle, "%s C[%d] package element[1] type(%x) is not integer, skip...\n",
+ method, i, obj->type);
continue;
}
@@ -947,8 +970,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
cx.entry_method = ACPI_CSTATE_HALT;
snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
} else {
- acpi_handle_info(handle, "_CST C%d declares FIXED_HARDWARE C-state but not supported in hardware, skip...\n",
- i);
+ acpi_handle_info(handle, "%s C%d declares FIXED_HARDWARE C-state but not supported in hardware, skip...\n",
+ method, i);
continue;
}
} else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
@@ -956,8 +979,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
cx.address);
} else {
- acpi_handle_info(handle, "_CST C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n",
- i, reg->space_id);
+ acpi_handle_info(handle, "%s C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n",
+ method, i, reg->space_id);
continue;
}
@@ -966,8 +989,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
obj = &element->package.elements[2];
if (obj->type != ACPI_TYPE_INTEGER) {
- acpi_handle_info(handle, "_CST C%d package element[2] type(%x) not integer, skip...\n",
- i, obj->type);
+ acpi_handle_info(handle, "%s C%d package element[2] type(%x) not integer, skip...\n",
+ method, i, obj->type);
continue;
}
@@ -975,8 +998,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
obj = &element->package.elements[3];
if (obj->type != ACPI_TYPE_INTEGER) {
- acpi_handle_info(handle, "_CST C%d package element[3] type(%x) not integer, skip...\n",
- i, obj->type);
+ acpi_handle_info(handle, "%s C%d package element[3] type(%x) not integer, skip...\n",
+ method, i, obj->type);
continue;
}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 9e25d6124..0844147d9 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -17,6 +17,7 @@
#include <linux/cpufreq.h>
#include <linux/slab.h>
#include <linux/acpi.h>
+#include <linux/platform_data/x86/apple.h>
#include <acpi/processor.h>
#ifdef CONFIG_X86
#include <asm/cpufeature.h>
@@ -313,6 +314,23 @@ static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
}
}
+static bool acpi_evaluate_apple_apss(acpi_handle handle, struct acpi_buffer *buffer)
+{
+ acpi_status status;
+
+ if (!x86_apple_machine)
+ return false;
+
+ status = acpi_evaluate_object(handle, "APSS", NULL, buffer);
+ if (ACPI_FAILURE(status)) {
+ buffer->length = ACPI_ALLOCATE_BUFFER;
+ buffer->pointer = NULL;
+ return false;
+ }
+
+ return true;
+}
+
static int acpi_processor_get_performance_states(struct acpi_processor *pr)
{
int result = 0;
@@ -323,16 +341,21 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
union acpi_object *pss = NULL;
int i;
int last_invalid = -1;
+ const char *method = "_PSS";
- status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
- if (ACPI_FAILURE(status)) {
- acpi_evaluation_failure_warn(pr->handle, "_PSS", status);
- return -ENODEV;
+ if (acpi_evaluate_apple_apss(pr->handle, &buffer))
+ method = "APSS";
+ else {
+ status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
+ if (ACPI_FAILURE(status)) {
+ acpi_evaluation_failure_warn(pr->handle, "_PSS", status);
+ return -ENODEV;
+ }
}
pss = buffer.pointer;
if (!pss || pss->type != ACPI_TYPE_PACKAGE) {
- pr_err("Invalid _PSS data\n");
+ pr_err("Invalid %s data\n", method);
result = -EFAULT;
goto end;
}
@@ -360,7 +383,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
status = acpi_extract_package(&(pss->package.elements[i]),
&format, &state);
if (ACPI_FAILURE(status)) {
- acpi_handle_warn(pr->handle, "Invalid _PSS data: %s\n",
+ acpi_handle_warn(pr->handle, "Invalid %s data: %s\n",
+ method,
acpi_format_exception(status));
result = -EFAULT;
kfree(pr->performance->states);
@@ -384,8 +408,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
if (!px->core_frequency ||
(u32)(px->core_frequency * 1000) != px->core_frequency * 1000) {
pr_err(FW_BUG
- "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
- pr->id, px->core_frequency);
+ "Invalid BIOS %s frequency found for processor %d: 0x%llx MHz\n",
+ method, pr->id, px->core_frequency);
if (last_invalid == -1)
last_invalid = i;
} else {
@@ -402,7 +426,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
if (last_invalid == 0) {
pr_err(FW_BUG
- "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
+ "No valid BIOS %s frequency found for processor %d\n",
+ method, pr->id);
result = -EFAULT;
kfree(pr->performance->states);
pr->performance->states = NULL;
--
2.55.0
next reply other threads:[~2026-11-21 21:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 21:58 Atharva Tiwari [this message]
2026-11-30 8:52 ` [PATCH v3] ACPI: processor: Use Apple-specific methods for P/C-states Atharva Tiwari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261121215841.1286-1-atharvatiwarilinuxdev@gmail.com \
--to=atharvatiwarilinuxdev@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sidemantoine@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.