Skip to contentSkip to conversation

ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

PATCH New Ben Dooks 3 participants 6 messages Dec 11, 2013

Subsystems (4)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

If the system has been started in non-secure mode, then the ARM generic timer is not configurable during the kernel initialisation. Currently the only thing we can check for is if the timer has been correctly configured during the boot process.

---
 arch/arm/mach-shmobile/setup-rcar-gen2.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/setup-rcar-gen2.c +13 -5
index 5734c24..6b7b7f1 100644
@@ -78,12 +78,20 @@ void __init rcar_gen2_timer_init(void)
 	/* Remap "armgcnt address map" space */
 	base = ioremap(0xe6080000, PAGE_SIZE);
 
-	/* Update registers with correct frequency */
-	iowrite32(freq, base + CNTFID0);
-	asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+	/* Update the timer if it is either not running, or is not at the
+	 * right frequency. The timer is only configurable in secure mode
+	 * so this avoids an abort if the loader started the timer and
+	 * started the kernel in non-secure mode. */
+	if ((ioread32(base + CNTCR) & 1) == 0 ||
+	    ioread32(base + CNTFID0) != freq) {
+		/* Update registers with correct frequency */
+		iowrite32(freq, base + CNTFID0);
+		asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+
+		/* make sure arch timer is started by setting bit 0 of CNTCR */
+		iowrite32(1, base + CNTCR);
+	}
 
-	/* make sure arch timer is started by setting bit 0 of CNTCR */
-	iowrite32(1, base + CNTCR);
 	iounmap(base);
 #endif /* CONFIG_ARM_ARCH_TIMER */
 
Signature · 1 line
1.8.5.1
maintainer
#1 lore raw

PATCH 1/1 ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

Quoted 7 lines · Ben Dooks

If the system has been started in non-secure mode, then the ARM generic timer is not configurable during the kernel initialisation. Currently the only thing we can check for is if the timer has been correctly configured during the boot process.

Looks fine, thanks!

author
#2 lore raw

PATCH 1/1 ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

In reply to Ben Dooks
Quoted 7 lines · Ben Dooks

If the system has been started in non-secure mode, then the ARM generic timer is not configurable during the kernel initialisation. Currently the only thing we can check for is if the timer has been correctly configured during the boot process.

Sorry, I've gone and re-posted the same patch as yesterday.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#3 lore raw

PATCH 1/1 ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

In reply to Ben Dooks

Hello.

Quoted 16 lines · Ben Dooks

If the system has been started in non-secure mode, then the ARM generic timer is not configurable during the kernel initialisation. Currently the only thing we can check for is if the timer has been correctly configured during the boot process.

---
  arch/arm/mach-shmobile/setup-rcar-gen2.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/setup-rcar-gen2.c +0 -0
index 5734c24..6b7b7f1 100644

arch/arm/mach-shmobile/setup-rcar-gen2.c void __init rcar_gen2_timer_init(void) · line 84

Quoted 10 lines
arch/arm/mach-shmobile/setup-rcar-gen2.c +4 -3
@@ -78,12 +78,20 @@ void __init rcar_gen2_timer_init(void)
  	/* Remap "armgcnt address map" space */
  	base = ioremap(0xe6080000, PAGE_SIZE);
 
-	/* Update registers with correct frequency */
-	iowrite32(freq, base + CNTFID0);
-	asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+	/* Update the timer if it is either not running, or is not at the
+	 * right frequency. The timer is only configurable in secure mode
+	 * so this avoids an abort if the loader started the timer and
+	 * started the kernel in non-secure mode. */

You said you've fixed the comment style but you haven't as I see.

WBR, Sergei

author
#4 lore raw

PATCH 1/1 ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

Quoted 24 lines · Sergei Shtylyov

Hello.

Quoted 20 lines · Ben Dooks

If the system has been started in non-secure mode, then the ARM generic timer is not configurable during the kernel initialisation. Currently the only thing we can check for is if the timer has been correctly configured during the boot process.

---
  arch/arm/mach-shmobile/setup-rcar-gen2.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/setup-rcar-gen2.c +0 -0
index 5734c24..6b7b7f1 100644
@@ -78,12 +78,20 @@ void __init rcar_gen2_timer_init(void)
      /* Remap "armgcnt address map" space */
      base = ioremap(0xe6080000, PAGE_SIZE);
 
Quoted 9 lines

arch/arm/mach-shmobile/setup-rcar-gen2.c void __init rcar_gen2_timer_init(void) · line 84

Quoted 7 lines
arch/arm/mach-shmobile/setup-rcar-gen2.c +4 -3
-    /* Update registers with correct frequency */
-    iowrite32(freq, base + CNTFID0);
-    asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+    /* Update the timer if it is either not running, or is not at the
+     * right frequency. The timer is only configurable in secure mode
+     * so this avoids an abort if the loader started the timer and
+     * started the kernel in non-secure mode. */

You said you've fixed the comment style but you haven't as I see.

I also said I reposted the previous patch by accident this morning and posted the corrected one after it.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#5 lore raw

PATCH 1/1 ARM: rcar-gen2: Do not attempt to re-setup timer if running correctly

Hello.

Quoted 30 lines · Ben Dooks
Quoted 20 lines
Quoted 20 lines

If the system has been started in non-secure mode, then the ARM generic timer is not configurable during the kernel initialisation. Currently the only thing we can check for is if the timer has been correctly configured during the boot process.

---
  arch/arm/mach-shmobile/setup-rcar-gen2.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/setup-rcar-gen2.c +0 -0
index 5734c24..6b7b7f1 100644
@@ -78,12 +78,20 @@ void __init rcar_gen2_timer_init(void)
      /* Remap "armgcnt address map" space */
      base = ioremap(0xe6080000, PAGE_SIZE);
 
Quoted 9 lines

arch/arm/mach-shmobile/setup-rcar-gen2.c void __init rcar_gen2_timer_init(void) · line 84

Quoted 7 lines
arch/arm/mach-shmobile/setup-rcar-gen2.c +4 -3
-    /* Update registers with correct frequency */
-    iowrite32(freq, base + CNTFID0);
-    asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+    /* Update the timer if it is either not running, or is not at the
+     * right frequency. The timer is only configurable in secure mode
+     * so this avoids an abort if the loader started the timer and
+     * started the kernel in non-secure mode. */

You said you've fixed the comment style but you haven't as I see.

Quoted 2 lines

I also said I reposted the previous patch by accident this morning and posted the corrected one after it.

Sorry, I've only read that after sending my comment. I thought that was an
intended repost with a slightly corrected subject.

WBR, Sergei