From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux ACPI <linux-acpi@vger.kernel.org>,
Len Brown <len.brown@intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Len Brown <lenb@kernel.org>
Subject: [RFC][PATCH 2/6] ACPI: processor: Introduce acpi_processor_evaluate_cst()
Date: Fri, 06 Dec 2019 10:32:47 +0100 [thread overview]
Message-ID: <2604399.tYvJkFLScm@kreacher> (raw)
In-Reply-To: <2037014.bnAicLLH9b@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
In order to separate the ACPI _CST evaluation from checks
specific to the ACPI processor driver, move the majority of
the acpi_processor_get_power_info_cst() function body to a new
function, acpi_processor_evaluate_cst(), that will extract
the C-states information from _CST output, and redefine
acpi_processor_get_power_info_cst() as a wrapper around it.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/processor_idle.c | 52 +++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 20 deletions(-)
Index: linux-pm/drivers/acpi/processor_idle.c
===================================================================
--- linux-pm.orig/drivers/acpi/processor_idle.c
+++ linux-pm/drivers/acpi/processor_idle.c
@@ -297,21 +297,17 @@ static int acpi_processor_get_power_info
return 0;
}
-static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
+static int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
+ struct acpi_processor_power *info)
{
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *cst;
acpi_status status;
u64 count;
- int current_count;
+ int current_count = 0;
int i, ret = 0;
- struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
- union acpi_object *cst;
-
- if (nocst)
- return -ENODEV;
-
- current_count = 0;
- status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
+ status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n"));
return -ENODEV;
@@ -335,9 +331,6 @@ static int acpi_processor_get_power_info
goto end;
}
- /* Tell driver that at least _CST is supported. */
- pr->flags.has_cst = 1;
-
for (i = 1; i <= count; i++) {
union acpi_object *element;
union acpi_object *obj;
@@ -383,7 +376,7 @@ static int acpi_processor_get_power_info
cx.entry_method = ACPI_CSTATE_SYSTEMIO;
if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
if (acpi_processor_ffh_cstate_probe
- (pr->id, &cx, reg) == 0) {
+ (cpu, &cx, reg) == 0) {
cx.entry_method = ACPI_CSTATE_FFH;
} else if (cx.type == ACPI_STATE_C1) {
/*
@@ -432,7 +425,7 @@ static int acpi_processor_get_power_info
continue;
current_count++;
- memcpy(&(pr->power.states[current_count]), &cx, sizeof(cx));
+ memcpy(&info->states[current_count], &cx, sizeof(cx));
/*
* We support total ACPI_PROCESSOR_MAX_POWER - 1
@@ -446,12 +439,9 @@ static int acpi_processor_get_power_info
}
}
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n",
- current_count));
+ acpi_handle_info(handle, "Found %d idle states\n", current_count);
- /* Validate number of power states discovered */
- if (current_count < 2)
- ret = -EFAULT;
+ info->count = current_count;
end:
kfree(buffer.pointer);
@@ -459,6 +449,28 @@ static int acpi_processor_get_power_info
return ret;
}
+static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
+{
+ int ret;
+
+ if (nocst)
+ return -ENODEV;
+
+ ret = acpi_processor_evaluate_cst(pr->handle, pr->id, &pr->power);
+ if (ret)
+ return ret;
+
+ /*
+ * It is expected that there will be at least 2 states, C1 and
+ * something else (C2 or C3), so fail if that is not the case.
+ */
+ if (pr->power.count < 2)
+ return -EFAULT;
+
+ pr->flags.has_cst = 1;
+ return 0;
+}
+
static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
struct acpi_processor_cx *cx)
{
next prev parent reply other threads:[~2019-12-06 9:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-06 9:28 [RFC][PATCH 0/6] cpuidle: intel_idle: Use ACPI _CTS to get idle states information Rafael J. Wysocki
2019-12-06 9:31 ` [RFC][PATCH 1/6] ACPI: processor: Export function to claim _CST control Rafael J. Wysocki
2019-12-06 9:32 ` Rafael J. Wysocki [this message]
2019-12-06 9:36 ` [RFC][PATCH 3/6] ACPI: processor: Clean up acpi_processor_evaluate_cst() Rafael J. Wysocki
2019-12-06 9:37 ` [RFC][PATCH 4/6] ACPI: processor: Export acpi_processor_evaluate_cst() Rafael J. Wysocki
2019-12-06 9:46 ` [RFC][PATCH 5/6] intel_idle: Refactor intel_idle_cpuidle_driver_init() Rafael J. Wysocki
2019-12-06 9:46 ` [RFC][PATCH 6/6] intel_idle: Use ACPI _CST for processor models without C-state tables Rafael J. Wysocki
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=2604399.tYvJkFLScm@kreacher \
--to=rjw@rjwysocki.net \
--cc=len.brown@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).