Linux ACPI
 help / color / mirror / Atom feed
From: "lihuisong (C)" <lihuisong@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>
Cc: Linux ACPI <linux-acpi@vger.kernel.org>,
	Sudeep Holla <Sudeep.Holla@arm.com>
Subject: Re: [PATCH v1 08/17] ACPI: processor: idle: Rework first-level _LPI states processing
Date: Thu, 16 Jul 2026 20:44:31 +0800	[thread overview]
Message-ID: <db010283-a568-4683-a880-53c0b27f8a8c@huawei.com> (raw)
In-Reply-To: <3703077.iIbC2pHGDl@rafael.j.wysocki>


On 7/9/2026 8:37 PM, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> The first-level _LPI states need not be combined with the previous
> level and the entry method for them cannot be ACPI_CSTATE_INTEGER, so
> process them directly in acpi_processor_get_lpi_info() instead of doing
> a special case for them in flatten_lpi_states().
>
> Also bail out if there are no _LPI states at the first level because
> that means that there are no _LPI states at all.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   drivers/acpi/processor_idle.c | 47 +++++++++++++++++++++++++++--------
>   1 file changed, 37 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index e990a43514e6..efd3e76377fa 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -1068,13 +1068,6 @@ static unsigned int flatten_lpi_states(struct acpi_processor *pr,
>   
>   		flpi = &pr->power.lpi_states[flat_state_cnt];
>   
> -		if (!prev_level) { /* leaf/processor node */
> -			memcpy(flpi, t, sizeof(*t));
> -			stash_composite_state(curr_level, flpi);
> -			flat_state_cnt++;
> -			continue;
> -		}
> -
>   		for (i = 0; i < prev_level->composite_states_size; i++) {
>   			p = prev_level->composite_states[i];
>   			if (t->index <= p->enable_parent_state &&
> @@ -1101,9 +1094,10 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
>   {
>   	struct acpi_lpi_states_array info[2], *prev, *curr;
>   	acpi_handle handle = pr->handle;
> -	unsigned int state_count;
> +	unsigned int state_count = 0;
>   	acpi_status status;
> -	int ret, i;
> +	unsigned int i;
> +	int ret;
>   
>   	/* make sure our architecture has support */
>   	ret = acpi_processor_ffh_lpi_probe(pr->id);
> @@ -1117,12 +1111,45 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
>   		return -EINVAL;
>   
>   	curr = &info[0];
> +	curr->composite_states_size = 0;
>   
>   	ret = acpi_processor_evaluate_lpi(handle, curr);
>   	if (ret)
>   		return ret;
>   
> -	state_count = flatten_lpi_states(pr, 0, curr, NULL);
> +	/* Copy all of the usable first-level states to power.lpi_states[]. */
> +	for (i = 0; i < curr->size; i++) {
> +		struct acpi_lpi_state *lpi = &curr->entries[i];
> +		struct acpi_lpi_state *flpi;
> +
> +		/*
> +		 * Skip states that are not enabled or have an inadequate entry
> +		 * method for this level.
> +		 */
> +		if (!(lpi->flags & ACPI_LPI_STATE_FLAGS_ENABLED) ||
> +		    lpi->entry_method == ACPI_CSTATE_INTEGER)
> +			continue;
> +
> +		if (state_count >= ACPI_PROCESSOR_MAX_POWER) {
> +			acpi_handle_info(handle,
> +					 "No space for more _LPI states than %d\n",
> +					 ACPI_PROCESSOR_MAX_POWER);
> +			break;
> +		}
> +
> +		flpi = &pr->power.lpi_states[state_count++];
> +		memcpy(flpi, lpi, sizeof(*lpi));
> +		stash_composite_state(curr, flpi);
> +	}
> +
> +	kfree(curr->entries);
> +
> +	/*
> +	 * If there are no _LPI states at the first level, there are no _LPI
> +	 * states at all.
> +	 */
> +	if (!state_count)
> +		return -ENODATA;
>   
The code is easier to understand after this rework.
But the "first level" is not good to me.
IIUC, the first level is processor, right?
In addition, how about extract a function, like, 
flatten_processor_lpi_states, for these codes?
>   	prev = curr;
>   	curr = &info[1];

  parent reply	other threads:[~2026-07-16 12:44 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 12:29 [PATCH v1 00/17] ACPI: processor: idle/intel_idle: Add ACPI _LPI support to intel_idle Rafael J. Wysocki
2026-07-09 12:30 ` [PATCH v1 01/17] ACPI: processor: idle: Expand _LPI package sanity checks Rafael J. Wysocki
2026-07-13 11:22   ` Sudeep Holla
2026-07-16  9:05   ` lihuisong (C)
2026-07-09 12:31 ` [PATCH v1 02/17] ACPI: processor: idle: Ignore _LPI states with SYSTEMIO entry method Rafael J. Wysocki
2026-07-13 11:24   ` Sudeep Holla
2026-07-16  9:08   ` lihuisong (C)
2026-07-09 12:32 ` [PATCH v1 03/17] ACPI: processor: idle: Unify debug in acpi_processor_evaluate_lpi() Rafael J. Wysocki
2026-07-13 11:27   ` Sudeep Holla
2026-07-16  9:16   ` lihuisong (C)
2026-07-09 12:33 ` [PATCH v1 04/17] ACPI: processor: idle: Rearrange acpi_processor_evaluate_lpi() Rafael J. Wysocki
2026-07-13 11:29   ` Sudeep Holla
2026-07-16  9:46   ` lihuisong (C)
2026-07-16 10:36     ` Rafael J. Wysocki (Intel)
2026-07-16 11:51   ` lihuisong (C)
2026-07-16 12:57     ` Rafael J. Wysocki (Intel)
2026-07-09 12:34 ` [PATCH v1 05/17] ACPI: processor: idle: Split acpi_processor_evaluate_lpi() Rafael J. Wysocki
2026-07-13 13:17   ` Sudeep Holla
2026-07-16 11:55   ` lihuisong (C)
2026-07-16 12:58     ` Rafael J. Wysocki (Intel)
2026-07-17  2:04       ` lihuisong (C)
2026-07-09 12:35 ` [PATCH v1 06/17] ACPI: processor: idle: Introduce lpi_state_debug() Rafael J. Wysocki
2026-07-09 12:36 ` [PATCH v1 07/17] ACPI: processor: idle: Rearrange acpi_processor_get_lpi_info() Rafael J. Wysocki
2026-07-13 13:18   ` Sudeep Holla
2026-07-16 12:06   ` lihuisong (C)
2026-07-09 12:37 ` [PATCH v1 08/17] ACPI: processor: idle: Rework first-level _LPI states processing Rafael J. Wysocki
2026-07-13 13:20   ` Sudeep Holla
2026-07-16 12:44   ` lihuisong (C) [this message]
2026-07-16 13:03     ` Rafael J. Wysocki (Intel)
2026-07-09 12:37 ` [PATCH v1 09/17] ACPI: processor: idle: Drop redundant _LPI presence checks Rafael J. Wysocki
2026-07-13 13:21   ` Sudeep Holla
2026-07-16 12:47   ` lihuisong (C)
2026-07-09 12:38 ` [PATCH v1 10/17] ACPI: processor: idle: Rearrange loop in acpi_processor_get_lpi_info() Rafael J. Wysocki
2026-07-13 13:21   ` Sudeep Holla
2026-07-16 12:49   ` lihuisong (C)
2026-07-09 12:39 ` [PATCH v1 11/17] ACPI: processor: idle: Rework flatten_lpi_states() Rafael J. Wysocki
2026-07-13 13:23   ` Sudeep Holla
2026-07-17  1:36   ` lihuisong (C)
2026-07-09 12:39 ` [PATCH v1 12/17] ACPI: processor: idle: Introduce too_many_states() for _LPI Rafael J. Wysocki
2026-07-13 13:23   ` Sudeep Holla
2026-07-17  1:38   ` lihuisong (C)
2026-07-09 12:40 ` [PATCH v1 13/17] ACPI: processor: idle: Introduce acpi_processor_extract_lpi_info() Rafael J. Wysocki
2026-07-13 13:32   ` Sudeep Holla
2026-07-17  1:46     ` lihuisong (C)
2026-07-09 12:41 ` [PATCH v1 14/17] ACPI: processor: idle: Relocate acpi_processor_extract_lpi_info() Rafael J. Wysocki
2026-07-13 13:30   ` Sudeep Holla
2026-07-17  1:56     ` lihuisong (C)
2026-07-09 12:42 ` [PATCH v1 15/17] ACPI: processor: idle: Add switch for strict _LPI processing Rafael J. Wysocki
2026-07-13 13:33   ` Sudeep Holla
2026-07-17  1:58     ` lihuisong (C)
2026-07-09 12:43 ` [PATCH v1 16/17] intel_idle: Prepare for adding ACPI _LPI support Rafael J. Wysocki
2026-07-09 12:44 ` [PATCH v1 17/17] intel_idle: Add " Rafael J. Wysocki
2026-07-13 14:56   ` Sudeep Holla
2026-07-14 13:25     ` Rafael J. Wysocki (Intel)

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=db010283-a568-4683-a880-53c0b27f8a8c@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=Sudeep.Holla@arm.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox