Skip to contentSkip to conversation

ARM: EXYNOS: Fix incorrect usage of S5P_ARM_CORE1_* registers

PATCH In review Tomasz Figa 6 participants 16 messages Jun 18, 2013 – Jun 20, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: EXYNOS: Fix incorrect usage of S5P_ARM_CORE1_* registers

S5P_ARM_CORE1_* registers affect only core 1. To control further cores properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off. In addition, bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off secondary cores by default.

Cc stable at vger.kernel.org
---
 arch/arm/mach-exynos/hotplug.c               |  9 +++++----
 arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
 arch/arm/mach-exynos/platsmp.c               |  9 +++++----
 3 files changed, 17 insertions(+), 11 deletions(-)
arch/arm/mach-exynos/hotplug.c +5 -4
index af90cfa..c089943 100644
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 {
 	for (;;) {
+		void __iomem *reg_base;
+		unsigned int phys_cpu = cpu_logical_map(cpu);
 
-		/* make cpu1 to be turned off at next WFI command */
-		if (cpu == 1)
-			__raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+		reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
+		__raw_writel(0, reg_base);
 
 		/*
 		 * here's the WFI
@@ -106,7 +107,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu_logical_map(cpu)) {
+		if (pen_release == phys_cpu) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
arch/arm/mach-exynos/include/mach/regs-pmu.h +7 -3
index 57344b7..cf40b86 100644
@@ -125,10 +125,14 @@
 #define S5P_GPS_ALIVE_LOWPWR			S5P_PMUREG(0x13A0)
 
 #define S5P_ARM_CORE0_CONFIGURATION		S5P_PMUREG(0x2000)
+#define S5P_ARM_CORE0_STATUS			S5P_PMUREG(0x2004)
 #define S5P_ARM_CORE0_OPTION			S5P_PMUREG(0x2008)
-#define S5P_ARM_CORE1_CONFIGURATION		S5P_PMUREG(0x2080)
-#define S5P_ARM_CORE1_STATUS			S5P_PMUREG(0x2084)
-#define S5P_ARM_CORE1_OPTION			S5P_PMUREG(0x2088)
+#define S5P_ARM_CORE_CONFIGURATION(_nr)		\
+		(S5P_ARM_CORE0_CONFIGURATION + ((_nr) * 0x80))
+#define S5P_ARM_CORE_STATUS(_nr)		\
+		(S5P_ARM_CORE0_STATUS + ((_nr) * 0x80))
+#define S5P_ARM_CORE_OPTION(_nr)		\
+		(S5P_ARM_CORE0_OPTION + ((_nr) * 0x80))
 
 #define S5P_ARM_COMMON_OPTION			S5P_PMUREG(0x2408)
 #define S5P_TOP_PWR_OPTION			S5P_PMUREG(0x2C48)
arch/arm/mach-exynos/platsmp.c +5 -4
index d9c6d0a..2cbabc8 100644
@@ -109,14 +109,15 @@ static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct
 	 */
 	write_pen_release(phys_cpu);
 
-	if (!(__raw_readl(S5P_ARM_CORE1_STATUS) & S5P_CORE_LOCAL_PWR_EN)) {
+	if (!(__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
+	    & S5P_CORE_LOCAL_PWR_EN)) {
 		__raw_writel(S5P_CORE_LOCAL_PWR_EN,
-			     S5P_ARM_CORE1_CONFIGURATION);
+			     S5P_ARM_CORE_CONFIGURATION(phys_cpu));
 
 		timeout = 10;
 
 		/* wait max 10 ms until cpu1 is on */
-		while ((__raw_readl(S5P_ARM_CORE1_STATUS)
+		while ((__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
 			& S5P_CORE_LOCAL_PWR_EN) != S5P_CORE_LOCAL_PWR_EN) {
 			if (timeout-- == 0)
 				break;
@@ -125,7 +126,7 @@ static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct
 		}
 
 		if (timeout == 0) {
-			printk(KERN_ERR "cpu1 power enable failed");
+			printk(KERN_ERR "cpu%u power enable failed", cpu);
 			spin_unlock(&boot_lock);
 			return -ETIMEDOUT;
 		}
Signature · 1 line
1.8.2.1
#1 lore raw

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 9 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 70 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off secondary cores by default.

Cc stable at vger.kernel.org
---
 arch/arm/mach-exynos/hotplug.c               |  9 +++++----
 arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
 arch/arm/mach-exynos/platsmp.c               |  9 +++++----
 3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +5 -4
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 static inline void platform_do_lowpower(unsigned int cpu, int
 *spurious) {
 	for (;;) {
+		void __iomem *reg_base;
+		unsigned int phys_cpu = cpu_logical_map(cpu);
 
-		/* make cpu1 to be turned off at next WFI command */
-		if (cpu == 1)
-			__raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+		reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
+		__raw_writel(0, reg_base);
 
 		/*
 		 * here's the WFI
@@ -106,7 +107,7 @@ static inline void platform_do_lowpower(unsigned int
 cpu, int *spurious)
 		    : "memory", "cc");
 
-		if (pen_release == cpu_logical_map(cpu)) {
+		if (pen_release == phys_cpu) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
(quoted diff) +0 -0

b/arch/arm/mach-exynos/include/mach/regs-pmu.h index 57344b7..cf40b86 100644

arch/arm/mach-exynos/include/mach/regs-pmu.h +7 -3
@@ -125,10 +125,14 @@
 #define S5P_GPS_ALIVE_LOWPWR			S5P_PMUREG(0x13A0)
 
 #define S5P_ARM_CORE0_CONFIGURATION		S5P_PMUREG(0x2000)
+#define S5P_ARM_CORE0_STATUS			S5P_PMUREG(0x2004)
 #define S5P_ARM_CORE0_OPTION			S5P_PMUREG(0x2008)
-#define S5P_ARM_CORE1_CONFIGURATION		S5P_PMUREG(0x2080)
-#define S5P_ARM_CORE1_STATUS			S5P_PMUREG(0x2084)
-#define S5P_ARM_CORE1_OPTION			S5P_PMUREG(0x2088)
+#define S5P_ARM_CORE_CONFIGURATION(_nr)		\
+		(S5P_ARM_CORE0_CONFIGURATION + ((_nr) * 0x80))
+#define S5P_ARM_CORE_STATUS(_nr)		\
+		(S5P_ARM_CORE0_STATUS + ((_nr) * 0x80))
+#define S5P_ARM_CORE_OPTION(_nr)		\
+		(S5P_ARM_CORE0_OPTION + ((_nr) * 0x80))
 
 #define S5P_ARM_COMMON_OPTION			S5P_PMUREG(0x2408)
 #define S5P_TOP_PWR_OPTION			S5P_PMUREG(0x2C48)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/platsmp.c index d9c6d0a..2cbabc8 100644

arch/arm/mach-exynos/platsmp.c +0 -0
@@ -109,14 +109,15 @@ static int __cpuinit

exynos_boot_secondary(unsigned int cpu, struct task_struct */

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct

Quoted 3 lines
arch/arm/mach-exynos/platsmp.c +0 -1
 	write_pen_release(phys_cpu);
 
-	if (!(__raw_readl(S5P_ARM_CORE1_STATUS) & S5P_CORE_LOCAL_PWR_EN)) 

{

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct

Quoted 12 lines
arch/arm/mach-exynos/platsmp.c +4 -2
+	if (!(__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
+	    & S5P_CORE_LOCAL_PWR_EN)) {
 		__raw_writel(S5P_CORE_LOCAL_PWR_EN,
-			     S5P_ARM_CORE1_CONFIGURATION);
+			     S5P_ARM_CORE_CONFIGURATION(phys_cpu));
 
 		timeout = 10;
 
 		/* wait max 10 ms until cpu1 is on */
-		while ((__raw_readl(S5P_ARM_CORE1_STATUS)
+		while ((__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
 			& S5P_CORE_LOCAL_PWR_EN) != S5P_CORE_LOCAL_PWR_EN) 

{

Quoted 11 lines
arch/arm/mach-exynos/platsmp.c +1 -1
 			if (timeout-- == 0)
 				break;
@@ -125,7 +126,7 @@ static int __cpuinit exynos_boot_secondary(unsigned
 int cpu, struct task_struct }
 
 		if (timeout == 0) {
-			printk(KERN_ERR "cpu1 power enable failed");
+			printk(KERN_ERR "cpu%u power enable failed", cpu);
 			spin_unlock(&boot_lock);
 			return -ETIMEDOUT;
 		}
#2 lore raw
Quoted 8 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 3 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores properly another registers must be used.

Quoted 8 lines
Quoted 6 lines

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but

Yes, not happened...and just note exynos5440 doesn't support hotplug :) so this is available on exynos4412 and added 5420.

Quoted 9 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 4 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off secondary cores by default.

I need to test on board about above...

Quoted 95 lines
Quoted 68 lines
Cc stable at vger.kernel.org
---
  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +5 -4
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
  static inline void platform_do_lowpower(unsigned int cpu, int
 *spurious) {
  	for (;;) {
+		void __iomem *reg_base;
+		unsigned int phys_cpu = cpu_logical_map(cpu);
 
-		/* make cpu1 to be turned off at next WFI command */
-		if (cpu == 1)
-			__raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+		reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
+		__raw_writel(0, reg_base);
 
  		/*
  		 * here's the WFI
@@ -106,7 +107,7 @@ static inline void platform_do_lowpower(unsigned int
 cpu, int *spurious)
  		    : "memory", "cc");
 
-		if (pen_release == cpu_logical_map(cpu)) {
+		if (pen_release == phys_cpu) {
  			/*
  			 * OK, proper wakeup, we're done
  			 */
(quoted diff) +0 -0

b/arch/arm/mach-exynos/include/mach/regs-pmu.h index 57344b7..cf40b86 100644

arch/arm/mach-exynos/include/mach/regs-pmu.h +7 -3
@@ -125,10 +125,14 @@
  #define S5P_GPS_ALIVE_LOWPWR			S5P_PMUREG(0x13A0)
 
  #define S5P_ARM_CORE0_CONFIGURATION		S5P_PMUREG(0x2000)
+#define S5P_ARM_CORE0_STATUS			S5P_PMUREG(0x2004)
  #define S5P_ARM_CORE0_OPTION			S5P_PMUREG(0x2008)
-#define S5P_ARM_CORE1_CONFIGURATION		S5P_PMUREG(0x2080)
-#define S5P_ARM_CORE1_STATUS			S5P_PMUREG(0x2084)
-#define S5P_ARM_CORE1_OPTION			S5P_PMUREG(0x2088)
+#define S5P_ARM_CORE_CONFIGURATION(_nr)		\
+		(S5P_ARM_CORE0_CONFIGURATION + ((_nr) * 0x80))
+#define S5P_ARM_CORE_STATUS(_nr)		\
+		(S5P_ARM_CORE0_STATUS + ((_nr) * 0x80))
+#define S5P_ARM_CORE_OPTION(_nr)		\
+		(S5P_ARM_CORE0_OPTION + ((_nr) * 0x80))
 
  #define S5P_ARM_COMMON_OPTION			S5P_PMUREG(0x2408)
  #define S5P_TOP_PWR_OPTION			S5P_PMUREG(0x2C48)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/platsmp.c index d9c6d0a..2cbabc8 100644

arch/arm/mach-exynos/platsmp.c +0 -0
@@ -109,14 +109,15 @@ static int __cpuinit

exynos_boot_secondary(unsigned int cpu, struct task_struct */
write_pen_release(phys_cpu);

arch/arm/mach-exynos/platsmp.c

Quoted 1 line
arch/arm/mach-exynos/platsmp.c +0 -1
-	if (!(__raw_readl(S5P_ARM_CORE1_STATUS)&  S5P_CORE_LOCAL_PWR_EN))

{

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct

Quoted 12 lines
arch/arm/mach-exynos/platsmp.c +4 -2
+	if (!(__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
+	&  S5P_CORE_LOCAL_PWR_EN)) {
  		__raw_writel(S5P_CORE_LOCAL_PWR_EN,
-			     S5P_ARM_CORE1_CONFIGURATION);
+			     S5P_ARM_CORE_CONFIGURATION(phys_cpu));
 
  		timeout = 10;
 
  		/* wait max 10 ms until cpu1 is on */
-		while ((__raw_readl(S5P_ARM_CORE1_STATUS)
+		while ((__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
  			&  S5P_CORE_LOCAL_PWR_EN) != S5P_CORE_LOCAL_PWR_EN)

{

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned · line 132

Quoted 11 lines

if (timeout-- == 0)
break;

arch/arm/mach-exynos/platsmp.c +1 -1
@@ -125,7 +126,7 @@ static int __cpuinit exynos_boot_secondary(unsigned
 int cpu, struct task_struct }
 
  		if (timeout == 0) {
-			printk(KERN_ERR "cpu1 power enable failed");
+			printk(KERN_ERR "cpu%u power enable failed", cpu);
  			spin_unlock(&boot_lock);
  			return -ETIMEDOUT;
  		}

--

#3 lore raw
Quoted 57 lines · Kukjin Kim
Quoted 14 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 5 lines
Quoted 2 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but

Yes, not happened...and just note exynos5440 doesn't support hotplug :) so this is available on exynos4412 and added 5420.

Quoted 9 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 4 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off secondary cores by default.

I need to test on board about above...

Quoted 20 lines
Quoted 20 lines
Cc stable at vger.kernel.org
---
  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
  static inline void platform_do_lowpower(unsigned int cpu, int
 *spurious) {
        for (;;) {
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 4 lines
Quoted 4 lines

arch/arm/mach-exynos/hotplug.c static inline void cpu_leave_lowpower(void) · line 99

Quoted 4 lines
arch/arm/mach-exynos/hotplug.c +1 -3
-               /* make cpu1 to be turned off at next WFI command */
-               if (cpu == 1)
-                       __raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+               reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Quoted 54 lines
Quoted 54 lines
Quoted 42 lines
arch/arm/mach-exynos/hotplug.c +2 -1
+               __raw_writel(0, reg_base);
 
                /*
                 * here's the WFI
@@ -106,7 +107,7 @@ static inline void platform_do_lowpower(unsigned int
 cpu, int *spurious)
                    : "memory", "cc");
 
-               if (pen_release == cpu_logical_map(cpu)) {
+               if (pen_release == phys_cpu) {
                        /*
                         * OK, proper wakeup, we're done
                         */
(quoted diff) +0 -0

b/arch/arm/mach-exynos/include/mach/regs-pmu.h index 57344b7..cf40b86 100644

arch/arm/mach-exynos/include/mach/regs-pmu.h +7 -3
@@ -125,10 +125,14 @@
  #define S5P_GPS_ALIVE_LOWPWR                  S5P_PMUREG(0x13A0)
 
  #define S5P_ARM_CORE0_CONFIGURATION           S5P_PMUREG(0x2000)
+#define S5P_ARM_CORE0_STATUS                   S5P_PMUREG(0x2004)
  #define S5P_ARM_CORE0_OPTION                  S5P_PMUREG(0x2008)
-#define S5P_ARM_CORE1_CONFIGURATION            S5P_PMUREG(0x2080)
-#define S5P_ARM_CORE1_STATUS                   S5P_PMUREG(0x2084)
-#define S5P_ARM_CORE1_OPTION                   S5P_PMUREG(0x2088)
+#define S5P_ARM_CORE_CONFIGURATION(_nr)                \
+               (S5P_ARM_CORE0_CONFIGURATION + ((_nr) * 0x80))
+#define S5P_ARM_CORE_STATUS(_nr)               \
+               (S5P_ARM_CORE0_STATUS + ((_nr) * 0x80))
+#define S5P_ARM_CORE_OPTION(_nr)               \
+               (S5P_ARM_CORE0_OPTION + ((_nr) * 0x80))
 
  #define S5P_ARM_COMMON_OPTION                 S5P_PMUREG(0x2408)
  #define S5P_TOP_PWR_OPTION                    S5P_PMUREG(0x2C48)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/platsmp.c index d9c6d0a..2cbabc8 100644

arch/arm/mach-exynos/platsmp.c +0 -0
@@ -109,14 +109,15 @@ static int __cpuinit

exynos_boot_secondary(unsigned int cpu, struct task_struct */

Quoted 3 lines
        write_pen_release(phys_cpu);

- if (!(__raw_readl(S5P_ARM_CORE1_STATUS)& S5P_CORE_LOCAL_PWR_EN))

{

Quoted 7 lines
arch/arm/mach-exynos/platsmp.c +3 -1
+       if (!(__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
+       &  S5P_CORE_LOCAL_PWR_EN)) {
                __raw_writel(S5P_CORE_LOCAL_PWR_EN,
-                            S5P_ARM_CORE1_CONFIGURATION);
+                            S5P_ARM_CORE_CONFIGURATION(phys_cpu));
Quoted 5 lines
Quoted 5 lines

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct · line 120

Quoted 5 lines
                timeout = 10;

                /* wait max 10 ms until cpu1 is on */
arch/arm/mach-exynos/platsmp.c +1 -1
-               while ((__raw_readl(S5P_ARM_CORE1_STATUS)
+               while ((__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))

Ditto

Quoted 20 lines
Quoted 10 lines
Quoted 2 lines
                        &  S5P_CORE_LOCAL_PWR_EN) !=

S5P_CORE_LOCAL_PWR_EN)

{

Quoted 6 lines
                        if (timeout-- == 0)
                                break;
arch/arm/mach-exynos/platsmp.c +0 -0
@@ -125,7 +126,7 @@ static int __cpuinit exynos_boot_secondary(unsigned
 int cpu, struct task_struct }
 
Quoted 9 lines
Quoted 7 lines
arch/arm/mach-exynos/platsmp.c +1 -1
                if (timeout == 0) {
-                       printk(KERN_ERR "cpu1 power enable failed");
+                       printk(KERN_ERR "cpu%u power enable failed",
 cpu);
                        spin_unlock(&boot_lock);
                        return -ETIMEDOUT;
                }

--

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap

#4 lore raw
Quoted 61 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 60 lines · Kukjin Kim
Quoted 13 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 5 lines
Quoted 2 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :) so this is available on exynos4412 and added 5420.

Quoted 10 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 4 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off
secondary cores by default.

I need to test on board about above...

Quoted 25 lines
Quoted 25 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu, int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

arch/arm/mach-exynos/hotplug.c static inline void cpu_leave_lowpower(void) · line 99

Quoted 4 lines
arch/arm/mach-exynos/hotplug.c +1 -3
-               /* make cpu1 to be turned off at next WFI command */
-               if (cpu == 1)
-                       __raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+               reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Hmm, according to the code initializing __cpu_logical_map[] array this is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any problem here.

If I'm wrong, feel free to correct me.

Cc'ing people who should have more knowledge on this.

Best regards,
Tomasz

Quoted 118 lines
Quoted 69 lines
Quoted 69 lines
Quoted 55 lines
arch/arm/mach-exynos/hotplug.c +1 -0
+               __raw_writel(0, reg_base);
 
                /*
 
                 * here's the WFI
@@ -106,7 +107,7 @@ static inline void platform_do_lowpower(unsigned

int
cpu, int *spurious)

                    : "memory", "cc");
arch/arm/mach-exynos/hotplug.c +1 -1
-               if (pen_release == cpu_logical_map(cpu)) {
+               if (pen_release == phys_cpu) {
 
                        /*
 
                         * OK, proper wakeup, we're done
                         */
(quoted diff) +0 -0

b/arch/arm/mach-exynos/include/mach/regs-pmu.h index 57344b7..cf40b86 100644

arch/arm/mach-exynos/include/mach/regs-pmu.h +7 -3
@@ -125,10 +125,14 @@
 
  #define S5P_GPS_ALIVE_LOWPWR                  S5P_PMUREG(0x13A0)
 
  #define S5P_ARM_CORE0_CONFIGURATION           S5P_PMUREG(0x2000)
 
+#define S5P_ARM_CORE0_STATUS                   S5P_PMUREG(0x2004)
 
  #define S5P_ARM_CORE0_OPTION                  S5P_PMUREG(0x2008)
 
-#define S5P_ARM_CORE1_CONFIGURATION            S5P_PMUREG(0x2080)
-#define S5P_ARM_CORE1_STATUS                   S5P_PMUREG(0x2084)
-#define S5P_ARM_CORE1_OPTION                   S5P_PMUREG(0x2088)
+#define S5P_ARM_CORE_CONFIGURATION(_nr)                \
+               (S5P_ARM_CORE0_CONFIGURATION + ((_nr) * 0x80))
+#define S5P_ARM_CORE_STATUS(_nr)               \
+               (S5P_ARM_CORE0_STATUS + ((_nr) * 0x80))
+#define S5P_ARM_CORE_OPTION(_nr)               \
+               (S5P_ARM_CORE0_OPTION + ((_nr) * 0x80))
 
  #define S5P_ARM_COMMON_OPTION                 S5P_PMUREG(0x2408)
  #define S5P_TOP_PWR_OPTION                    S5P_PMUREG(0x2C48)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/platsmp.c index d9c6d0a..2cbabc8 100644

arch/arm/mach-exynos/platsmp.c +0 -0
@@ -109,14 +109,15 @@ static int __cpuinit

exynos_boot_secondary(unsigned int cpu, struct task_struct */

Quoted 4 lines
        write_pen_release(phys_cpu);

- if (!(__raw_readl(S5P_ARM_CORE1_STATUS)&
S5P_CORE_LOCAL_PWR_EN))>>

{

Quoted 8 lines
arch/arm/mach-exynos/platsmp.c +3 -1
+       if (!(__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
+       &  S5P_CORE_LOCAL_PWR_EN)) {
 
                __raw_writel(S5P_CORE_LOCAL_PWR_EN,
 
-                            S5P_ARM_CORE1_CONFIGURATION);
+                            S5P_ARM_CORE_CONFIGURATION(phys_cpu));
Quoted 6 lines
Quoted 6 lines

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct · line 120

Quoted 6 lines
                timeout = 10;
                
                /* wait max 10 ms until cpu1 is on */
arch/arm/mach-exynos/platsmp.c +1 -1
-               while ((__raw_readl(S5P_ARM_CORE1_STATUS)
+               while ((__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))

Ditto

Quoted 27 lines
Quoted 20 lines
Quoted 3 lines
                        &  S5P_CORE_LOCAL_PWR_EN) !=

S5P_CORE_LOCAL_PWR_EN)

{

Quoted 14 lines
                        if (timeout-- == 0)
                        
                                break;
arch/arm/mach-exynos/platsmp.c +0 -0
@@ -125,7 +126,7 @@ static int __cpuinit

exynos_boot_secondary(unsigned
int cpu, struct task_struct }

                if (timeout == 0) {
arch/arm/mach-exynos/platsmp.c +1 -1
-                       printk(KERN_ERR "cpu1 power enable failed");
+                       printk(KERN_ERR "cpu%u power enable failed",

cpu);

Quoted 6 lines
Quoted 4 lines
                        spin_unlock(&boot_lock);
                        return -ETIMEDOUT;
                
                }

--

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 84 lines · Tomasz Figa
Quoted 61 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 60 lines · Kukjin Kim
Quoted 13 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 5 lines
Quoted 2 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :) so this is available on exynos4412 and added 5420.

Quoted 10 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 4 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off
secondary cores by default.

I need to test on board about above...

Quoted 25 lines
Quoted 25 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu, int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

arch/arm/mach-exynos/hotplug.c static inline void cpu_leave_lowpower(void) · line 99

Quoted 4 lines
arch/arm/mach-exynos/hotplug.c +1 -3
-               /* make cpu1 to be turned off at next WFI command */
-               if (cpu == 1)
-                       __raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+               reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Hmm, according to the code initializing __cpu_logical_map[] array this is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Quoted 7 lines

Now the structure of the MPIDR register:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any problem here.

Kindly look at implementation of "arm_dt_init_cpu_maps" in "arch/arm/kernel/devtree.c". When you pass the cpu nodes thru DT, and cluster id is non zero, the phys_cpu will include clusterID. Say e.g exynos4210 has CLusterID=9, hence phys_cpu value for cpu0 will be 0x901.

Quoted 126 lines

If I'm wrong, feel free to correct me.

Cc'ing people who should have more knowledge on this.

Best regards,
Tomasz

Quoted 118 lines
Quoted 69 lines
Quoted 69 lines
Quoted 55 lines
arch/arm/mach-exynos/hotplug.c +1 -0
+               __raw_writel(0, reg_base);
 
                /*
 
                 * here's the WFI
@@ -106,7 +107,7 @@ static inline void platform_do_lowpower(unsigned

int
cpu, int *spurious)

                    : "memory", "cc");
arch/arm/mach-exynos/hotplug.c +1 -1
-               if (pen_release == cpu_logical_map(cpu)) {
+               if (pen_release == phys_cpu) {
 
                        /*
 
                         * OK, proper wakeup, we're done
                         */
(quoted diff) +0 -0

b/arch/arm/mach-exynos/include/mach/regs-pmu.h index 57344b7..cf40b86 100644

arch/arm/mach-exynos/include/mach/regs-pmu.h +7 -3
@@ -125,10 +125,14 @@
 
  #define S5P_GPS_ALIVE_LOWPWR                  S5P_PMUREG(0x13A0)
 
  #define S5P_ARM_CORE0_CONFIGURATION           S5P_PMUREG(0x2000)
 
+#define S5P_ARM_CORE0_STATUS                   S5P_PMUREG(0x2004)
 
  #define S5P_ARM_CORE0_OPTION                  S5P_PMUREG(0x2008)
 
-#define S5P_ARM_CORE1_CONFIGURATION            S5P_PMUREG(0x2080)
-#define S5P_ARM_CORE1_STATUS                   S5P_PMUREG(0x2084)
-#define S5P_ARM_CORE1_OPTION                   S5P_PMUREG(0x2088)
+#define S5P_ARM_CORE_CONFIGURATION(_nr)                \
+               (S5P_ARM_CORE0_CONFIGURATION + ((_nr) * 0x80))
+#define S5P_ARM_CORE_STATUS(_nr)               \
+               (S5P_ARM_CORE0_STATUS + ((_nr) * 0x80))
+#define S5P_ARM_CORE_OPTION(_nr)               \
+               (S5P_ARM_CORE0_OPTION + ((_nr) * 0x80))
 
  #define S5P_ARM_COMMON_OPTION                 S5P_PMUREG(0x2408)
  #define S5P_TOP_PWR_OPTION                    S5P_PMUREG(0x2C48)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/platsmp.c index d9c6d0a..2cbabc8 100644

arch/arm/mach-exynos/platsmp.c +0 -0
@@ -109,14 +109,15 @@ static int __cpuinit

exynos_boot_secondary(unsigned int cpu, struct task_struct */

Quoted 4 lines
        write_pen_release(phys_cpu);

- if (!(__raw_readl(S5P_ARM_CORE1_STATUS)&
S5P_CORE_LOCAL_PWR_EN))>>

{

Quoted 8 lines
arch/arm/mach-exynos/platsmp.c +3 -1
+       if (!(__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))
+       &  S5P_CORE_LOCAL_PWR_EN)) {
 
                __raw_writel(S5P_CORE_LOCAL_PWR_EN,
 
-                            S5P_ARM_CORE1_CONFIGURATION);
+                            S5P_ARM_CORE_CONFIGURATION(phys_cpu));
Quoted 6 lines
Quoted 6 lines

arch/arm/mach-exynos/platsmp.c static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct · line 120

Quoted 6 lines
                timeout = 10;

                /* wait max 10 ms until cpu1 is on */
arch/arm/mach-exynos/platsmp.c +1 -1
-               while ((__raw_readl(S5P_ARM_CORE1_STATUS)
+               while ((__raw_readl(S5P_ARM_CORE_STATUS(phys_cpu))

Ditto

Quoted 27 lines
Quoted 20 lines
Quoted 3 lines
                        &  S5P_CORE_LOCAL_PWR_EN) !=

S5P_CORE_LOCAL_PWR_EN)

{

Quoted 14 lines
                        if (timeout-- == 0)

                                break;
arch/arm/mach-exynos/platsmp.c +0 -0
@@ -125,7 +126,7 @@ static int __cpuinit

exynos_boot_secondary(unsigned
int cpu, struct task_struct }

                if (timeout == 0) {
arch/arm/mach-exynos/platsmp.c +1 -1
-                       printk(KERN_ERR "cpu1 power enable failed");
+                       printk(KERN_ERR "cpu%u power enable failed",

cpu);

Quoted 6 lines
Quoted 4 lines
                        spin_unlock(&boot_lock);
                        return -ETIMEDOUT;

                }

--

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap

#6 lore raw
In reply to Tomasz Figa
Quoted 62 lines · Tomasz Figa
Quoted 61 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 60 lines · Kukjin Kim
Quoted 13 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 5 lines
Quoted 2 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :) so this is available on exynos4412 and added 5420.

Quoted 10 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 4 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off
secondary cores by default.

I need to test on board about above...

Quoted 25 lines
Quoted 25 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu, int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

arch/arm/mach-exynos/hotplug.c static inline void cpu_leave_lowpower(void) · line 99

Quoted 4 lines
arch/arm/mach-exynos/hotplug.c +1 -3
-               /* make cpu1 to be turned off at next WFI command */
-               if (cpu == 1)
-                       __raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+               reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 12 lines

Hmm, according to the code initializing __cpu_logical_map[] array this is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Quoted 7 lines

Now the structure of the MPIDR register:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any problem here.

Define "physical CPU ID" :-)

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

You need to perform a mapping between logical cpus and registers offset, you can't use the cpu_logical_map directly for that.

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED), where cpu_logical_map is used erroneously as an index.

Lorenzo

#7 lore raw
Quoted 74 lines · Lorenzo Pieralisi
Quoted 62 lines · Tomasz Figa
Quoted 61 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 60 lines · Kukjin Kim
Quoted 13 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 5 lines
Quoted 2 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1), but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :) so this is available on exynos4412 and added 5420.

Quoted 10 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 4 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers off
secondary cores by default.

I need to test on board about above...

Quoted 25 lines
Quoted 25 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu, int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

arch/arm/mach-exynos/hotplug.c static inline void cpu_leave_lowpower(void) · line 99

Quoted 4 lines
arch/arm/mach-exynos/hotplug.c +1 -3
-               /* make cpu1 to be turned off at next WFI command */
-               if (cpu == 1)
-                       __raw_writel(0, S5P_ARM_CORE1_CONFIGURATION);
+               reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Quoted 1 line

Honestly, I did not understand the reasoning above, please clarify.

Sorry not non-zero MPIDR but non-zero ClusterID. All the power register addresses are at offset 0x80.

Quoted 30 lines
Quoted 13 lines

Hmm, according to the code initializing __cpu_logical_map[] array this is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Quoted 7 lines

Now the structure of the MPIDR register:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any problem here.

Define "physical CPU ID" :-)

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

Quoted 8 lines

You need to perform a mapping between logical cpus and registers offset, you can't use the cpu_logical_map directly for that.

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED), where cpu_logical_map is used erroneously as an index.

Lorenzo

--
with warm regards,
Chander Kashyap

#8 lore raw
In reply to Lorenzo Pieralisi
Quoted 110 lines · On Wednesday 19 of June 2013 14:24:17 Lorenzo Pieralisi wrote:
Quoted 68 lines · Tomasz Figa
Quoted 67 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 66 lines · Kukjin Kim
Quoted 14 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 7 lines
Quoted 3 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently
offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1),
but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :)
so this is available on exynos4412 and added 5420.

Quoted 11 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 5 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers
off
secondary cores by default.

I need to test on board about above...

Quoted 25 lines
Quoted 25 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu, int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-exynos/hotplug.c +0 -3
-               /* make cpu1 to be turned off at next WFI command
 */
-               if (cpu == 1)
-                       __raw_writel(0,

S5P_ARM_CORE1_CONFIGURATION);
+ reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Quoted 6 lines

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for
cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 15 lines

Hmm, according to the code initializing __cpu_logical_map[] array this is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/a
rch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/a
rch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

Quoted 7 lines

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CI
HEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any
problem here.

Define "physical CPU ID" :-)

Quoted 7 lines

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch
/arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

OK. This is what I was missing. Thanks.

Quoted 3 lines

You need to perform a mapping between logical cpus and registers offset, you can't use the cpu_logical_map directly for that.

Hmm, can't I just extract cluster ID and CPU ID from the MPIDR value and use them appropriately to calculate register offsets?

Best regards,
Tomasz

Quoted 4 lines

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED), where cpu_logical_map is used erroneously as an index.

Lorenzo

#9 lore raw
Quoted 119 lines · Tomasz Figa
Quoted 110 lines · On Wednesday 19 of June 2013 14:24:17 Lorenzo Pieralisi wrote:
Quoted 68 lines · Tomasz Figa
Quoted 67 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 66 lines · Kukjin Kim
Quoted 14 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 8 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for specified core.

Quoted 7 lines
Quoted 3 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently
offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu == 1),
but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :)
so this is available on exynos4412 and added 5420.

Quoted 11 lines

if logical cpu1 turned out not to be physical cpu1, then it would crash.

Best regards,
Tomasz

Quoted 5 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers
off
secondary cores by default.

I need to test on board about above...

Quoted 25 lines
Quoted 25 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu, int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
 
Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-exynos/hotplug.c +0 -3
-               /* make cpu1 to be turned off at next WFI command
 */
-               if (cpu == 1)
-                       __raw_writel(0,

S5P_ARM_CORE1_CONFIGURATION);
+ reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Quoted 6 lines

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for
cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 15 lines

Hmm, according to the code initializing __cpu_logical_map[] array this is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/a
rch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/a
rch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

Quoted 7 lines

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CI
HEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any
problem here.

Define "physical CPU ID" :-)

Quoted 7 lines

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch
/arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

Quoted 8 lines

OK. This is what I was missing. Thanks.

Quoted 3 lines

You need to perform a mapping between logical cpus and registers offset, you can't use the cpu_logical_map directly for that.

Hmm, can't I just extract cluster ID and CPU ID from the MPIDR value and use them appropriately to calculate register offsets?

That will create problem for multi-cluster systems. Say we have two clusters then with clusterID 0 and 1. So phys-cpu will be 0x0/0x100, 0x1/0x101 ans so on.

Quoted 8 lines

Best regards,
Tomasz

Quoted 4 lines

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED), where cpu_logical_map is used erroneously as an index.

Lorenzo

--
with warm regards,
Chander Kashyap

#10 lore raw
Quoted 138 lines · On Wednesday 19 of June 2013 19:25:27 Chander Kashyap wrote:
Quoted 137 lines · Tomasz Figa
Quoted 122 lines · On Wednesday 19 of June 2013 14:24:17 Lorenzo Pieralisi wrote:
Quoted 74 lines · Tomasz Figa
Quoted 73 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 72 lines · Kukjin Kim
Quoted 16 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 10 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further
cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for
specified core.

Quoted 8 lines
Quoted 3 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently
offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu ==
1),
but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :)
so this is available on exynos4412 and added 5420.

Quoted 4 lines

if logical cpu1 turned out not to be physical cpu1, then it would
crash.

Quoted 8 lines

Best regards,
Tomasz

Quoted 5 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers
off
secondary cores by default.

I need to test on board about above...

Quoted 27 lines
Quoted 27 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void
 cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu,
  int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-exynos/hotplug.c +0 -1
-               /* make cpu1 to be turned off at next WFI

command
*/

arch/arm/mach-exynos/hotplug.c +0 -2
-               if (cpu == 1)
-                       __raw_writel(0,

S5P_ARM_CORE1_CONFIGURATION);
+ reg_base =
S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Quoted 6 lines

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for
cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 18 lines

Hmm, according to the code initializing __cpu_logical_map[] array this
is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tre
e/a rch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tre
e/a rch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

Quoted 8 lines

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e
/CI
HEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any
problem here.

Define "physical CPU ID" :-)

Quoted 7 lines

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/a
rch /arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

OK. This is what I was missing. Thanks.

Quoted 3 lines

You need to perform a mapping between logical cpus and registers offset,
you can't use the cpu_logical_map directly for that.

Quoted 7 lines
Quoted 3 lines

Hmm, can't I just extract cluster ID and CPU ID from the MPIDR value and
use them appropriately to calculate register offsets?

That will create problem for multi-cluster systems. Say we have two clusters then with clusterID 0 and 1. So phys-cpu will be 0x0/0x100, 0x1/0x101 ans so on.

I mean, calculate register offset based on two parameters - cluster ID and CPU ID, like:

	...

	u32 mpidr = cpu_logical_map(cpu);
	u32 phys_cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);

	if (soc_is_exynosXXXX()) {
		u32 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);

		phys_cpu += EXYNOSXXXX_CPUS_PER_CLUSTER * cluster;
	}

	reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
	__raw_writel(0, reg_base);

	...

Best regards,
Tomasz

Quoted 15 lines
Quoted 7 lines

Best regards,
Tomasz

Quoted 4 lines

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED), where cpu_logical_map is used erroneously as an index.

Lorenzo

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
Quoted 150 lines · Tomasz Figa
Quoted 138 lines · On Wednesday 19 of June 2013 19:25:27 Chander Kashyap wrote:
Quoted 137 lines · Tomasz Figa
Quoted 122 lines · On Wednesday 19 of June 2013 14:24:17 Lorenzo Pieralisi wrote:
Quoted 74 lines · Tomasz Figa
Quoted 73 lines · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:
Quoted 72 lines · Kukjin Kim
Quoted 16 lines · Tomasz Figa

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 10 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further
cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with S5P_ARM_CORE_*(x) macro which return addresses of registers for
specified core.

Quoted 8 lines
Quoted 3 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently
offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Obviously this doesn't happen currently because of the if (cpu ==
1),
but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :)
so this is available on exynos4412 and added 5420.

Quoted 4 lines

if logical cpu1 turned out not to be physical cpu1, then it would
crash.

Quoted 8 lines

Best regards,
Tomasz

Quoted 5 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers
off
secondary cores by default.

I need to test on board about above...

Quoted 27 lines
Quoted 27 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9 +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10 +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9 +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void
 cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu,
  int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu = cpu_logical_map(cpu);
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-exynos/hotplug.c +0 -1
-               /* make cpu1 to be turned off at next WFI

command
*/

arch/arm/mach-exynos/hotplug.c +0 -2
-               if (cpu == 1)
-                       __raw_writel(0,

S5P_ARM_CORE1_CONFIGURATION);
+ reg_base =
S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Quoted 6 lines

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then for
cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION +
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 18 lines

Hmm, according to the code initializing __cpu_logical_map[] array this
is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tre
e/a rch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tre
e/a rch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

Quoted 8 lines

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e
/CI
HEBGFG.html

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see any
problem here.

Define "physical CPU ID" :-)

Quoted 7 lines

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/a
rch /arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

OK. This is what I was missing. Thanks.

Quoted 3 lines

You need to perform a mapping between logical cpus and registers offset,
you can't use the cpu_logical_map directly for that.

Quoted 7 lines
Quoted 3 lines

Hmm, can't I just extract cluster ID and CPU ID from the MPIDR value and
use them appropriately to calculate register offsets?

That will create problem for multi-cluster systems. Say we have two clusters then with clusterID 0 and 1. So phys-cpu will be 0x0/0x100, 0x1/0x101 ans so on.

I mean, calculate register offset based on two parameters - cluster ID and CPU ID, like:

Quoted 14 lines
        ...

        u32 mpidr = cpu_logical_map(cpu);
        u32 phys_cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);

        if (soc_is_exynosXXXX()) {
                u32 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);

                phys_cpu += EXYNOSXXXX_CPUS_PER_CLUSTER * cluster;
        }

        reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
        __raw_writel(0, reg_base);

This does not seems to viable solution, as eg. clusterID for exynos4210 is 0x9 and exynos 4412 is 0xa. But if we wass the cpu nodes thru DT, the we can comfortably rely on the logical cpu number. Also EXYNOSXXXX_CPUS_PER_CLUSTER can vary from cluster to cluster.

Quoted 20 lines
        ...

Best regards,
Tomasz

Quoted 15 lines
Quoted 7 lines

Best regards,
Tomasz

Quoted 4 lines

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED), where cpu_logical_map is used erroneously as an index.

