mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Add CPU frequency policy change notification support
@ 2026-01-20  9:24 Tony W Wang-oc
  2026-01-21  5:51 ` Viresh Kumar
  0 siblings, 1 reply; 7+ messages in thread
From: Tony W Wang-oc @ 2026-01-20  9:24 UTC (permalink / raw)
  To: rafael, viresh.kumar, linux-pm, linux-kernel
  Cc: CobeChen, TimGuo, LeoLiu-oc, LindaChai

Implemented CPUFREQ_CHANGE_POLICY notification in cpufreq subsystem.
This enhancement allows kernel modules to be notified when a CPU frequency
policy is modified, facilitating more integrated system management.
The notification is dispatched after a successful governor switch during
policy updates.

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
---
 drivers/cpufreq/cpufreq.c | 2 ++
 include/linux/cpufreq.h   | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a7a69f4d7675..b35fed93bca4 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2707,6 +2707,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 		ret = cpufreq_start_governor(policy);
 		if (!ret) {
 			pr_debug("governor change\n");
+			blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
+						     CPUFREQ_CHANGE_POLICY, policy);
 			return 0;
 		}
 		cpufreq_exit_governor(policy);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index cc894fc38971..b1cc9138e801 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -528,6 +528,7 @@ static inline void cpufreq_resume(void) {}
 /* Policy Notifiers  */
 #define CPUFREQ_CREATE_POLICY		(0)
 #define CPUFREQ_REMOVE_POLICY		(1)
+#define CPUFREQ_CHANGE_POLICY		(2)
 
 #ifdef CONFIG_CPU_FREQ
 int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] cpufreq: Add CPU frequency policy change notification support
  2026-01-20  9:24 [PATCH] cpufreq: Add CPU frequency policy change notification support Tony W Wang-oc
@ 2026-01-21  5:51 ` Viresh Kumar
  2026-01-21  8:37   ` Tony W Wang-oc
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2026-01-21  5:51 UTC (permalink / raw)
  To: Tony W Wang-oc
  Cc: rafael, linux-pm, linux-kernel, CobeChen, TimGuo, LeoLiu-oc, LindaChai

On 20-01-26, 17:24, Tony W Wang-oc wrote:
> Implemented CPUFREQ_CHANGE_POLICY notification in cpufreq subsystem.
> This enhancement allows kernel modules to be notified when a CPU frequency
> policy is modified, facilitating more integrated system management.
> The notification is dispatched after a successful governor switch during
> policy updates.
> 
> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
> ---
>  drivers/cpufreq/cpufreq.c | 2 ++
>  include/linux/cpufreq.h   | 1 +
>  2 files changed, 3 insertions(+)

Who is using this stuff ? Please explain why you need this and how you
are going to use it. I don't think it is a great idea, but I still
want to see what you are doing in the first place.

-- 
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] cpufreq: Add CPU frequency policy change notification support
  2026-01-21  5:51 ` Viresh Kumar
@ 2026-01-21  8:37   ` Tony W Wang-oc
  2026-01-21 10:02     ` Viresh Kumar
  0 siblings, 1 reply; 7+ messages in thread
From: Tony W Wang-oc @ 2026-01-21  8:37 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rafael, linux-pm, linux-kernel, CobeChen, TimGuo, LeoLiu-oc, LindaChai



On 2026/1/21 13:51, Viresh Kumar wrote:
> 
> 
> 
> On 20-01-26, 17:24, Tony W Wang-oc wrote:
>> Implemented CPUFREQ_CHANGE_POLICY notification in cpufreq subsystem.
>> This enhancement allows kernel modules to be notified when a CPU frequency
>> policy is modified, facilitating more integrated system management.
>> The notification is dispatched after a successful governor switch during
>> policy updates.
>>
>> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
>> ---
>>   drivers/cpufreq/cpufreq.c | 2 ++
>>   include/linux/cpufreq.h   | 1 +
>>   2 files changed, 3 insertions(+)
> 
> Who is using this stuff ? Please explain why you need this and how you
> are going to use it. I don't think it is a great idea, but I still
> want to see what you are doing in the first place.
> 

The expectation is to register a notifier of type 
CPUFREQ_POLICY_NOTIFIER via cpufreq_register_notifier in one of our 
drivers. The notifier callback will configure Zhaoxin registers to 
different values based on the different cpufreq governors when the event 
is CPUFREQ_GOVERNOR_CHANGE, thereby allowing the Zhaoxin hardware to 
adopt different power management strategies.

