diff mbox

[v6,2/6] ARM: allow user access to arch timer virtual counter

Message ID 10ed3f4cfce13a80a9a3070934fc0e31619a1242.1398213562.git.nathan_lynch@mentor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nathan Lynch April 23, 2014, 12:48 a.m. UTC
As ARM64 does.  This is a necessary prerequisite for implementing
gettimeofday and clock_gettime in a vdso.

Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
---
 arch/arm/include/asm/arch_timer.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Will Deacon April 23, 2014, 5:32 p.m. UTC | #1
On Wed, Apr 23, 2014 at 01:48:53AM +0100, Nathan Lynch wrote:
> As ARM64 does.  This is a necessary prerequisite for implementing
> gettimeofday and clock_gettime in a vdso.

Doesn't this change make arch_counter_set_user_access identical for arm and
arm64? In which case, we could move it into the driver itself.

Will
Nathan Lynch April 23, 2014, 5:41 p.m. UTC | #2
On 04/23/2014 12:32 PM, Will Deacon wrote:
> On Wed, Apr 23, 2014 at 01:48:53AM +0100, Nathan Lynch wrote:
>> As ARM64 does.  This is a necessary prerequisite for implementing
>> gettimeofday and clock_gettime in a vdso.
> 
> Doesn't this change make arch_counter_set_user_access identical for arm and
> arm64? In which case, we could move it into the driver itself.

True; I had considered this but wasn't sure how it could be staged.

Would a single patch updating arch/arm64, arch/arm, and
drivers/clocksource/arm_arch_timer.c be okay?
Will Deacon April 24, 2014, 10:18 a.m. UTC | #3
On Wed, Apr 23, 2014 at 06:41:03PM +0100, Nathan Lynch wrote:
> On 04/23/2014 12:32 PM, Will Deacon wrote:
> > On Wed, Apr 23, 2014 at 01:48:53AM +0100, Nathan Lynch wrote:
> >> As ARM64 does.  This is a necessary prerequisite for implementing
> >> gettimeofday and clock_gettime in a vdso.
> > 
> > Doesn't this change make arch_counter_set_user_access identical for arm and
> > arm64? In which case, we could move it into the driver itself.
> 
> True; I had considered this but wasn't sure how it could be staged.
> 
> Would a single patch updating arch/arm64, arch/arm, and
> drivers/clocksource/arm_arch_timer.c be okay?

I'd probably modify arm_arch_timer.c to have it's own implementation, then
have follow-up patches removing the arch-private definitions. You could
probably deal with arch_timer_evtstrm_enable at the same time.

Will
diff mbox

Patch

diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 0704e0cf5571..047c800b57f0 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -103,13 +103,16 @@  static inline void arch_counter_set_user_access(void)
 {
 	u32 cntkctl = arch_timer_get_cntkctl();
 
-	/* Disable user access to both physical/virtual counters/timers */
+	/* Disable user access to the timers and the physical counter */
 	/* Also disable virtual event stream */
 	cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
 			| ARCH_TIMER_USR_VT_ACCESS_EN
 			| ARCH_TIMER_VIRT_EVT_EN
-			| ARCH_TIMER_USR_VCT_ACCESS_EN
 			| ARCH_TIMER_USR_PCT_ACCESS_EN);
+
+	/* Enable user access to the virtual counter */
+	cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
+
 	arch_timer_set_cntkctl(cntkctl);
 }