* [PATCH v4 0/1] ACPI: processor: Fix function declaration of processor_idle.c
@ 2025-09-22 7:03 Huisong Li
2025-09-22 7:03 ` [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable Huisong Li
0 siblings, 1 reply; 4+ messages in thread
From: Huisong Li @ 2025-09-22 7:03 UTC (permalink / raw)
To: rafael, lenb
Cc: linux-acpi, linux-kernel, linuxarm, jonathan.cameron, zhanjie9,
zhenglifeng1, yubowen8, lihuisong
This serises is aimed to fix the function declaration of processor_idle.c.
And the modification idea of this series is from the link[1].
Except for this patch, all other patches in this series have been merged.
[1] https://lore.kernel.org/oe-kbuild-all/202508300519.tZQHY6HA-lkp@intel.com/
---
Changelog
v4:
- remove other patches merged.
- add static for global variable as Rafael suggested.
v3:
- remove the merged patch which fixed the warning in link[1]
- add a separate patch to handle the "extern struct
cpuidle_driver acpi_idle_driver" in processor.h.
https://patchwork.kernel.org/project/linux-acpi/cover/20250728070612.1260859-1-lihuisong@huawei.com/
v2:
- split patch v1
https://patchwork.kernel.org/project/linux-acpi/cover/20250905081900.663869-1-lihuisong@huawei.com/
Huisong Li (1):
ACPI: processor: Do not expose the global acpi_idle_driver variable
drivers/acpi/processor_driver.c | 3 +--
drivers/acpi/processor_idle.c | 12 +++++++++++-
include/acpi/processor.h | 1 -
3 files changed, 12 insertions(+), 4 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable
2025-09-22 7:03 [PATCH v4 0/1] ACPI: processor: Fix function declaration of processor_idle.c Huisong Li
@ 2025-09-22 7:03 ` Huisong Li
2025-09-22 17:38 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Huisong Li @ 2025-09-22 7:03 UTC (permalink / raw)
To: rafael, lenb
Cc: linux-acpi, linux-kernel, linuxarm, jonathan.cameron, zhanjie9,
zhenglifeng1, yubowen8, lihuisong
Currently, processor_driver just use the global acpi_idle_driver variable
to check if the cpuidle driver is acpi_idle_driver. Actually, there is no
need to expose this global variable defined in processor_idle.c to outside.
So move the related check to acpi_processor_power_init() and limit the
global variable to a static one.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/acpi/processor_driver.c | 3 +--
drivers/acpi/processor_idle.c | 12 +++++++++++-
include/acpi/processor.h | 1 -
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index de17c1412678..5d824435b26b 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -166,8 +166,7 @@ static int __acpi_processor_start(struct acpi_device *device)
if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
dev_dbg(&device->dev, "CPPC data invalid or not present\n");
- if (cpuidle_get_driver() == &acpi_idle_driver)
- acpi_processor_power_init(pr);
+ acpi_processor_power_init(pr);
acpi_pss_perf_init(pr);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 698d14c19587..42948495f4f1 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -51,7 +51,7 @@ module_param(latency_factor, uint, 0644);
static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
-struct cpuidle_driver acpi_idle_driver = {
+static struct cpuidle_driver acpi_idle_driver = {
.name = "acpi_idle",
.owner = THIS_MODULE,
};
@@ -1402,8 +1402,18 @@ void acpi_processor_unregister_idle_driver(void)
void acpi_processor_power_init(struct acpi_processor *pr)
{
+ struct cpuidle_driver *drv = cpuidle_get_driver();
struct cpuidle_device *dev;
+ /*
+ * Normally, the ACPI idle driver has already been registered before
+ * CPU online. But the 'drv' may be NULL if register idle driver failed.
+ * So do not anything if the idle driver isn't acpi_idle_driver or the
+ * 'drv' is NULL.
+ */
+ if (drv != &acpi_idle_driver)
+ return;
+
if (disabled_by_idle_boot_param())
return;
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 24fdaa3c2899..7146a8e9e9c2 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -417,7 +417,6 @@ static inline void acpi_processor_throttling_init(void) {}
#endif /* CONFIG_ACPI_CPU_FREQ_PSS */
/* in processor_idle.c */
-extern struct cpuidle_driver acpi_idle_driver;
#ifdef CONFIG_ACPI_PROCESSOR_IDLE
void acpi_processor_power_init(struct acpi_processor *pr);
void acpi_processor_power_exit(struct acpi_processor *pr);
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable
2025-09-22 7:03 ` [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable Huisong Li
@ 2025-09-22 17:38 ` Rafael J. Wysocki
2025-09-23 3:03 ` lihuisong (C)
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2025-09-22 17:38 UTC (permalink / raw)
To: Huisong Li
Cc: rafael, lenb, linux-acpi, linux-kernel, linuxarm,
jonathan.cameron, zhanjie9, zhenglifeng1, yubowen8
On Mon, Sep 22, 2025 at 9:04 AM Huisong Li <lihuisong@huawei.com> wrote:
>
> Currently, processor_driver just use the global acpi_idle_driver variable
> to check if the cpuidle driver is acpi_idle_driver. Actually, there is no
> need to expose this global variable defined in processor_idle.c to outside.
> So move the related check to acpi_processor_power_init() and limit the
> global variable to a static one.
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
> drivers/acpi/processor_driver.c | 3 +--
> drivers/acpi/processor_idle.c | 12 +++++++++++-
> include/acpi/processor.h | 1 -
> 3 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
> index de17c1412678..5d824435b26b 100644
> --- a/drivers/acpi/processor_driver.c
> +++ b/drivers/acpi/processor_driver.c
> @@ -166,8 +166,7 @@ static int __acpi_processor_start(struct acpi_device *device)
> if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
> dev_dbg(&device->dev, "CPPC data invalid or not present\n");
>
> - if (cpuidle_get_driver() == &acpi_idle_driver)
> - acpi_processor_power_init(pr);
> + acpi_processor_power_init(pr);
>
> acpi_pss_perf_init(pr);
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index 698d14c19587..42948495f4f1 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -51,7 +51,7 @@ module_param(latency_factor, uint, 0644);
>
> static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
>
> -struct cpuidle_driver acpi_idle_driver = {
> +static struct cpuidle_driver acpi_idle_driver = {
> .name = "acpi_idle",
> .owner = THIS_MODULE,
> };
> @@ -1402,8 +1402,18 @@ void acpi_processor_unregister_idle_driver(void)
>
> void acpi_processor_power_init(struct acpi_processor *pr)
> {
> + struct cpuidle_driver *drv = cpuidle_get_driver();
This variable is not needed any more.
> struct cpuidle_device *dev;
>
> + /*
> + * Normally, the ACPI idle driver has already been registered before
> + * CPU online. But the 'drv' may be NULL if register idle driver failed.
> + * So do not anything if the idle driver isn't acpi_idle_driver or the
> + * 'drv' is NULL.
And this comment can be much shorter, maybe something like "The code
below only works if acpi_idle_driver is the current cpuidle driver."
> + */
> + if (drv != &acpi_idle_driver)
> + return;
> +
> if (disabled_by_idle_boot_param())
> return;
>
> diff --git a/include/acpi/processor.h b/include/acpi/processor.h
> index 24fdaa3c2899..7146a8e9e9c2 100644
> --- a/include/acpi/processor.h
> +++ b/include/acpi/processor.h
> @@ -417,7 +417,6 @@ static inline void acpi_processor_throttling_init(void) {}
> #endif /* CONFIG_ACPI_CPU_FREQ_PSS */
>
> /* in processor_idle.c */
> -extern struct cpuidle_driver acpi_idle_driver;
> #ifdef CONFIG_ACPI_PROCESSOR_IDLE
> void acpi_processor_power_init(struct acpi_processor *pr);
> void acpi_processor_power_exit(struct acpi_processor *pr);
> --
> 2.33.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable
2025-09-22 17:38 ` Rafael J. Wysocki
@ 2025-09-23 3:03 ` lihuisong (C)
0 siblings, 0 replies; 4+ messages in thread
From: lihuisong (C) @ 2025-09-23 3:03 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: lenb, linux-acpi, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, zhenglifeng1, yubowen8
在 2025/9/23 1:38, Rafael J. Wysocki 写道:
> On Mon, Sep 22, 2025 at 9:04 AM Huisong Li <lihuisong@huawei.com> wrote:
>> Currently, processor_driver just use the global acpi_idle_driver variable
>> to check if the cpuidle driver is acpi_idle_driver. Actually, there is no
>> need to expose this global variable defined in processor_idle.c to outside.
>> So move the related check to acpi_processor_power_init() and limit the
>> global variable to a static one.
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> ---
>> drivers/acpi/processor_driver.c | 3 +--
>> drivers/acpi/processor_idle.c | 12 +++++++++++-
>> include/acpi/processor.h | 1 -
>> 3 files changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
>> index de17c1412678..5d824435b26b 100644
>> --- a/drivers/acpi/processor_driver.c
>> +++ b/drivers/acpi/processor_driver.c
>> @@ -166,8 +166,7 @@ static int __acpi_processor_start(struct acpi_device *device)
>> if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
>> dev_dbg(&device->dev, "CPPC data invalid or not present\n");
>>
>> - if (cpuidle_get_driver() == &acpi_idle_driver)
>> - acpi_processor_power_init(pr);
>> + acpi_processor_power_init(pr);
>>
>> acpi_pss_perf_init(pr);
>>
>> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
>> index 698d14c19587..42948495f4f1 100644
>> --- a/drivers/acpi/processor_idle.c
>> +++ b/drivers/acpi/processor_idle.c
>> @@ -51,7 +51,7 @@ module_param(latency_factor, uint, 0644);
>>
>> static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
>>
>> -struct cpuidle_driver acpi_idle_driver = {
>> +static struct cpuidle_driver acpi_idle_driver = {
>> .name = "acpi_idle",
>> .owner = THIS_MODULE,
>> };
>> @@ -1402,8 +1402,18 @@ void acpi_processor_unregister_idle_driver(void)
>>
>> void acpi_processor_power_init(struct acpi_processor *pr)
>> {
>> + struct cpuidle_driver *drv = cpuidle_get_driver();
> This variable is not needed any more.
Ack
>
>> struct cpuidle_device *dev;
>>
>> + /*
>> + * Normally, the ACPI idle driver has already been registered before
>> + * CPU online. But the 'drv' may be NULL if register idle driver failed.
>> + * So do not anything if the idle driver isn't acpi_idle_driver or the
>> + * 'drv' is NULL.
> And this comment can be much shorter, maybe something like "The code
> below only works if acpi_idle_driver is the current cpuidle driver."
will fix it.
>
>> + */
>> + if (drv != &acpi_idle_driver)
>> + return;
>> +
>> if (disabled_by_idle_boot_param())
>> return;
>>
>> diff --git a/include/acpi/processor.h b/include/acpi/processor.h
>> index 24fdaa3c2899..7146a8e9e9c2 100644
>> --- a/include/acpi/processor.h
>> +++ b/include/acpi/processor.h
>> @@ -417,7 +417,6 @@ static inline void acpi_processor_throttling_init(void) {}
>> #endif /* CONFIG_ACPI_CPU_FREQ_PSS */
>>
>> /* in processor_idle.c */
>> -extern struct cpuidle_driver acpi_idle_driver;
>> #ifdef CONFIG_ACPI_PROCESSOR_IDLE
>> void acpi_processor_power_init(struct acpi_processor *pr);
>> void acpi_processor_power_exit(struct acpi_processor *pr);
>> --
>> 2.33.0
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-23 3:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-22 7:03 [PATCH v4 0/1] ACPI: processor: Fix function declaration of processor_idle.c Huisong Li
2025-09-22 7:03 ` [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable Huisong Li
2025-09-22 17:38 ` Rafael J. Wysocki
2025-09-23 3:03 ` lihuisong (C)
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®