linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks
@ 2016-06-19  1:09 Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 1/5] i.MX: system.c: Convert goto to if statement Andrey Smirnov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Andrey Smirnov @ 2016-06-19  1:09 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrey Smirnov, Russell King, Shawn Guo, Sascha Hauer,
	Uwe Kleine-König, Arnd Bergmann, linux-kernel

Hi everyone,

Here's the fourth (aka v3 with patch 3/5 not broken) version of i.MX
L2-cache related patches. Here's what's new from v2:

       - Generic ARM patches were split into a separte series

       - Typo and whitespace fixes (as per Uwe's suggestions)

       - Re-ordered l2c_aux_val, and l2c_aux_mask such that
         initializers are placed in the order of their declaration.

Let me know if any more changes to the series are needed.

Andrey Smirnov

Andrey Smirnov (5):
  i.MX: system.c: Convert goto to if statement
  i.MX: system.c: Remove redundant errata 752271 code
  i.MX: system.c: Replace magic numbers
  i.MX: system.c: Tweak prefetch settings for performance
  i.MX: Do not explicitly call l2x0_of_init()

 arch/arm/mach-imx/imx35-dt.c    | 10 +++-------
 arch/arm/mach-imx/mach-imx6q.c  |  2 ++
 arch/arm/mach-imx/mach-imx6sl.c |  2 ++
 arch/arm/mach-imx/mach-imx6sx.c |  2 ++
 arch/arm/mach-imx/system.c      | 42 ++++++++++++++++-------------------------
 5 files changed, 25 insertions(+), 33 deletions(-)

-- 
2.5.5

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

* [PATCH v4 1/5] i.MX: system.c: Convert goto to if statement
  2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
@ 2016-06-19  1:09 ` Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 2/5] i.MX: system.c: Remove redundant errata 752271 code Andrey Smirnov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2016-06-19  1:09 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrey Smirnov, Russell King, Shawn Guo, Sascha Hauer,
	Uwe Kleine-König, Arnd Bergmann, linux-kernel

Using goto here doesn't bring any advantages and only makes the code
flow less clear. No functional changes.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/system.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c
index 105d1ce..d9f8b0e 100644
--- a/arch/arm/mach-imx/system.c
+++ b/arch/arm/mach-imx/system.c
@@ -106,26 +106,24 @@ void __init imx_init_l2cache(void)
 		goto out;
 	}
 
-	if (readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)
-		goto skip_if_enabled;
-
-	/* Configure the L2 PREFETCH and POWER registers */
-	val = readl_relaxed(l2x0_base + L310_PREFETCH_CTRL);
-	val |= 0x70800000;
-	/*
-	 * The L2 cache controller(PL310) version on the i.MX6D/Q is r3p1-50rel0
-	 * The L2 cache controller(PL310) version on the i.MX6DL/SOLO/SL is r3p2
-	 * But according to ARM PL310 errata: 752271
-	 * ID: 752271: Double linefill feature can cause data corruption
-	 * Fault Status: Present in: r3p0, r3p1, r3p1-50rel0. Fixed in r3p2
-	 * Workaround: The only workaround to this erratum is to disable the
-	 * double linefill feature. This is the default behavior.
-	 */
-	if (cpu_is_imx6q())
-		val &= ~(1 << 30 | 1 << 23);
-	writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL);
+	if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) {
+		/* Configure the L2 PREFETCH and POWER registers */
+		val = readl_relaxed(l2x0_base + L310_PREFETCH_CTRL);
+		val |= 0x70800000;
+		/*
+		 * The L2 cache controller(PL310) version on the i.MX6D/Q is r3p1-50rel0
+		 * The L2 cache controller(PL310) version on the i.MX6DL/SOLO/SL is r3p2
+		 * But according to ARM PL310 errata: 752271
+		 * ID: 752271: Double linefill feature can cause data corruption
+		 * Fault Status: Present in: r3p0, r3p1, r3p1-50rel0. Fixed in r3p2
+		 * Workaround: The only workaround to this erratum is to disable the
+		 * double linefill feature. This is the default behavior.
+		 */
+		if (cpu_is_imx6q())
+			val &= ~(1 << 30 | 1 << 23);
+		writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL);
+	}
 
-skip_if_enabled:
 	iounmap(l2x0_base);
 	of_node_put(np);
 
-- 
2.5.5

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

* [PATCH v4 2/5] i.MX: system.c: Remove redundant errata 752271 code
  2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 1/5] i.MX: system.c: Convert goto to if statement Andrey Smirnov
@ 2016-06-19  1:09 ` Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 3/5] i.MX: system.c: Replace magic numbers Andrey Smirnov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2016-06-19  1:09 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrey Smirnov, Russell King, Shawn Guo, Sascha Hauer,
	Uwe Kleine-König, Arnd Bergmann, linux-kernel

