* drivers/acpi/processor_thermal.c: avoid cpufreq_get_policy()
@ 2021-12-22 19:14 Manfred Spraul
2021-12-30 16:23 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2021-12-22 19:14 UTC (permalink / raw)
To: LKML, linux-acpi, Rafael J . Wysocki , Zhang Rui, Len Brown
Cc: 1vier1, Manfred Spraul
cpu_has_cpufreq() stores a 'struct cpufreq_policy' on the stack.
Unfortunately, with debugging options enabled, the structure can be
larger than 1024 bytes, which causes a compiler warning/error.
(actually observed: 1184 bytes).
Therefore: Switch to cpufreq_cpu_get().
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
---
drivers/acpi/processor_thermal.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index a3d34e3f9f94..74210d63f62c 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -53,10 +53,19 @@ static int phys_package_first_cpu(int cpu)
static int cpu_has_cpufreq(unsigned int cpu)
{
- struct cpufreq_policy policy;
- if (!acpi_processor_cpufreq_init || cpufreq_get_policy(&policy, cpu))
+ struct cpufreq_policy *policy;
+ int retval;
+
+ if (!acpi_processor_cpufreq_init)
return 0;
- return 1;
+
+ retval = 0;
+ policy = cpufreq_cpu_get(cpu);
+ if (policy) {
+ cpufreq_cpu_put(policy);
+ retval = 1;
+ }
+ return retval;
}
static int cpufreq_get_max_state(unsigned int cpu)
--
2.33.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: drivers/acpi/processor_thermal.c: avoid cpufreq_get_policy()
2021-12-22 19:14 drivers/acpi/processor_thermal.c: avoid cpufreq_get_policy() Manfred Spraul
@ 2021-12-30 16:23 ` Rafael J. Wysocki
2021-12-30 16:47 ` Manfred Spraul
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-12-30 16:23 UTC (permalink / raw)
To: Manfred Spraul
Cc: LKML, ACPI Devel Maling List, Rafael J . Wysocki, Zhang Rui,
Len Brown, 1vier1
On Wed, Dec 22, 2021 at 8:14 PM Manfred Spraul <manfred@colorfullife.com> wrote:
>
> cpu_has_cpufreq() stores a 'struct cpufreq_policy' on the stack.
> Unfortunately, with debugging options enabled, the structure can be
> larger than 1024 bytes, which causes a compiler warning/error.
>
> (actually observed: 1184 bytes).
>
> Therefore: Switch to cpufreq_cpu_get().
>
> Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
>
> ---
> drivers/acpi/processor_thermal.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
> index a3d34e3f9f94..74210d63f62c 100644
> --- a/drivers/acpi/processor_thermal.c
> +++ b/drivers/acpi/processor_thermal.c
> @@ -53,10 +53,19 @@ static int phys_package_first_cpu(int cpu)
>
> static int cpu_has_cpufreq(unsigned int cpu)
> {
> - struct cpufreq_policy policy;
> - if (!acpi_processor_cpufreq_init || cpufreq_get_policy(&policy, cpu))
> + struct cpufreq_policy *policy;
> + int retval;
Why is this needed?
> +
> + if (!acpi_processor_cpufreq_init)
> return 0;
> - return 1;
> +
> + retval = 0;
> + policy = cpufreq_cpu_get(cpu);
> + if (policy) {
> + cpufreq_cpu_put(policy);
return 1;
> + retval = 1;
> + }
> + return retval;
return 0;
> }
>
> static int cpufreq_get_max_state(unsigned int cpu)
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: drivers/acpi/processor_thermal.c: avoid cpufreq_get_policy()
2021-12-30 16:23 ` Rafael J. Wysocki
@ 2021-12-30 16:47 ` Manfred Spraul
0 siblings, 0 replies; 3+ messages in thread
From: Manfred Spraul @ 2021-12-30 16:47 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: LKML, ACPI Devel Maling List, Zhang Rui, Len Brown, 1vier1
[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]
Hi Rafael,
On 12/30/21 17:23, Rafael J. Wysocki wrote:
> On Wed, Dec 22, 2021 at 8:14 PM Manfred Spraul <manfred@colorfullife.com> wrote:
>> cpu_has_cpufreq() stores a 'struct cpufreq_policy' on the stack.
>> Unfortunately, with debugging options enabled, the structure can be
>> larger than 1024 bytes, which causes a compiler warning/error.
>>
>> (actually observed: 1184 bytes).
>>
>> Therefore: Switch to cpufreq_cpu_get().
>>
>> Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
>>
>> ---
>> drivers/acpi/processor_thermal.c | 15 ++++++++++++---
>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
>> index a3d34e3f9f94..74210d63f62c 100644
>> --- a/drivers/acpi/processor_thermal.c
>> +++ b/drivers/acpi/processor_thermal.c
>> @@ -53,10 +53,19 @@ static int phys_package_first_cpu(int cpu)
>>
>> static int cpu_has_cpufreq(unsigned int cpu)
>> {
>> - struct cpufreq_policy policy;
>> - if (!acpi_processor_cpufreq_init || cpufreq_get_policy(&policy, cpu))
>> + struct cpufreq_policy *policy;
>> + int retval;
> Why is this needed?
You are right, this can be simplified. Updated patch is attached.
>> +
>> + if (!acpi_processor_cpufreq_init)
>> return 0;
>> - return 1;
>> +
>> + retval = 0;
>> + policy = cpufreq_cpu_get(cpu);
>> + if (policy) {
>> + cpufreq_cpu_put(policy);
> return 1;
>
>> + retval = 1;
>> + }
>> + return retval;
> return 0;
>
>> }
>>
>> static int cpufreq_get_max_state(unsigned int cpu)
>> --
>> 2.33.1
>>
[-- Attachment #2: 0001-drivers-acpi-processor_thermal.c-avoid-cpufreq_get_p.patch --]
[-- Type: text/x-patch, Size: 1363 bytes --]
From b6a988751d93692026b62531f0b55a7fe69b1092 Mon Sep 17 00:00:00 2001
From: Manfred Spraul <manfred@colorfullife.com>
Date: Wed, 22 Dec 2021 15:09:31 +0100
Subject: [PATCH] drivers/acpi/processor_thermal.c: avoid cpufreq_get_policy()
cpu_has_cpufreq() stores a 'struct cpufreq_policy' on the stack.
Unfortunately, with debugging options enabled, the structure can be
larger than 1024 bytes, which causes a compiler warning/error.
(actually observed: 1184 bytes).
Therefore: Switch to cpufreq_cpu_get().
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
---
drivers/acpi/processor_thermal.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index a3d34e3f9f94..d8b2dfcd59b5 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -53,10 +53,17 @@ static int phys_package_first_cpu(int cpu)
static int cpu_has_cpufreq(unsigned int cpu)
{
- struct cpufreq_policy policy;
- if (!acpi_processor_cpufreq_init || cpufreq_get_policy(&policy, cpu))
+ struct cpufreq_policy *policy;
+
+ if (!acpi_processor_cpufreq_init)
return 0;
- return 1;
+
+ policy = cpufreq_cpu_get(cpu);
+ if (policy) {
+ cpufreq_cpu_put(policy);
+ return 1;
+ }
+ return 0;
}
static int cpufreq_get_max_state(unsigned int cpu)
--
2.33.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-30 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 19:14 drivers/acpi/processor_thermal.c: avoid cpufreq_get_policy() Manfred Spraul
2021-12-30 16:23 ` Rafael J. Wysocki
2021-12-30 16:47 ` Manfred Spraul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).