From: sudeep.holla@arm.com (Sudeep Holla)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9 2/7] ACPI / processor_idle: Add support for Low Power Idle(LPI) states
Date: Mon, 18 Jul 2016 16:48:40 +0100 [thread overview]
Message-ID: <578CFA58.404@arm.com> (raw)
In-Reply-To: <1500653.yRCxZC8x7Y@vostro.rjw.lan>
On 16/07/16 01:32, Rafael J. Wysocki wrote:
> On Friday, July 08, 2016 06:07:53 PM Sudeep Holla wrote:
>> ACPI 6.0 introduced an optional object _LPI that provides an alternate
>> method to describe Low Power Idle states. It defines the local power
>> states for each node in a hierarchical processor topology. The OSPM can
>> use _LPI object to select a local power state for each level of processor
>> hierarchy in the system. They used to produce a composite power state
>> request that is presented to the platform by the OSPM.
>>
>> Since multiple processors affect the idle state for any non-leaf hierarchy
>> node, coordination of idle state requests between the processors is
>> required. ACPI supports two different coordination schemes: Platform
>> coordinated and OS initiated.
>>
>> This patch adds initial support for Platform coordination scheme of LPI.
>>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>> ---
>> drivers/acpi/bus.c | 14 +-
>> drivers/acpi/processor_driver.c | 2 +-
>> drivers/acpi/processor_idle.c | 468 +++++++++++++++++++++++++++++++++++-----
>> include/acpi/processor.h | 24 ++-
>> include/linux/acpi.h | 4 +
>> 5 files changed, 452 insertions(+), 60 deletions(-)
>>
[...]
>> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
>> index ca0de35d1c3a..98e8c62a961c 100644
>> --- a/drivers/acpi/processor_idle.c
>> +++ b/drivers/acpi/processor_idle.c
[....]
>> +static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
>> +{
>> + int ret, i;
>> + struct acpi_lpi_states_array *info;
>> + struct acpi_device *d = NULL;
>> + acpi_handle handle = pr->handle, pr_ahandle;
>> + acpi_status status;
>> +
>> + if (!osc_pc_lpi_support_confirmed)
>> + return -EOPNOTSUPP;
>> +
>> + max_leaf_depth = 0;
>> + if (!acpi_has_method(handle, "_LPI"))
>> + return -EINVAL;
>> + flat_state_cnt = 0;
>> +
>> + while (ACPI_SUCCESS(status = acpi_get_parent(handle, &pr_ahandle))) {
>> + acpi_bus_get_device(pr_ahandle, &d);
>> + handle = pr_ahandle;
>> +
>> + if (strcmp(acpi_device_hid(d), ACPI_PROCESSOR_CONTAINER_HID))
>> + break;
>> +
>> + if (!acpi_has_method(pr_ahandle, "_LPI"))
>> + break;
>> +
>> + max_leaf_depth++;
>> + }
>> +
>> + info = kcalloc(max_leaf_depth + 1, sizeof(*info), GFP_KERNEL);
>> + if (!info)
>> + return -ENOMEM;
>> +
>> + pr_ahandle = pr->handle;
>> + for (i = max_leaf_depth; i >= 0 && ACPI_SUCCESS(status); i--) {
>> + handle = pr_ahandle;
>> + ret = acpi_processor_evaluate_lpi(handle, info + i);
>> + if (ret)
>> + break;
>> +
>> + status = acpi_get_parent(handle, &pr_ahandle);
>> + }
>> +
>> + /* flatten all the LPI states in the entire hierarchy */
>> + flatten_lpi_states(pr, info, NULL, max_leaf_depth);
>> +
>
> The above code doesn't look particularly straightforward and it seems to be
> using more memory than necessary.
>
> For instance, you don't need to store the acpi_processor_evaluate_lpi() data
> for all levels at the same time. It only needs to be stored for the current
> level and you need a list of states enabling the ones at the current from
> the previous one. Plus the current list of effective states available to the
> CPU.
>
Agreed with all the comments and fixed locally except this one. This
approach considered one leaf node and searched till the root each time.
To save memory we need to complete one level at a time. I am making
changes for this now but make require more testing with all combinations.
> It also should check the upper bound of pr->power.lpi_states[] somewhere which
> it doesn't do AFAICS.
>
Fixed now
--
Regards,
Sudeep
next prev parent reply other threads:[~2016-07-18 15:48 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 [this message]
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 ` [PATCH v9 5/7] drivers: firmware: psci: initialise idle states using ACPI LPI Sudeep Holla
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=578CFA58.404@arm.com \
--to=sudeep.holla@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).