Applying a fix for ARM errata 752271 would already be taken care by a
call to a 'fixup' hook as a part of l2x0_of_init() -> __l2c_init() call
chain. Moreso the code in 'fixup' function would do that based on the
PL310's revsion information, whereas removed code does so based on SoC
version which does not work very well on i.MX6Q+ which identifies itself
as i.MX6Q as well but is not affected by 752271.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/system.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c
index d9f8b0e..b153376 100644
--- a/arch/arm/mach-imx/system.c
+++ b/arch/arm/mach-imx/system.c
@@ -110,17 +110,6 @@ void __init imx_init_l2cache(void)
 		/* Configure the L2 PREFETCH and POWER registers */
 		val = readl_relaxed(l2x0_base + L310_PREFETCH_CTRL);
 		val |= 0x70800000;
-		/*
-		 * The L2 cache controller(PL310) version on the i.MX6D/Q is r3p1-50rel0
-		 * The L2 cache controller(PL310) version on the i.MX6DL/SOLO/SL is r3p2
-		 * But according to ARM PL310 errata: 752271
-		 * ID: 752271: Double linefill feature can cause data corruption
-		 * Fault Status: Present in: r3p0, r3p1, r3p1-50rel0. Fixed in r3p2
-		 * Workaround: The only workaround to this erratum is to disable the
-		 * double linefill feature. This is the default behavior.
-		 */
-		if (cpu_is_imx6q())
-			val &= ~(1 << 30 | 1 << 23);
 		writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL);
 	}
 
-- 
2.5.5

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

* [PATCH v4 3/5] i.MX: system.c: Replace magic numbers
  2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 1/5] i.MX: system.c: Convert goto to if statement Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 2/5] i.MX: system.c: Remove redundant errata 752271 code Andrey Smirnov
@ 2016-06-19  1:09 ` Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 4/5] i.MX: system.c: Tweak prefetch settings for performance Andrey Smirnov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2016-06-19  1:09 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrey Smirnov, Russell King, Shawn Guo, Sascha Hauer,
	Uwe Kleine-König, Arnd Bergmann, linux-kernel

Replace magic numbers used to form L310 Prefetch Control Register value.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/system.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c
index b153376..76d7ebe 100644
--- a/arch/arm/mach-imx/system.c
+++ b/arch/arm/mach-imx/system.c
@@ -109,7 +109,10 @@ void __init imx_init_l2cache(void)
 	if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) {
 		/* Configure the L2 PREFETCH and POWER registers */
 		val = readl_relaxed(l2x0_base + L310_PREFETCH_CTRL);
-		val |= 0x70800000;
+		val |= L310_PREFETCH_CTRL_DBL_LINEFILL |
+			L310_PREFETCH_CTRL_INSTR_PREFETCH |
+			L310_PREFETCH_CTRL_DATA_PREFETCH |
+			L310_PREFETCH_CTRL_DBL_LINEFILL_INCR;
 		writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL);
 	}
 
-- 
2.5.5

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

* [PATCH v4 4/5] i.MX: system.c: Tweak prefetch settings for performance
  2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
                   ` (2 preceding siblings ...)
  2016-06-19  1:09 ` [PATCH v4 3/5] i.MX: system.c: Replace magic numbers Andrey Smirnov
@ 2016-06-19  1:09 ` Andrey Smirnov
  2016-06-19  1:09 ` [PATCH v4 5/5] i.MX: Do not explicitly call l2x0_of_init() Andrey Smirnov
  2016-06-21 13:41 ` [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Shawn Guo
  5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2016-06-19  1:09 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrey Smirnov, Russell King, Shawn Guo, Sascha Hauer,
	Uwe Kleine-König, Arnd Bergmann, linux-kernel

Update Prefetch Control Register settings to match that of Freescale's
Linux tree. As the commit e3addf1b773964eac7f797e8538c69481be4279c
states (author Nitin Garg):

"... set Prefetch offset to 15, since it improves memcpy performance by
35%. Don't enable Incr double Linefill enable since it adversely affects
memcpy performance by about 32MB/s and reads by 90MB/s. Tested with 4K
to 16MB sized src and dst aligned buffer..."

Those results are also corroborated by our own testing.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/system.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c
index 76d7ebe..bf7ab77 100644
--- a/arch/arm/mach-imx/system.c
+++ b/arch/arm/mach-imx/system.c
@@ -111,8 +111,12 @@ void __init imx_init_l2cache(void)
 		val = readl_relaxed(l2x0_base + L310_PREFETCH_CTRL);
 		val |= L310_PREFETCH_CTRL_DBL_LINEFILL |
 			L310_PREFETCH_CTRL_INSTR_PREFETCH |
-			L310_PREFETCH_CTRL_DATA_PREFETCH |
-			L310_PREFETCH_CTRL_DBL_LINEFILL_INCR;
+			L310_PREFETCH_CTRL_DATA_PREFETCH;
+
+		/* Set perfetch offset to improve performance */
+		val &= ~L310_PREFETCH_CTRL_OFFSET_MASK;
+		val |= 15;
+
 		writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL);
 	}
 