Lorenzo

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap

#12 lore raw
Quoted 7 lines · On Wednesday 19 of June 2013 20:26:50 Chander Kashyap wrote:
Quoted 6 lines · Tomasz Figa
Quoted 5 lines · On Wednesday 19 of June 2013 19:25:27 Chander Kashyap wrote:
Quoted 4 lines · Tomasz Figa
Quoted 3 lines · On Wednesday 19 of June 2013 14:24:17 Lorenzo Pieralisi wrote:
Quoted 2 lines · Tomasz Figa
Quoted 1 line · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:

On 18 June 2013 23:29, Kukjin Kim <[email protected]>

Quoted 169 lines · wrote:
Quoted 169 lines
Quoted 147 lines
Quoted 147 lines
Quoted 132 lines
Quoted 88 lines
Quoted 88 lines
Quoted 87 lines · Tomasz Figa
Quoted 21 lines

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 11 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further
cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with
S5P_ARM_CORE_*(x) macro which return addresses of registers for
specified core.

Quoted 3 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently
offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Quoted 5 lines

Obviously this doesn't happen currently because of the if (cpu
==
1),
but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :)
so this is available on exynos4412 and added 5420.

Quoted 4 lines

if logical cpu1 turned out not to be physical cpu1, then it would
crash.

Quoted 8 lines

Best regards,
Tomasz

Quoted 5 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers
off
secondary cores by default.

I need to test on board about above...

Quoted 40 lines
Quoted 40 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9
  +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10
  +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9
  +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void
 cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu,
  int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu =

cpu_logical_map(cpu);

- /* make cpu1 to be turned off at next WFI
command
*/

arch/arm/mach-exynos/hotplug.c +0 -2
-               if (cpu == 1)
-                       __raw_writel(0,

S5P_ARM_CORE1_CONFIGURATION);
+ reg_base =
S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Quoted 8 lines
Quoted 8 lines

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then
for
cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION
+
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 25 lines

Hmm, according to the code initializing __cpu_logical_map[] array this
is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/
tre
e/a rch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/
tre
e/a rch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi03
88e
/CI
HEBGFG.html

Quoted 5 lines

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see
any
problem here.

Define "physical CPU ID" :-)

Quoted 8 lines

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tre
e/a
rch /arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

OK. This is what I was missing. Thanks.

Quoted 3 lines

You need to perform a mapping between logical cpus and registers offset,
you can't use the cpu_logical_map directly for that.

Quoted 7 lines
Quoted 3 lines

Hmm, can't I just extract cluster ID and CPU ID from the MPIDR value and
use them appropriately to calculate register offsets?

