All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] lib: sbi: Allow programmable counters to monitor cycle/instret events for Andes PMU
@ 2025-03-28  8:41 Leo Yu-Chi Liang
  2025-03-31 22:45 ` Atish Patra
  2025-04-14 12:30 ` Anup Patel
  0 siblings, 2 replies; 3+ messages in thread
From: Leo Yu-Chi Liang @ 2025-03-28  8:41 UTC (permalink / raw)
  To: opensbi; +Cc: ycliang

Referencing commit 0c304b661965
("lib: sbi: Allow programmable counters to monitor cycle/instret events")
to support this functionality for Andes PMU.

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
---
Change since v1:
	- Modify the comment
---
 lib/sbi/sbi_pmu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index b9e84543..575799eb 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -719,12 +719,13 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs,
 		return SBI_EINVAL;
 
 	/**
-	 * If Sscof is present try to find the programmable counter for
-	 * cycle/instret as well.
+	 * If Sscofpmf or Andes PMU is present, try to find
+	 * the programmable counter for cycle/instret as well.
 	 */
 	fixed_ctr = pmu_ctr_find_fixed_hw(event_idx);
 	if (fixed_ctr >= 0 &&
-	    !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))
+	    !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF) &&
+	    !sbi_hart_has_extension(scratch, SBI_HART_EXT_XANDESPMU))
 		return pmu_fixed_ctr_update_inhibit_bits(fixed_ctr, flags);
 
 	if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11)
-- 
2.34.1


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

* Re: [PATCH v2 1/1] lib: sbi: Allow programmable counters to monitor cycle/instret events for Andes PMU
  2025-03-28  8:41 [PATCH v2 1/1] lib: sbi: Allow programmable counters to monitor cycle/instret events for Andes PMU Leo Yu-Chi Liang
@ 2025-03-31 22:45 ` Atish Patra
  2025-04-14 12:30 ` Anup Patel
  1 sibling, 0 replies; 3+ messages in thread
From: Atish Patra @ 2025-03-31 22:45 UTC (permalink / raw)
  To: Leo Yu-Chi Liang, opensbi

On 3/28/25 1:41 AM, Leo Yu-Chi Liang wrote:
> Referencing commit 0c304b661965
> ("lib: sbi: Allow programmable counters to monitor cycle/instret events")
> to support this functionality for Andes PMU.
> 
> Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
> ---
> Change since v1:
> 	- Modify the comment
> ---
>   lib/sbi/sbi_pmu.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
> index b9e84543..575799eb 100644
> --- a/lib/sbi/sbi_pmu.c
> +++ b/lib/sbi/sbi_pmu.c
> @@ -719,12 +719,13 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs,
>   		return SBI_EINVAL;
>   
>   	/**
> -	 * If Sscof is present try to find the programmable counter for
> -	 * cycle/instret as well.
> +	 * If Sscofpmf or Andes PMU is present, try to find
> +	 * the programmable counter for cycle/instret as well.
>   	 */
>   	fixed_ctr = pmu_ctr_find_fixed_hw(event_idx);
>   	if (fixed_ctr >= 0 &&
> -	    !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))
> +	    !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF) &&
> +	    !sbi_hart_has_extension(scratch, SBI_HART_EXT_XANDESPMU))
>   		return pmu_fixed_ctr_update_inhibit_bits(fixed_ctr, flags);
>   
>   	if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11)

Reviewed-by: Atish Patra <atishp@rivosinc.com>

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

* Re: [PATCH v2 1/1] lib: sbi: Allow programmable counters to monitor cycle/instret events for Andes PMU
  2025-03-28  8:41 [PATCH v2 1/1] lib: sbi: Allow programmable counters to monitor cycle/instret events for Andes PMU Leo Yu-Chi Liang
  2025-03-31 22:45 ` Atish Patra
@ 2025-04-14 12:30 ` Anup Patel
  1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2025-04-14 12:30 UTC (permalink / raw)
  To: Leo Yu-Chi Liang; +Cc: opensbi

On Fri, Mar 28, 2025 at 2:12 PM Leo Yu-Chi Liang <ycliang@andestech.com> wrote:
>
> Referencing commit 0c304b661965
> ("lib: sbi: Allow programmable counters to monitor cycle/instret events")
> to support this functionality for Andes PMU.
>
> Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
> Change since v1:
>         - Modify the comment
> ---
>  lib/sbi/sbi_pmu.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
> index b9e84543..575799eb 100644
> --- a/lib/sbi/sbi_pmu.c
> +++ b/lib/sbi/sbi_pmu.c
> @@ -719,12 +719,13 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs,
>                 return SBI_EINVAL;
>
>         /**
> -        * If Sscof is present try to find the programmable counter for
> -        * cycle/instret as well.
> +        * If Sscofpmf or Andes PMU is present, try to find
> +        * the programmable counter for cycle/instret as well.
>          */
>         fixed_ctr = pmu_ctr_find_fixed_hw(event_idx);
>         if (fixed_ctr >= 0 &&
> -           !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))
> +           !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF) &&
> +           !sbi_hart_has_extension(scratch, SBI_HART_EXT_XANDESPMU))
>                 return pmu_fixed_ctr_update_inhibit_bits(fixed_ctr, flags);
>
>         if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11)
> --
> 2.34.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

end of thread, other threads:[~2025-04-14 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28  8:41 [PATCH v2 1/1] lib: sbi: Allow programmable counters to monitor cycle/instret events for Andes PMU Leo Yu-Chi Liang
2025-03-31 22:45 ` Atish Patra
2025-04-14 12:30 ` Anup Patel

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.