Sincerely!
TonyWWang-oc

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] cpufreq: Add CPU frequency policy change notification support
  2026-01-21  8:37   ` Tony W Wang-oc
@ 2026-01-21 10:02     ` Viresh Kumar
  2026-01-22  2:13       ` Tony W Wang-oc
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2026-01-21 10:02 UTC (permalink / raw)
  To: Tony W Wang-oc
  Cc: rafael, linux-pm, linux-kernel, CobeChen, TimGuo, LeoLiu-oc, LindaChai

On 21-01-26, 16:37, Tony W Wang-oc wrote:
> The expectation is to register a notifier of type CPUFREQ_POLICY_NOTIFIER
> via cpufreq_register_notifier in one of our drivers. The notifier callback
> will configure Zhaoxin registers to different values based on the different
> cpufreq governors when the event is CPUFREQ_GOVERNOR_CHANGE, thereby
> allowing the Zhaoxin hardware to adopt different power management
> strategies.

Firstly, for this change to be acceptable, we would need your upstream
platform specific changes as well.

And then I am still not sure if this it the right way to solve this
problem.

-- 
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] cpufreq: Add CPU frequency policy change notification support
  2026-01-21 10:02     ` Viresh Kumar
@ 2026-01-22  2:13       ` Tony W Wang-oc
  2026-01-22  5:26         ` Viresh Kumar
  0 siblings, 1 reply; 7+ messages in thread
From: Tony W Wang-oc @ 2026-01-22  2:13 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rafael, linux-pm, linux-kernel, CobeChen, TimGuo, LeoLiu-oc, LindaChai



On 2026/1/21 18:02, Viresh Kumar wrote:
> 
> 
> On 21-01-26, 16:37, Tony W Wang-oc wrote:
>> The expectation is to register a notifier of type CPUFREQ_POLICY_NOTIFIER
>> via cpufreq_register_notifier in one of our drivers. The notifier callback
>> will configure Zhaoxin registers to different values based on the different
>> cpufreq governors when the event is CPUFREQ_GOVERNOR_CHANGE, thereby
>> allowing the Zhaoxin hardware to adopt different power management
>> strategies.
> 
> Firstly, for this change to be acceptable, we would need your upstream
> platform specific changes as well.
> 
> And then I am still not sure if this it the right way to solve this
> problem.
> 
The driver for Zhaoxin using this patch still needs further verification 
on actual platforms; it cannot yet be submitted to the mainline. 
However, we have already verified that this patch itself has no issues 
with Zhaoxin's driver.

 From the perspective of this patch itself, we think it provides the 
capability to perceive changes in cpufreq policy for all modules 
concerned, and it can serve not just this Zhaoxin driver.

Sincerely
TonyWWang-oc

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] cpufreq: Add CPU frequency policy change notification support
  2026-01-22  2:13       ` Tony W Wang-oc
@ 2026-01-22  5:26         ` Viresh Kumar
  2026-01-22  7:41           ` Tony W Wang-oc
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2026-01-22  5:26 UTC (permalink / raw)
  To: Tony W Wang-oc
  Cc: rafael, linux-pm, linux-kernel, CobeChen, TimGuo, LeoLiu-oc, LindaChai

On 22-01-26, 10:13, Tony W Wang-oc wrote:
> The driver for Zhaoxin using this patch still needs further verification on
> actual platforms; it cannot yet be submitted to the mainline. However, we
> have already verified that this patch itself has no issues with Zhaoxin's
> driver.

Upstream features are only allowed if we have an upstream user of the
same. Can't take this without a user.

-- 
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] cpufreq: Add CPU frequency policy change notification support
  2026-01-22  5:26         ` Viresh Kumar
@ 2026-01-22  7:41           ` Tony W Wang-oc
  0 siblings, 0 replies; 7+ messages in thread
From: Tony W Wang-oc @ 2026-01-22  7:41 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rafael, linux-pm, linux-kernel, CobeChen, TimGuo, LeoLiu-oc, LindaChai



On 2026/1/22 13:26, Viresh Kumar wrote:
> 
> 
> 
> On 22-01-26, 10:13, Tony W Wang-oc wrote:
>> The driver for Zhaoxin using this patch still needs further verification on
>> actual platforms; it cannot yet be submitted to the mainline. However, we
>> have already verified that this patch itself has no issues with Zhaoxin's
>> driver.
> 
> Upstream features are only allowed if we have an upstream user of the
> same. Can't take this without a user.
> 

Okay, thank you for your explanation.

Sincerely
TonyWWang-oc

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-22  8:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-20  9:24 [PATCH] cpufreq: Add CPU frequency policy change notification support Tony W Wang-oc
2026-01-21  5:51 ` Viresh Kumar
2026-01-21  8:37   ` Tony W Wang-oc
2026-01-21 10:02     ` Viresh Kumar
2026-01-22  2:13       ` Tony W Wang-oc
2026-01-22  5:26         ` Viresh Kumar
2026-01-22  7:41           ` Tony W Wang-oc

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®