linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ARM: imx: replicate the diagnostic register of boot cpu into secondary cores
@ 2013-04-25 15:18 Shawn Guo
  2013-04-25 15:21 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Guo @ 2013-04-25 15:18 UTC (permalink / raw)
  To: linux-arm-kernel

The diagnostic register holds the errata bits.  Mostly bootloader
does not bring up secondary cores, so that when errata bits are set
in bootloader, they are set only for boot cpu.  But on a SMP
configuration, it should be equally done on every single core.
Set up the diagnostic register for secondary cores by replicating
the register from boot cpu.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
Changes since v1:
 * Move get_diag_reg() and set_diag_reg() into IMX file, as Will has
   concern to have it be globally available.

 arch/arm/mach-imx/platsmp.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm/mach-imx/platsmp.c b/arch/arm/mach-imx/platsmp.c
index 7061bde..b13458f 100644
--- a/arch/arm/mach-imx/platsmp.c
+++ b/arch/arm/mach-imx/platsmp.c
@@ -23,6 +23,7 @@
 #define SCU_STANDBY_ENABLE	(1 << 5)
 
 static void __iomem *scu_base;
+static u32 diag_reg;
 
 static struct map_desc scu_io_desc __initdata = {
 	/* .virtual and .pfn are run-time assigned */
@@ -52,6 +53,19 @@ void imx_scu_standby_enable(void)
 	writel_relaxed(val, scu_base);
 }
 
+static inline unsigned int get_diag_reg(void)
+{
+	unsigned int val;
+	asm("mrc p15, 0, %0, c15, c0, 1" : "=r" (val) : : "cc");
+	return val;
+}
+
+static inline void set_diag_reg(unsigned int val)
+{
+	asm volatile("mcr p15, 0, %0, c15, c0, 1" : : "r" (val) : "cc");
+	isb();
+}
+
 static void __cpuinit imx_secondary_init(unsigned int cpu)
 {
 	/*
@@ -60,6 +74,9 @@ static void __cpuinit imx_secondary_init(unsigned int cpu)
 	 * for us: do so
 	 */
 	gic_secondary_init(0);
+
+	/* Replicate the diagnostic register of boot cpu */
+	set_diag_reg(diag_reg);
 }
 
 static int __cpuinit imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
@@ -91,6 +108,16 @@ void imx_smp_prepare(void)
 static void __init imx_smp_prepare_cpus(unsigned int max_cpus)
 {
 	imx_smp_prepare();
+
+	/*
+	 * The diagnostic register holds the errata bits.  Mostly bootloader
+	 * does not bring up secondary cores, so that when errata bits are set
+	 * in bootloader, they are set only for boot cpu.  But on a SMP
+	 * configuration, it should be equally done on every single core.
+	 * Read the register from boot cpu here, and will replicate it into
+	 * secondary cores when booting them.
+	 */
+	diag_reg = get_diag_reg();
 }
 
 struct smp_operations  imx_smp_ops __initdata = {
-- 
1.7.9.5

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

* [PATCH v2] ARM: imx: replicate the diagnostic register of boot cpu into secondary cores
  2013-04-25 15:18 [PATCH v2] ARM: imx: replicate the diagnostic register of boot cpu into secondary cores Shawn Guo
@ 2013-04-25 15:21 ` Will Deacon
  2013-04-26  3:52   ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2013-04-25 15:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shawn,

On Thu, Apr 25, 2013 at 04:18:35PM +0100, Shawn Guo wrote:
> The diagnostic register holds the errata bits.  Mostly bootloader
> does not bring up secondary cores, so that when errata bits are set
> in bootloader, they are set only for boot cpu.  But on a SMP
> configuration, it should be equally done on every single core.
> Set up the diagnostic register for secondary cores by replicating
> the register from boot cpu.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> Changes since v1:
>  * Move get_diag_reg() and set_diag_reg() into IMX file, as Will has
>    concern to have it be globally available.
> 
>  arch/arm/mach-imx/platsmp.c |   27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/platsmp.c b/arch/arm/mach-imx/platsmp.c
> index 7061bde..b13458f 100644
> --- a/arch/arm/mach-imx/platsmp.c
> +++ b/arch/arm/mach-imx/platsmp.c
> @@ -23,6 +23,7 @@
>  #define SCU_STANDBY_ENABLE	(1 << 5)
>  
>  static void __iomem *scu_base;
> +static u32 diag_reg;
>  
>  static struct map_desc scu_io_desc __initdata = {
>  	/* .virtual and .pfn are run-time assigned */
> @@ -52,6 +53,19 @@ void imx_scu_standby_enable(void)
>  	writel_relaxed(val, scu_base);
>  }
>  
> +static inline unsigned int get_diag_reg(void)
> +{
> +	unsigned int val;
> +	asm("mrc p15, 0, %0, c15, c0, 1" : "=r" (val) : : "cc");
> +	return val;
> +}
> +
> +static inline void set_diag_reg(unsigned int val)
> +{
> +	asm volatile("mcr p15, 0, %0, c15, c0, 1" : : "r" (val) : "cc");
> +	isb();
> +}

I'm still against setting this register with the MMU enabled. It is a
CPU-specific, undocumented register so it's hard for me to make a case here,
but the feedback from the hardware guys is that this may have unintended
consequences.

Will

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

* [PATCH v2] ARM: imx: replicate the diagnostic register of boot cpu into secondary cores
  2013-04-25 15:21 ` Will Deacon
@ 2013-04-26  3:52   ` Shawn Guo
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2013-04-26  3:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 25, 2013 at 04:21:52PM +0100, Will Deacon wrote:
> I'm still against setting this register with the MMU enabled. It is a
> CPU-specific, undocumented register so it's hard for me to make a case here,
> but the feedback from the hardware guys is that this may have unintended
> consequences.

I see that Exynos cpuidle driver has been doing that since Mar last
year.  But I respect your comment and will try to set the register
before MMU is enabled.

Shawn

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

end of thread, other threads:[~2013-04-26  3:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25 15:18 [PATCH v2] ARM: imx: replicate the diagnostic register of boot cpu into secondary cores Shawn Guo
2013-04-25 15:21 ` Will Deacon
2013-04-26  3:52   ` Shawn Guo

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