From: Beata Michalska <beata.michalska@arm.com>
To: Jie Zhan <zhanjie9@hisilicon.com>
Cc: viresh.kumar@linaro.org, rafael@kernel.org,
ionela.voinescu@arm.com, pierre.gondois@arm.com,
zhenglifeng1@huawei.com, linux-pm@vger.kernel.org,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linuxarm@huawei.com, jonathan.cameron@huawei.com,
prime.zeng@hisilicon.com, yubowen8@huawei.com,
lihuisong@huawei.com, zhangpengjie2@huawei.com,
wangzhi12@huawei.com
Subject: Re: [PATCH v4 1/3] ACPI: CPPC: Factor out and export per-cpu cppc_perf_ctrs_in_pcc_cpu()
Date: Mon, 8 Dec 2025 17:17:30 +0100 [thread overview]
Message-ID: <aTb6Gvzvc9C7vnVP@arm.com> (raw)
In-Reply-To: <20251203032422.3232957-2-zhanjie9@hisilicon.com>
On Wed, Dec 03, 2025 at 11:24:20AM +0800, Jie Zhan wrote:
> Factor out cppc_perf_ctrs_in_pcc_cpu() for checking whether per-cpu CPC
> regs are defined in PCC channels, and export it out for further use.
>
> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
> ---
> drivers/acpi/cppc_acpi.c | 45 +++++++++++++++++++++-------------------
> include/acpi/cppc_acpi.h | 5 +++++
> 2 files changed, 29 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 3bdeeee3414e..aa80dbcf42c0 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1422,6 +1422,29 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
> }
> EXPORT_SYMBOL_GPL(cppc_get_perf_caps);
>
> +bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu)
> +{
> + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
> + struct cpc_register_resource *ref_perf_reg;
> +
> + /*
> + * If reference perf register is not supported then we should use the
> + * nominal perf value
> + */
> + ref_perf_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
> + if (!CPC_SUPPORTED(ref_perf_reg))
> + ref_perf_reg = &cpc_desc->cpc_regs[NOMINAL_PERF];
> +
> + if (CPC_IN_PCC(&cpc_desc->cpc_regs[DELIVERED_CTR]) ||
> + CPC_IN_PCC(&cpc_desc->cpc_regs[REFERENCE_CTR]) ||
> + CPC_IN_PCC(&cpc_desc->cpc_regs[CTR_WRAP_TIME]) ||
> + CPC_IN_PCC(ref_perf_reg))
> + return true;
> +
> + return false;
> +}
> +EXPORT_SYMBOL_GPL(cppc_perf_ctrs_in_pcc_cpu);
It is minor, but I would prefer the earlier version when we grab the reference
performance reg only when none of the other regs is in the PCC.
---
BR
Beata
> +
> /**
> * cppc_perf_ctrs_in_pcc - Check if any perf counters are in a PCC region.
> *
> @@ -1436,27 +1459,7 @@ bool cppc_perf_ctrs_in_pcc(void)
> int cpu;
>
> for_each_online_cpu(cpu) {
> - struct cpc_register_resource *ref_perf_reg;
> - struct cpc_desc *cpc_desc;
> -
> - cpc_desc = per_cpu(cpc_desc_ptr, cpu);
> -
> - if (CPC_IN_PCC(&cpc_desc->cpc_regs[DELIVERED_CTR]) ||
> - CPC_IN_PCC(&cpc_desc->cpc_regs[REFERENCE_CTR]) ||
> - CPC_IN_PCC(&cpc_desc->cpc_regs[CTR_WRAP_TIME]))
> - return true;
> -
> -
> - ref_perf_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
> -
> - /*
> - * If reference perf register is not supported then we should
> - * use the nominal perf value
> - */
> - if (!CPC_SUPPORTED(ref_perf_reg))
> - ref_perf_reg = &cpc_desc->cpc_regs[NOMINAL_PERF];
> -
> - if (CPC_IN_PCC(ref_perf_reg))
> + if (cppc_perf_ctrs_in_pcc_cpu(cpu))
> return true;
> }
>
> diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
> index 13fa81504844..4bcdcaf8bf2c 100644
> --- a/include/acpi/cppc_acpi.h
> +++ b/include/acpi/cppc_acpi.h
> @@ -154,6 +154,7 @@ extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
> extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
> extern int cppc_set_enable(int cpu, bool enable);
> extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
> +extern bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu);
> extern bool cppc_perf_ctrs_in_pcc(void);
> extern unsigned int cppc_perf_to_khz(struct cppc_perf_caps *caps, unsigned int perf);
> extern unsigned int cppc_khz_to_perf(struct cppc_perf_caps *caps, unsigned int freq);
> @@ -204,6 +205,10 @@ static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps)
> {
> return -EOPNOTSUPP;
> }
> +static inline bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu)
> +{
> + return false;
> +}
> static inline bool cppc_perf_ctrs_in_pcc(void)
> {
> return false;
> --
> 2.33.0
>
next prev parent reply other threads:[~2025-12-08 16:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 3:24 [PATCH v4 0/3] cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs Jie Zhan
2025-12-03 3:24 ` [PATCH v4 1/3] ACPI: CPPC: Factor out and export per-cpu cppc_perf_ctrs_in_pcc_cpu() Jie Zhan
2025-12-05 15:13 ` Rafael J. Wysocki
2025-12-08 4:02 ` Jie Zhan
2025-12-08 16:17 ` Beata Michalska [this message]
2025-12-09 13:37 ` Jie Zhan
2025-12-03 3:24 ` [PATCH v4 2/3] cpufreq: CPPC: Factor out cppc_fie_kworker_init() Jie Zhan
2025-12-03 3:24 ` [PATCH v4 3/3] cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs Jie Zhan
2025-12-08 10:08 ` Pierre Gondois
2025-12-09 13:23 ` Jie Zhan
2025-12-03 7:55 ` [PATCH v4 0/3] " zhenglifeng (A)
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=aTb6Gvzvc9C7vnVP@arm.com \
--to=beata.michalska@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=jonathan.cameron@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=pierre.gondois@arm.com \
--cc=prime.zeng@hisilicon.com \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=wangzhi12@huawei.com \
--cc=yubowen8@huawei.com \
--cc=zhangpengjie2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.