2014-10-22 08:26:42

by Chai Wen

[permalink] [raw]
Subject: [PATCH 1/2] ARM: perf: armv7 remove useless return and check of idx in counter handling

Idx sanity check was once implemented separately in these counter handling
functions and then return value was treated as a judgement.
armv7_pmnc_select_counter()
armv7_pmnc_enable_counter()
armv7_pmnc_disable_counter()
armv7_pmnc_enable_intens()
armv7_pmnc_disable_intens()
But we do not need to do this now, and the return of idx is useless.

Signed-off-by: chai wen <[email protected]>
---
arch/arm/kernel/perf_event_v7.c | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
index 116758b..f66a9b8 100644
--- a/arch/arm/kernel/perf_event_v7.c
+++ b/arch/arm/kernel/perf_event_v7.c
@@ -564,13 +564,11 @@ static inline int armv7_pmnc_counter_has_overflowed(u32 pmnc, int idx)
return pmnc & BIT(ARMV7_IDX_TO_COUNTER(idx));
}

-static inline int armv7_pmnc_select_counter(int idx)
+static inline void armv7_pmnc_select_counter(int idx)
{
u32 counter = ARMV7_IDX_TO_COUNTER(idx);
asm volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (counter));
isb();
-
- return idx;
}

static inline u32 armv7pmu_read_counter(struct perf_event *event)
@@ -585,8 +583,10 @@ static inline u32 armv7pmu_read_counter(struct perf_event *event)
smp_processor_id(), idx);
else if (idx == ARMV7_IDX_CYCLE_COUNTER)
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value));
- else if (armv7_pmnc_select_counter(idx) == idx)
+ else {
+ armv7_pmnc_select_counter(idx);
asm volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (value));
+ }

return value;
}
@@ -602,40 +602,38 @@ static inline void armv7pmu_write_counter(struct perf_event *event, u32 value)
smp_processor_id(), idx);
else if (idx == ARMV7_IDX_CYCLE_COUNTER)
asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (value));
- else if (armv7_pmnc_select_counter(idx) == idx)
+ else {
+ armv7_pmnc_select_counter(idx);
asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (value));
+ }
}

static inline void armv7_pmnc_write_evtsel(int idx, u32 val)
{
- if (armv7_pmnc_select_counter(idx) == idx) {
- val &= ARMV7_EVTYPE_MASK;
- asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
- }
+ armv7_pmnc_select_counter(idx);
+ val &= ARMV7_EVTYPE_MASK;
+ asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
}

-static inline int armv7_pmnc_enable_counter(int idx)
+static inline void armv7_pmnc_enable_counter(int idx)
{
u32 counter = ARMV7_IDX_TO_COUNTER(idx);
asm volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (BIT(counter)));
- return idx;
}

-static inline int armv7_pmnc_disable_counter(int idx)
+static inline void armv7_pmnc_disable_counter(int idx)
{
u32 counter = ARMV7_IDX_TO_COUNTER(idx);
asm volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (BIT(counter)));
- return idx;
}

-static inline int armv7_pmnc_enable_intens(int idx)
+static inline void armv7_pmnc_enable_intens(int idx)
{
u32 counter = ARMV7_IDX_TO_COUNTER(idx);
asm volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (BIT(counter)));
- return idx;
}

-static inline int armv7_pmnc_disable_intens(int idx)
+static inline void armv7_pmnc_disable_intens(int idx)
{
u32 counter = ARMV7_IDX_TO_COUNTER(idx);
asm volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (BIT(counter)));
@@ -643,8 +641,6 @@ static inline int armv7_pmnc_disable_intens(int idx)
/* Clear the overflow flag in case an interrupt is pending. */
asm volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (BIT(counter)));
isb();
-
- return idx;
}

static inline u32 armv7_pmnc_getreset_flags(void)
--
1.7.1


2014-10-22 08:27:05

by Chai Wen

[permalink] [raw]
Subject: [PATCH 2/2] ARM: perf: armv7: wrap unsupported arch init functions via micro

Signed-off-by: chai wen <[email protected]>
---
arch/arm/kernel/perf_event_v7.c | 52 +++++++++-----------------------------
1 files changed, 13 insertions(+), 39 deletions(-)

diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
index f66a9b8..6c088e8 100644
--- a/arch/arm/kernel/perf_event_v7.c
+++ b/arch/arm/kernel/perf_event_v7.c
@@ -1459,43 +1459,17 @@ static int krait_pmu_init(struct arm_pmu *cpu_pmu)
return 0;
}
#else
-static inline int armv7_a8_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int armv7_a9_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int armv7_a5_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int armv7_a15_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int armv7_a7_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int armv7_a12_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int armv7_a17_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
-
-static inline int krait_pmu_init(struct arm_pmu *cpu_pmu)
-{
- return -ENODEV;
-}
+#define WRAP_UNSUPPORTED_INIT(__FUNC) \
+static inline int __FUNC(struct arm_pmu *cpu_pmu) \
+{ \
+ return -ENODEV; \
+}
+WRAP_UNSUPPORTED_INIT(armv7_a8_pmu_init);
+WRAP_UNSUPPORTED_INIT(armv7_a9_pmu_init);
+WRAP_UNSUPPORTED_INIT(armv7_a5_pmu_init);
+WRAP_UNSUPPORTED_INIT(armv7_a15_pmu_init);
+WRAP_UNSUPPORTED_INIT(armv7_a7_pmu_init);
+WRAP_UNSUPPORTED_INIT(armv7_a12_pmu_init);
+WRAP_UNSUPPORTED_INIT(armv7_a17_pmu_init);
+WRAP_UNSUPPORTED_INIT(krait_pmu_init);
#endif /* CONFIG_CPU_V7 */
--
1.7.1

2014-10-22 10:48:49

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: perf: armv7 remove useless return and check of idx in counter handling

Hi,

On Wed, Oct 22, 2014 at 09:21:46AM +0100, chai wen wrote:
> Idx sanity check was once implemented separately in these counter handling
> functions and then return value was treated as a judgement.
> armv7_pmnc_select_counter()
> armv7_pmnc_enable_counter()
> armv7_pmnc_disable_counter()
> armv7_pmnc_enable_intens()
> armv7_pmnc_disable_intens()
> But we do not need to do this now, and the return of idx is useless.
>
> Signed-off-by: chai wen <[email protected]>

It looks like the validation was moved out of all of these functions in
7279adbd9bb8ef8f (ARM: perf: check ARMv7 counter validity on a per-pmu
basis), and we just missed the opportunity to simplify callers at the
time.

It would be nice if we mentioned that in the commit message -- it takes
a while to figure out and it's handy for reference.

> ---
> arch/arm/kernel/perf_event_v7.c | 32 ++++++++++++++------------------
> 1 files changed, 14 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
> index 116758b..f66a9b8 100644
> --- a/arch/arm/kernel/perf_event_v7.c
> +++ b/arch/arm/kernel/perf_event_v7.c
> @@ -564,13 +564,11 @@ static inline int armv7_pmnc_counter_has_overflowed(u32 pmnc, int idx)
> return pmnc & BIT(ARMV7_IDX_TO_COUNTER(idx));
> }
>
> -static inline int armv7_pmnc_select_counter(int idx)
> +static inline void armv7_pmnc_select_counter(int idx)
> {
> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
> asm volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (counter));
> isb();
> -
> - return idx;
> }
>
> static inline u32 armv7pmu_read_counter(struct perf_event *event)
> @@ -585,8 +583,10 @@ static inline u32 armv7pmu_read_counter(struct perf_event *event)
> smp_processor_id(), idx);
> else if (idx == ARMV7_IDX_CYCLE_COUNTER)
> asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value));
> - else if (armv7_pmnc_select_counter(idx) == idx)
> + else {
> + armv7_pmnc_select_counter(idx);
> asm volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (value));
> + }

Please make the braces consistent -- if one branch in an if .. else
chain needs them, they all do (see Documentation/CodingStyle).

>
> return value;
> }
> @@ -602,40 +602,38 @@ static inline void armv7pmu_write_counter(struct perf_event *event, u32 value)
> smp_processor_id(), idx);
> else if (idx == ARMV7_IDX_CYCLE_COUNTER)
> asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (value));
> - else if (armv7_pmnc_select_counter(idx) == idx)
> + else {
> + armv7_pmnc_select_counter(idx);
> asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (value));
> + }

Likewise here.

Otherwise this looks like a nice cleanup to me, so with those changes:

Acked-by: Mark Rutland <[email protected]>

Thanks,
Mark.

> }
>
> static inline void armv7_pmnc_write_evtsel(int idx, u32 val)
> {
> - if (armv7_pmnc_select_counter(idx) == idx) {
> - val &= ARMV7_EVTYPE_MASK;
> - asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
> - }
> + armv7_pmnc_select_counter(idx);
> + val &= ARMV7_EVTYPE_MASK;
> + asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
> }
>
> -static inline int armv7_pmnc_enable_counter(int idx)
> +static inline void armv7_pmnc_enable_counter(int idx)
> {
> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
> asm volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (BIT(counter)));
> - return idx;
> }
>
> -static inline int armv7_pmnc_disable_counter(int idx)
> +static inline void armv7_pmnc_disable_counter(int idx)
> {
> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
> asm volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (BIT(counter)));
> - return idx;
> }
>
> -static inline int armv7_pmnc_enable_intens(int idx)
> +static inline void armv7_pmnc_enable_intens(int idx)
> {
> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
> asm volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (BIT(counter)));
> - return idx;
> }
>
> -static inline int armv7_pmnc_disable_intens(int idx)
> +static inline void armv7_pmnc_disable_intens(int idx)
> {
> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
> asm volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (BIT(counter)));
> @@ -643,8 +641,6 @@ static inline int armv7_pmnc_disable_intens(int idx)
> /* Clear the overflow flag in case an interrupt is pending. */
> asm volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (BIT(counter)));
> isb();
> -
> - return idx;
> }
>
> static inline u32 armv7_pmnc_getreset_flags(void)
> --
> 1.7.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

2014-10-22 11:02:14

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCH 2/2] ARM: perf: armv7: wrap unsupported arch init functions via micro

Hi,

On Wed, Oct 22, 2014 at 09:21:47AM +0100, chai wen wrote:
> Signed-off-by: chai wen <[email protected]>
> ---
> arch/arm/kernel/perf_event_v7.c | 52 +++++++++-----------------------------
> 1 files changed, 13 insertions(+), 39 deletions(-)

I'm currently in the process of decoupling perf_event_{xscale,v6,v7}.c,
which will result in the removal of these stubs and for the ARMv7,
ARMv6, and XScale perf backends.

I haven't yet posted all the patches, but the basic idea is to make the
arm_pmu code stateless and turn it into a library used by each of the
three backends mentioned above. Each would have their own pmu_probe_info
table (introduced in [1]), and would support the platform device IDs
introduced in commit 253d8c3d2518ca6f (arm: perf: add more specific
platform device IDs). The stubs would no longer be necessary.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/295822.html

Thanks,
Mark.

>
> diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
> index f66a9b8..6c088e8 100644
> --- a/arch/arm/kernel/perf_event_v7.c
> +++ b/arch/arm/kernel/perf_event_v7.c
> @@ -1459,43 +1459,17 @@ static int krait_pmu_init(struct arm_pmu *cpu_pmu)
> return 0;
> }
> #else
> -static inline int armv7_a8_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int armv7_a9_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int armv7_a5_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int armv7_a15_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int armv7_a7_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int armv7_a12_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int armv7_a17_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> -
> -static inline int krait_pmu_init(struct arm_pmu *cpu_pmu)
> -{
> - return -ENODEV;
> -}
> +#define WRAP_UNSUPPORTED_INIT(__FUNC) \
> +static inline int __FUNC(struct arm_pmu *cpu_pmu) \
> +{ \
> + return -ENODEV; \
> +}
> +WRAP_UNSUPPORTED_INIT(armv7_a8_pmu_init);
> +WRAP_UNSUPPORTED_INIT(armv7_a9_pmu_init);
> +WRAP_UNSUPPORTED_INIT(armv7_a5_pmu_init);
> +WRAP_UNSUPPORTED_INIT(armv7_a15_pmu_init);
> +WRAP_UNSUPPORTED_INIT(armv7_a7_pmu_init);
> +WRAP_UNSUPPORTED_INIT(armv7_a12_pmu_init);
> +WRAP_UNSUPPORTED_INIT(armv7_a17_pmu_init);
> +WRAP_UNSUPPORTED_INIT(krait_pmu_init);
> #endif /* CONFIG_CPU_V7 */
> --
> 1.7.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

2014-10-22 11:27:22

by Chai Wen

[permalink] [raw]
Subject: Re: [PATCH 2/2] ARM: perf: armv7: wrap unsupported arch init functions via micro

On 10/22/2014 07:01 PM, Mark Rutland wrote:

> Hi,
>
> On Wed, Oct 22, 2014 at 09:21:47AM +0100, chai wen wrote:
>> Signed-off-by: chai wen <[email protected]>
>> ---
>> arch/arm/kernel/perf_event_v7.c | 52 +++++++++-----------------------------
>> 1 files changed, 13 insertions(+), 39 deletions(-)
>
> I'm currently in the process of decoupling perf_event_{xscale,v6,v7}.c,
> which will result in the removal of these stubs and for the ARMv7,
> ARMv6, and XScale perf backends.
>
> I haven't yet posted all the patches, but the basic idea is to make the
> arm_pmu code stateless and turn it into a library used by each of the
> three backends mentioned above. Each would have their own pmu_probe_info
> table (introduced in [1]), and would support the platform device IDs
> introduced in commit 253d8c3d2518ca6f (arm: perf: add more specific
> platform device IDs). The stubs would no longer be necessary.
>
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-October/295822.html


Hi Mark

Got it.

Thanks for your information.
Your patches looks reasonable, I am OK with it.

thanks
chai wen

>
> Thanks,
> Mark.
>
>>
>> diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
>> index f66a9b8..6c088e8 100644
>> --- a/arch/arm/kernel/perf_event_v7.c
>> +++ b/arch/arm/kernel/perf_event_v7.c
>> @@ -1459,43 +1459,17 @@ static int krait_pmu_init(struct arm_pmu *cpu_pmu)
>> return 0;
>> }
>> #else
>> -static inline int armv7_a8_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int armv7_a9_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int armv7_a5_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int armv7_a15_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int armv7_a7_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int armv7_a12_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int armv7_a17_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> -
>> -static inline int krait_pmu_init(struct arm_pmu *cpu_pmu)
>> -{
>> - return -ENODEV;
>> -}
>> +#define WRAP_UNSUPPORTED_INIT(__FUNC) \
>> +static inline int __FUNC(struct arm_pmu *cpu_pmu) \
>> +{ \
>> + return -ENODEV; \
>> +}
>> +WRAP_UNSUPPORTED_INIT(armv7_a8_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(armv7_a9_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(armv7_a5_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(armv7_a15_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(armv7_a7_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(armv7_a12_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(armv7_a17_pmu_init);
>> +WRAP_UNSUPPORTED_INIT(krait_pmu_init);
>> #endif /* CONFIG_CPU_V7 */
>> --
>> 1.7.1
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> [email protected]
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
> .
>



--
Regards

Chai Wen

2014-10-22 11:31:12

by Chai Wen

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: perf: armv7 remove useless return and check of idx in counter handling

On 10/22/2014 06:47 PM, Mark Rutland wrote:

> Hi,
>
> On Wed, Oct 22, 2014 at 09:21:46AM +0100, chai wen wrote:
>> Idx sanity check was once implemented separately in these counter handling
>> functions and then return value was treated as a judgement.
>> armv7_pmnc_select_counter()
>> armv7_pmnc_enable_counter()
>> armv7_pmnc_disable_counter()
>> armv7_pmnc_enable_intens()
>> armv7_pmnc_disable_intens()
>> But we do not need to do this now, and the return of idx is useless.
>>
>> Signed-off-by: chai wen <[email protected]>
>
> It looks like the validation was moved out of all of these functions in
> 7279adbd9bb8ef8f (ARM: perf: check ARMv7 counter validity on a per-pmu
> basis), and we just missed the opportunity to simplify callers at the
> time.
>
> It would be nice if we mentioned that in the commit message -- it takes
> a while to figure out and it's handy for reference.
>


Yeah, sorry for forgetting to point out that.

>> ---
>> arch/arm/kernel/perf_event_v7.c | 32 ++++++++++++++------------------
>> 1 files changed, 14 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
>> index 116758b..f66a9b8 100644
>> --- a/arch/arm/kernel/perf_event_v7.c
>> +++ b/arch/arm/kernel/perf_event_v7.c
>> @@ -564,13 +564,11 @@ static inline int armv7_pmnc_counter_has_overflowed(u32 pmnc, int idx)
>> return pmnc & BIT(ARMV7_IDX_TO_COUNTER(idx));
>> }
>>
>> -static inline int armv7_pmnc_select_counter(int idx)
>> +static inline void armv7_pmnc_select_counter(int idx)
>> {
>> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
>> asm volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (counter));
>> isb();
>> -
>> - return idx;
>> }
>>
>> static inline u32 armv7pmu_read_counter(struct perf_event *event)
>> @@ -585,8 +583,10 @@ static inline u32 armv7pmu_read_counter(struct perf_event *event)
>> smp_processor_id(), idx);
>> else if (idx == ARMV7_IDX_CYCLE_COUNTER)
>> asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value));
>> - else if (armv7_pmnc_select_counter(idx) == idx)
>> + else {
>> + armv7_pmnc_select_counter(idx);
>> asm volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (value));
>> + }
>
> Please make the braces consistent -- if one branch in an if .. else
> chain needs them, they all do (see Documentation/CodingStyle).
>
>>
>> return value;
>> }
>> @@ -602,40 +602,38 @@ static inline void armv7pmu_write_counter(struct perf_event *event, u32 value)
>> smp_processor_id(), idx);
>> else if (idx == ARMV7_IDX_CYCLE_COUNTER)
>> asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (value));
>> - else if (armv7_pmnc_select_counter(idx) == idx)
>> + else {
>> + armv7_pmnc_select_counter(idx);
>> asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (value));
>> + }
>
> Likewise here.
>
> Otherwise this looks like a nice cleanup to me, so with those changes:
>
> Acked-by: Mark Rutland <[email protected]>


Thanks for your review. I'll send a update version later.

thanks
chai wen

>
> Thanks,
> Mark.
>
>> }
>>
>> static inline void armv7_pmnc_write_evtsel(int idx, u32 val)
>> {
>> - if (armv7_pmnc_select_counter(idx) == idx) {
>> - val &= ARMV7_EVTYPE_MASK;
>> - asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
>> - }
>> + armv7_pmnc_select_counter(idx);
>> + val &= ARMV7_EVTYPE_MASK;
>> + asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
>> }
>>
>> -static inline int armv7_pmnc_enable_counter(int idx)
>> +static inline void armv7_pmnc_enable_counter(int idx)
>> {
>> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
>> asm volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (BIT(counter)));
>> - return idx;
>> }
>>
>> -static inline int armv7_pmnc_disable_counter(int idx)
>> +static inline void armv7_pmnc_disable_counter(int idx)
>> {
>> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
>> asm volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (BIT(counter)));
>> - return idx;
>> }
>>
>> -static inline int armv7_pmnc_enable_intens(int idx)
>> +static inline void armv7_pmnc_enable_intens(int idx)
>> {
>> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
>> asm volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (BIT(counter)));
>> - return idx;
>> }
>>
>> -static inline int armv7_pmnc_disable_intens(int idx)
>> +static inline void armv7_pmnc_disable_intens(int idx)
>> {
>> u32 counter = ARMV7_IDX_TO_COUNTER(idx);
>> asm volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (BIT(counter)));
>> @@ -643,8 +641,6 @@ static inline int armv7_pmnc_disable_intens(int idx)
>> /* Clear the overflow flag in case an interrupt is pending. */
>> asm volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (BIT(counter)));
>> isb();
>> -
>> - return idx;
>> }
>>
>> static inline u32 armv7_pmnc_getreset_flags(void)
>> --
>> 1.7.1
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> [email protected]
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
> .
>



--
Regards

Chai Wen