From: Sunil V L <sunilvl@ventanamicro.com>
To: yunhui cui <cuiyunhui@bytedance.com>
Cc: rafael@kernel.org, lenb@kernel.org, paul.walmsley@sifive.com,
palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
linux-acpi@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org,
Anup Patel <apatel@ventanamicro.com>,
Rahul Pathak <rpathak@ventanamicro.com>
Subject: Re: [PATCH] ACPI: RISC-V: CPPC: Add CSR_CYCLE for CPPC FFH
Date: Tue, 12 Aug 2025 18:45:20 +0530 [thread overview]
Message-ID: <aJs-aPH32OxpzR3G@sunil-laptop> (raw)
In-Reply-To: <CAEEQ3w=XqoKmVu1kvc5XUbGbQJsHVkRx=T65tXvYEYo0HCTcnQ@mail.gmail.com>
On Tue, Aug 12, 2025 at 07:25:44PM +0800, yunhui cui wrote:
> Hi Sunil,
>
> On Thu, May 15, 2025 at 5:44 PM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
> >
> > Add the read of CSR_CYCLE to cppc_ffh_csr_read() to fix the
> > warning message: "CPPC Cpufreq: cppc_scale_freq_wokrfn: failed
> > to read perf counters".
> >
> > Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> > ---
> > drivers/acpi/riscv/cppc.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/acpi/riscv/cppc.c b/drivers/acpi/riscv/cppc.c
> > index 4cdff387deff6..c1acaeb18eac3 100644
> > --- a/drivers/acpi/riscv/cppc.c
> > +++ b/drivers/acpi/riscv/cppc.c
> > @@ -69,11 +69,14 @@ static void cppc_ffh_csr_read(void *read_data)
> > struct sbi_cppc_data *data = (struct sbi_cppc_data *)read_data;
> >
> > switch (data->reg) {
> > - /* Support only TIME CSR for now */
> > case CSR_TIME:
> > data->ret.value = csr_read(CSR_TIME);
> > data->ret.error = 0;
> > break;
> > + case CSR_CYCLE:
> > + data->ret.value = csr_read(CSR_CYCLE);
> > + data->ret.error = 0;
> > + break;
> > default:
> > data->ret.error = -EINVAL;
> > break;
> > --
> > 2.39.2
> >
>
> The purpose of cppc_ffh_csr_read() is to calculate the actual
> frequency of the CPU, which is delta_CSR_CYCLE/delta_CSR_XXX.
>
> CSR_XXX should be a reference clock and does not count during WFI
> (Wait For Interrupt).
>
> Similar solutions include: x86's aperf/mperf, and ARM64's AMU with
> registers SYS_AMEVCNTR0_CORE_EL0/SYS_AMEVCNTR0_CONST_EL0.
>
> However, we know that CSR_TIME in the current code does count during
> WFI. So, is this design unreasonable?
>
> Should we consider proposing an extension to support such a dedicated
> counter (a reference clock that does not count during WFI)? This way,
> the value can be obtained directly in S-mode without trapping to
> M-mode, especially since reading this counter is very frequent.
>
Hi Yunhui,
Yes, but we anticipated that vendors might define their own custom CSRs.
So, we introduced FFH encoding to accommodate such cases.
Thanks,
Sunil
next prev parent reply other threads:[~2025-08-12 13:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 9:43 [PATCH] ACPI: RISC-V: CPPC: Add CSR_CYCLE for CPPC FFH Yunhui Cui
2025-08-12 11:25 ` yunhui cui
2025-08-12 13:15 ` Sunil V L [this message]
2025-08-12 13:32 ` [External] " yunhui cui
2025-08-12 14:06 ` Sunil V L
2025-08-13 3:23 ` yunhui cui
2025-08-13 5:27 ` Sunil V L
2025-08-13 6:43 ` yunhui cui
2025-08-13 11:11 ` Anup Patel
2025-08-14 3:37 ` yunhui cui
2025-08-14 5:48 ` Anup Patel
2025-08-14 6:19 ` yunhui cui
2025-08-14 13:37 ` Anup Patel
2025-08-14 16:56 ` [External] " Jessica Clarke
2025-08-15 2:46 ` yunhui cui
2025-08-15 4:07 ` Anup Patel
2025-08-13 7:06 ` [External] " 鞠文龙
2025-08-13 12:09 ` Sunil V L
2025-08-14 6:08 ` 鞠文龙
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=aJs-aPH32OxpzR3G@sunil-laptop \
--to=sunilvl@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=cuiyunhui@bytedance.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rafael@kernel.org \
--cc=rpathak@ventanamicro.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;
as well as URLs for NNTP newsgroup(s).