From: Alexandre Ghiti <alex@ghiti.fr>
To: Atish Patra <atishp@rivosinc.com>,
Anup Patel <anup@brainfault.org>, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Mayuresh Chitale <mchitale@ventanamicro.com>
Cc: linux-riscv@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Palmer Dabbelt <palmer@rivosinc.com>,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Subject: Re: [PATCH 2/8] drivers/perf: riscv: Fix Platform firmware event data
Date: Thu, 28 Nov 2024 14:10:53 +0100 [thread overview]
Message-ID: <77b7b44f-e05a-4845-8d45-0e0d831bb8e7@ghiti.fr> (raw)
In-Reply-To: <20241119-pmu_event_info-v1-2-a4f9691421f8@rivosinc.com>
Hi Atish,
On 19/11/2024 21:29, Atish Patra wrote:
> Platform firmware event data field is allowed to be 62 bits for
> Linux as uppper most two bits are reserved to indicate SBI fw or
> platform specific firmware events.
> However, the event data field is masked as per the hardware raw
> event mask which is not correct.
>
> Fix the platform firmware event data field with proper mask.
>
> Fixes: f0c9363db2dd ("perf/riscv-sbi: Add platform specific firmware event handling")
>
> Signed-off-by: Atish Patra <atishp@rivosinc.com>
> ---
> arch/riscv/include/asm/sbi.h | 1 +
> drivers/perf/riscv_pmu_sbi.c | 12 +++++-------
> 2 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index 98f631b051db..9be38b05f4ad 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -158,6 +158,7 @@ struct riscv_pmu_snapshot_data {
> };
>
> #define RISCV_PMU_RAW_EVENT_MASK GENMASK_ULL(47, 0)
> +#define RISCV_PMU_PLAT_FW_EVENT_MASK GENMASK_ULL(61, 0)
> #define RISCV_PMU_RAW_EVENT_IDX 0x20000
> #define RISCV_PLAT_FW_EVENT 0xFFFF
>
> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
> index cb98efa9b106..50cbdbf66bb7 100644
> --- a/drivers/perf/riscv_pmu_sbi.c
> +++ b/drivers/perf/riscv_pmu_sbi.c
> @@ -508,7 +508,6 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
> {
> u32 type = event->attr.type;
> u64 config = event->attr.config;
> - u64 raw_config_val;
> int ret;
>
> /*
> @@ -529,21 +528,20 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
> case PERF_TYPE_RAW:
> /*
> * As per SBI specification, the upper 16 bits must be unused
> - * for a raw event.
> + * for a hardware raw event.
> * Bits 63:62 are used to distinguish between raw events
> * 00 - Hardware raw event
> * 10 - SBI firmware events
> * 11 - Risc-V platform specific firmware event
> */
> - raw_config_val = config & RISCV_PMU_RAW_EVENT_MASK;
> +
> switch (config >> 62) {
> case 0:
> ret = RISCV_PMU_RAW_EVENT_IDX;
> - *econfig = raw_config_val;
> + *econfig = config & RISCV_PMU_RAW_EVENT_MASK;
> break;
> case 2:
> - ret = (raw_config_val & 0xFFFF) |
> - (SBI_PMU_EVENT_TYPE_FW << 16);
> + ret = (config & 0xFFFF) | (SBI_PMU_EVENT_TYPE_FW << 16);
> break;
> case 3:
> /*
> @@ -552,7 +550,7 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
> * Event data - raw event encoding
> */
> ret = SBI_PMU_EVENT_TYPE_FW << 16 | RISCV_PLAT_FW_EVENT;
> - *econfig = raw_config_val;
> + *econfig = config & RISCV_PMU_PLAT_FW_EVENT_MASK;
> break;
> }
> break;
>
It seems independent from the other patches, so I guess we should take
it for 6.13 rcX.
Let me know if that's not the case.
Thanks,
Alex
next prev parent reply other threads:[~2024-11-28 13:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 20:29 [PATCH 0/8] Add SBI v3.0 PMU enhancements Atish Patra
2024-11-19 20:29 ` [PATCH 1/8] drivers/perf: riscv: Add SBI v3.0 flag Atish Patra
2024-11-19 20:29 ` [PATCH 2/8] drivers/perf: riscv: Fix Platform firmware event data Atish Patra
2024-11-28 13:10 ` Alexandre Ghiti [this message]
2024-12-02 18:26 ` Atish Kumar Patra
2024-11-19 20:29 ` [PATCH 3/8] drivers/perf: riscv: Add raw event v2 support Atish Patra
2024-12-02 22:37 ` Samuel Holland
2024-12-03 0:15 ` Atish Kumar Patra
2024-12-03 2:39 ` Samuel Holland
2024-12-09 18:52 ` Atish Kumar Patra
2024-11-19 20:29 ` [PATCH 4/8] RISC-V: KVM: Add support for Raw event v2 Atish Patra
2024-11-19 20:29 ` [PATCH 5/8] drivers/perf: riscv: Implement PMU event info function Atish Patra
2024-12-02 22:49 ` Samuel Holland
2024-12-10 1:16 ` Atish Kumar Patra
2024-11-19 20:29 ` [PATCH 6/8] drivers/perf: riscv: Export " Atish Patra
2024-11-19 20:29 ` [PATCH 7/8] RISC-V: KVM: Implement get " Atish Patra
2024-12-02 23:02 ` Samuel Holland
2024-12-10 1:16 ` Atish Kumar Patra
2024-11-19 20:29 ` [PATCH 8/8] RISC-V: KVM: Upgrade the supported SBI version to 3.0 Atish Patra
2025-01-09 19:40 ` [PATCH 0/8] Add SBI v3.0 PMU enhancements patchwork-bot+linux-riscv
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=77b7b44f-e05a-4845-8d45-0e0d831bb8e7@ghiti.fr \
--to=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=atishp@rivosinc.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mchitale@ventanamicro.com \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.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 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®