Skip to contentSkip to conversation

cpufreq: create cooling device based on ACPI

PATCH In review [email protected] 4 participants 7 messages Apr 28, 2023 – May 10, 2023 2 messages not in the archive CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: create cooling device based on ACPI

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error occurs:cpufreq_cooling: OF node not available for cpu*. The current computer motherboard is using ACPI firmware. Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface. comment:create cpufreq cooling device based on DT.

---
 drivers/cpufreq/cpufreq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +6 -1
index 6b52ebe5a890..3418c68959d5 100644
@@ -1528,8 +1528,13 @@ static int cpufreq_online(unsigned int cpu)
 	if (cpufreq_driver->ready)
 		cpufreq_driver->ready(policy);
 
-	if (cpufreq_thermal_control_enabled(cpufreq_driver))
+	if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
+#ifdef CONFIG_ACPI
+		policy->cdev = cpufreq_cooling_register(policy);
+#else
 		policy->cdev = of_cpufreq_cooling_register(policy);
+#endif
+	}
 
 	pr_debug("initialization complete\n");
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 20 lines · On Fri, Apr 28, 2023 at 9:19 AM <[email protected]> wrote:

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error occurs:cpufreq_cooling: OF node not available for cpu*. The current computer motherboard is using ACPI firmware. Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface. comment:create cpufreq cooling device based on DT.

---
 drivers/cpufreq/cpufreq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +0 -0
index 6b52ebe5a890..3418c68959d5 100644

drivers/cpufreq/cpufreq.c static int cpufreq_online(unsigned int cpu) · line 1536

Quoted 10 lines
drivers/cpufreq/cpufreq.c +5 -1
@@ -1528,8 +1528,13 @@ static int cpufreq_online(unsigned int cpu)
        if (cpufreq_driver->ready)
                cpufreq_driver->ready(policy);
 
-       if (cpufreq_thermal_control_enabled(cpufreq_driver))
+       if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
+#ifdef CONFIG_ACPI
+               policy->cdev = cpufreq_cooling_register(policy);
+#else
                policy->cdev = of_cpufreq_cooling_register(policy);
+#endif

Please avoid adding #ifdefs like this in random places.

Moreover, what if the kernel supports ACPI and the platform is DT-based?

Quoted 5 lines
drivers/cpufreq/cpufreq.c +1 -1
+       }
 
        pr_debug("initialization complete\n");
 
--
author
#2 lore raw

Okay, thank you for the reminder!
If I make this change, I'm not sure if it will work. If it does, I'll submit a new patch.

drivers/cpufreq/cpufreq.c +0 -0
@@ -1494,8 +1494,13 @@ static int cpufreq_online(unsigned int cpu)

        if (cpufreq_driver->ready) cpufreq_driver->ready(policy);

-       if (cpufreq_thermal_control_enabled(cpufreq_driver))
-               policy->cdev = of_cpufreq_cooling_register(policy); +       if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
+               struct device_node *np = of_get_cpu_node(policy->cpu, NULL); +               if (np)
+                       policy->cdev = of_cpufreq_cooling_register(policy); +               else
+                       policy->cdev = cpufreq_cooling_register(policy);

+       }

Quoted 41 lines · Rafael J. Wysocki
Quoted 20 lines · On Fri, Apr 28, 2023 at 9:19 AM <[email protected]> wrote:

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error occurs:cpufreq_cooling: OF node not available for cpu*. The current computer motherboard is using ACPI firmware. Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface. comment:create cpufreq cooling device based on DT.

---
 drivers/cpufreq/cpufreq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +0 -0
index 6b52ebe5a890..3418c68959d5 100644

drivers/cpufreq/cpufreq.c static int cpufreq_online(unsigned int cpu) · line 1536

Quoted 10 lines
drivers/cpufreq/cpufreq.c +5 -1
@@ -1528,8 +1528,13 @@ static int cpufreq_online(unsigned int cpu)
        if (cpufreq_driver->ready)
                cpufreq_driver->ready(policy);
 
-       if (cpufreq_thermal_control_enabled(cpufreq_driver))
+       if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
+#ifdef CONFIG_ACPI
+               policy->cdev = cpufreq_cooling_register(policy);
+#else
                policy->cdev = of_cpufreq_cooling_register(policy);
+#endif

Please avoid adding #ifdefs like this in random places.

Moreover, what if the kernel supports ACPI and the platform is DT-based?

Quoted 5 lines
drivers/cpufreq/cpufreq.c +1 -1
+       }
 
        pr_debug("initialization complete\n");
 
--
#3 lore raw
In reply to [email protected]

Hi,

Quoted 3 lines · On 28/04/23 12:33, [email protected] wrote:

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error

Pardon, do you mean drivers/cpufreq/acpi-cpufreq.c ?

Quoted 1 line

occurs:cpufreq_cooling: OF node not available for cpu*.

If this is fixing some errors/ bugs, maybe add an appropriate fixes tag?

Quoted 9 lines

The current computer motherboard is using ACPI firmware. Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface. comment:create cpufreq cooling device based on DT.

---
  drivers/cpufreq/cpufreq.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

[...]

Quoted 1 line
Signature · 2 lines
Thanks and Regards,
Dhruva Gole
author
#4 lore raw

I'm sorry, but I'm using the 5.4 kernel, and the "scpi-cpufreq" function is used in the scpi_clocks_probe_acpi function.

Quoted 30 lines · Dhruva Gole

Hi,

Quoted 3 lines · On 28/04/23 12:33, [email protected] wrote:

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error

Pardon, do you mean drivers/cpufreq/acpi-cpufreq.c ?

Quoted 1 line

occurs:cpufreq_cooling: OF node not available for cpu*.

If this is fixing some errors/ bugs, maybe add an appropriate fixes tag?

Quoted 9 lines

The current computer motherboard is using ACPI firmware. Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface. comment:create cpufreq cooling device based on DT.

---
  drivers/cpufreq/cpufreq.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

[...]

Quoted 1 line
Signature · 2 lines
Thanks and Regards,
Dhruva Gole
#5 lore raw
In reply to [email protected]

Does this patch need to be packaged with other patches? Whether the function cpufreq_cooling_register is declared in cpufreq.c?

-----邮件原件-----
发件人: [email protected] <[email protected]>
发送时间: 2023年4月28日 15:03
收件人: [email protected]; [email protected]
抄送: [email protected]; [email protected]; youwan Wang <[email protected]> 主题: [PATCH] cpufreq: create cooling device based on ACPI

EXTERNAL EMAIL

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error
occurs:cpufreq_cooling: OF node not available for cpu*.
The current computer motherboard is using ACPI firmware.
Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface. comment:create cpufreq cooling device based on DT.

---
 drivers/cpufreq/cpufreq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +5 -1
@@ -1528,8 +1528,13 @@ static int cpufreq_online(unsigned int cpu)
        if (cpufreq_driver->ready)
                cpufreq_driver->ready(policy);
 
-       if (cpufreq_thermal_control_enabled(cpufreq_driver))
+       if (cpufreq_thermal_control_enabled(cpufreq_driver)) { #ifdef
+CONFIG_ACPI
+               policy->cdev = cpufreq_cooling_register(policy); #else
                policy->cdev = of_cpufreq_cooling_register(policy);
+#endif
+       }
 
        pr_debug("initialization complete\n");
 

--
2.25.1

This email (including its attachments) is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Unauthorized use, dissemination, distribution or copying of this email or the information herein or taking any action in reliance on the contents of this email or the information herein, by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is strictly prohibited. If you are not the intended recipient, please do not read, copy, use or disclose any part of this e-mail to others. Please notify the sender immediately and permanently delete this e-mail and any attachments if you received it in error. Internet communications cannot be guaranteed to be timely, secure, error-free or virus-free. The sender does not accept liability for any errors or omissions.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): PUZPR06MB5498536FCB73BD6D5BD928ECF0779@PUZPR06MB5498.apcprd06.prod.outlook.com

