From: Jie Zhan <zhanjie9@hisilicon.com>
To: "lihuisong (C)" <lihuisong@huawei.com>, <ionela.voinescu@arm.com>,
<beata.michalska@arm.com>, <wangxiongfeng2@huawei.com>,
<viresh.kumar@linaro.org>, <rafael@kernel.org>
Cc: <linux-pm@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <linuxarm@huawei.com>,
<jonathan.cameron@huawei.com>, <wanghuiqiang@huawei.com>,
<zhenglifeng1@huawei.com>, <yangyicong@huawei.com>,
<liaochang1@huawei.com>, <zengheng4@huawei.com>
Subject: Re: [PATCH v3 1/2] cppc_cpufreq: Use desired perf if feedback ctrs are 0 or unchanged
Date: Thu, 26 Sep 2024 16:44:36 +0800 [thread overview]
Message-ID: <08f5f2fa-7bce-2374-f58b-a1df9f481255@hisilicon.com> (raw)
In-Reply-To: <e8fdf684-07ca-fc05-e490-72fca37657e4@huawei.com>
On 26/09/2024 14:07, lihuisong (C) wrote:
>
> 在 2024/9/26 10:57, Jie Zhan 写道:
>>
>> On 25/09/2024 17:28, lihuisong (C) wrote:
>>> Hi Jie,
>>>
>>> LGTM except for some trivial,
>>> Reviewed-by: Huisong Li <lihuisong@huawei.com>
>> Thanks.
>>
>>>
>>> 在 2024/9/19 16:45, Jie Zhan 写道:
>>>> The CPPC performance feedback counters could be 0 or unchanged when the
>>>> target cpu is in a low-power idle state, e.g. power-gated or clock-gated.
>>>>
>>>> When the counters are 0, cppc_cpufreq_get_rate() returns 0 KHz, which makes
>>>> cpufreq_online() get a false error and fail to generate a cpufreq policy.
>>>>
>>>> When the counters are unchanged, the existing cppc_perf_from_fbctrs()
>>>> returns a cached desired perf, but some platforms may update the real
>>>> frequency back to the desired perf reg.
>>>>
>>>> For the above cases in cppc_cpufreq_get_rate(), get the latest desired perf
>>>> to reflect the frequency; if failed, return the cached desired perf.
>>>>
>>>> Fixes: 6a4fec4f6d30 ("cpufreq: cppc: cppc_cpufreq_get_rate() returns zero in all error cases.")
>>>> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
>>>> Reviewed-by: Zeng Heng <zengheng4@huawei.com>
>>>> Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com>
>>>> ---
>>>> drivers/cpufreq/cppc_cpufreq.c | 49 +++++++++++++++++++++++++++-------
>>>> 1 file changed, 39 insertions(+), 10 deletions(-)
>>>>
>>>> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
>>>> index bafa32dd375d..e55192303a9f 100644
>>>> --- a/drivers/cpufreq/cppc_cpufreq.c
>>>> +++ b/drivers/cpufreq/cppc_cpufreq.c
>>>> @@ -118,6 +118,9 @@ static void cppc_scale_freq_workfn(struct kthread_work *work)
>>>> perf = cppc_perf_from_fbctrs(cpu_data, &cppc_fi->prev_perf_fb_ctrs,
>>>> &fb_ctrs);
>>>> + if (!perf)
>>>> + return;
>>>> +
>>>> cppc_fi->prev_perf_fb_ctrs = fb_ctrs;
>>>> perf <<= SCHED_CAPACITY_SHIFT;
>>>> @@ -726,11 +729,26 @@ static int cppc_perf_from_fbctrs(struct cppc_cpudata *cpu_data,
>>>> /* Check to avoid divide-by zero and invalid delivered_perf */
>>> Now this comment can be removed, right?
>> Didn't notice this comment, but, having a check, I think it still fits.
>> '!delta_reference' avoids divide-by zero, and '!delta_delivered' checks
>> invalid delivered_perf.
> The comment "avoid divide-by zero" is just for the below code: "(reference_perf * delta_delivered) / delta_reference".
> So It is also useful, but I think It's obvious and it doesn't make much sense.
>
> The comment "avoid invalid delivered_perf" is for the return value.
> Now this func return zero which can't count as a valid delivered_perf, right?
so, what about this?
/*
* Avoid divide-by zero and unchanged feedback counters.
* Leave it for callers to handle.
*/
>>
>> So I think we just leave it unchanged.
>>
...
next prev parent reply other threads:[~2024-09-26 8:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-19 8:45 [PATCH v3 0/2] cppc_cpufreq: Rework ->get() error handling when cores are idle Jie Zhan
2024-09-19 8:45 ` [PATCH v3 1/2] cppc_cpufreq: Use desired perf if feedback ctrs are 0 or unchanged Jie Zhan
2024-09-25 9:28 ` lihuisong (C)
2024-09-26 2:57 ` Jie Zhan
2024-09-26 6:07 ` lihuisong (C)
2024-09-26 8:44 ` Jie Zhan [this message]
2024-09-26 10:08 ` lihuisong (C)
2024-09-19 8:45 ` [PATCH v3 2/2] cppc_cpufreq: Remove HiSilicon CPPC workaround Jie Zhan
2024-09-25 6:30 ` Xiongfeng Wang
2024-09-26 2:59 ` Jie Zhan
2024-09-25 9:36 ` lihuisong (C)
2024-09-26 2:59 ` Jie Zhan
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=08f5f2fa-7bce-2374-f58b-a1df9f481255@hisilicon.com \
--to=zhanjie9@hisilicon.com \
--cc=beata.michalska@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=liaochang1@huawei.com \
--cc=lihuisong@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=wanghuiqiang@huawei.com \
--cc=wangxiongfeng2@huawei.com \
--cc=yangyicong@huawei.com \
--cc=zengheng4@huawei.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