That will create problem for multi-cluster systems. Say we have two clusters then with clusterID 0 and 1. So phys-cpu will be 0x0/0x100, 0x1/0x101 ans so on.

I mean, calculate register offset based on two parameters - cluster ID and>
CPU ID, like:

        ...
        
        u32 mpidr = cpu_logical_map(cpu);
        u32 phys_cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
        
        if (soc_is_exynosXXXX()) {
        
                u32 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
                
                phys_cpu += EXYNOSXXXX_CPUS_PER_CLUSTER * cluster;
Quoted 7 lines
Quoted 4 lines
        }
        
        reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
        __raw_writel(0, reg_base);

This does not seems to viable solution, as eg. clusterID for exynos4210 is 0x9 and exynos 4412 is 0xa.

We don't need to consider cluster ID for any SoC that has just one cluster. That's why there is the if (soc_is_exynosXXXX()) clause, where exynosXXXX is the SoC that we support and has more clusters.

Quoted 3 lines

But if we wass the cpu nodes
thru DT, the we can comfortably rely on the logical cpu number. Also EXYNOSXXXX_CPUS_PER_CLUSTER can vary from cluster to cluster.

There is nothing that prevents you from specifying the CPUs in DT in different order. Moreover, even if you specify them in correct order, there is nothing that prevents you from using any of the listed CPUs as boot CPU, which will get the logical ID of 0.