-- 
2.5.5

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

* [PATCH v4 5/5] i.MX: Do not explicitly call l2x0_of_init()
  2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
                   ` (3 preceding siblings ...)
  2016-06-19  1:09 ` [PATCH v4 4/5] i.MX: system.c: Tweak prefetch settings for performance Andrey Smirnov
@ 2016-06-19  1:09 ` Andrey Smirnov
  2016-06-21 13:41 ` [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Shawn Guo
  5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2016-06-19  1:09 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrey Smirnov, Russell King, Shawn Guo, Sascha Hauer,
	Uwe Kleine-König, Arnd Bergmann, linux-kernel

There's no need to explicitly call l2x0_of_init() since it will be
called as a part of init_IRQ() (see arch/arm/kernel/irq.c for
details). This way we can simplify imx_init_l2cache() and ditch the call
to it on i.MX35 (which does not claim compatibility with
"arm,pl310-cache") alltogether.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx35-dt.c    | 10 +++-------
 arch/arm/mach-imx/mach-imx6q.c  |  2 ++
 arch/arm/mach-imx/mach-imx6sl.c |  2 ++
 arch/arm/mach-imx/mach-imx6sx.c |  2 ++
 arch/arm/mach-imx/system.c      | 12 ++++--------
 5 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-imx/imx35-dt.c b/arch/arm/mach-imx/imx35-dt.c
index e939603..99bb63d 100644
--- a/arch/arm/mach-imx/imx35-dt.c
+++ b/arch/arm/mach-imx/imx35-dt.c
@@ -20,20 +20,16 @@
 #include "common.h"
 #include "mx35.h"
 
-static void __init imx35_irq_init(void)
-{
-	imx_init_l2cache();
-	mx35_init_irq();
-}
-
 static const char * const imx35_dt_board_compat[] __initconst = {
 	"fsl,imx35",
 	NULL
 };
 
 DT_MACHINE_START(IMX35_DT, "Freescale i.MX35 (Device Tree Support)")
+	.l2c_aux_val 	= 0,
+	.l2c_aux_mask	= ~0,
 	.map_io		= mx35_map_io,
 	.init_early	= imx35_init_early,
-	.init_irq	= imx35_irq_init,
+	.init_irq	= mx35_init_irq,
 	.dt_compat	= imx35_dt_board_compat,
 MACHINE_END
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index cb27d56..b31890f 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -407,6 +407,8 @@ static const char * const imx6q_dt_compat[] __initconst = {
 };
 
 DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
+	.l2c_aux_val 	= 0,
+	.l2c_aux_mask	= ~0,
 	.smp		= smp_ops(imx_smp_ops),
 	.map_io		= imx6q_map_io,
 	.init_irq	= imx6q_init_irq,
diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c
index 3003263..f9a9a36 100644
--- a/arch/arm/mach-imx/mach-imx6sl.c
+++ b/arch/arm/mach-imx/mach-imx6sl.c
@@ -75,6 +75,8 @@ static const char * const imx6sl_dt_compat[] __initconst = {
 };
 
 DT_MACHINE_START(IMX6SL, "Freescale i.MX6 SoloLite (Device Tree)")
+	.l2c_aux_val 	= 0,
+	.l2c_aux_mask	= ~0,
 	.init_irq	= imx6sl_init_irq,
 	.init_machine	= imx6sl_init_machine,
 	.init_late      = imx6sl_init_late,
diff --git a/arch/arm/mach-imx/mach-imx6sx.c b/arch/arm/mach-imx/mach-imx6sx.c
index 6a0b061..07a3a34 100644
--- a/arch/arm/mach-imx/mach-imx6sx.c
+++ b/arch/arm/mach-imx/mach-imx6sx.c
@@ -103,6 +103,8 @@ static const char * const imx6sx_dt_compat[] __initconst = {
 };
 
 DT_MACHINE_START(IMX6SX, "Freescale i.MX6 SoloX (Device Tree)")
+	.l2c_aux_val 	= 0,
+	.l2c_aux_mask	= ~0,
 	.init_irq	= imx6sx_init_irq,
 	.init_machine	= imx6sx_init_machine,
 	.dt_compat	= imx6sx_dt_compat,
diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c
index bf7ab77..e442ed7 100644
--- a/arch/arm/mach-imx/system.c
+++ b/arch/arm/mach-imx/system.c
@@ -98,13 +98,11 @@ void __init imx_init_l2cache(void)
 
 	np = of_find_compatible_node(NULL, NULL, "arm,pl310-cache");
 	if (!np)
-		goto out;
+		return;
 
 	l2x0_base = of_iomap(np, 0);
-	if (!l2x0_base) {
-		of_node_put(np);
-		goto out;
-	}
+	if (!l2x0_base)
+		goto put_node;
 
 	if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) {
 		/* Configure the L2 PREFETCH and POWER registers */
@@ -121,9 +119,7 @@ void __init imx_init_l2cache(void)
 	}
 
 	iounmap(l2x0_base);
