mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sumit Gupta <sumitg@nvidia.com>
To: Christian Loehle <christian.loehle@arm.com>,
	rafael@kernel.org, viresh.kumar@linaro.org,
	pierre.gondois@arm.com, ionela.voinescu@arm.com,
	zhenglifeng1@huawei.com, zhanjie9@hisilicon.com,
	saket.dumbre@intel.com, lenb@kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev,
	linux-tegra@vger.kernel.org
Cc: treding@nvidia.com, jonathanh@nvidia.com, vsethi@nvidia.com,
	ksitaraman@nvidia.com, sanjayc@nvidia.com, mochs@nvidia.com,
	bbasu@nvidia.com, sumitg@nvidia.com
Subject: Re: [PATCH v2 1/3] cpufreq: CPPC: Keep the policy across CPU hotplug
Date: Fri, 24 Jul 2026 02:57:53 +0530	[thread overview]
Message-ID: <697493bc-4879-45c0-ab59-6006d70d3428@nvidia.com> (raw)
In-Reply-To: <bc0ba136-7f40-4198-8b71-557de0babc0f@arm.com>


On 22/07/26 15:48, Christian Loehle wrote:
> External email: Use caution opening links or attachments
>
>
> On 7/16/26 16:38, Sumit Gupta wrote:
>> Without online()/offline() callbacks, the cpufreq core fully tears
>> down a policy during exit() when its last online CPU is offlined,
>> and rebuilds it during init() when it comes back.
>>
>> Add lightweight online()/offline() callbacks so the core instead
>> keeps the policy live and reuses the driver's cpu_data across
>> CPU hotplug. This avoids re-reading the CPPC capabilities on every
>> offline/online, making CPU hotplug faster.
>>
>> Re-enable CPPC from online(), as it may have been disabled while
>> the CPU was offline.
>>
>> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
>> ---
>>   drivers/cpufreq/cppc_cpufreq.c | 27 +++++++++++++++++++++++++++
>>   1 file changed, 27 insertions(+)
>>
>> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
>> index f6cea0c54dd9..432c6a6288a7 100644
>> --- a/drivers/cpufreq/cppc_cpufreq.c
>> +++ b/drivers/cpufreq/cppc_cpufreq.c
>> @@ -722,6 +722,31 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
>>        return ret;
>>   }
>>
>> +/*
>> + * With offline() defined, the cpufreq core keeps the policy alive when
>> + * a CPU is hotplugged out.
>> + */
>> +static int cppc_cpufreq_cpu_offline(struct cpufreq_policy *policy)
>> +{
>> +     return 0;
>> +}
>> +
>> +/*
>> + * Re-enable CPPC when the policy's CPU comes back online, since the platform
>> + * may have disabled it while the CPU was offline.
>> + */
>> +static int cppc_cpufreq_cpu_online(struct cpufreq_policy *policy)
>> +{
>> +     unsigned int cpu = policy->cpu;
>> +     int ret;
>> +
>> +     ret = cppc_set_enable(cpu, true);
>> +     if (ret && ret != -EOPNOTSUPP)
>> +             pr_warn("Failed to re-enable CPPC for CPU%d (%d)\n", cpu, ret);
> Keeping the policy alive means cpu_data->perf_ctrls survives hotplug, but the callback does not
> reapply it. A governor restart does not guarantee an immediate target callback, so the controls
> may remain reset indefinitely.
>
> I think the online path needs to restore a complete, current performance-control request before
> returning. MIN/MAX should be recomputed from the policy and the last requested DESIRED value
> clamped into that range.

Agreed.
Will change online() to recompute MIN/MAX from the policy and clamp the
retained DESIRED into that range, as described in my reply on patch 3/3.

>
> Also, what about suspend/resume?
>

Good point. On the platform I test on these registers are retained
across both hotplug and suspend, so I left suspend/resume out initially.
But the same mechanism extends to platforms that do reset them.
So I will add it as its own patch in v3 where suspend() saves the
OSPM set values and resume() restores them, reusing the online() path.

Thanks,
Sumit

....



  reply	other threads:[~2026-07-23 21:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 15:38 [PATCH v2 0/3] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload Sumit Gupta
2026-07-16 15:38 ` [PATCH v2 1/3] cpufreq: CPPC: Keep the policy across CPU hotplug Sumit Gupta
2026-07-22 10:18   ` Christian Loehle
2026-07-23 21:27     ` Sumit Gupta [this message]
2026-07-16 15:38 ` [PATCH v2 2/3] ACPI: CPPC: Add u64 wrappers for the autonomous selection register Sumit Gupta
2026-07-17  3:47   ` zhenglifeng (A)
2026-07-21 15:34     ` Rafael J. Wysocki (Intel)
2026-07-23 19:28       ` Sumit Gupta
2026-07-16 15:38 ` [PATCH v2 3/3] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload Sumit Gupta
2026-07-22 10:17   ` Christian Loehle
2026-07-23 19:39     ` Sumit Gupta

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=697493bc-4879-45c0-ab59-6006d70d3428@nvidia.com \
    --to=sumitg@nvidia.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=bbasu@nvidia.com \
    --cc=christian.loehle@arm.com \
    --cc=ionela.voinescu@arm.com \
    --cc=jonathanh@nvidia.com \
    --cc=ksitaraman@nvidia.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mochs@nvidia.com \
    --cc=pierre.gondois@arm.com \
    --cc=rafael@kernel.org \
    --cc=saket.dumbre@intel.com \
    --cc=sanjayc@nvidia.com \
    --cc=treding@nvidia.com \
    --cc=viresh.kumar@linaro.org \
    --cc=vsethi@nvidia.com \
    --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

all inboxes | Powered by JetHome®