Best regards,
Tomasz

Quoted 30 lines
Quoted 22 lines
        ...

Best regards,
Tomasz

Quoted 17 lines
Quoted 8 lines

Best regards,
Tomasz

Quoted 5 lines

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED),
where cpu_logical_map is used erroneously as an index.

Lorenzo

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw
Quoted 190 lines · Tomasz Figa
Quoted 7 lines · On Wednesday 19 of June 2013 20:26:50 Chander Kashyap wrote:
Quoted 6 lines · Tomasz Figa
Quoted 5 lines · On Wednesday 19 of June 2013 19:25:27 Chander Kashyap wrote:
Quoted 4 lines · Tomasz Figa
Quoted 3 lines · On Wednesday 19 of June 2013 14:24:17 Lorenzo Pieralisi wrote:
Quoted 2 lines · Tomasz Figa
Quoted 1 line · On Wednesday 19 of June 2013 17:39:21 Chander Kashyap wrote:

On 18 June 2013 23:29, Kukjin Kim <[email protected]>

Quoted 169 lines · wrote:
Quoted 169 lines
Quoted 147 lines
Quoted 147 lines
Quoted 132 lines
Quoted 88 lines
Quoted 88 lines
Quoted 87 lines · Tomasz Figa
Quoted 21 lines

