[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250922070354.485296-2-lihuisong@huawei.com>
Date: Mon, 22 Sep 2025 15:03:54 +0800
From: Huisong Li <lihuisong@...wei.com>
To: <rafael@...nel.org>, <lenb@...nel.org>
CC: <linux-acpi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linuxarm@...wei.com>, <jonathan.cameron@...wei.com>,
<zhanjie9@...ilicon.com>, <zhenglifeng1@...wei.com>, <yubowen8@...wei.com>,
<lihuisong@...wei.com>
Subject: [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable
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@...wei.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
Powered by blists - more mailing lists