From: Paul Walmsley <pjw@kernel.org>
To: Anup Patel <apatel@ventanamicro.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Alexandre Ghiti <alex@ghiti.fr>, Len Brown <lenb@kernel.org>,
Atish Patra <atish.patra@linux.dev>,
Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <anup@brainfault.org>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-acpi@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, Atish Patra <atishp@rivosinc.com>,
Nutty Liu <nutty.liu@hotmail.com>
Subject: Re: [PATCH v3 1/1] RISC-V: Add common csr_read_num() and csr_write_num() functions
Date: Wed, 29 Oct 2025 13:04:59 -0600 (MDT) [thread overview]
Message-ID: <012aaa39-a37b-e682-0e34-9b7d7cd87f75@kernel.org> (raw)
In-Reply-To: <20251014132106.181155-2-apatel@ventanamicro.com>
Hi Anup,
On Tue, 14 Oct 2025, Anup Patel wrote:
> In RISC-V, there is no CSR read/write instruction which takes CSR
> number via register so add common csr_read_num() and csr_write_num()
> functions which allow accessing certain CSRs by passing CSR number
> as parameter. These common functions will be first used by the
> ACPI CPPC driver and RISC-V PMU driver.
>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> Reviewed-by: Atish Patra <atishp@rivosinc.com>
> Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
This patch also (silently) removes the CSR number filtering, e.g.
> diff --git a/drivers/acpi/riscv/cppc.c b/drivers/acpi/riscv/cppc.c
> index 42c1a9052470..fe491937ed25 100644
> --- a/drivers/acpi/riscv/cppc.c
> +++ b/drivers/acpi/riscv/cppc.c
> @@ -65,24 +65,19 @@ static void sbi_cppc_write(void *write_data)
> static void cppc_ffh_csr_read(void *read_data)
> {
> struct sbi_cppc_data *data = (struct sbi_cppc_data *)read_data;
> + int err;
>
> - switch (data->reg) {
> - /* Support only TIME CSR for now */
> - case CSR_TIME:
> - data->ret.value = csr_read(CSR_TIME);
> - data->ret.error = 0;
> - break;
> - default:
> - data->ret.error = -EINVAL;
> - break;
> - }
... the above code, and:
> /*
> * Read the CSR of a corresponding counter.
> */
> unsigned long riscv_pmu_ctr_read_csr(unsigned long csr)
> {
> - if (csr < CSR_CYCLE || csr > CSR_HPMCOUNTER31H ||
> - (csr > CSR_HPMCOUNTER31 && csr < CSR_CYCLEH)) {
> - pr_err("Invalid performance counter csr %lx\n", csr);
> - return -EINVAL;
... the above code.
I'm thinking that we probably want to keep the CSR number filtering code
in; at least, I can't think of a good reason to remove it. Care to add it
back in?
- Paul
WARNING: multiple messages have this Message-ID (diff)
From: Paul Walmsley <pjw@kernel.org>
To: Anup Patel <apatel@ventanamicro.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alexandre Ghiti <alex@ghiti.fr>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Anup Patel <anup@brainfault.org>,
Atish Patra <atish.patra@linux.dev>,
Atish Patra <atishp@rivosinc.com>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Nutty Liu <nutty.liu@hotmail.com>,
linux-riscv@lists.infradead.org,
Andrew Jones <ajones@ventanamicro.com>,
Will Deacon <will@kernel.org>, Len Brown <lenb@kernel.org>
Subject: Re: [PATCH v3 1/1] RISC-V: Add common csr_read_num() and csr_write_num() functions
Date: Wed, 29 Oct 2025 13:04:59 -0600 (MDT) [thread overview]
Message-ID: <012aaa39-a37b-e682-0e34-9b7d7cd87f75@kernel.org> (raw)
In-Reply-To: <20251014132106.181155-2-apatel@ventanamicro.com>
Hi Anup,
On Tue, 14 Oct 2025, Anup Patel wrote:
> In RISC-V, there is no CSR read/write instruction which takes CSR
> number via register so add common csr_read_num() and csr_write_num()
> functions which allow accessing certain CSRs by passing CSR number
> as parameter. These common functions will be first used by the
> ACPI CPPC driver and RISC-V PMU driver.
>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> Reviewed-by: Atish Patra <atishp@rivosinc.com>
> Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
This patch also (silently) removes the CSR number filtering, e.g.
> diff --git a/drivers/acpi/riscv/cppc.c b/drivers/acpi/riscv/cppc.c
> index 42c1a9052470..fe491937ed25 100644
> --- a/drivers/acpi/riscv/cppc.c
> +++ b/drivers/acpi/riscv/cppc.c
> @@ -65,24 +65,19 @@ static void sbi_cppc_write(void *write_data)
> static void cppc_ffh_csr_read(void *read_data)
> {
> struct sbi_cppc_data *data = (struct sbi_cppc_data *)read_data;
> + int err;
>
> - switch (data->reg) {
> - /* Support only TIME CSR for now */
> - case CSR_TIME:
> - data->ret.value = csr_read(CSR_TIME);
> - data->ret.error = 0;
> - break;
> - default:
> - data->ret.error = -EINVAL;
> - break;
> - }
... the above code, and:
> /*
> * Read the CSR of a corresponding counter.
> */
> unsigned long riscv_pmu_ctr_read_csr(unsigned long csr)
> {
> - if (csr < CSR_CYCLE || csr > CSR_HPMCOUNTER31H ||
> - (csr > CSR_HPMCOUNTER31 && csr < CSR_CYCLEH)) {
> - pr_err("Invalid performance counter csr %lx\n", csr);
> - return -EINVAL;
... the above code.
I'm thinking that we probably want to keep the CSR number filtering code
in; at least, I can't think of a good reason to remove it. Care to add it
back in?
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-10-29 19:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 13:21 [PATCH v3 0/1] Common csr_read_num() and csr_write_num() for RISC-V Anup Patel
2025-10-14 13:21 ` Anup Patel
2025-10-14 13:21 ` [PATCH v3 1/1] RISC-V: Add common csr_read_num() and csr_write_num() functions Anup Patel
2025-10-14 13:21 ` Anup Patel
2025-10-29 19:04 ` Paul Walmsley [this message]
2025-10-29 19:04 ` Paul Walmsley
2025-10-30 6:07 ` Anup Patel
2025-10-30 6:07 ` Anup Patel
2025-11-22 1:14 ` Paul Walmsley
2025-11-22 1:14 ` Paul Walmsley
2025-11-24 4:49 ` Anup Patel
2025-11-24 4:49 ` Anup Patel
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=012aaa39-a37b-e682-0e34-9b7d7cd87f75@kernel.org \
--to=pjw@kernel.org \
--cc=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=apatel@ventanamicro.com \
--cc=atish.patra@linux.dev \
--cc=atishp@rivosinc.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=nutty.liu@hotmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rafael@kernel.org \
--cc=sunilvl@ventanamicro.com \
--cc=will@kernel.org \
/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.