linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: RISC-V: fix failure for custom firmware events
@ 2022-09-19 15:52 Mayuresh Chitale
  2022-09-20  8:30 ` Atish Patra
  0 siblings, 1 reply; 2+ messages in thread
From: Mayuresh Chitale @ 2022-09-19 15:52 UTC (permalink / raw)
  To: Atish Patra, Anup Patel; +Cc: Mayuresh Chitale, linux-riscv, Andrew Jones

We can have SBI implementation specific firmware events in addition
to standard firmware events so we should not check firmware event code
against any limit. This patch removes the check so that programming
of the custom firmware events can be supported by the driver.

Fixes: e9991434596f5 ("RISC-V: Add perf platform driver based on SBI PMU extension")
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
 drivers/perf/riscv_pmu_sbi.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
index 8de4ca2fef21..df044292615c 100644
--- a/drivers/perf/riscv_pmu_sbi.c
+++ b/drivers/perf/riscv_pmu_sbi.c
@@ -381,11 +381,8 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
 		bSoftware = config >> 63;
 		raw_config_val = config & RISCV_PMU_RAW_EVENT_MASK;
 		if (bSoftware) {
-			if (raw_config_val < SBI_PMU_FW_MAX)
-				ret = (raw_config_val & 0xFFFF) |
-				      (SBI_PMU_EVENT_TYPE_FW << 16);
-			else
-				return -EINVAL;
+			ret = (raw_config_val & 0xFFFF) |
+				(SBI_PMU_EVENT_TYPE_FW << 16);
 		} else {
 			ret = RISCV_PMU_RAW_EVENT_IDX;
 			*econfig = raw_config_val;
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf: RISC-V: fix failure for custom firmware events
  2022-09-19 15:52 [PATCH] perf: RISC-V: fix failure for custom firmware events Mayuresh Chitale
@ 2022-09-20  8:30 ` Atish Patra
  0 siblings, 0 replies; 2+ messages in thread
From: Atish Patra @ 2022-09-20  8:30 UTC (permalink / raw)
  To: Mayuresh Chitale; +Cc: Anup Patel, linux-riscv, Andrew Jones

On Mon, Sep 19, 2022 at 8:52 AM Mayuresh Chitale
<mchitale@ventanamicro.com> wrote:
>
> We can have SBI implementation specific firmware events in addition
> to standard firmware events so we should not check firmware event code
> against any limit. This patch removes the check so that programming
> of the custom firmware events can be supported by the driver.
>
> Fixes: e9991434596f5 ("RISC-V: Add perf platform driver based on SBI PMU extension")
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> ---
>  drivers/perf/riscv_pmu_sbi.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
> index 8de4ca2fef21..df044292615c 100644
> --- a/drivers/perf/riscv_pmu_sbi.c
> +++ b/drivers/perf/riscv_pmu_sbi.c
> @@ -381,11 +381,8 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
>                 bSoftware = config >> 63;
>                 raw_config_val = config & RISCV_PMU_RAW_EVENT_MASK;
>                 if (bSoftware) {
> -                       if (raw_config_val < SBI_PMU_FW_MAX)
> -                               ret = (raw_config_val & 0xFFFF) |
> -                                     (SBI_PMU_EVENT_TYPE_FW << 16);
> -                       else
> -                               return -EINVAL;
> +                       ret = (raw_config_val & 0xFFFF) |
> +                               (SBI_PMU_EVENT_TYPE_FW << 16);
>                 } else {
>                         ret = RISCV_PMU_RAW_EVENT_IDX;
>                         *econfig = raw_config_val;
> --
> 2.25.1
>

I don't think this should be tagged as a fix. The SBI spec currently
does not mention anything about custom firmware events.
As it only defined a certain set of firmware events, the check was
added in the driver.

Just to be clear, I am not against this patch. We should allow
firmware to support custom events beyond what standard firmware events
that SBI specification defines.
The SBI spec will be improved to add provisions for custom firmware events.
The patch looks good to me with the fixes tag removed.

-- 
Regards,
Atish

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-20  8:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19 15:52 [PATCH] perf: RISC-V: fix failure for custom firmware events Mayuresh Chitale
2022-09-20  8:30 ` Atish Patra

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).