Ccing Arnd and Olof, because I forgot to add them to git send-email...

Sorry for the noise.

Quoted 11 lines · On Tuesday 18 of June 2013 17:26:31 Tomasz Figa wrote:

S5P_ARM_CORE1_* registers affect only core 1. To control further
cores
properly another registers must be used.

This patch replaces S5P_ARM_CORE1_* register definitions with
S5P_ARM_CORE_*(x) macro which return addresses of registers for
specified core.

Quoted 3 lines

This fixes CPU hotplug on quad core Exynos SoCs on which currently
offlining CPUs 2 or 3 caused CPU 1 to be turned off.

Quoted 5 lines

Obviously this doesn't happen currently because of the if (cpu
==
1),
but>

Yes, not happened...and just note exynos5440 doesn't support hotplug :)
so this is available on exynos4412 and added 5420.

Quoted 4 lines

if logical cpu1 turned out not to be physical cpu1, then it would
crash.

Quoted 8 lines

Best regards,
Tomasz

Quoted 5 lines

In addition,
bring-up of CPU 2 and 3 is fixed on boards where bootloader powers
off
secondary cores by default.

I need to test on board about above...

Quoted 40 lines
Quoted 40 lines
Cc stable at vger.kernel.org

---

  arch/arm/mach-exynos/hotplug.c               |  9
  +++++----
  arch/arm/mach-exynos/include/mach/regs-pmu.h | 10
  +++++++---
  arch/arm/mach-exynos/platsmp.c               |  9
  +++++----
  3 files changed, 17 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index af90cfa..c089943 100644

