arm64/perf: Replace PMU version number '0' with ID_AA64DFR0_EL1_PMUVer_NI

Message ID 20221128025449.39085-1-anshuman.khandual@arm.com
State New
Headers
Series arm64/perf: Replace PMU version number '0' with ID_AA64DFR0_EL1_PMUVer_NI |

Commit Message

Anshuman Khandual Nov. 28, 2022, 2:54 a.m. UTC
  __armv8pmu_probe_pmu() returns if detected PMU is either not implemented or
implementation defined. Extracted ID_AA64DFR0_EL1_PMUVer value, when PMU is
not implemented is '0' which can be replaced with ID_AA64DFR0_EL1_PMUVer_NI
defined as '0b0000'.

Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on v6.1-rc6

 arch/arm64/kernel/perf_event.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Anshuman Khandual Nov. 28, 2022, 3:06 a.m. UTC | #1
On 11/28/22 08:24, Anshuman Khandual wrote:
> __armv8pmu_probe_pmu() returns if detected PMU is either not implemented or
> implementation defined. Extracted ID_AA64DFR0_EL1_PMUVer value, when PMU is
> not implemented is '0' which can be replaced with ID_AA64DFR0_EL1_PMUVer_NI
> defined as '0b0000'.
> 
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> This applies on v6.1-rc6
> 
>  arch/arm64/kernel/perf_event.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> index 85a3aaefc0fb..b638f584b4dd 100644
> --- a/arch/arm64/kernel/perf_event.c
> +++ b/arch/arm64/kernel/perf_event.c
> @@ -1188,7 +1188,8 @@ static void __armv8pmu_probe_pmu(void *info)
>  	dfr0 = read_sysreg(id_aa64dfr0_el1);
>  	pmuver = cpuid_feature_extract_unsigned_field(dfr0,
>  			ID_AA64DFR0_EL1_PMUVer_SHIFT);
> -	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF || pmuver == 0)
> +	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF ||
> +	    pmuver == ID_AA64DFR0_EL1_PMUVer_NI)
>  		return;
>  
>  	cpu_pmu->pmuver = pmuver;
> --

+ Marc Zyngier <maz@kernel.org>

There are some KVM related pmuver not-implemented check as well, should they be
replaced in this patch or rather in a separate patch ?

arch/arm64/kvm/pmu-emul.c:      if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)
arch/arm64/kvm/pmu-emul.c:              if (pmu->pmuver == 0 ||
arch/arm64/kvm/pmu-emul.c:                  pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)

- Anshuman
  
Marc Zyngier Nov. 28, 2022, 8:28 a.m. UTC | #2
On Mon, 28 Nov 2022 03:06:15 +0000,
Anshuman Khandual <anshuman.khandual@arm.com> wrote:
> 
> 
> 
> On 11/28/22 08:24, Anshuman Khandual wrote:
> > __armv8pmu_probe_pmu() returns if detected PMU is either not implemented or
> > implementation defined. Extracted ID_AA64DFR0_EL1_PMUVer value, when PMU is
> > not implemented is '0' which can be replaced with ID_AA64DFR0_EL1_PMUVer_NI
> > defined as '0b0000'.
> > 
> > Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> > Cc: Mark Rutland <mark.rutland@arm.com>
> > Cc: Will Deacon <will@kernel.org>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: linux-perf-users@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-arm-kernel@lists.infradead.org
> > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> > ---
> > This applies on v6.1-rc6
> > 
> >  arch/arm64/kernel/perf_event.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> > index 85a3aaefc0fb..b638f584b4dd 100644
> > --- a/arch/arm64/kernel/perf_event.c
> > +++ b/arch/arm64/kernel/perf_event.c
> > @@ -1188,7 +1188,8 @@ static void __armv8pmu_probe_pmu(void *info)
> >  	dfr0 = read_sysreg(id_aa64dfr0_el1);
> >  	pmuver = cpuid_feature_extract_unsigned_field(dfr0,
> >  			ID_AA64DFR0_EL1_PMUVer_SHIFT);
> > -	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF || pmuver == 0)
> > +	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF ||
> > +	    pmuver == ID_AA64DFR0_EL1_PMUVer_NI)
> >  		return;
> >  
> >  	cpu_pmu->pmuver = pmuver;
> > --
> 
> + Marc Zyngier <maz@kernel.org>
> 
> There are some KVM related pmuver not-implemented check as well, should they be
> replaced in this patch or rather in a separate patch ?
> 
> arch/arm64/kvm/pmu-emul.c:      if (pmu->pmuver == 0 || pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)
> arch/arm64/kvm/pmu-emul.c:              if (pmu->pmuver == 0 ||
> arch/arm64/kvm/pmu-emul.c:                  pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)

Separate patch please, as I have a large KVM PMU rework already
queued.

Thanks,

	M.
  
Mark Rutland Nov. 28, 2022, 12:06 p.m. UTC | #3
On Mon, Nov 28, 2022 at 08:24:49AM +0530, Anshuman Khandual wrote:
> __armv8pmu_probe_pmu() returns if detected PMU is either not implemented or
> implementation defined. Extracted ID_AA64DFR0_EL1_PMUVer value, when PMU is
> not implemented is '0' which can be replaced with ID_AA64DFR0_EL1_PMUVer_NI
> defined as '0b0000'.
> 
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

This looks fine to me, so:

Acked-by: Mark Rutland <mark.rutland@arm.com>

I'll leave it to Will to pick this as his convenience.

Mark.

> ---
> This applies on v6.1-rc6
> 
>  arch/arm64/kernel/perf_event.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> index 85a3aaefc0fb..b638f584b4dd 100644
> --- a/arch/arm64/kernel/perf_event.c
> +++ b/arch/arm64/kernel/perf_event.c
> @@ -1188,7 +1188,8 @@ static void __armv8pmu_probe_pmu(void *info)
>  	dfr0 = read_sysreg(id_aa64dfr0_el1);
>  	pmuver = cpuid_feature_extract_unsigned_field(dfr0,
>  			ID_AA64DFR0_EL1_PMUVer_SHIFT);
> -	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF || pmuver == 0)
> +	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF ||
> +	    pmuver == ID_AA64DFR0_EL1_PMUVer_NI)
>  		return;
>  
>  	cpu_pmu->pmuver = pmuver;
> -- 
> 2.25.1
>
  
Will Deacon Nov. 29, 2022, 7:52 p.m. UTC | #4
On Mon, 28 Nov 2022 08:24:49 +0530, Anshuman Khandual wrote:
> __armv8pmu_probe_pmu() returns if detected PMU is either not implemented or
> implementation defined. Extracted ID_AA64DFR0_EL1_PMUVer value, when PMU is
> not implemented is '0' which can be replaced with ID_AA64DFR0_EL1_PMUVer_NI
> defined as '0b0000'.
> 
> 

Applied to will (for-next/perf), thanks!

[1/1] arm64/perf: Replace PMU version number '0' with ID_AA64DFR0_EL1_PMUVer_NI
      https://git.kernel.org/will/c/cc91b9481605

Cheers,
  

Patch

diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index 85a3aaefc0fb..b638f584b4dd 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -1188,7 +1188,8 @@  static void __armv8pmu_probe_pmu(void *info)
 	dfr0 = read_sysreg(id_aa64dfr0_el1);
 	pmuver = cpuid_feature_extract_unsigned_field(dfr0,
 			ID_AA64DFR0_EL1_PMUVer_SHIFT);
-	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF || pmuver == 0)
+	if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF ||
+	    pmuver == ID_AA64DFR0_EL1_PMUVer_NI)
 		return;
 
 	cpu_pmu->pmuver = pmuver;