+put_node:
 	of_node_put(np);
-
-out:
-	l2x0_of_init(0, ~0);
 }
 #endif
-- 
2.5.5

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

* Re: [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks
  2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
                   ` (4 preceding siblings ...)
  2016-06-19  1:09 ` [PATCH v4 5/5] i.MX: Do not explicitly call l2x0_of_init() Andrey Smirnov
@ 2016-06-21 13:41 ` Shawn Guo
  5 siblings, 0 replies; 7+ messages in thread
From: Shawn Guo @ 2016-06-21 13:41 UTC (permalink / raw)
  To: Andrey Smirnov
  Cc: linux-arm-kernel, Russell King, Arnd Bergmann, linux-kernel,
	Sascha Hauer, Uwe Kleine-König

On Sat, Jun 18, 2016 at 06:09:26PM -0700, Andrey Smirnov wrote:
> Andrey Smirnov (5):
>   i.MX: system.c: Convert goto to if statement
>   i.MX: system.c: Remove redundant errata 752271 code
>   i.MX: system.c: Replace magic numbers
>   i.MX: system.c: Tweak prefetch settings for performance
>   i.MX: Do not explicitly call l2x0_of_init()

Applied all, thanks.

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

end of thread, other threads:[~2016-06-21 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-19  1:09 [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks Andrey Smirnov
2016-06-19  1:09 ` [PATCH v4 1/5] i.MX: system.c: Convert goto to if statement Andrey Smirnov
2016-06-19  1:09 ` [PATCH v4 2/5] i.MX: system.c: Remove redundant errata 752271 code Andrey Smirnov
2016-06-19  1:09 ` [PATCH v4 3/5] i.MX: system.c: Replace magic numbers Andrey Smirnov
2016-06-19  1:09 ` [PATCH v4 4/5] i.MX: system.c: Tweak prefetch settings for performance Andrey Smirnov
2016-06-19  1:09 ` [PATCH v4 5/5] i.MX: Do not explicitly call l2x0_of_init() Andrey Smirnov
2016-06-21 13:41 ` [PATCH v4 0/5] i.MX L2-cache code cleanups and performance tweaks 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).