From: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Cc: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI: processor: Use Apple-specific methods for P/C-states
Date: Tue, 13 Oct 2026 06:14:30 -0400 [thread overview]
Message-ID: <20261013101432.9712-1-atharvatiwarilinuxdev@gmail.com> (raw)
Use APSS and ACST instead of _PSS and _CST when available on Intel Macs.
These methods are used in X86PlatformPlugin.kext, and when not found we
fallback to generic _PSS and _CST methods.
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
---
drivers/acpi/acpi_processor.c | 22 +++++++++++++++++-----
drivers/acpi/processor_perflib.c | 10 ++++++++++
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 00775b91b..37beb1a2e 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>
@@ -837,27 +838,38 @@ 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;
+ if (x86_apple_machine) {
+ status = acpi_evaluate_object(handle, "ACST", NULL, &buffer);
+ if (ACPI_SUCCESS(status)) {
+ base = 1; /* ACST is a 4 field variable we need to skip the first field */
+ goto success;
+ }
+
+ buffer.length = ACPI_ALLOCATE_BUFFER;
+ buffer.pointer = NULL;
+ }
status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
if (ACPI_FAILURE(status)) {
acpi_handle_debug(handle, "No _CST\n");
return -ENODEV;
}
+success:
cst = buffer.pointer;
/* There must be at least 2 elements. */
- if (!cst || cst->type != ACPI_TYPE_PACKAGE || cst->package.count < 2) {
+ if (!cst || cst->type != ACPI_TYPE_PACKAGE || cst->package.count < base + 2) {
acpi_handle_warn(handle, "Invalid _CST output\n");
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) {
+ if (count < 1 || count != cst->package.count - 1 - base) {
acpi_handle_warn(handle, "Inconsistent _CST data\n");
ret = -EFAULT;
goto end;
@@ -882,7 +894,7 @@ 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);
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index fdf55c285..4b9e17d65 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>
@@ -323,11 +324,20 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
int i;
int last_invalid = -1;
+ if (x86_apple_machine) {
+ status = acpi_evaluate_object(pr->handle, "APSS", NULL, &buffer);
+ if (ACPI_SUCCESS(status))
+ goto success;
+
+ buffer.length = ACPI_ALLOCATE_BUFFER;
+ buffer.pointer = NULL;
+ }
status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
if (ACPI_FAILURE(status)) {
acpi_evaluation_failure_warn(pr->handle, "_PSS", status);
return -ENODEV;
}
+success:
pss = buffer.pointer;
if (!pss || pss->type != ACPI_TYPE_PACKAGE) {
--
2.55.0
reply other threads:[~2026-10-13 10:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261013101432.9712-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 \
/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.