From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/5] drivers: psci: refactor psci_cpu_init_idle in preparation for ACPI LPI support
Date: Thu, 9 Jun 2016 14:24:08 +0100 [thread overview]
Message-ID: <20160609132408.GA16831@red-moon> (raw)
In-Reply-To: <1461069013-13292-4-git-send-email-sudeep.holla@arm.com>
On Tue, Apr 19, 2016 at 01:30:11PM +0100, Sudeep Holla wrote:
> Inorder to accomodate bot DT and ACPI LPI support in psci_cpu_init_idle,
> move the device tree specific into psci_dt_cpu_init_idle.
>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/firmware/psci.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> index 11bfee8b79a9..af6c5c839568 100644
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -250,11 +250,11 @@ static int __init psci_features(u32 psci_func_id)
> #ifdef CONFIG_CPU_IDLE
> static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state);
>
> -static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)
> +static int psci_dt_cpu_init_idle(unsigned int cpu)
Unfortunately you would break ARM 32-bit if you did that.
> {
> int i, ret, count = 0;
> u32 *psci_states;
> - struct device_node *state_node;
> + struct device_node *state_node, *cpu_node;
>
> /*
> * If the PSCI cpu_suspend function hook has not been initialized
> @@ -263,6 +263,10 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)
> if (!psci_ops.cpu_suspend)
> return -EOPNOTSUPP;
>
> + cpu_node = of_get_cpu_node(cpu, NULL);
> + if (!cpu_node)
> + return -ENODEV;
> +
> /* Count idle states */
> while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states",
> count))) {
> @@ -303,27 +307,18 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)
> }
> /* Idle states parsed correctly, initialize per-cpu pointer */
> per_cpu(psci_power_state, cpu) = psci_states;
> + of_node_put(cpu_node);
> return 0;
>
> free_mem:
> + of_node_put(cpu_node);
> kfree(psci_states);
> return ret;
> }
>
> int psci_cpu_init_idle(unsigned int cpu)
> {
> - struct device_node *cpu_node;
> - int ret;
> -
> - cpu_node = of_get_cpu_node(cpu, NULL);
> - if (!cpu_node)
> - return -ENODEV;
> -
> - ret = psci_dt_cpu_init_idle(cpu_node, cpu);
> -
> - of_node_put(cpu_node);
> -
> - return ret;
> + return psci_dt_cpu_init_idle(cpu);
How about leaving code as is and you wrap the cpu_node retrieval:
if (!acpi_disabled) {
acpi_idle_init();
} else {
cpu_node = of_get_cpu_node(cpu, NULL);
if (!cpu_node)
return -ENODEV;
ret = psci_dt_cpu_init_idle(cpu_node, cpu);
of_node_put(cpu_node);
}
?
Alternatively, you could create an intermediate stub
__psci_dt_cpu_init_idle(), that will be used for CONFIG_ARM
cpuidle_ops.init and psci_dt_cpu_init_idle() after retrieving
the cpu_node, which I think is slightly cleaner.
Lorenzo
next prev parent reply other threads:[~2016-06-09 13:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 12:30 [PATCH v4 0/5] ACPI / processor_idle: Add ACPI v6.0 LPI support Sudeep Holla
2016-04-19 12:30 ` [PATCH v4 1/5] ACPI / processor_idle: introduce ARCH_SUPPORTS_ACPI_PROCESSOR_CSTATE Sudeep Holla
2016-04-19 12:49 ` kbuild test robot
2016-04-19 13:00 ` Sudeep Holla
2016-04-20 9:56 ` Vikas Sajjan
2016-04-20 10:09 ` Sudeep Holla
2016-05-10 0:02 ` Rafael J. Wysocki
2016-05-11 15:07 ` Sudeep Holla
2016-04-19 12:30 ` [PATCH v4 2/5] ACPI / processor_idle: Add support for Low Power Idle(LPI) states Sudeep Holla
2016-05-10 0:04 ` Rafael J. Wysocki
2016-05-11 0:03 ` Rafael J. Wysocki
2016-05-11 15:06 ` Sudeep Holla
2016-05-11 20:45 ` Rafael J. Wysocki
2016-04-19 12:30 ` [PATCH v4 3/5] drivers: psci: refactor psci_cpu_init_idle in preparation for ACPI LPI support Sudeep Holla
2016-06-09 13:24 ` Lorenzo Pieralisi [this message]
2016-06-09 14:26 ` Sudeep Holla
2016-04-19 12:30 ` [PATCH v4 4/5] arm64: add support for ACPI Low Power Idle(LPI) Sudeep Holla
2016-04-19 13:59 ` kbuild test robot
2016-04-19 15:42 ` Sudeep Holla
2016-04-20 9:59 ` Vikas Sajjan
2016-04-20 10:20 ` Sudeep Holla
2016-04-20 10:39 ` Jisheng Zhang
2016-04-26 15:51 ` Prakash, Prashanth
2016-04-26 16:01 ` Sudeep Holla
2016-05-11 0:07 ` Rafael J. Wysocki
2016-05-11 15:06 ` Sudeep Holla
2016-04-19 12:30 ` [PATCH v4 5/5] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64 Sudeep Holla
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=20160609132408.GA16831@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 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).