author
#8 lore raw

thanks,i try

At 2023-05-10 16:26:14, "Xinglong Yang" <[email protected]> wrote:

P {margin-top:0;margin-bottom:0;}

If you use ACPI firware, why you register cpu as cooling devices device in cpufreq_online
function?

When
the kernel use ACPI firmware, CPUs will be registed as cooling devices during the cpu initialization, please refs to the file "processor_driver.c"

That is not needed to register it again.

发件人: wangyouwan <[email protected]>

发送时间: 2023年5月10日 16:07

收件人: Xinglong Yang <[email protected]>

主题: Re:回复: [PATCH] cpufreq: create cooling device based on ACPI

EXTERNAL EMAIL

yes , I'm using the 5.4 kernel, and the "scpi-cpufreq" function is used in the scpi_clocks_probe_acpi function.

Quoted 94 lines · Xinglong Yang

Does this patch need to be packaged with other patches?

Whether the function cpufreq_cooling_register is declared in cpufreq.c?

-----邮件原件-----

发件人: [email protected] <[email protected]>

发送时间: 2023年4月28日 15:03

收件人: [email protected]; [email protected]

抄送: [email protected]; [email protected]; youwan Wang <[email protected]>

主题: [PATCH] cpufreq: create cooling device based on ACPI

EXTERNAL EMAIL

From: youwan Wang <[email protected]>

When using the "scpi_cpufreq" driver, an error

occurs:cpufreq_cooling: OF node not available for cpu*.

The current computer motherboard is using ACPI firmware.

Go to see that the error is caused by calling the "of_cpufreq_cooling_register" interface.

comment:create cpufreq cooling device based on DT.

---

drivers/cpufreq/cpufreq.c | 7 ++++++-

1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c index 6b52ebe5a890..3418c68959d5 100644 renamed from drivers/cpufreq/cpufreq.c +4 -2
 
--- a/drivers/cpufreq/cpufreq.c
 
+++ b/drivers/cpufreq/cpufreq.c
@@ -1528,8 +1528,13 @@ static int cpufreq_online(unsigned int cpu)
 
         if (cpufreq_driver->ready)
 
                 cpufreq_driver->ready(policy);
 
 
 
-       if (cpufreq_thermal_control_enabled(cpufreq_driver))
 
+       if (cpufreq_thermal_control_enabled(cpufreq_driver)) { #ifdef
 
+CONFIG_ACPI
 
+               policy->cdev = cpufreq_cooling_register(policy); #else

                policy->cdev = of_cpufreq_cooling_register(policy);

+#endif

+       }

        pr_debug("initialization complete\n");

--

2.25.1

Quoted 1 line

This email (including its attachments) is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Unauthorized use, dissemination, distribution or

copying of this email or the information herein or taking any action in reliance on the contents of this email or the information herein, by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is strictly prohibited. If you are not the intended recipient, please do not read, copy, use or disclose any part of this e-mail to others. Please notify the sender immediately and permanently delete this e-mail and any attachments if you received it in error. Internet communications cannot be guaranteed to be timely, secure, error-free or virus-free. The sender does not accept liability for any errors or omissions.

This email (including its attachments) is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Unauthorized use, dissemination,
distribution or copying of this email or the information herein or taking any action in reliance on the contents of this email or the information herein, by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is strictly prohibited. If you are not the intended recipient, please do not read, copy, use or disclose any part of this e-mail to others. Please notify the sender immediately and permanently delete this e-mail and any attachments if you received it in error. Internet communications cannot be guaranteed to be timely, secure, error-free or virus-free. The sender does not accept liability for any errors or omissions.