Linux Power Management development
 help / color / mirror / Atom feed
From: Sumit Gupta <sumitg@nvidia.com>
To: luoxueqin <luoxueqin@kylinos.cn>,
	rafael@kernel.org, viresh.kumar@linaro.org,
	zhanjie9@hisilicon.com, zhenglifeng1@huawei.com,
	pierre.gondois@arm.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] cpufreq: CPPC: mask Desired_Excursion when autonomous selection is enabled
Date: Tue, 12 May 2026 15:32:16 +0530	[thread overview]
Message-ID: <f76548b2-a6cb-4577-bc19-a8e47508b398@nvidia.com> (raw)
In-Reply-To: <20260506101834.343001-1-luoxueqin@kylinos.cn>


On 06/05/26 15:48, luoxueqin wrote:
> External email: Use caution opening links or attachments
>
>
> From: Xueqin Luo <luoxueqin@kylinos.cn>
>
> According to the ACPI specification, the Desired_Excursion field is not
> utilized when Autonomous Selection is enabled. In this mode, the bit is
> architecturally ignored and does not carry meaningful information.
>
> Currently, the kernel exposes the raw Performance Limited register
> value to userspace through the cpufreq sysfs interface. This may lead to
> misinterpretation, as userspace may assume Desired_Excursion is valid
> even when autonomous selection is active.
>
> To provide a stable and semantically correct ABI, mask out the
> Desired_Excursion bit when autonomous selection is enabled, so that
> userspace does not observe undefined or misleading values.
>
> Writes are left unchanged, as the field is architecturally ignored in
> this mode and write attempts are harmless.
>
> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
> ---
> v2->v3:
> - Use cached auto_sel from cpufreq driver data
> - Fall back to raw value when policy is unavailable
> - Keep sysfs ABI unchanged by using a wrapper around cppc_get_perf_limited()
> ---
>   drivers/cpufreq/cppc_cpufreq.c | 29 ++++++++++++++++++++++++++++-
>   1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 7e7f9dfb7a24..a439d9621eed 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -982,7 +982,34 @@ store_energy_performance_preference_val(struct cpufreq_policy *policy,
>          return count;
>   }
>
> -CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited,
> +static int cppc_get_perf_limited_filtered(int cpu, u64 *perf_limited)
> +{
> +       struct cpufreq_policy *policy;
> +       struct cppc_cpudata *cpu_data;
> +       bool auto_sel_enabled = false;
> +       int ret;
> +
> +       policy = cpufreq_cpu_get_raw(cpu);
> +       if (policy && policy->driver_data) {
> +               cpu_data = policy->driver_data;
> +               auto_sel_enabled = cpu_data->perf_ctrls.auto_sel;
> +       }
> +
> +       ret = cppc_get_perf_limited(cpu, perf_limited);
> +       if (ret)
> +               return ret;
> +

Small nit:
Call cppc_get_perf_limited() first and return early on error before
cpufreq_cpu_get_raw(). You can then drop the auto_sel_enabled
variable and test cpu_data->perf_ctrls.auto_sel directly.

Thank you,
Sumit Gupta


> +       /*
> +        * Desired_Excursion is ignored when Autonomous Selection is enabled.
> +        * Mask it to avoid exposing misleading values to userspace.
> +        */
> +       if (auto_sel_enabled)
> +               *perf_limited &= ~CPPC_PERF_LIMITED_DESIRED_EXCURSION;
> +
> +       return 0;
> +}
> +
> +CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited_filtered,
>                           cppc_set_perf_limited)
>
>   cpufreq_freq_attr_ro(freqdomain_cpus);
> --
> 2.43.0
>

      parent reply	other threads:[~2026-05-12 10:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 10:18 [PATCH v3] cpufreq: CPPC: mask Desired_Excursion when autonomous selection is enabled luoxueqin
2026-05-11 14:33 ` Pierre Gondois
2026-05-12 10:02 ` Sumit Gupta [this message]

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=f76548b2-a6cb-4577-bc19-a8e47508b398@nvidia.com \
    --to=sumitg@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luoxueqin@kylinos.cn \
    --cc=pierre.gondois@arm.com \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=zhanjie9@hisilicon.com \
    --cc=zhenglifeng1@huawei.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