mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "zhenglifeng (A)" <zhenglifeng1@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <viresh.kumar@linaro.org>, <ionela.voinescu@arm.com>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<linuxarm@huawei.com>, <jonathan.cameron@huawei.com>,
	<zhanjie9@hisilicon.com>, <lihuisong@huawei.com>,
	<yubowen8@huawei.com>
Subject: Re: [PATCH 5/7] cpufreq: Move the check of cpufreq_driver->get into cpufreq_verify_current_freq()
Date: Fri, 4 Jul 2025 17:16:13 +0800	[thread overview]
Message-ID: <3c51a0b3-9027-4397-9912-8c7635989dc6@huawei.com> (raw)
In-Reply-To: <CAJZ5v0jz9Bc82AnpcuGLyiu4zC4J6CzHVj7YRmaqhz71S4NEYg@mail.gmail.com>

On 2025/6/23 23:35, Rafael J. Wysocki wrote:

> On Mon, Jun 23, 2025 at 3:34 PM Lifeng Zheng <zhenglifeng1@huawei.com> wrote:
>>
>> Move the check of cpufreq_driver->get into cpufreq_verify_current_freq() in
>> case of calling it without check.
>>
>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
>> ---
>>  drivers/cpufreq/cpufreq.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index c4891bf5dc84..9b2578b905a5 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -1800,6 +1800,9 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b
>>  {
>>         unsigned int new_freq;
>>
>> +       if (!cpufreq_driver->get)
>> +               return 0;
>> +
> 
> This will duplicate the check in cpufreq_policy_refresh(), won't it?

Yes, the check will duplicate but I think it's OK. If remove the check in
cpufreq_policy_refresh(), the logic will be changed.

> 
>>         new_freq = cpufreq_driver->get(policy->cpu);
>>         if (!new_freq)
>>                 return 0;
>> @@ -1922,10 +1925,7 @@ unsigned int cpufreq_get(unsigned int cpu)
>>
>>         guard(cpufreq_policy_read)(policy);
>>
>> -       if (cpufreq_driver->get)
>> -               return __cpufreq_get(policy);
>> -
>> -       return 0;
>> +       return __cpufreq_get(policy);
>>  }
>>  EXPORT_SYMBOL(cpufreq_get);
>>
>> @@ -2479,8 +2479,7 @@ int cpufreq_start_governor(struct cpufreq_policy *policy)
>>
>>         pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
>>
>> -       if (cpufreq_driver->get)
>> -               cpufreq_verify_current_freq(policy, false);
>> +       cpufreq_verify_current_freq(policy, false);
>>
>>         if (policy->governor->start) {
>>                 ret = policy->governor->start(policy);
>> --
>> 2.33.0
>>


  reply	other threads:[~2025-07-04  9:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 13:33 [PATCH 0/7] cpufreq: Some optimizations for cpufreq.c Lifeng Zheng
2025-06-23 13:33 ` [PATCH 1/7] cpufreq: Disable cpufreq-based invariance when fail to register driver Lifeng Zheng
2025-06-23 15:27   ` Rafael J. Wysocki
2025-07-04  9:03     ` zhenglifeng (A)
2025-06-23 13:33 ` [PATCH 2/7] cpufreq: Init policy->rwsem before it may be possibly used Lifeng Zheng
2025-06-23 15:29   ` Rafael J. Wysocki
2025-07-04  9:04     ` zhenglifeng (A)
2025-06-23 13:33 ` [PATCH 3/7] cpufreq: Contain scaling_cur_freq.attr in cpufreq_attrs Lifeng Zheng
2025-06-23 15:30   ` Rafael J. Wysocki
2025-07-03 14:59     ` Rafael J. Wysocki
2025-07-04  9:07       ` zhenglifeng (A)
2025-06-23 13:33 ` [PATCH 4/7] cpufreq: Remove duplicate check in __cpufreq_offline() Lifeng Zheng
2025-06-23 15:31   ` Rafael J. Wysocki
2025-06-23 13:34 ` [PATCH 5/7] cpufreq: Move the check of cpufreq_driver->get into cpufreq_verify_current_freq() Lifeng Zheng
2025-06-23 15:35   ` Rafael J. Wysocki
2025-07-04  9:16     ` zhenglifeng (A) [this message]
2025-06-23 13:34 ` [PATCH 6/7] cpufreq: Refactor code about starting governor in cpufreq_set_policy() Lifeng Zheng
2025-06-23 15:13   ` Rafael J. Wysocki
2025-07-04  9:37     ` zhenglifeng (A)
2025-06-23 13:34 ` [PATCH 7/7] cpufreq: Exit governor when failed to start old governor Lifeng Zheng
2025-06-23 15:12   ` Rafael J. Wysocki
2025-07-04  9:38     ` zhenglifeng (A)
2025-07-04  9:48       ` Rafael J. Wysocki

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=3c51a0b3-9027-4397-9912-8c7635989dc6@huawei.com \
    --to=zhenglifeng1@huawei.com \
    --cc=ionela.voinescu@arm.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=yubowen8@huawei.com \
    --cc=zhanjie9@hisilicon.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®