From: "lihuisong (C)" <lihuisong@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <lenb@kernel.org>, <linux-acpi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
<jonathan.cameron@huawei.com>, <zhanjie9@hisilicon.com>,
<zhenglifeng1@huawei.com>, <yubowen8@huawei.com>
Subject: Re: [PATCH v4 1/1] ACPI: processor: Do not expose the global acpi_idle_driver variable
Date: Tue, 23 Sep 2025 11:03:48 +0800 [thread overview]
Message-ID: <da422ab9-363d-4266-a964-aea2e181691e@huawei.com> (raw)
In-Reply-To: <CAJZ5v0gWSRE1WX0GTVqHhpDZW8ZaWpviuQ+zEyS4E6ne4rutLQ@mail.gmail.com>
在 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
>>
prev parent reply other threads:[~2025-09-23 3:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da422ab9-363d-4266-a964-aea2e181691e@huawei.com \
--to=lihuisong@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=rafael@kernel.org \
--cc=yubowen8@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®