Skip to contentSkip to conversation

OMAP4: Add L2 Cache support

PATCH Superseded Santosh Shilimkar 4 participants 8 messages Jan 29, 2010 – Feb 2, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 OMAP4: Add L2 Cache support

This patch adds L2 Cache support for OMAP4. External L2 cache is used in OMPA4

---
 arch/arm/mach-omap2/board-4430sdp.c        |   33 ++++++++++++++++++++++++++++
 arch/arm/mm/Kconfig                        |    2 +-
 arch/arm/plat-omap/include/plat/omap44xx.h |    1 +
 3 files changed, 35 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/board-4430sdp.c +33 -0
index 0c6be6b..194d633 100644
@@ -28,6 +28,7 @@
 #include <plat/control.h>
 #include <plat/timer-gp.h>
 #include <asm/hardware/gic.h>
+#include <asm/hardware/cache-l2x0.h>
 
 static struct platform_device sdp4430_lcd_device = {
 	.name		= "sdp4430_lcd",
@@ -49,6 +50,38 @@ static struct omap_lcd_config sdp4430_lcd_config __initdata = {
 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&sdp4430_lcd_config },
 };
+#ifdef CONFIG_CACHE_L2X0
+static int __init omap_l2_cache_init(void)
+{
+	void __iomem *l2cache_base;
+
+	/* Static mapping, never released */
+	l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
+	BUG_ON(!l2cache_base);
+
+	/* Enable L2 Cache using secure api
+	 * r0 contains the value to be modified and "r12" contains
+	 * the monitor API number. This API uses few CPU registers
+	 * internally and hence they need be backed up including
+	 * link register "lr".
+	 */
+	__asm__ __volatile__(
+		"stmfd r13!, {r0-r12, r14}\n"
+		"mov r0, #1\n"
+		"ldr r12, =0x102\n"
+		"dsb\n"
+		"smc\n"
+		"ldmfd r13!, {r0-r12, r14}");
+
+	/* 32KB way size, 16-way associativity,
+	* parity disabled
+	*/
+	l2x0_init(l2cache_base, 0x0e050000, 0xc0000fff);
+
+	return 0;
+}
+early_initcall(omap_l2_cache_init);
+#endif
 
 static void __init gic_init_irq(void)
 {
arch/arm/mm/Kconfig +1 -1
index baf6384..696e83e 100644
@@ -754,7 +754,7 @@ config CACHE_FEROCEON_L2_WRITETHROUGH
 config CACHE_L2X0
 	bool "Enable the L2x0 outer cache controller"
 	depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176 || \
-		   REALVIEW_EB_A9MP || ARCH_MX35 || ARCH_MX31 || MACH_REALVIEW_PBX || ARCH_NOMADIK
+		   REALVIEW_EB_A9MP || ARCH_MX35 || ARCH_MX31 || MACH_REALVIEW_PBX || ARCH_NOMADIK || ARCH_OMAP4
 	default y
 	select OUTER_CACHE
 	help
arch/arm/plat-omap/include/plat/omap44xx.h +1 -0
index ef870de..c7d628e 100644
@@ -40,6 +40,7 @@
 #define OMAP44XX_GIC_CPU_BASE		0x48240100
 #define OMAP44XX_SCU_BASE		0x48240000
 #define OMAP44XX_LOCAL_TWD_BASE		0x48240600
+#define OMAP44XX_L2CACHE_BASE		0x48242000
 #define OMAP44XX_WKUPGEN_BASE		0x48281000
 
 #define OMAP44XX_MAILBOX_BASE		(L4_44XX_BASE + 0xF4000)
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/3 OMAP4: Clean the secondary_data from L2

The boot_secondary() needs to call outer_clean_range() because the L2 cache is already enabled in the kernel boot with early_initcall

---
 arch/arm/mach-omap2/omap-smp.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap-smp.c +2 -0
index 38153e5..2d0733a 100644
@@ -73,6 +73,8 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * the AuxCoreBoot1 register is updated with cpu state
 	 * A barrier is added to ensure that write buffer is drained
 	 */
+	flush_cache_all();
+	outer_clean_range(__pa(&secondary_data), __pa(&secondary_data + 1));
 	omap_modify_auxcoreboot0(0x200, 0x0);
 	flush_cache_all();
 	smp_wmb();
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 3/3 OMAP4: Enable L2 Cache

This patch enables L2 cache and associated Errata on the OMAP4430 SDP.

---
 arch/arm/configs/omap_4430sdp_defconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/configs/omap_4430sdp_defconfig +2 -0
index 3de640a..781770f 100644
@@ -242,6 +242,8 @@ CONFIG_CPU_CP15_MMU=y
 # CONFIG_CPU_DCACHE_DISABLE is not set
 # CONFIG_CPU_BPREDICT_DISABLE is not set
 CONFIG_HAS_TLS_REG=y
+CONFIG_OUTER_CACHE=y
+CONFIG_CACHE_L2X0=y
 CONFIG_ARM_L1_CACHE_SHIFT=5
 # CONFIG_ARM_ERRATA_430973 is not set
 # CONFIG_ARM_ERRATA_458693 is not set
Signature · 1 line
1.6.0.4
#3 lore raw

PATCH 1/3 OMAP4: Add L2 Cache support

In reply to Santosh Shilimkar
Quoted 26 lines · Santosh Shilimkar
arch/arm/mach-omap2/board-4430sdp.c +13 -0
@@ -28,6 +28,7 @@
 #include <plat/control.h>
 #include <plat/timer-gp.h>
 #include <asm/hardware/gic.h>
+#include <asm/hardware/cache-l2x0.h>
 
 static struct platform_device sdp4430_lcd_device = {
        .name           = "sdp4430_lcd",
@@ -49,6 +50,38 @@ static struct omap_lcd_config sdp4430_lcd_config __initdata = {
 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
        { OMAP_TAG_LCD,         &sdp4430_lcd_config },
 };
+#ifdef CONFIG_CACHE_L2X0
+static int __init omap_l2_cache_init(void)
+{
+       void __iomem *l2cache_base;
+
+       /* Static mapping, never released */
+       l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
+       BUG_ON(!l2cache_base);
+
+       /* Enable L2 Cache using secure api
+        * r0 contains the value to be modified and "r12" contains
+        * the monitor API number. This API uses few CPU registers

arch/arm/mach-omap2/board-4430sdp.c static struct omap_lcd_config sdp4430_lcd_config __initdata = { · line 74

Quoted 10 lines
arch/arm/mach-omap2/board-4430sdp.c +10 -0
+        * internally and hence they need be backed up including
+        * link register "lr".
+        */
+       __asm__ __volatile__(
+               "stmfd r13!, {r0-r12, r14}\n"
+               "mov r0, #1\n"
+               "ldr r12, =0x102\n"
+               "dsb\n"
+               "smc\n"
+               "ldmfd r13!, {r0-r12, r14}");

Same comments as on the cache-l2x0.c changes - can you not let the compiler choose what to saved by declaring the clobbered register in the asm directive?

Signature · 1 line
Catalin
#4 lore raw

PATCH 1/3 OMAP4: Add L2 Cache support

Thanks for quick comment.

Quoted 41 lines

-----Original Message-----
From: Catalin Marinas [mailto:catalin.marinas at arm.com]
Sent: Friday, January 29, 2010 5:46 PM
To: Shilimkar, Santosh
Cc: tony at atomide.com; linux-arm-kernel at lists.infradead.org; rmk at arm.linux.org.uk; linux- omap at vger.kernel.org
Subject: Re: [PATCH 1/3] OMAP4: Add L2 Cache support

Quoted 32 lines · Santosh Shilimkar
arch/arm/mach-omap2/board-4430sdp.c +19 -0
@@ -28,6 +28,7 @@
 #include <plat/control.h>
 #include <plat/timer-gp.h>
 #include <asm/hardware/gic.h>
+#include <asm/hardware/cache-l2x0.h>
 
 static struct platform_device sdp4430_lcd_device = {
        .name           = "sdp4430_lcd",
@@ -49,6 +50,38 @@ static struct omap_lcd_config sdp4430_lcd_config __initdata = {
 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
        { OMAP_TAG_LCD,         &sdp4430_lcd_config },
 };
+#ifdef CONFIG_CACHE_L2X0
+static int __init omap_l2_cache_init(void)
+{
+       void __iomem *l2cache_base;
+
+       /* Static mapping, never released */
+       l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
+       BUG_ON(!l2cache_base);
+
+       /* Enable L2 Cache using secure api
+        * r0 contains the value to be modified and "r12" contains
+        * the monitor API number. This API uses few CPU registers
+        * internally and hence they need be backed up including
+        * link register "lr".
+        */
+       __asm__ __volatile__(
+               "stmfd r13!, {r0-r12, r14}\n"
+               "mov r0, #1\n"
Quoted 8 lines

arch/arm/mach-omap2/board-4430sdp.c static struct omap_lcd_config sdp4430_lcd_config __initdata = { · line 74

Quoted 4 lines
arch/arm/mach-omap2/board-4430sdp.c +4 -0
+               "ldr r12, =0x102\n"
+               "dsb\n"
+               "smc\n"
+               "ldmfd r13!, {r0-r12, r14}");

Same comments as on the cache-l2x0.c changes - can you not let the compiler choose what to saved by declaring the clobbered register in the asm directive?

Since this code was used only ones in init, I haven't converted it to function. With clobber list as well as you know adding r12 to clobber list, compiler don't generate the save code and r11 can't be added to clobber list.

But I can do the same change as I did in the "cache-l2x0.c" Will send updated version.

Regards,
Santosh

#5 lore raw

PATCH 1/3 OMAP4: Add L2 Cache support

Quoted 37 lines · Santosh

Thanks for quick comment.

Quoted 27 lines

-----Original Message-----
From: Catalin Marinas [mailto:catalin.marinas at arm.com]
Sent: Friday, January 29, 2010 5:46 PM
To: Shilimkar, Santosh
Cc: tony at atomide.com; linux-arm-kernel at lists.infradead.org; rmk at arm.linux.org.uk; linux- omap at vger.kernel.org
Subject: Re: [PATCH 1/3] OMAP4: Add L2 Cache support

Quoted 18 lines · Santosh Shilimkar
arch/arm/mach-omap2/board-4430sdp.c +18 -0
+#ifdef CONFIG_CACHE_L2X0
+static int __init omap_l2_cache_init(void)
+{
+       void __iomem *l2cache_base;
+
+       /* Static mapping, never released */
+       l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
+       BUG_ON(!l2cache_base);
+
+       /* Enable L2 Cache using secure api
+        * r0 contains the value to be modified and "r12" contains
+        * the monitor API number. This API uses few CPU registers
+        * internally and hence they need be backed up including
+        * link register "lr".
+        */
+       __asm__ __volatile__(
+               "stmfd r13!, {r0-r12, r14}\n"
+               "mov r0, #1\n"
Quoted 8 lines

arch/arm/mach-omap2/board-4430sdp.c static struct omap_lcd_config sdp4430_lcd_config __initdata = { · line 74

Quoted 4 lines
arch/arm/mach-omap2/board-4430sdp.c +4 -0
+               "ldr r12, =0x102\n"
+               "dsb\n"
+               "smc\n"
+               "ldmfd r13!, {r0-r12, r14}");

Same comments as on the cache-l2x0.c changes - can you not let the compiler choose what to saved by declaring the clobbered register in the asm directive?

Quoted 4 lines

Since this code was used only ones in init, I haven't converted it to function. With clobber list as well as you know adding r12 to clobber list, compiler don't generate the save code and r11 can't be added to clobber list.

Well, we seem to have two places with the same code structure. Let's pull them together into a common function, such as:

void omap_smc1(u32 fn, u32 arg)

{
	register u32 r12 asm("r12") = fn;
	register u32 r0 asm("r0") = arg;
	asm volatile(
		"str r11, [sp], #-4\n"
		"dsb\n"
		"smc\n"
		"ldr r11, [sp, #4]!"
		: "+r" (r0), "+r" (r12)
		:
		: "r0-r10", "lr", "cc");
}

EXPORT_SYMBOL(omap_smc1);

The code there probably may not be Thumb-2 compatible.

#6 lore raw

PATCH 1/3 OMAP4: Add L2 Cache support

Quoted 21 lines
Quoted 4 lines

Since this code was used only ones in init, I haven't converted it to function. With clobber list as well as you know adding r12 to clobber list, compiler don't generate the save code and r11 can't be added to clobber list.

Well, we seem to have two places with the same code structure. Let's pull them together into a common function, such as:

void omap_smc1(u32 fn, u32 arg)

{
	register u32 r12 asm("r12") = fn;
	register u32 r0 asm("r0") = arg;
	asm volatile(
		"str r11, [sp], #-4\n"
		"dsb\n"
		"smc\n"
		"ldr r11, [sp, #4]!"
		: "+r" (r0), "+r" (r12)
		:
		: "r0-r10", "lr", "cc");
}
Quoted 3 lines

EXPORT_SYMBOL(omap_smc1);

The code there probably may not be Thumb-2 compatible.

I will re-arrange the series and sent combined the errata + l2 support with above change since dependency.

Regards,
Santosh

maintainer
#7 lore raw

PATCH 1/3 OMAP4: Add L2 Cache support

In reply to Santosh Shilimkar
Quoted 23 lines · Santosh Shilimkar

This patch adds L2 Cache support for OMAP4. External L2 cache is used in OMPA4

---
 arch/arm/mach-omap2/board-4430sdp.c        |   33 ++++++++++++++++++++++++++++
 arch/arm/mm/Kconfig                        |    2 +-
 arch/arm/plat-omap/include/plat/omap44xx.h |    1 +
 3 files changed, 35 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/board-4430sdp.c +1 -0
index 0c6be6b..194d633 100644
@@ -28,6 +28,7 @@
 #include <plat/control.h>
 #include <plat/timer-gp.h>
 #include <asm/hardware/gic.h>
+#include <asm/hardware/cache-l2x0.h>
 
 static struct platform_device sdp4430_lcd_device = {
 	.name		= "sdp4430_lcd",

arch/arm/mach-omap2/board-4430sdp.c static struct omap_lcd_config sdp4430_lcd_config __initdata = { · line 56

Quoted 7 lines
arch/arm/mach-omap2/board-4430sdp.c +4 -0
@@ -49,6 +50,38 @@ static struct omap_lcd_config sdp4430_lcd_config __initdata = {
 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
 	{ OMAP_TAG_LCD,		&sdp4430_lcd_config },
 };
+#ifdef CONFIG_CACHE_L2X0
+static int __init omap_l2_cache_init(void)
+{
+	void __iomem *l2cache_base;

Since this is an initcall, you need to return here early to avoid running on other omaps:

	if (!cpu_is_omap44xx())
		return -ENODEV;
Quoted 18 lines
arch/arm/mach-omap2/board-4430sdp.c +18 -0
+
+	/* Static mapping, never released */
+	l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
+	BUG_ON(!l2cache_base);
+
+	/* Enable L2 Cache using secure api
+	 * r0 contains the value to be modified and "r12" contains
+	 * the monitor API number. This API uses few CPU registers
+	 * internally and hence they need be backed up including
+	 * link register "lr".
+	 */
+	__asm__ __volatile__(
+		"stmfd r13!, {r0-r12, r14}\n"
+		"mov r0, #1\n"
+		"ldr r12, =0x102\n"
+		"dsb\n"
+		"smc\n"
+		"ldmfd r13!, {r0-r12, r14}");

arch/arm/mach-omap2/board-4430sdp.c static struct omap_lcd_config sdp4430_lcd_config __initdata = { · line 84

Quoted 10 lines
arch/arm/mach-omap2/board-4430sdp.c +10 -0
+
+	/* 32KB way size, 16-way associativity,
+	* parity disabled
+	*/
+	l2x0_init(l2cache_base, 0x0e050000, 0xc0000fff);
+
+	return 0;
+}
+early_initcall(omap_l2_cache_init);
+#endif

Regards,

Tony