Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Pierre Gondois <pierre.gondois@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>, Sumit Gupta <sumitg@nvidia.com>
Cc: viresh.kumar@linaro.org, ionela.voinescu@arm.com,
	zhenglifeng1@huawei.com, zhanjie9@hisilicon.com,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-tegra@vger.kernel.org, treding@nvidia.com,
	jonathanh@nvidia.com, vsethi@nvidia.com, ksitaraman@nvidia.com,
	sanjayc@nvidia.com, mochs@nvidia.com, bbasu@nvidia.com
Subject: Re: [PATCH] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload
Date: Wed, 1 Jul 2026 18:24:16 +0200	[thread overview]
Message-ID: <15def9ce-abbd-4ef5-bb8f-0c55b42a0181@arm.com> (raw)
In-Reply-To: <CAJZ5v0h+Fhj8+xLC=TAqx43+tQCPDUj-eP9YMW=BwKzn8CPUDw@mail.gmail.com>

Hello Rafael, Sumit,

On 6/24/26 15:20, Rafael J. Wysocki wrote:
> On Wed, Jun 24, 2026 at 2:56 PM Sumit Gupta<sumitg@nvidia.com> wrote:
>> Hi Rafael,
>>
>>
>> On 23/06/26 16:30, Rafael J. Wysocki wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> On Tue, Jun 23, 2026 at 11:54 AM Sumit Gupta<sumitg@nvidia.com> wrote:
>>>> Values written to OSPM-set CPPC registers (via sysfs or the autonomous
>>>> boot parameter) can be lost in two ways:
>>>>
>>>>     - Across CPU hotplug: the platform may reset a CPU's registers when it
>>>>       is offlined.
>>>>     - On driver unload: the value the driver wrote is left in the register
>>>>       instead of returning to its pre-driver state.
>>>>
>>>> Add a small table-driven mechanism that handles both:
>>>>
>>>>     - Capture each register's firmware value when a CPU is first seen and
>>>>       restore it on driver unload.
>>>>     - Record the last value the driver set and reapply it from ->init()
>>>>       when the policy is reactivated after CPU hotplug.
>>> I'm not sure if this is a good idea TBH.
>>>
>>> The overall system state when the CPU goes online may be completely
>>> different from the system state when the CPU was online last time, so
>>> there is no reason to restore its settings from before offline, at
>>> least in principle.
>> These are values userspace deliberately set, more like a frequency QoS
>> request that persists until userspace changes it than transient state.
>> It's platform dependent though, as the platform I test on preserves them
>> across hotplug, but where the platform resets the register on offline
>> the value is silently lost. Should the kernel re-apply it on online,
>> or is that better left to userspace? If so, I will drop the hotplug reapply
>> and keep only the restore on driver unload.
>>
>> intel_pstate and amd-pstate already re-sync these on CPU online, as they
>> keep the policy across hotplug via ->online()/->offline(). So for them
>> it's re-syncing the hardware, not restoring state from before offline.
>>
>> cppc_cpufreq has no ->online()/->offline() today, so it fully tears the
>> policy down and rebuilds it, which is why this reads as "restoring
>> settings from before offline".
>> Would adding ->online()/->offline() be acceptable, with policy preserved
>> and ->online() just re-syncing the registers the platform reset?
> That would be a better approach IMV.
Just an example to be sure I understand correctly.

1. on a platform, auto_sel=0 by default
2. cppc_cpufreq driver is loaded + we set auto_sel=1
3. all the CPUs of a policy are unplugged
4. cppc_cpufreq driver is unloaded

To be sure we let the platform in the default state,
we should set auto_sel=0 in step A.3, i.e. in the
.offline() callback.
Doing it at A.4 (i.e. in the .exit()) would not be possible:
the CPU's registers might not be available anymore once offline.

IoW, we should only need:
.init()
\-cppc_cpufreq_save_firmware_regs()
firmware_captured=0, save the firmware regs.

.online()
\-cppc_cpufreq_save_firmware_regs()
firmware_captured=1, restore the user (or previous)
values that were saved in the previous .offline() call
(as .online() is not called for new policies).

.offline()
\-cppc_cpufreq_restore_firmware_regs()
Save the user/current regs values
+ Restore the firmware registers.

And it should be ok to remove:
- cppc_cpufreq_reapply_requested_regs()
- the firmware_captured field.
If during .init(), we init requested_val to the firmware
values aswell, firmware_captured should be useless

  reply	other threads:[~2026-07-01 16:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23  9:54 [PATCH] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload Sumit Gupta
2026-06-23 11:00 ` Rafael J. Wysocki
2026-06-24 12:56   ` Sumit Gupta
2026-06-24 13:20     ` Rafael J. Wysocki
2026-07-01 16:24       ` Pierre Gondois [this message]
2026-07-06 18:34         ` Rafael J. Wysocki (Intel)
2026-07-07 19:45           ` Sumit Gupta
2026-07-01 16:24 ` Pierre Gondois
2026-07-07 20:14   ` 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=15def9ce-abbd-4ef5-bb8f-0c55b42a0181@arm.com \
    --to=pierre.gondois@arm.com \
    --cc=bbasu@nvidia.com \
    --cc=ionela.voinescu@arm.com \
    --cc=jonathanh@nvidia.com \
    --cc=ksitaraman@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mochs@nvidia.com \
    --cc=rafael@kernel.org \
    --cc=sanjayc@nvidia.com \
    --cc=sumitg@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