arch/arm/mach-exynos/hotplug.c +2 -0
@@ -93,10 +93,11 @@ static inline void
 cpu_leave_lowpower(void)
 
  static inline void platform_do_lowpower(unsigned int cpu,
  int
 
 *spurious) {
 
        for (;;) {
 
+               void __iomem *reg_base;
+               unsigned int phys_cpu =

cpu_logical_map(cpu);

- /* make cpu1 to be turned off at next WFI
command
*/

arch/arm/mach-exynos/hotplug.c +0 -2
-               if (cpu == 1)
-                       __raw_writel(0,

S5P_ARM_CORE1_CONFIGURATION);
+ reg_base =
S5P_ARM_CORE_CONFIGURATION(phys_cpu);

Quoted 8 lines
Quoted 8 lines

Tomasz,
This will break for non-zero, MPIDR value. Say if MPIDR is 1 then
for
cpu0 phys_cpu value will be 0x100,
and address calculation will be (S5P_ARM_CORE0_CONFIGURATION
+
((0x101) * 0x80)), which is wrong.

Honestly, I did not understand the reasoning above, please clarify.

Quoted 25 lines

Hmm, according to the code initializing __cpu_logical_map[] array this
is not true.

Here's the code:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/
tre
e/a rch/arm/kernel/setup.c?id=refs/tags/next-20130619#n468

and for used macros and bitmasks:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/
tre
e/a rch/arm/include/asm/cputype.h?id=refs/tags/next-20130619#n45

Now the structure of the MPIDR register:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi03
88e
/CI
HEBGFG.html

Quoted 5 lines

As you can see, the value read from the register in smp_setup_processor_id() is only the physical CPU ID, so I don't see
any
problem here.

Define "physical CPU ID" :-)

Quoted 8 lines

There is a problem here: the MPIDR is not an index, and the cpu_logical_map is populated in arm_dt_init_cpu_maps in:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tre
e/a
rch /arm/kernel/devtree.c?id=refs/tags/v3.10-rc6

with all affinity levels.

OK. This is what I was missing. Thanks.

Quoted 3 lines

You need to perform a mapping between logical cpus and registers offset,
you can't use the cpu_logical_map directly for that.

Quoted 7 lines
Quoted 3 lines

Hmm, can't I just extract cluster ID and CPU ID from the MPIDR value and
use them appropriately to calculate register offsets?

That will create problem for multi-cluster systems. Say we have two clusters then with clusterID 0 and 1. So phys-cpu will be 0x0/0x100, 0x1/0x101 ans so on.

I mean, calculate register offset based on two parameters - cluster ID and>
CPU ID, like:

        ...

        u32 mpidr = cpu_logical_map(cpu);
        u32 phys_cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);

        if (soc_is_exynosXXXX()) {

                u32 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);

                phys_cpu += EXYNOSXXXX_CPUS_PER_CLUSTER * cluster;
