* [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup
@ 2025-09-18 21:07 Rafael J. Wysocki
2025-09-18 21:09 ` [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start() Rafael J. Wysocki
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-09-18 21:07 UTC (permalink / raw)
To: Linux ACPI
Cc: Huisong Li, LKML, Linux PM, Mario Limonciello,
Shenoy, Gautham Ranjal
Hi All,
One of the recent changes forgot to update a cpuidle driver check in the
ACPI processor driver, so fix this (first patch).
In addition, redefine two functions whose return values are ignored as
void (second patch).
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start()
2025-09-18 21:07 [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Rafael J. Wysocki
@ 2025-09-18 21:09 ` Rafael J. Wysocki
2025-09-19 11:17 ` Rafael J. Wysocki
2025-09-18 21:10 ` [PATCH v1 2/2] ACPI: processor: idle: Redefine two functions as void Rafael J. Wysocki
2025-09-19 18:44 ` [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Mario Limonciello (AMD) (kernel.org)
2 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-09-18 21:09 UTC (permalink / raw)
To: Linux ACPI
Cc: Huisong Li, LKML, Linux PM, Mario Limonciello,
Shenoy, Gautham Ranjal
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Commit 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle
driver registration") moved the ACPI idle driver registration to
acpi_processor_driver_init() and acpi_processor_power_init() does
not register an idle driver any more, so the cpuidle driver check
in __acpi_processor_start() needs to be updated to avoid calling
acpi_processor_power_init() without a cpuidle driver (in which
case the registration of the cpuidle device in that function
would fail anyway).
Fixes: 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle driver registration")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Commit 7a8c994cbb2d is only in linux-next at this point.
---
drivers/acpi/processor_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -166,7 +166,7 @@ static int __acpi_processor_start(struct
if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
dev_dbg(&device->dev, "CPPC data invalid or not present\n");
- if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
+ if (cpuidle_get_driver() == &acpi_idle_driver)
acpi_processor_power_init(pr);
acpi_pss_perf_init(pr);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 2/2] ACPI: processor: idle: Redefine two functions as void
2025-09-18 21:07 [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Rafael J. Wysocki
2025-09-18 21:09 ` [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start() Rafael J. Wysocki
@ 2025-09-18 21:10 ` Rafael J. Wysocki
2025-09-22 1:17 ` lihuisong (C)
2025-09-19 18:44 ` [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Mario Limonciello (AMD) (kernel.org)
2 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-09-18 21:10 UTC (permalink / raw)
To: Linux ACPI
Cc: Huisong Li, LKML, Linux PM, Mario Limonciello,
Shenoy, Gautham Ranjal
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Notice that acpi_processor_power_init() and acpi_processor_power_exit()
don't need to return any values because their callers don't check them
anyway, so redefine those functions as void.
While at it, rearrange the code in acpi_processor_power_init() to
reduce the indentation level, get rid of a redundant local variable
in that function, and rephrase a code comment in it.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/processor_idle.c | 47 +++++++++++++++++++-----------------------
include/acpi/processor.h | 4 +--
2 files changed, 24 insertions(+), 27 deletions(-)
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1137,47 +1137,45 @@ void acpi_processor_unregister_idle_driv
cpuidle_unregister_driver(&acpi_idle_driver);
}
-int acpi_processor_power_init(struct acpi_processor *pr)
+void acpi_processor_power_init(struct acpi_processor *pr)
{
- int retval;
struct cpuidle_device *dev;
if (disabled_by_idle_boot_param())
- return 0;
+ return;
acpi_processor_cstate_first_run_checks();
if (!acpi_processor_get_power_info(pr))
pr->flags.power_setup_done = 1;
- if (pr->flags.power) {
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev)
- return -ENOMEM;
- per_cpu(acpi_cpuidle_device, pr->id) = dev;
-
- acpi_processor_setup_cpuidle_dev(pr, dev);
-
- /* Register per-cpu cpuidle_device. Cpuidle driver
- * must already be registered before registering device
- */
- retval = cpuidle_register_device(dev);
- if (retval) {
-
- per_cpu(acpi_cpuidle_device, pr->id) = NULL;
- kfree(dev);
- return retval;
- }
+ if (!pr->flags.power)
+ return;
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return;
+
+ per_cpu(acpi_cpuidle_device, pr->id) = dev;
+
+ acpi_processor_setup_cpuidle_dev(pr, dev);
+
+ /*
+ * Register a cpuidle device for this CPU. The cpuidle driver using
+ * this device is expected to be registered.
+ */
+ if (cpuidle_register_device(dev)) {
+ per_cpu(acpi_cpuidle_device, pr->id) = NULL;
+ kfree(dev);
}
- return 0;
}
-int acpi_processor_power_exit(struct acpi_processor *pr)
+void acpi_processor_power_exit(struct acpi_processor *pr)
{
struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
if (disabled_by_idle_boot_param())
- return 0;
+ return;
if (pr->flags.power) {
cpuidle_unregister_device(dev);
@@ -1185,7 +1183,6 @@ int acpi_processor_power_exit(struct acp
}
pr->flags.power_setup_done = 0;
- return 0;
}
MODULE_IMPORT_NS("ACPI_PROCESSOR_IDLE");
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -419,8 +419,8 @@ static inline void acpi_processor_thrott
/* in processor_idle.c */
extern struct cpuidle_driver acpi_idle_driver;
#ifdef CONFIG_ACPI_PROCESSOR_IDLE
-int acpi_processor_power_init(struct acpi_processor *pr);
-int acpi_processor_power_exit(struct acpi_processor *pr);
+void acpi_processor_power_init(struct acpi_processor *pr);
+void acpi_processor_power_exit(struct acpi_processor *pr);
int acpi_processor_power_state_has_changed(struct acpi_processor *pr);
int acpi_processor_hotplug(struct acpi_processor *pr);
void acpi_processor_register_idle_driver(void);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start()
2025-09-18 21:09 ` [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start() Rafael J. Wysocki
@ 2025-09-19 11:17 ` Rafael J. Wysocki
2025-09-22 1:16 ` lihuisong (C)
0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-09-19 11:17 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, Huisong Li, LKML, Linux PM, Mario Limonciello,
Shenoy, Gautham Ranjal
On Thu, Sep 18, 2025 at 11:10 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Commit 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle
> driver registration") moved the ACPI idle driver registration to
> acpi_processor_driver_init() and acpi_processor_power_init() does
> not register an idle driver any more, so the cpuidle driver check
> in __acpi_processor_start() needs to be updated to avoid calling
> acpi_processor_power_init() without a cpuidle driver (in which
> case the registration of the cpuidle device in that function
> would fail anyway).
It's worse, it won't just fail, it'll lead to a NULL pointer
dereference in __cpuidle_register_device().
I'll update the changelog while applying the patch.
> Fixes: 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle driver registration")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> Commit 7a8c994cbb2d is only in linux-next at this point.
>
> ---
> drivers/acpi/processor_driver.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/acpi/processor_driver.c
> +++ b/drivers/acpi/processor_driver.c
> @@ -166,7 +166,7 @@ static int __acpi_processor_start(struct
> if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
> dev_dbg(&device->dev, "CPPC data invalid or not present\n");
>
> - if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
> + if (cpuidle_get_driver() == &acpi_idle_driver)
> acpi_processor_power_init(pr);
>
> acpi_pss_perf_init(pr);
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup
2025-09-18 21:07 [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Rafael J. Wysocki
2025-09-18 21:09 ` [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start() Rafael J. Wysocki
2025-09-18 21:10 ` [PATCH v1 2/2] ACPI: processor: idle: Redefine two functions as void Rafael J. Wysocki
@ 2025-09-19 18:44 ` Mario Limonciello (AMD) (kernel.org)
2 siblings, 0 replies; 7+ messages in thread
From: Mario Limonciello (AMD) (kernel.org) @ 2025-09-19 18:44 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux ACPI
Cc: Huisong Li, LKML, Linux PM, Shenoy, Gautham Ranjal
On 9/18/2025 4:07 PM, Rafael J. Wysocki wrote:
> Hi All,
>
> One of the recent changes forgot to update a cpuidle driver check in the
> ACPI processor driver, so fix this (first patch).
>
> In addition, redefine two functions whose return values are ignored as
> void (second patch).
>
> Thanks!
>
>
>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start()
2025-09-19 11:17 ` Rafael J. Wysocki
@ 2025-09-22 1:16 ` lihuisong (C)
0 siblings, 0 replies; 7+ messages in thread
From: lihuisong (C) @ 2025-09-22 1:16 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, LKML, Linux PM, Mario Limonciello,
Shenoy, Gautham Ranjal
在 2025/9/19 19:17, Rafael J. Wysocki 写道:
> On Thu, Sep 18, 2025 at 11:10 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> Commit 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle
>> driver registration") moved the ACPI idle driver registration to
>> acpi_processor_driver_init() and acpi_processor_power_init() does
>> not register an idle driver any more, so the cpuidle driver check
>> in __acpi_processor_start() needs to be updated to avoid calling
>> acpi_processor_power_init() without a cpuidle driver (in which
>> case the registration of the cpuidle device in that function
>> would fail anyway).
> It's worse, it won't just fail, it'll lead to a NULL pointer
> dereference in __cpuidle_register_device().
>
> I'll update the changelog while applying the patch.
Yeah, thanks for fixing it.
Acked-by: lihuisong@huawei.com
>
>> Fixes: 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle driver registration")
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> ---
>>
>> Commit 7a8c994cbb2d is only in linux-next at this point.
>>
>> ---
>> drivers/acpi/processor_driver.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> --- a/drivers/acpi/processor_driver.c
>> +++ b/drivers/acpi/processor_driver.c
>> @@ -166,7 +166,7 @@ static int __acpi_processor_start(struct
>> if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
>> dev_dbg(&device->dev, "CPPC data invalid or not present\n");
>>
>> - if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
>> + if (cpuidle_get_driver() == &acpi_idle_driver)
>> acpi_processor_power_init(pr);
>>
>> acpi_pss_perf_init(pr);
>>
>>
>>
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 2/2] ACPI: processor: idle: Redefine two functions as void
2025-09-18 21:10 ` [PATCH v1 2/2] ACPI: processor: idle: Redefine two functions as void Rafael J. Wysocki
@ 2025-09-22 1:17 ` lihuisong (C)
0 siblings, 0 replies; 7+ messages in thread
From: lihuisong (C) @ 2025-09-22 1:17 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux ACPI
Cc: LKML, Linux PM, Mario Limonciello, Shenoy, Gautham Ranjal
在 2025/9/19 5:10, Rafael J. Wysocki 写道:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Notice that acpi_processor_power_init() and acpi_processor_power_exit()
> don't need to return any values because their callers don't check them
> anyway, so redefine those functions as void.
>
> While at it, rearrange the code in acpi_processor_power_init() to
> reduce the indentation level, get rid of a redundant local variable
> in that function, and rephrase a code comment in it.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
LGTM,
Acked-by: lihuisong@huawei.com
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-09-22 1:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 21:07 [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Rafael J. Wysocki
2025-09-18 21:09 ` [PATCH v1 1/2] ACPI: processor: Update cpuidle driver check in __acpi_processor_start() Rafael J. Wysocki
2025-09-19 11:17 ` Rafael J. Wysocki
2025-09-22 1:16 ` lihuisong (C)
2025-09-18 21:10 ` [PATCH v1 2/2] ACPI: processor: idle: Redefine two functions as void Rafael J. Wysocki
2025-09-22 1:17 ` lihuisong (C)
2025-09-19 18:44 ` [PATCH v1 0/2] ACPI: processor: idle: Fix and cleanup Mario Limonciello (AMD) (kernel.org)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox