linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] clocksource/arm_arch_timer: extract elf_hwcap use to arch-helper
@ 2019-06-13 12:51 Andrew Murray
  2019-06-13 13:03 ` Marc Zyngier
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Murray @ 2019-06-13 12:51 UTC (permalink / raw)
  To: Mark Rutland, Marc Zyngier, Catalin Marinas, Will Deacon
  Cc: linux-kernel, linux-arm-kernel

Different mechanisms are used to test and set elf_hwcaps between ARM
and ARM64, this results in the use of ifdeferry in this file when
setting/testing for the EVTSTRM hwcap.

Let's improve readability by extracting this to an arch helper.

Signed-off-by: Andrew Murray <andrew.murray@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm/include/asm/arch_timer.h    | 10 ++++++++++
 arch/arm64/include/asm/arch_timer.h  | 13 +++++++++++++
 drivers/clocksource/arm_arch_timer.c | 15 ++-------------
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 4b66ecd6be99..ae533caec1e9 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -4,6 +4,7 @@
 
 #include <asm/barrier.h>
 #include <asm/errno.h>
+#include <asm/hwcap.h>
 #include <linux/clocksource.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -124,6 +125,15 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
 	isb();
 }
 
+static inline bool arch_timer_set_evtstrm_feature(void)
+{
+	elf_hwcap |= HWCAP_EVTSTRM;
+}
+
+static inline bool arch_timer_have_evtstrm_feature(void)
+{
+	return elf_hwcap & HWCAP_EVTSTRM;
+}
 #endif
 
 #endif
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index 50b3ab7ded4f..a847a3ee6cab 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -20,6 +20,7 @@
 #define __ASM_ARCH_TIMER_H
 
 #include <asm/barrier.h>
+#include <asm/hwcap.h>
 #include <asm/sysreg.h>
 
 #include <linux/bug.h>
@@ -240,4 +241,16 @@ static inline int arch_timer_arch_init(void)
 	return 0;
 }
 
+static inline void arch_timer_set_evtstrm_feature(void)
+{
+	cpu_set_named_feature(EVTSTRM);
+#ifdef CONFIG_COMPAT
+	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
+#endif
+}
+
+static inline bool arch_timer_have_evtstrm_feature(void)
+{
+	return cpu_have_named_feature(EVTSTRM);
+}
 #endif
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index b2a951a798e2..3583a92ad960 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -804,14 +804,7 @@ static void arch_timer_evtstrm_enable(int divider)
 	cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
 			| ARCH_TIMER_VIRT_EVT_EN;
 	arch_timer_set_cntkctl(cntkctl);
-#ifdef CONFIG_ARM64
-	cpu_set_named_feature(EVTSTRM);
-#else
-	elf_hwcap |= HWCAP_EVTSTRM;
-#endif
-#ifdef CONFIG_COMPAT
-	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
-#endif
+	arch_timer_set_evtstrm_feature();
 	cpumask_set_cpu(smp_processor_id(), &evtstrm_available);
 }
 
@@ -1040,11 +1033,7 @@ static int arch_timer_cpu_pm_notify(struct notifier_block *self,
 	} else if (action == CPU_PM_ENTER_FAILED || action == CPU_PM_EXIT) {
 		arch_timer_set_cntkctl(__this_cpu_read(saved_cntkctl));
 
-#ifdef CONFIG_ARM64
-		if (cpu_have_named_feature(EVTSTRM))
-#else
-		if (elf_hwcap & HWCAP_EVTSTRM)
-#endif
+		if (arch_timer_have_evtstrm_feature())
 			cpumask_set_cpu(smp_processor_id(), &evtstrm_available);
 	}
 	return NOTIFY_OK;
-- 
2.21.0


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

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

* Re: [PATCH v2] clocksource/arm_arch_timer: extract elf_hwcap use to arch-helper
  2019-06-13 12:51 [PATCH v2] clocksource/arm_arch_timer: extract elf_hwcap use to arch-helper Andrew Murray
@ 2019-06-13 13:03 ` Marc Zyngier
  2019-06-13 13:08   ` Daniel Lezcano
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Zyngier @ 2019-06-13 13:03 UTC (permalink / raw)
  To: Andrew Murray
  Cc: Mark Rutland, Catalin Marinas, Daniel Lezcano, Will Deacon,
	linux-kernel, linux-arm-kernel

+ Daniel

On Thu, 13 Jun 2019 13:51:02 +0100,
Andrew Murray <andrew.murray@arm.com> wrote:
> 
> Different mechanisms are used to test and set elf_hwcaps between ARM
> and ARM64, this results in the use of ifdeferry in this file when
> setting/testing for the EVTSTRM hwcap.
> 
> Let's improve readability by extracting this to an arch helper.
> 
> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> Acked-by: Will Deacon <will.deacon@arm.com>

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

Daniel, can you please take this though the clocksource tree?

Thanks,

	M.

> ---
>  arch/arm/include/asm/arch_timer.h    | 10 ++++++++++
>  arch/arm64/include/asm/arch_timer.h  | 13 +++++++++++++
>  drivers/clocksource/arm_arch_timer.c | 15 ++-------------
>  3 files changed, 25 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> index 4b66ecd6be99..ae533caec1e9 100644
> --- a/arch/arm/include/asm/arch_timer.h
> +++ b/arch/arm/include/asm/arch_timer.h
> @@ -4,6 +4,7 @@
>  
>  #include <asm/barrier.h>
>  #include <asm/errno.h>
> +#include <asm/hwcap.h>
>  #include <linux/clocksource.h>
>  #include <linux/init.h>
>  #include <linux/types.h>
> @@ -124,6 +125,15 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
>  	isb();
>  }
>  
> +static inline bool arch_timer_set_evtstrm_feature(void)
> +{
> +	elf_hwcap |= HWCAP_EVTSTRM;
> +}
> +
> +static inline bool arch_timer_have_evtstrm_feature(void)
> +{
> +	return elf_hwcap & HWCAP_EVTSTRM;
> +}
>  #endif
>  
>  #endif
> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> index 50b3ab7ded4f..a847a3ee6cab 100644
> --- a/arch/arm64/include/asm/arch_timer.h
> +++ b/arch/arm64/include/asm/arch_timer.h
> @@ -20,6 +20,7 @@
>  #define __ASM_ARCH_TIMER_H
>  
>  #include <asm/barrier.h>
> +#include <asm/hwcap.h>
>  #include <asm/sysreg.h>
>  
>  #include <linux/bug.h>
> @@ -240,4 +241,16 @@ static inline int arch_timer_arch_init(void)
>  	return 0;
>  }
>  
> +static inline void arch_timer_set_evtstrm_feature(void)
> +{
> +	cpu_set_named_feature(EVTSTRM);
> +#ifdef CONFIG_COMPAT
> +	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
> +#endif
> +}
> +
> +static inline bool arch_timer_have_evtstrm_feature(void)
> +{
> +	return cpu_have_named_feature(EVTSTRM);
> +}
>  #endif
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index b2a951a798e2..3583a92ad960 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -804,14 +804,7 @@ static void arch_timer_evtstrm_enable(int divider)
>  	cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
>  			| ARCH_TIMER_VIRT_EVT_EN;
>  	arch_timer_set_cntkctl(cntkctl);
> -#ifdef CONFIG_ARM64
> -	cpu_set_named_feature(EVTSTRM);
> -#else
> -	elf_hwcap |= HWCAP_EVTSTRM;
> -#endif
> -#ifdef CONFIG_COMPAT
> -	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
> -#endif
> +	arch_timer_set_evtstrm_feature();
>  	cpumask_set_cpu(smp_processor_id(), &evtstrm_available);
>  }
>  
> @@ -1040,11 +1033,7 @@ static int arch_timer_cpu_pm_notify(struct notifier_block *self,
>  	} else if (action == CPU_PM_ENTER_FAILED || action == CPU_PM_EXIT) {
>  		arch_timer_set_cntkctl(__this_cpu_read(saved_cntkctl));
>  
> -#ifdef CONFIG_ARM64
> -		if (cpu_have_named_feature(EVTSTRM))
> -#else
> -		if (elf_hwcap & HWCAP_EVTSTRM)
> -#endif
> +		if (arch_timer_have_evtstrm_feature())
>  			cpumask_set_cpu(smp_processor_id(), &evtstrm_available);
>  	}
>  	return NOTIFY_OK;
> -- 
> 2.21.0
> 

-- 
Jazz is not dead, it just smells funny.

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

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

* Re: [PATCH v2] clocksource/arm_arch_timer: extract elf_hwcap use to arch-helper
  2019-06-13 13:03 ` Marc Zyngier
@ 2019-06-13 13:08   ` Daniel Lezcano
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2019-06-13 13:08 UTC (permalink / raw)
  To: Marc Zyngier, Andrew Murray
  Cc: Mark Rutland, Catalin Marinas, Will Deacon, linux-kernel,
	linux-arm-kernel

On 13/06/2019 15:03, Marc Zyngier wrote:
> + Daniel
> 
> On Thu, 13 Jun 2019 13:51:02 +0100,
> Andrew Murray <andrew.murray@arm.com> wrote:
>>
>> Different mechanisms are used to test and set elf_hwcaps between ARM
>> and ARM64, this results in the use of ifdeferry in this file when
>> setting/testing for the EVTSTRM hwcap.
>>
>> Let's improve readability by extracting this to an arch helper.
>>
>> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
>> Acked-by: Mark Rutland <mark.rutland@arm.com>
>> Acked-by: Will Deacon <will.deacon@arm.com>
> 
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
> 
> Daniel, can you please take this though the clocksource tree?

Applied, thanks

  -- Daniel

>> ---
>>  arch/arm/include/asm/arch_timer.h    | 10 ++++++++++
>>  arch/arm64/include/asm/arch_timer.h  | 13 +++++++++++++
>>  drivers/clocksource/arm_arch_timer.c | 15 ++-------------
>>  3 files changed, 25 insertions(+), 13 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
>> index 4b66ecd6be99..ae533caec1e9 100644
>> --- a/arch/arm/include/asm/arch_timer.h
>> +++ b/arch/arm/include/asm/arch_timer.h
>> @@ -4,6 +4,7 @@
>>  
>>  #include <asm/barrier.h>
>>  #include <asm/errno.h>
>> +#include <asm/hwcap.h>
>>  #include <linux/clocksource.h>
>>  #include <linux/init.h>
>>  #include <linux/types.h>
>> @@ -124,6 +125,15 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
>>  	isb();
>>  }
>>  
>> +static inline bool arch_timer_set_evtstrm_feature(void)
>> +{
>> +	elf_hwcap |= HWCAP_EVTSTRM;
>> +}
>> +
>> +static inline bool arch_timer_have_evtstrm_feature(void)
>> +{
>> +	return elf_hwcap & HWCAP_EVTSTRM;
>> +}
>>  #endif
>>  
>>  #endif
>> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
>> index 50b3ab7ded4f..a847a3ee6cab 100644
>> --- a/arch/arm64/include/asm/arch_timer.h
>> +++ b/arch/arm64/include/asm/arch_timer.h
>> @@ -20,6 +20,7 @@
>>  #define __ASM_ARCH_TIMER_H
>>  
>>  #include <asm/barrier.h>
>> +#include <asm/hwcap.h>
>>  #include <asm/sysreg.h>
>>  
>>  #include <linux/bug.h>
>> @@ -240,4 +241,16 @@ static inline int arch_timer_arch_init(void)
>>  	return 0;
>>  }
>>  
>> +static inline void arch_timer_set_evtstrm_feature(void)
>> +{
>> +	cpu_set_named_feature(EVTSTRM);
>> +#ifdef CONFIG_COMPAT
>> +	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
>> +#endif
>> +}
>> +
>> +static inline bool arch_timer_have_evtstrm_feature(void)
>> +{
>> +	return cpu_have_named_feature(EVTSTRM);
>> +}
>>  #endif
>> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
>> index b2a951a798e2..3583a92ad960 100644
>> --- a/drivers/clocksource/arm_arch_timer.c
>> +++ b/drivers/clocksource/arm_arch_timer.c
>> @@ -804,14 +804,7 @@ static void arch_timer_evtstrm_enable(int divider)
>>  	cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
>>  			| ARCH_TIMER_VIRT_EVT_EN;
>>  	arch_timer_set_cntkctl(cntkctl);
>> -#ifdef CONFIG_ARM64
>> -	cpu_set_named_feature(EVTSTRM);
>> -#else
>> -	elf_hwcap |= HWCAP_EVTSTRM;
>> -#endif
>> -#ifdef CONFIG_COMPAT
>> -	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
>> -#endif
>> +	arch_timer_set_evtstrm_feature();
>>  	cpumask_set_cpu(smp_processor_id(), &evtstrm_available);
>>  }
>>  
>> @@ -1040,11 +1033,7 @@ static int arch_timer_cpu_pm_notify(struct notifier_block *self,
>>  	} else if (action == CPU_PM_ENTER_FAILED || action == CPU_PM_EXIT) {
>>  		arch_timer_set_cntkctl(__this_cpu_read(saved_cntkctl));
>>  
>> -#ifdef CONFIG_ARM64
>> -		if (cpu_have_named_feature(EVTSTRM))
>> -#else
>> -		if (elf_hwcap & HWCAP_EVTSTRM)
>> -#endif
>> +		if (arch_timer_have_evtstrm_feature())
>>  			cpumask_set_cpu(smp_processor_id(), &evtstrm_available);
>>  	}
>>  	return NOTIFY_OK;
>> -- 
>> 2.21.0
>>
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

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

end of thread, other threads:[~2019-06-13 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 12:51 [PATCH v2] clocksource/arm_arch_timer: extract elf_hwcap use to arch-helper Andrew Murray
2019-06-13 13:03 ` Marc Zyngier
2019-06-13 13:08   ` Daniel Lezcano

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