From: Sudeep Holla <sudeep.holla@arm.com>
To: ACPI List <linux-acpi@vger.kernel.org>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
Vikas Sajjan <vikas.cha.sajjan@hpe.com>, Sunil <sunil.vl@hpe.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Prashanth Prakash <pprakash@codeaurora.org>,
Al Stone <al.stone@linaro.org>,
Ashwin Chaugule <ashwin.chaugule@linaro.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
LKML <linux-kernel@vger.kernel.org>,
ALKML <linux-arm-kernel@lists.infradead.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: [PATCH v9 5/7] drivers: firmware: psci: initialise idle states using ACPI LPI
Date: Fri, 8 Jul 2016 18:07:56 +0100 [thread overview]
Message-ID: <1467997678-7107-6-git-send-email-sudeep.holla@arm.com> (raw)
In-Reply-To: <1467997678-7107-1-git-send-email-sudeep.holla@arm.com>
This patch adds support for initialisation of PSCI CPUIdle states
from Low Power Idle(_LPI) entries in the ACPI tables when acpi is
enabled.
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/psci.c | 66 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 59 insertions(+), 7 deletions(-)
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 03e04582791c..8263429e21b8 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -13,6 +13,7 @@
#define pr_fmt(fmt) "psci: " fmt
+#include <linux/acpi.h>
#include <linux/arm-smccc.h>
#include <linux/cpuidle.h>
#include <linux/errno.h>
@@ -256,13 +257,6 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)
u32 *psci_states;
struct device_node *state_node;
- /*
- * If the PSCI cpu_suspend function hook has not been initialized
- * idle states must not be enabled, so bail out
- */
- if (!psci_ops.cpu_suspend)
- return -EOPNOTSUPP;
-
/* Count idle states */
while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states",
count))) {
@@ -310,11 +304,69 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)
return ret;
}
+#ifdef CONFIG_ACPI
+#include <acpi/processor.h>
+
+static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu)
+{
+ int i, count;
+ u32 *psci_states;
+ struct acpi_lpi_state *lpi;
+ struct acpi_processor *pr = per_cpu(processors, cpu);
+
+ if (unlikely(!pr || !pr->flags.has_lpi))
+ return -EINVAL;
+
+ count = pr->power.count - 1;
+ if (count <= 0)
+ return -ENODEV;
+
+ psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL);
+ if (!psci_states)
+ return -ENOMEM;
+
+ for (i = 0; i < count; i++) {
+ u32 state;
+
+ lpi = &pr->power.lpi_states[i + 1];
+ /*
+ * Only bits[31:0] represent a PSCI power_state while
+ * bits[63:32] must be 0x0 as per ARM ACPI FFH Specification
+ */
+ state = lpi->address;
+ if (!psci_power_state_is_valid(state)) {
+ pr_warn("Invalid PSCI power state %#x\n", state);
+ kfree(psci_states);
+ return -EINVAL;
+ }
+ psci_states[i] = state;
+ }
+ /* Idle states parsed correctly, initialize per-cpu pointer */
+ per_cpu(psci_power_state, cpu) = psci_states;
+ return 0;
+}
+#else
+static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu)
+{
+ return -EINVAL;
+}
+#endif
+
int psci_cpu_init_idle(unsigned int cpu)
{
struct device_node *cpu_node;
int ret;
+ /*
+ * If the PSCI cpu_suspend function hook has not been initialized
+ * idle states must not be enabled, so bail out
+ */
+ if (!psci_ops.cpu_suspend)
+ return -EOPNOTSUPP;
+
+ if (!acpi_disabled)
+ return psci_acpi_cpu_init_idle(cpu);
+
cpu_node = of_get_cpu_node(cpu, NULL);
if (!cpu_node)
return -ENODEV;
--
2.7.4
next prev parent reply other threads:[~2016-07-08 17:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-08 17:07 [PATCH v9 0/7] ACPI / processor_idle: Add ACPI v6.0 LPI support Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 1/7] ACPI / processor_idle: introduce ACPI_PROCESSOR_CSTATE Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 2/7] ACPI / processor_idle: Add support for Low Power Idle(LPI) states Sudeep Holla
2016-07-16 0:32 ` Rafael J. Wysocki
2016-07-18 15:48 ` Sudeep Holla
2016-07-08 17:07 ` [PATCH v9 3/7] arm64: cpuidle: drop __init section marker to arm_cpuidle_init Sudeep Holla
2016-07-12 15:23 ` Catalin Marinas
2016-07-08 17:07 ` [PATCH v9 4/7] cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32, 64} Sudeep Holla
2016-07-08 17:07 ` Sudeep Holla [this message]
2016-07-08 17:07 ` [PATCH v9 6/7] arm64: add support for ACPI Low Power Idle(LPI) Sudeep Holla
2016-07-12 15:22 ` Catalin Marinas
2016-07-08 17:07 ` [PATCH v9 7/7] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64 Sudeep Holla
2016-07-12 11:42 ` [PATCH v9 0/7] ACPI / processor_idle: Add ACPI v6.0 LPI support Sudeep Holla
2016-07-12 12:09 ` Rafael J. Wysocki
2016-07-12 12:59 ` Sudeep Holla
2016-07-14 1:15 ` 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=1467997678-7107-6-git-send-email-sudeep.holla@arm.com \
--to=sudeep.holla@arm.com \
--cc=al.stone@linaro.org \
--cc=ashwin.chaugule@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=pprakash@codeaurora.org \
--cc=rjw@rjwysocki.net \
--cc=sunil.vl@hpe.com \
--cc=vikas.cha.sajjan@hpe.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).