Quoted 7 lines
Quoted 4 lines
        }

        reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
        __raw_writel(0, reg_base);

This does not seems to viable solution, as eg. clusterID for exynos4210 is 0x9 and exynos 4412 is 0xa.

We don't need to consider cluster ID for any SoC that has just one cluster. That's why there is the if (soc_is_exynosXXXX()) clause, where exynosXXXX is the SoC that we support and has more clusters.

Quoted 8 lines
Quoted 3 lines

But if we wass the cpu nodes
thru DT, the we can comfortably rely on the logical cpu number. Also EXYNOSXXXX_CPUS_PER_CLUSTER can vary from cluster to cluster.

There is nothing that prevents you from specifying the CPUs in DT in different order. Moreover, even if you specify them in correct order, there is nothing that prevents you from using any of the listed CPUs as boot CPU, which will get the logical ID of 0.

Ah Sorry I missed this point.
Then either pass the power register address thru dt or do the way you described. Thanks

Quoted 34 lines

Best regards,
Tomasz

Quoted 30 lines
Quoted 22 lines
        ...

Best regards,
Tomasz

Quoted 17 lines
Quoted 8 lines

Best regards,
Tomasz

Quoted 5 lines

Next accident waiting to happen is GIC code (CONFIG_GIC_NON_BANKED),
where cpu_logical_map is used erroneously as an index.

Lorenzo

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

--
with warm regards,
Chander Kashyap

#14 lore raw
In reply to Tomasz Figa
Quoted 28 lines · Tomasz Figa
Quoted 15 lines · On Wednesday 19 of June 2013 20:26:50 Chander Kashyap wrote:
Quoted 14 lines · Tomasz Figa

I mean, calculate register offset based on two parameters - cluster ID and>
CPU ID, like:

        ...
        
        u32 mpidr = cpu_logical_map(cpu);
        u32 phys_cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
        
        if (soc_is_exynosXXXX()) {
        
                u32 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
                
                phys_cpu += EXYNOSXXXX_CPUS_PER_CLUSTER * cluster;
Quoted 7 lines
Quoted 4 lines
        }
        
        reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
        __raw_writel(0, reg_base);

This does not seems to viable solution, as eg. clusterID for exynos4210 is 0x9 and exynos 4412 is 0xa.

We don't need to consider cluster ID for any SoC that has just one cluster. That's why there is the if (soc_is_exynosXXXX()) clause, where exynosXXXX is the SoC that we support and has more clusters.

Quoted 8 lines
Quoted 3 lines

But if we wass the cpu nodes
thru DT, the we can comfortably rely on the logical cpu number. Also EXYNOSXXXX_CPUS_PER_CLUSTER can vary from cluster to cluster.

There is nothing that prevents you from specifying the CPUs in DT in different order. Moreover, even if you specify them in correct order, there is nothing that prevents you from using any of the listed CPUs as boot CPU, which will get the logical ID of 0.

Relying on the logical CPU number to index into hardware related register space is wrong, please don't do that.

If the MPIDR allocation isn't linear then this cannot be used either.

The best solution is probably to add this reg_base as a property of each CPU node in DT, and extract it at boot time to stash it into an array which can be indexed with the logical CPU number afterwards.

Nicolas

#15 lore raw
Quoted 40 lines · On Wednesday 19 of June 2013 11:19:30 Nicolas Pitre wrote:
Quoted 30 lines · Tomasz Figa
Quoted 17 lines · On Wednesday 19 of June 2013 20:26:50 Chander Kashyap wrote:
Quoted 16 lines · Tomasz Figa

I mean, calculate register offset based on two parameters - cluster ID
and>

CPU ID, like:

        ...
        
        u32 mpidr = cpu_logical_map(cpu);
        u32 phys_cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
        
        if (soc_is_exynosXXXX()) {
        
                u32 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
                
                phys_cpu += EXYNOSXXXX_CPUS_PER_CLUSTER * cluster;
Quoted 7 lines
Quoted 4 lines
        }
        
        reg_base = S5P_ARM_CORE_CONFIGURATION(phys_cpu);
        __raw_writel(0, reg_base);

This does not seems to viable solution, as eg. clusterID for exynos4210 is 0x9 and exynos 4412 is 0xa.

We don't need to consider cluster ID for any SoC that has just one cluster. That's why there is the if (soc_is_exynosXXXX()) clause, where exynosXXXX is the SoC that we support and has more clusters.

Quoted 8 lines
Quoted 3 lines

But if we wass the cpu nodes
thru DT, the we can comfortably rely on the logical cpu number. Also EXYNOSXXXX_CPUS_PER_CLUSTER can vary from cluster to cluster.

There is nothing that prevents you from specifying the CPUs in DT in different order. Moreover, even if you specify them in correct order, there is nothing that prevents you from using any of the listed CPUs as boot CPU, which will get the logical ID of 0.

Quoted 8 lines

Relying on the logical CPU number to index into hardware related register space is wrong, please don't do that.

If the MPIDR allocation isn't linear then this cannot be used either.

The best solution is probably to add this reg_base as a property of each CPU node in DT, and extract it at boot time to stash it into an array which can be indexed with the logical CPU number afterwards.

Currently we don't specify the cpu node in DT at all for Exynos 4210, 4212 and 4412. It's sure that their device tree sources need to be modified to correct his, but since DT is considered an ABI, we should keep compatibility with old device tree blobs.

This means that we can't strictly require this property to be present in device tree, because it will break existing boards with older device trees. So my suggestion is to user cluster ID and CPU ID to calculate the offset by default and add possibility to override it with a property in device tree if such need shows up.

What do you think?

Best regards,
Tomasz

Quoted 5 lines

Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html