Skip to contentSkip to conversation

ARM: get rid of a few StrongARM cache-related build time constants

PATCH New Nicolas Pitre 3 participants 13 messages Jul 6, 2011 – Jul 19, 2011

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

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

The StrongARM based machines define a couple constants which are obstacles to a single kernel image. Amongst them are FLUSH_BASE, FLUSH_BASE_PHYS, FLUSH_BASE_MINICACHE and UNCACHEABLE_ADDR. The affected code can be found in mm/mmu.c, mm/proc-sa110.S, mm/proc-sa1100.S and cache-v4wb.S. Let's create some code to deal with the differences at run time and initialize the proper mappings with common virtual addresses for them instead.

This should be functionally equivalent except for the following details:

- Mappings are created using second level PTEs instead of first level sections. The first level page table covering those PTEs is already there because of the fixmaps and the vector page so no additional memory is required. There might also be more TLB usage, however this is not something one might be concerned about when the whole cache is being flushed, completely pushing the cost of those TLBs below noise level.

- CACHE_DLIMIT is now the same for both SA110 and SA1100. This is unclear if loading a variable each time v4wb_flush_user_cache_range is called would be beneficial.

- The way UNCACHEABLE_ADDR was defined and used on RiscPC and Shark didn't produce a real uncacheable address, probably inhibiting the clock switching in cpu_sa110_do_idle(). As a side effect, this patch fixes this.

---
 Documentation/arm/memory.txt                     |    7 +-
 arch/arm/include/asm/cacheflush.h                |   10 +++
 arch/arm/mach-ebsa110/core.c                     |    4 +
 arch/arm/mach-ebsa110/include/mach/hardware.h    |    5 -
 arch/arm/mach-ebsa110/include/mach/memory.h      |    6 --
 arch/arm/mach-footbridge/common.c                |    3 +
 arch/arm/mach-footbridge/include/mach/hardware.h |    2 -
 arch/arm/mach-footbridge/include/mach/memory.h   |    7 --
 arch/arm/mach-rpc/include/mach/hardware.h        |    2 -
 arch/arm/mach-rpc/include/mach/memory.h          |    6 --
 arch/arm/mach-rpc/riscpc.c                       |    4 +
 arch/arm/mach-sa1100/generic.c                   |    7 ++-
 arch/arm/mach-sa1100/include/mach/hardware.h     |    4 -
 arch/arm/mach-sa1100/include/mach/memory.h       |    7 --
 arch/arm/mach-shark/core.c                       |    2 +
 arch/arm/mach-shark/include/mach/hardware.h      |    2 -
 arch/arm/mach-shark/include/mach/memory.h        |    6 --
 arch/arm/mm/Makefile                             |    2 +-
 arch/arm/mm/cache-v4wb-init.c                    |   89 ++++++++++++++++++++++
 arch/arm/mm/cache-v4wb.S                         |   31 +------
 arch/arm/mm/proc-sa110.S                         |    5 +
 arch/arm/mm/proc-sa1100.S                        |    5 +
 22 files changed, 138 insertions(+), 78 deletions(-)
 create mode 100644 arch/arm/mm/cache-v4wb-init.c
Documentation/arm/memory.txt +4 -3
index 771d48d..b7a5ae8 100644
@@ -31,9 +31,10 @@ ffff0000	ffff0fff	CPU vector page.
 				CPU supports vector relocation (control
 				register V bit.)
 
-fffe0000	fffeffff	XScale cache flush area.  This is used
-				in proc-xscale.S to flush the whole data
-				cache. (XScale does not have TCM.)
+fffe0000	fffeffff	StrongARM and XScale cache flush area.
+				This is used in cache-v4wb.S and proc-xscale.S
+				to flush the whole data cache.
+				(Neither StrongARM nor XScale have TCM.)
 
 fffe8000	fffeffff	DTCM mapping area for platforms with
 				DTCM mounted inside the CPU.
arch/arm/include/asm/cacheflush.h +10 -0
index d5d8d5c..1821757 100644
@@ -157,6 +157,16 @@ extern void dmac_flush_range(const void *, const void *);
 
 #endif
 
+#ifdef CONFIG_CPU_CACHE_V4WB
+
+enum cache_v4wb_cputype { CACHE_CPU_SA110, CACHE_CPU_SA1100 };
+
+extern void cache_v4wb_init(unsigned long flush_phys_addr,
+			    unsigned long uncached_phys_addr,
+			    enum cache_v4wb_cputype cpu_type);
+
+#endif
+
 /*
  * Copy user data from/to a page which is mapped into a different
  * processes address space.  Really, we want to allow our "user
arch/arm/mach-ebsa110/core.c +4 -0
index 087bc77..f8a94d6 100644
@@ -23,6 +23,7 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
@@ -114,9 +115,12 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
 	}
 };
 
+#define SRAM_PHYS		0xdf000000
+
 static void __init ebsa110_map_io(void)
 {
 	iotable_init(ebsa110_io_desc, ARRAY_SIZE(ebsa110_io_desc));
+	cache_v4wb_init(SRAM_PHYS, TRICK4_PHYS, CACHE_CPU_SA110);
 }
 
 
arch/arm/mach-ebsa110/include/mach/hardware.h +0 -5
index 4b2fb77..705dc40 100644
@@ -54,10 +54,5 @@
 #define PIT_BASE		0xfc000000
 #define SOFT_BASE		0xfd000000
 
-/*
- * RAM definitions
- */
-#define UNCACHEABLE_ADDR	0xff000000	/* IRQ_STAT */
-
 #endif
 
arch/arm/mach-ebsa110/include/mach/memory.h +0 -6
index 8e49066..2af7ec4 100644
@@ -21,10 +21,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
-/*
- * Cache flushing area - SRAM
- */
-#define FLUSH_BASE_PHYS		0x40000000
-#define FLUSH_BASE		0xdf000000
-
 #endif
arch/arm/mach-footbridge/common.c +3 -0
index 38a44f9..2b9d83a 100644
@@ -21,6 +21,7 @@
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <asm/setup.h>
+#include <asm/cacheflush.h>
 #include <asm/hardware/dec21285.h>
 
 #include <asm/mach/irq.h>
@@ -185,6 +186,8 @@ static struct map_desc ebsa285_host_io_desc[] __initdata = {
 
 void __init footbridge_map_io(void)
 {
+	cache_v4wb_init(0x50000000, 0x50010000, CACHE_CPU_SA110);
+
 	/*
 	 * Set up the common mapping first; we need this to
 	 * determine whether we're in host mode or not.
arch/arm/mach-footbridge/include/mach/hardware.h +0 -2
index b6fdf23..f8b7e95 100644
@@ -63,8 +63,6 @@
 #define XBUS_SWITCH_J17_11	((*XBUS_SWITCH) & (1 << 5))
 #define XBUS_SWITCH_J17_9	((*XBUS_SWITCH) & (1 << 6))
 
-#define UNCACHEABLE_ADDR	(ARMCSR_BASE + 0x108)
-
 
 /* PIC irq control */
 #define PIC_LO			0x20
arch/arm/mach-footbridge/include/mach/memory.h +0 -7
index 5c6df37..3e17e5c 100644
@@ -55,15 +55,8 @@ extern unsigned long __bus_to_pfn(unsigned long);
 #endif
 
 /*
- * Cache flushing area.
- */
-#define FLUSH_BASE		0xf9000000
-
-/*
  * Physical DRAM offset.
  */
 #define PLAT_PHYS_OFFSET		UL(0x00000000)
 
-#define FLUSH_BASE_PHYS		0x50000000
-
 #endif
arch/arm/mach-rpc/include/mach/hardware.h +0 -2
index dde6b3c..4f3b227 100644
@@ -46,8 +46,6 @@
 #define SCREEN_END		0xdfc00000
 #define SCREEN_BASE		0xdf800000
 
-#define UNCACHEABLE_ADDR	0xdf010000
-
 /*
  * IO Addresses
  */
arch/arm/mach-rpc/include/mach/memory.h +0 -6
index 18a2210..e2fcf9b 100644
@@ -24,12 +24,6 @@
 #define PLAT_PHYS_OFFSET	UL(0x10000000)
 
 /*
- * Cache flushing area - ROM
- */
-#define FLUSH_BASE_PHYS		0x00000000
-#define FLUSH_BASE		0xdf000000
-
-/*
  * Sparsemem support.  Each section is a maximum of 64MB.  The sections
  * are offset by 128MB and can cover 128MB, so that gives us a maximum
  * of 29 physmem bits.
arch/arm/mach-rpc/riscpc.c +4 -0
index 580b3c7..fd086ff 100644
@@ -27,6 +27,7 @@
 #include <asm/page.h>
 #include <asm/domain.h>
 #include <asm/setup.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
@@ -84,6 +85,9 @@ static struct map_desc rpc_io_desc[] __initdata = {
 static void __init rpc_map_io(void)
 {
 	iotable_init(rpc_io_desc, ARRAY_SIZE(rpc_io_desc));
+#ifdef CPU_CACHE_V4WB
+	cache_v4wb_init(0, 0x10000, CACHE_CPU_SA110);
+#endif
 
 	/*
 	 * Turn off floppy.
arch/arm/mach-sa1100/generic.c +6 -1
index e21f347..9ddd265 100644
@@ -21,6 +21,7 @@
 #include <asm/div64.h>
 #include <mach/hardware.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 #include <asm/mach/map.h>
 #include <asm/mach/flash.h>
 #include <asm/irq.h>
@@ -403,12 +404,16 @@ static struct map_desc standard_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(0xb0000000),
 		.length		= 0x00200000,
 		.type		= MT_DEVICE
-	},
+	}
 };
 
+#define SA1100_ZERO_BANK	0xe0000000
+#define ICIP_PHYS_ADDR		0x90050000
+
 void __init sa1100_map_io(void)
 {
 	iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
+	cache_v4wb_init(SA1100_ZERO_BANK, ICIP_PHYS_ADDR, CACHE_CPU_SA1100);
 }
 
 /*
arch/arm/mach-sa1100/include/mach/hardware.h +0 -4
index 967ae76..355f0b0 100644
@@ -12,10 +12,6 @@
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-
-#define UNCACHEABLE_ADDR	0xfa050000
-
-
 /*
  * SA1100 internal I/O mappings
  *
arch/arm/mach-sa1100/include/mach/memory.h +0 -7
index 12d3767..8b56fb3 100644
@@ -31,11 +31,4 @@
 #define MAX_PHYSMEM_BITS	32
 #define SECTION_SIZE_BITS	27
 
-/*
- * Cache flushing area - SA1100 zero bank
- */
-#define FLUSH_BASE_PHYS		0xe0000000
-#define FLUSH_BASE		0xf5000000
-#define FLUSH_BASE_MINICACHE	0xf5100000
-
 #endif
arch/arm/mach-shark/core.c +2 -0
index ac2873c..1173082 100644
@@ -15,6 +15,7 @@
 #include <asm/mach-types.h>
 #include <asm/leds.h>
 #include <asm/param.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
@@ -116,6 +117,7 @@ static struct map_desc shark_io_desc[] __initdata = {
 static void __init shark_map_io(void)
 {
 	iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc));
+	cache_v4wb_init(0x80000000, 0x80010000, CACHE_CPU_SA110);
 }
 
 #define IRQ_TIMER 0
arch/arm/mach-shark/include/mach/hardware.h +0 -2
index 94d84b2..dab0857 100644
@@ -10,8 +10,6 @@
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-#define UNCACHEABLE_ADDR        0xdf010000
-
 #define pcibios_assign_all_busses()     1
 
 #define PCIBIOS_MIN_IO          0x6000
arch/arm/mach-shark/include/mach/memory.h +0 -6
index 1cf8d69..e19df6f 100644
@@ -17,10 +17,4 @@
  */
 #define PLAT_PHYS_OFFSET     UL(0x08000000)
 
-/*
- * Cache flushing area
- */
-#define FLUSH_BASE_PHYS		0x80000000
-#define FLUSH_BASE		0xdf000000
-
 #endif
arch/arm/mm/Makefile +1 -1
index bca7e61..14b0af1 100644
@@ -36,7 +36,7 @@ obj-$(CONFIG_CPU_PABRT_V7)	+= pabort-v7.o
 obj-$(CONFIG_CPU_CACHE_V3)	+= cache-v3.o
 obj-$(CONFIG_CPU_CACHE_V4)	+= cache-v4.o
 obj-$(CONFIG_CPU_CACHE_V4WT)	+= cache-v4wt.o
-obj-$(CONFIG_CPU_CACHE_V4WB)	+= cache-v4wb.o
+obj-$(CONFIG_CPU_CACHE_V4WB)	+= cache-v4wb.o cache-v4wb-init.o
 obj-$(CONFIG_CPU_CACHE_V6)	+= cache-v6.o
 obj-$(CONFIG_CPU_CACHE_V7)	+= cache-v7.o
 obj-$(CONFIG_CPU_CACHE_FA)	+= cache-fa.o
arch/arm/mm/cache-v4wb-init.c new file +89 -0

89 lines not on this page · raw message

arch/arm/mm/cache-v4wb.S +5 -26
index f40c696..bff5fec 100644
@@ -19,17 +19,6 @@
 #define CACHE_DLINESIZE	32
 
 /*
- * The total size of the data cache.
- */
-#if defined(CONFIG_CPU_SA110)
-# define CACHE_DSIZE	16384
-#elif defined(CONFIG_CPU_SA1100)
-# define CACHE_DSIZE	8192
-#else
-# error Unknown cache size
-#endif
-
-/*
  * This is the size at which it becomes more efficient to
  * clean the whole cache, rather than using the individual
  * cache line maintenance instructions.
@@ -43,11 +32,8 @@
  * 131072  591 591 591   656 657 651
  *  Whole  132 136 132   221 217 207 <---
  */
-#define CACHE_DLIMIT	(CACHE_DSIZE * 4)
+#define CACHE_DLIMIT	32768
 
-	.data
-flush_base:
-	.long	FLUSH_BASE
 	.text
 
 /*
@@ -78,21 +64,14 @@ ENTRY(v4wb_flush_kern_cache_all)
 	mov	ip, #0
 	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
 __flush_whole_cache:
-	ldr	r3, =flush_base
-	ldr	r1, [r3, #0]
-	eor	r1, r1, #CACHE_DSIZE
+	ldr	r3, =cache_v4wb_params
+	ldmia	r3, {r1, r2}
+	eor	r1, r1, #32768			@ FLUSH_OFF_ALT
 	str	r1, [r3, #0]
-	add	r2, r1, #CACHE_DSIZE
-1:	ldr	r3, [r1], #32
-	cmp	r1, r2
-	blo	1b
-#ifdef FLUSH_BASE_MINICACHE
-	add	r2, r2, #FLUSH_BASE_MINICACHE - FLUSH_BASE
-	sub	r1, r2, #512			@ only 512 bytes
+	add	r2, r1, r2
 1:	ldr	r3, [r1], #32
 	cmp	r1, r2
 	blo	1b
-#endif
 	mcr	p15, 0, ip, c7, c10, 4		@ drain write buffer
 	mov	pc, lr
 
arch/arm/mm/proc-sa110.S +5 -0
index 46f09ed..e8c44a2 100644
@@ -30,6 +30,11 @@
  */
 #define DCACHELINESIZE	32
 
+/*
+ * Address used for uncached access (mapping set up in cache-v4wb-init.c)
+ */
+#define UNCACHEABLE_ADDR 0xfffee000
+
 	.text
 
 /*
arch/arm/mm/proc-sa1100.S +5 -0
index 184a9c9..2d805ae 100644
@@ -34,6 +34,11 @@
  */
 #define DCACHELINESIZE	32
 
+/*
+ * Address used for uncached access (mapping set up in cache-v4wb-init.c)
+ */
+#define UNCACHEABLE_ADDR 0xfffee000
+
 	__INIT
 
 /*
Signature · 1 line
1.7.4
#1 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 16 lines · Nicolas Pitre

index 087bc77..f8a94d6 100644

arch/arm/mach-ebsa110/core.c +2 -0
@@ -23,6 +23,7 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
@@ -114,9 +115,12 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
 	}
 };
 
+#define SRAM_PHYS		0xdf000000

...

arch/arm/mach-ebsa110/core.c

Quoted 2 lines
arch/arm/mach-ebsa110/core.c +0 -2
-#define FLUSH_BASE_PHYS		0x40000000
-#define FLUSH_BASE		0xdf000000

Looks like you chose the wrong constant.

#2 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Nicolas Pitre

index 087bc77..f8a94d6 100644

arch/arm/mach-ebsa110/core.c +1 -0
@@ -23,6 +23,7 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
@@ -114,9 +115,12 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
 	}
 };
 
Quoted 6 lines
Quoted 1 line
arch/arm/mach-ebsa110/core.c +1 -0
+#define SRAM_PHYS		0xdf000000

...

arch/arm/mach-ebsa110/core.c

Quoted 2 lines
arch/arm/mach-ebsa110/core.c +0 -2
-#define FLUSH_BASE_PHYS		0x40000000
-#define FLUSH_BASE		0xdf000000

Looks like you chose the wrong constant.

Oops. Here's a fixed patch.

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

commit 14b70a36ce97d4c375ac88f0489a000616e1d1c5

Author: Nicolas Pitre <[email protected]>
Date:   Tue Jul 5 22:33:28 2011 -0400

ARM: get rid of a few StrongARM cache-related build time constants

The StrongARM based machines define a couple constants which are obstacles to a single kernel image. Amongst them are FLUSH_BASE, FLUSH_BASE_PHYS, FLUSH_BASE_MINICACHE and UNCACHEABLE_ADDR. The affected code can be found in mm/mmu.c, mm/proc-sa110.S, mm/proc-sa1100.S and cache-v4wb.S. Let's create some code to deal with the differences at run time and initialize the proper mappings with common virtual addresses for them instead.

This should be functionally equivalent except for the following details:

- Mappings are created using second level PTEs instead of first level sections. The first level page table covering those PTEs is already there because of the fixmaps and the vector page so no additional memory is required. There might also be more TLB usage, however this is not something one might be concerned about when the whole cache is being flushed, completely pushing the cost of those TLBs below noise level.

- CACHE_DLIMIT is now the same for both SA110 and SA1100. This is unclear if loading a variable each time v4wb_flush_user_cache_range is called would be beneficial.

- The way UNCACHEABLE_ADDR was defined and used on RiscPC and Shark didn't produce a real uncacheable address, probably inhibiting the clock switching in cpu_sa110_do_idle(). As a side effect, this patch fixes this.

Documentation/arm/memory.txt +4 -3
index 771d48d..b7a5ae8 100644
@@ -31,9 +31,10 @@ ffff0000	ffff0fff	CPU vector page.
 				CPU supports vector relocation (control
 				register V bit.)
 
-fffe0000	fffeffff	XScale cache flush area.  This is used
-				in proc-xscale.S to flush the whole data
-				cache. (XScale does not have TCM.)
+fffe0000	fffeffff	StrongARM and XScale cache flush area.
+				This is used in cache-v4wb.S and proc-xscale.S
+				to flush the whole data cache.
+				(Neither StrongARM nor XScale have TCM.)
 
 fffe8000	fffeffff	DTCM mapping area for platforms with
 				DTCM mounted inside the CPU.
arch/arm/include/asm/cacheflush.h +10 -0
index d5d8d5c..1821757 100644
@@ -157,6 +157,16 @@ extern void dmac_flush_range(const void *, const void *);
 
 #endif
 
+#ifdef CONFIG_CPU_CACHE_V4WB
+
+enum cache_v4wb_cputype { CACHE_CPU_SA110, CACHE_CPU_SA1100 };
+
+extern void cache_v4wb_init(unsigned long flush_phys_addr,
+			    unsigned long uncached_phys_addr,
+			    enum cache_v4wb_cputype cpu_type);
+
+#endif
+
 /*
  * Copy user data from/to a page which is mapped into a different
  * processes address space.  Really, we want to allow our "user
arch/arm/mach-ebsa110/core.c +4 -0
index 087bc77..66f9847 100644
@@ -23,6 +23,7 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
@@ -114,9 +115,12 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
 	}
 };
 
+#define SRAM_PHYS		0x40000000
+
 static void __init ebsa110_map_io(void)
 {
 	iotable_init(ebsa110_io_desc, ARRAY_SIZE(ebsa110_io_desc));
+	cache_v4wb_init(SRAM_PHYS, TRICK4_PHYS, CACHE_CPU_SA110);
 }
 
 
arch/arm/mach-ebsa110/include/mach/hardware.h +0 -5
index 4b2fb77..705dc40 100644
@@ -54,10 +54,5 @@
 #define PIT_BASE		0xfc000000
 #define SOFT_BASE		0xfd000000
 
-/*
- * RAM definitions
- */
-#define UNCACHEABLE_ADDR	0xff000000	/* IRQ_STAT */
-
 #endif
 
arch/arm/mach-ebsa110/include/mach/memory.h +0 -6
index 8e49066..2af7ec4 100644
@@ -21,10 +21,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
-/*
- * Cache flushing area - SRAM
- */
-#define FLUSH_BASE_PHYS		0x40000000
-#define FLUSH_BASE		0xdf000000
-
 #endif
arch/arm/mach-footbridge/common.c +3 -0
index 38a44f9..2b9d83a 100644
@@ -21,6 +21,7 @@
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <asm/setup.h>
+#include <asm/cacheflush.h>
 #include <asm/hardware/dec21285.h>
 
 #include <asm/mach/irq.h>
@@ -185,6 +186,8 @@ static struct map_desc ebsa285_host_io_desc[] __initdata = {
 
 void __init footbridge_map_io(void)
 {
+	cache_v4wb_init(0x50000000, 0x50010000, CACHE_CPU_SA110);
+
 	/*
 	 * Set up the common mapping first; we need this to
 	 * determine whether we're in host mode or not.
arch/arm/mach-footbridge/include/mach/hardware.h +0 -2
index b6fdf23..f8b7e95 100644
@@ -63,8 +63,6 @@
 #define XBUS_SWITCH_J17_11	((*XBUS_SWITCH) & (1 << 5))
 #define XBUS_SWITCH_J17_9	((*XBUS_SWITCH) & (1 << 6))
 
-#define UNCACHEABLE_ADDR	(ARMCSR_BASE + 0x108)
-
 
 /* PIC irq control */
 #define PIC_LO			0x20
arch/arm/mach-footbridge/include/mach/memory.h +0 -7
index 5c6df37..3e17e5c 100644
@@ -55,15 +55,8 @@ extern unsigned long __bus_to_pfn(unsigned long);
 #endif
 
 /*
- * Cache flushing area.
- */
-#define FLUSH_BASE		0xf9000000
-
-/*
  * Physical DRAM offset.
  */
 #define PLAT_PHYS_OFFSET		UL(0x00000000)
 
-#define FLUSH_BASE_PHYS		0x50000000
-
 #endif
arch/arm/mach-rpc/include/mach/hardware.h +0 -2
index dde6b3c..4f3b227 100644
@@ -46,8 +46,6 @@
 #define SCREEN_END		0xdfc00000
 #define SCREEN_BASE		0xdf800000
 
-#define UNCACHEABLE_ADDR	0xdf010000
-
 /*
  * IO Addresses
  */
arch/arm/mach-rpc/include/mach/memory.h +0 -6
index 18a2210..e2fcf9b 100644
@@ -24,12 +24,6 @@
 #define PLAT_PHYS_OFFSET	UL(0x10000000)
 
 /*
- * Cache flushing area - ROM
- */
-#define FLUSH_BASE_PHYS		0x00000000
-#define FLUSH_BASE		0xdf000000
-
-/*
  * Sparsemem support.  Each section is a maximum of 64MB.  The sections
  * are offset by 128MB and can cover 128MB, so that gives us a maximum
  * of 29 physmem bits.
arch/arm/mach-rpc/riscpc.c +4 -0
index 580b3c7..fd086ff 100644
@@ -27,6 +27,7 @@
 #include <asm/page.h>
 #include <asm/domain.h>
 #include <asm/setup.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
@@ -84,6 +85,9 @@ static struct map_desc rpc_io_desc[] __initdata = {
 static void __init rpc_map_io(void)
 {
 	iotable_init(rpc_io_desc, ARRAY_SIZE(rpc_io_desc));
+#ifdef CPU_CACHE_V4WB
+	cache_v4wb_init(0, 0x10000, CACHE_CPU_SA110);
+#endif
 
 	/*
 	 * Turn off floppy.
arch/arm/mach-sa1100/generic.c +6 -1
index e21f347..9ddd265 100644
@@ -21,6 +21,7 @@
 #include <asm/div64.h>
 #include <mach/hardware.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 #include <asm/mach/map.h>
 #include <asm/mach/flash.h>
 #include <asm/irq.h>
@@ -403,12 +404,16 @@ static struct map_desc standard_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(0xb0000000),
 		.length		= 0x00200000,
 		.type		= MT_DEVICE
-	},
+	}
 };
 
+#define SA1100_ZERO_BANK	0xe0000000
+#define ICIP_PHYS_ADDR		0x90050000
+
 void __init sa1100_map_io(void)
 {
 	iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
+	cache_v4wb_init(SA1100_ZERO_BANK, ICIP_PHYS_ADDR, CACHE_CPU_SA1100);
 }
 
 /*
arch/arm/mach-sa1100/include/mach/hardware.h +0 -4
index 967ae76..355f0b0 100644
@@ -12,10 +12,6 @@
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-
-#define UNCACHEABLE_ADDR	0xfa050000
-
-
 /*
  * SA1100 internal I/O mappings
  *
arch/arm/mach-sa1100/include/mach/memory.h +0 -7
index 12d3767..8b56fb3 100644
@@ -31,11 +31,4 @@
 #define MAX_PHYSMEM_BITS	32
 #define SECTION_SIZE_BITS	27
 
-/*
- * Cache flushing area - SA1100 zero bank
- */
-#define FLUSH_BASE_PHYS		0xe0000000
-#define FLUSH_BASE		0xf5000000
-#define FLUSH_BASE_MINICACHE	0xf5100000
-
 #endif
arch/arm/mach-shark/core.c +2 -0
index ac2873c..1173082 100644
@@ -15,6 +15,7 @@
 #include <asm/mach-types.h>
 #include <asm/leds.h>
 #include <asm/param.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
@@ -116,6 +117,7 @@ static struct map_desc shark_io_desc[] __initdata = {
 static void __init shark_map_io(void)
 {
 	iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc));
+	cache_v4wb_init(0x80000000, 0x80010000, CACHE_CPU_SA110);
 }
 
 #define IRQ_TIMER 0
arch/arm/mach-shark/include/mach/hardware.h +0 -2
index 94d84b2..dab0857 100644
@@ -10,8 +10,6 @@
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-#define UNCACHEABLE_ADDR        0xdf010000
-
 #define pcibios_assign_all_busses()     1
 
 #define PCIBIOS_MIN_IO          0x6000
arch/arm/mach-shark/include/mach/memory.h +0 -6
index 1cf8d69..e19df6f 100644
@@ -17,10 +17,4 @@
  */
 #define PLAT_PHYS_OFFSET     UL(0x08000000)
 
-/*
- * Cache flushing area
- */
-#define FLUSH_BASE_PHYS		0x80000000
-#define FLUSH_BASE		0xdf000000
-
 #endif
arch/arm/mm/Makefile +1 -1
index bca7e61..14b0af1 100644
@@ -36,7 +36,7 @@ obj-$(CONFIG_CPU_PABRT_V7)	+= pabort-v7.o
 obj-$(CONFIG_CPU_CACHE_V3)	+= cache-v3.o
 obj-$(CONFIG_CPU_CACHE_V4)	+= cache-v4.o
 obj-$(CONFIG_CPU_CACHE_V4WT)	+= cache-v4wt.o
-obj-$(CONFIG_CPU_CACHE_V4WB)	+= cache-v4wb.o
+obj-$(CONFIG_CPU_CACHE_V4WB)	+= cache-v4wb.o cache-v4wb-init.o
 obj-$(CONFIG_CPU_CACHE_V6)	+= cache-v6.o
 obj-$(CONFIG_CPU_CACHE_V7)	+= cache-v7.o
 obj-$(CONFIG_CPU_CACHE_FA)	+= cache-fa.o
arch/arm/mm/cache-v4wb-init.c new file +89 -0

89 lines not on this page · raw message

arch/arm/mm/cache-v4wb.S +5 -26
index f40c696..bff5fec 100644
@@ -19,17 +19,6 @@
 #define CACHE_DLINESIZE	32
 
 /*
- * The total size of the data cache.
- */
-#if defined(CONFIG_CPU_SA110)
-# define CACHE_DSIZE	16384
-#elif defined(CONFIG_CPU_SA1100)
-# define CACHE_DSIZE	8192
-#else
-# error Unknown cache size
-#endif
-
-/*
  * This is the size at which it becomes more efficient to
  * clean the whole cache, rather than using the individual
  * cache line maintenance instructions.
@@ -43,11 +32,8 @@
  * 131072  591 591 591   656 657 651
  *  Whole  132 136 132   221 217 207 <---
  */
-#define CACHE_DLIMIT	(CACHE_DSIZE * 4)
+#define CACHE_DLIMIT	32768
 
-	.data
-flush_base:
-	.long	FLUSH_BASE
 	.text
 
 /*
@@ -78,21 +64,14 @@ ENTRY(v4wb_flush_kern_cache_all)
 	mov	ip, #0
 	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
 __flush_whole_cache:
-	ldr	r3, =flush_base
-	ldr	r1, [r3, #0]
-	eor	r1, r1, #CACHE_DSIZE
+	ldr	r3, =cache_v4wb_params
+	ldmia	r3, {r1, r2}
+	eor	r1, r1, #32768			@ FLUSH_OFF_ALT
 	str	r1, [r3, #0]
-	add	r2, r1, #CACHE_DSIZE
-1:	ldr	r3, [r1], #32
-	cmp	r1, r2
-	blo	1b
-#ifdef FLUSH_BASE_MINICACHE
-	add	r2, r2, #FLUSH_BASE_MINICACHE - FLUSH_BASE
-	sub	r1, r2, #512			@ only 512 bytes
+	add	r2, r1, r2
 1:	ldr	r3, [r1], #32
 	cmp	r1, r2
 	blo	1b
-#endif
 	mcr	p15, 0, ip, c7, c10, 4		@ drain write buffer
 	mov	pc, lr
 
arch/arm/mm/proc-sa110.S +5 -0
index 46f09ed..e8c44a2 100644
@@ -30,6 +30,11 @@
  */
 #define DCACHELINESIZE	32
 
+/*
+ * Address used for uncached access (mapping set up in cache-v4wb-init.c)
+ */
+#define UNCACHEABLE_ADDR 0xfffee000
+
 	.text
 
 /*
arch/arm/mm/proc-sa1100.S +5 -0
index 184a9c9..2d805ae 100644
@@ -34,6 +34,11 @@
  */
 #define DCACHELINESIZE	32
 
+/*
+ * Address used for uncached access (mapping set up in cache-v4wb-init.c)
+ */
+#define UNCACHEABLE_ADDR 0xfffee000
+
 	__INIT
 
 /*
Quoted 1 line
#3 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 4 lines · Nicolas Pitre

Oops. Here's a fixed patch.

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Will do - the assabet is still running as a test machine. The ebsa110 is still alive but as that's (still) the firewall I won't run a test on that until a quiet weekend. I can also test the Netwinder and RiscPC...

#4 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Nicolas Pitre

Oops. Here's a fixed patch.

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Will do - the assabet is still running as a test machine. The ebsa110 is still alive but as that's (still) the firewall I won't run a test on that until a quiet weekend. I can also test the Netwinder and RiscPC...

Thanks. The Assabet covers SA1100, Netwinder is good for SA110, and RiscPC would also confirm that the change for the uncached mapping is harmless. That should provide enough confidence in the patch.

Nicolas

#5 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

In reply to Russell King - ARM Linux
Quoted 9 lines · Russell King - ARM Linux
Quoted 4 lines · Nicolas Pitre

Oops. Here's a fixed patch.

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Will do - the assabet is still running as a test machine. The ebsa110 is still alive but as that's (still) the firewall I won't run a test on that until a quiet weekend. I can also test the Netwinder and RiscPC...

Sorry to break in: does somebody know if there is still a way to purchase/gain assabet and mainstone boards?

Signature · 2 lines
With best wishes
Dmitry
#6 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

In reply to Nicolas Pitre
Quoted 2 lines · Nicolas Pitre

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Tested on Assabet, and unfortunately, this doesn't work on its own because we don't permit iotable_init() to create pages with MT_CACHECLEAN and MT_MINICLEAN.

<4>BUG: map for 0xe0000000 at 0xfffe0000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0004000 at 0xfffe4000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0008000 at 0xfffe8000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe000c000 at 0xfffec000 can not be mapped using pages, ignoring.

The fix is below (probably with offsets):

arch/arm/mm/mmu.c +9 -15
index 027f118..8aeaf25 100644
@@ -225,12 +225,16 @@ static struct mem_type mem_types[] = {
 		.domain		= DOMAIN_IO,
 	},
 	[MT_CACHECLEAN] = {
-		.prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
-		.domain    = DOMAIN_KERNEL,
+		.prot_pte	= L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
+				  L_PTE_XN,
+		.prot_l1	= PMD_TYPE_TABLE,
+		.domain		= DOMAIN_KERNEL,
 	},
 	[MT_MINICLEAN] = {
-		.prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
-		.domain    = DOMAIN_KERNEL,
+		.prot_pte	= L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
+				  L_PTE_XN | L_PTE_MT_MINICACHE,
+		.prot_l1	= PMD_TYPE_TABLE,
+		.domain		= DOMAIN_KERNEL,
 	},
 	[MT_LOW_VECTORS] = {
 		.prot_pte  = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
@@ -437,8 +430,6 @@ static void __init build_mem_type_table(void)
 		 * from SVC mode and no access from userspace.
 		 */
 		mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
-		mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
-		mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
 
 		if (is_smp()) {
 			/*
@@ -506,16 +488,8 @@ static void __init build_mem_type_table(void)
 	mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
 	mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
 	mem_types[MT_ROM].prot_sect |= cp->pmd;
+	mem_types[MT_CACHECLEAN].prot_pte |= kern_pgprot;
 
-	switch (cp->pmd) {
-	case PMD_SECT_WT:
-		mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
-		break;
-	case PMD_SECT_WB:
-	case PMD_SECT_WBWA:
-		mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
-		break;
-	}
 	printk("Memory policy: ECC %sabled, Data cache %s\n",
 		ecc_mask ? "en" : "dis", cp->policy);
 
#7 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Nicolas Pitre

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Tested on Assabet, and unfortunately, this doesn't work on its own because we don't permit iotable_init() to create pages with MT_CACHECLEAN and MT_MINICLEAN.

Quoted 6 lines

<4>BUG: map for 0xe0000000 at 0xfffe0000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0004000 at 0xfffe4000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0008000 at 0xfffe8000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe000c000 at 0xfffec000 can not be mapped using pages, ignoring.

The fix is below (probably with offsets):

Great. Are you providing an ACK or tested-by with this patch folded in?

arch/arm/mm/mmu.c static void __init build_mem_type_table(void) · line 492

Quoted 6 lines
arch/arm/mm/mmu.c +1 -0
@@ -506,16 +488,8 @@ static void __init build_mem_type_table(void)
 	mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
 	mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
 	mem_types[MT_ROM].prot_sect |= cp->pmd;
+	mem_types[MT_CACHECLEAN].prot_pte |= kern_pgprot;
 

Doesn't MT_MINICLEAN require kern_pgprot as well?

Nicolas

#8 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 19 lines · Nicolas Pitre
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Nicolas Pitre

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Tested on Assabet, and unfortunately, this doesn't work on its own because we don't permit iotable_init() to create pages with MT_CACHECLEAN and MT_MINICLEAN.

Quoted 6 lines

<4>BUG: map for 0xe0000000 at 0xfffe0000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0004000 at 0xfffe4000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0008000 at 0xfffe8000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe000c000 at 0xfffec000 can not be mapped using pages, ignoring.

The fix is below (probably with offsets):

Great. Are you providing an ACK or tested-by with this patch folded in?

Quoted 7 lines

arch/arm/mm/mmu.c static void __init build_mem_type_table(void) · line 492

Quoted 6 lines
arch/arm/mm/mmu.c +1 -0
@@ -506,16 +488,8 @@ static void __init build_mem_type_table(void)
 	mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
 	mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
 	mem_types[MT_ROM].prot_sect |= cp->pmd;
+	mem_types[MT_CACHECLEAN].prot_pte |= kern_pgprot;
 

Doesn't MT_MINICLEAN require kern_pgprot as well?

Only if you think the result of orring:

#define L_PTE_MT_WRITEBACK      (_AT(pteval_t, 0x03) << 2)      /* 0011 */
#define L_PTE_MT_MINICACHE      (_AT(pteval_t, 0x06) << 2)      /* 0110 (sa1100, xscale) */

together would make sense... it'd make it:

#define L_PTE_MT_WRITEALLOC (_AT(pteval_t, 0x07) << 2) /* 0111 */

though, so I don't think so.

#9 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 30 lines · Russell King - ARM Linux
Quoted 19 lines · Nicolas Pitre
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Nicolas Pitre

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Tested on Assabet, and unfortunately, this doesn't work on its own because we don't permit iotable_init() to create pages with MT_CACHECLEAN and MT_MINICLEAN.

Quoted 6 lines

<4>BUG: map for 0xe0000000 at 0xfffe0000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0004000 at 0xfffe4000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0008000 at 0xfffe8000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe000c000 at 0xfffec000 can not be mapped using pages, ignoring.

The fix is below (probably with offsets):

Great. Are you providing an ACK or tested-by with this patch folded in?

Quoted 7 lines

arch/arm/mm/mmu.c static void __init build_mem_type_table(void) · line 492

Quoted 6 lines
arch/arm/mm/mmu.c +1 -0
@@ -506,16 +488,8 @@ static void __init build_mem_type_table(void)
 	mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
 	mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
 	mem_types[MT_ROM].prot_sect |= cp->pmd;
+	mem_types[MT_CACHECLEAN].prot_pte |= kern_pgprot;
 

Doesn't MT_MINICLEAN require kern_pgprot as well?

Only if you think the result of orring:

Quoted 8 lines
#define L_PTE_MT_WRITEBACK      (_AT(pteval_t, 0x03) << 2)      /* 0011 */
#define L_PTE_MT_MINICACHE      (_AT(pteval_t, 0x06) << 2)      /* 0110 (sa1100, xscale) */

together would make sense... it'd make it:

#define L_PTE_MT_WRITEALLOC (_AT(pteval_t, 0x07) << 2) /* 0111 */

though, so I don't think so.

Agreed.

Nicolas

#10 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

In reply to Russell King - ARM Linux
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Nicolas Pitre

Could you test this patch as well? You're the only one I know who might still have access to the affected hardware.

Tested on Assabet, and unfortunately, this doesn't work on its own because we don't permit iotable_init() to create pages with MT_CACHECLEAN and MT_MINICLEAN.

Quoted 6 lines

<4>BUG: map for 0xe0000000 at 0xfffe0000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0004000 at 0xfffe4000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe0008000 at 0xfffe8000 can not be mapped using pages, ignoring. <4>BUG: map for 0xe000c000 at 0xfffec000 can not be mapped using pages, ignoring.

The fix is below (probably with offsets):

[...]

So here is this patch again with all fixes folded in:

From: Nicolas Pitre <[email protected]>
Date: Tue, 5 Jul 2011 22:33:28 -0400
Subject: [PATCH] ARM: get rid of a few StrongARM cache-related build time constants

The StrongARM based machines define a couple constants which are obstacles to a single kernel image. Amongst them are FLUSH_BASE, FLUSH_BASE_PHYS, FLUSH_BASE_MINICACHE and UNCACHEABLE_ADDR. The affected code can be found in mm/mmu.c, mm/proc-sa110.S, mm/proc-sa1100.S and cache-v4wb.S. Let's create some code to deal with the differences at run time and initialize the proper mappings with common virtual addresses for them instead.

This should be functionally equivalent except for the following details:

- Mappings are created using second level PTEs instead of first level sections. The first level page table covering those PTEs is already there because of the fixmaps and the vector page so no additional memory is required. There might also be more TLB usage, however this is not something one might be concerned about when the whole cache is being flushed, completely pushing the cost of those TLBs below noise level.

- CACHE_DLIMIT is now the same for both SA110 and SA1100. This is unclear if loading a variable each time v4wb_flush_user_cache_range is called would be beneficial.

- The way UNCACHEABLE_ADDR was defined and used on RiscPC and Shark didn't produce a real uncacheable address, probably inhibiting the clock switching in cpu_sa110_do_idle(). As a side effect, this patch fixes this.

Thanks to Russell King for the mem_types[] fix.

Documentation/arm/memory.txt +4 -3
index 771d48d..b7a5ae8 100644
@@ -31,9 +31,10 @@ ffff0000	ffff0fff	CPU vector page.
 				CPU supports vector relocation (control
 				register V bit.)
 
-fffe0000	fffeffff	XScale cache flush area.  This is used
-				in proc-xscale.S to flush the whole data
-				cache. (XScale does not have TCM.)
+fffe0000	fffeffff	StrongARM and XScale cache flush area.
+				This is used in cache-v4wb.S and proc-xscale.S
+				to flush the whole data cache.
+				(Neither StrongARM nor XScale have TCM.)
 
 fffe8000	fffeffff	DTCM mapping area for platforms with
 				DTCM mounted inside the CPU.
arch/arm/include/asm/cacheflush.h +10 -0
index d5d8d5c..1821757 100644
@@ -157,6 +157,16 @@ extern void dmac_flush_range(const void *, const void *);
 
 #endif
 
+#ifdef CONFIG_CPU_CACHE_V4WB
+
+enum cache_v4wb_cputype { CACHE_CPU_SA110, CACHE_CPU_SA1100 };
+
+extern void cache_v4wb_init(unsigned long flush_phys_addr,
+			    unsigned long uncached_phys_addr,
+			    enum cache_v4wb_cputype cpu_type);
+
+#endif
+
 /*
  * Copy user data from/to a page which is mapped into a different
  * processes address space.  Really, we want to allow our "user
arch/arm/mach-ebsa110/core.c +4 -0
index 087bc77..66f9847 100644
@@ -23,6 +23,7 @@
 #include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
@@ -114,9 +115,12 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
 	}
 };
 
+#define SRAM_PHYS		0x40000000
+
 static void __init ebsa110_map_io(void)
 {
 	iotable_init(ebsa110_io_desc, ARRAY_SIZE(ebsa110_io_desc));
+	cache_v4wb_init(SRAM_PHYS, TRICK4_PHYS, CACHE_CPU_SA110);
 }
 
 
arch/arm/mach-ebsa110/include/mach/hardware.h +0 -5
index 4b2fb77..705dc40 100644
@@ -54,10 +54,5 @@
 #define PIT_BASE		0xfc000000
 #define SOFT_BASE		0xfd000000
 
-/*
- * RAM definitions
- */
-#define UNCACHEABLE_ADDR	0xff000000	/* IRQ_STAT */
-
 #endif
 
arch/arm/mach-ebsa110/include/mach/memory.h +0 -6
index 8e49066..2af7ec4 100644
@@ -21,10 +21,4 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
-/*
- * Cache flushing area - SRAM
- */
-#define FLUSH_BASE_PHYS		0x40000000
-#define FLUSH_BASE		0xdf000000
-
 #endif
arch/arm/mach-footbridge/common.c +3 -0
index 38a44f9..2b9d83a 100644
@@ -21,6 +21,7 @@
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <asm/setup.h>
+#include <asm/cacheflush.h>
 #include <asm/hardware/dec21285.h>
 
 #include <asm/mach/irq.h>
@@ -185,6 +186,8 @@ static struct map_desc ebsa285_host_io_desc[] __initdata = {
 
 void __init footbridge_map_io(void)
 {
+	cache_v4wb_init(0x50000000, 0x50010000, CACHE_CPU_SA110);
+
 	/*
 	 * Set up the common mapping first; we need this to
 	 * determine whether we're in host mode or not.
arch/arm/mach-footbridge/include/mach/hardware.h +0 -2
index b6fdf23..f8b7e95 100644
@@ -63,8 +63,6 @@
 #define XBUS_SWITCH_J17_11	((*XBUS_SWITCH) & (1 << 5))
 #define XBUS_SWITCH_J17_9	((*XBUS_SWITCH) & (1 << 6))
 
-#define UNCACHEABLE_ADDR	(ARMCSR_BASE + 0x108)
-
 
 /* PIC irq control */
 #define PIC_LO			0x20
arch/arm/mach-footbridge/include/mach/memory.h +0 -7
index 5c6df37..3e17e5c 100644
@@ -55,15 +55,8 @@ extern unsigned long __bus_to_pfn(unsigned long);
 #endif
 
 /*
- * Cache flushing area.
- */
-#define FLUSH_BASE		0xf9000000
-
-/*
  * Physical DRAM offset.
  */
 #define PLAT_PHYS_OFFSET		UL(0x00000000)
 
-#define FLUSH_BASE_PHYS		0x50000000
-
 #endif
arch/arm/mach-rpc/include/mach/hardware.h +0 -2
index dde6b3c..4f3b227 100644
@@ -46,8 +46,6 @@
 #define SCREEN_END		0xdfc00000
 #define SCREEN_BASE		0xdf800000
 
-#define UNCACHEABLE_ADDR	0xdf010000
-
 /*
  * IO Addresses
  */
arch/arm/mach-rpc/include/mach/memory.h +0 -6
index 18a2210..e2fcf9b 100644
@@ -24,12 +24,6 @@
 #define PLAT_PHYS_OFFSET	UL(0x10000000)
 
 /*
- * Cache flushing area - ROM
- */
-#define FLUSH_BASE_PHYS		0x00000000
-#define FLUSH_BASE		0xdf000000
-
-/*
  * Sparsemem support.  Each section is a maximum of 64MB.  The sections
  * are offset by 128MB and can cover 128MB, so that gives us a maximum
  * of 29 physmem bits.
arch/arm/mach-rpc/riscpc.c +4 -0
index 580b3c7..fd086ff 100644
@@ -27,6 +27,7 @@
 #include <asm/page.h>
 #include <asm/domain.h>
 #include <asm/setup.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
@@ -84,6 +85,9 @@ static struct map_desc rpc_io_desc[] __initdata = {
 static void __init rpc_map_io(void)
 {
 	iotable_init(rpc_io_desc, ARRAY_SIZE(rpc_io_desc));
+#ifdef CPU_CACHE_V4WB
+	cache_v4wb_init(0, 0x10000, CACHE_CPU_SA110);
+#endif
 
 	/*
 	 * Turn off floppy.
arch/arm/mach-sa1100/generic.c +5 -0
index e21f347..36b6980 100644
@@ -21,6 +21,7 @@
 #include <asm/div64.h>
 #include <mach/hardware.h>
 #include <asm/system.h>
+#include <asm/cacheflush.h>
 #include <asm/mach/map.h>
 #include <asm/mach/flash.h>
 #include <asm/irq.h>
@@ -406,9 +407,13 @@ static struct map_desc standard_io_desc[] __initdata = {
 	},
 };
 
+#define SA1100_ZERO_BANK	0xe0000000
+#define ICIP_PHYS_ADDR		0x90050000
+
 void __init sa1100_map_io(void)
 {
 	iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
+	cache_v4wb_init(SA1100_ZERO_BANK, ICIP_PHYS_ADDR, CACHE_CPU_SA1100);
 }
 
 /*
arch/arm/mach-sa1100/include/mach/hardware.h +0 -4
index 967ae76..355f0b0 100644
@@ -12,10 +12,6 @@
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-
-#define UNCACHEABLE_ADDR	0xfa050000
-
-
 /*
  * SA1100 internal I/O mappings
  *
arch/arm/mach-sa1100/include/mach/memory.h +0 -7
index 12d3767..8b56fb3 100644
@@ -31,11 +31,4 @@
 #define MAX_PHYSMEM_BITS	32
 #define SECTION_SIZE_BITS	27
 
-/*
- * Cache flushing area - SA1100 zero bank
- */
-#define FLUSH_BASE_PHYS		0xe0000000
-#define FLUSH_BASE		0xf5000000
-#define FLUSH_BASE_MINICACHE	0xf5100000
-
 #endif
arch/arm/mach-shark/core.c +2 -0
index ac2873c..1173082 100644
@@ -15,6 +15,7 @@
 #include <asm/mach-types.h>
 #include <asm/leds.h>
 #include <asm/param.h>
+#include <asm/cacheflush.h>
 
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
@@ -116,6 +117,7 @@ static struct map_desc shark_io_desc[] __initdata = {
 static void __init shark_map_io(void)
 {
 	iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc));
+	cache_v4wb_init(0x80000000, 0x80010000, CACHE_CPU_SA110);
 }
 
 #define IRQ_TIMER 0
arch/arm/mach-shark/include/mach/hardware.h +0 -2
index 94d84b2..dab0857 100644
@@ -10,8 +10,6 @@
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-#define UNCACHEABLE_ADDR        0xdf010000
-
 #define pcibios_assign_all_busses()     1
 
 #define PCIBIOS_MIN_IO          0x6000
arch/arm/mach-shark/include/mach/memory.h +0 -6
index 1cf8d69..e19df6f 100644
@@ -17,10 +17,4 @@
  */
 #define PLAT_PHYS_OFFSET     UL(0x08000000)
 
-/*
- * Cache flushing area
- */
-#define FLUSH_BASE_PHYS		0x80000000
-#define FLUSH_BASE		0xdf000000
-
 #endif
arch/arm/mm/Makefile +1 -1
index bca7e61..14b0af1 100644
@@ -36,7 +36,7 @@ obj-$(CONFIG_CPU_PABRT_V7)	+= pabort-v7.o
 obj-$(CONFIG_CPU_CACHE_V3)	+= cache-v3.o
 obj-$(CONFIG_CPU_CACHE_V4)	+= cache-v4.o
 obj-$(CONFIG_CPU_CACHE_V4WT)	+= cache-v4wt.o
-obj-$(CONFIG_CPU_CACHE_V4WB)	+= cache-v4wb.o
+obj-$(CONFIG_CPU_CACHE_V4WB)	+= cache-v4wb.o cache-v4wb-init.o
 obj-$(CONFIG_CPU_CACHE_V6)	+= cache-v6.o
 obj-$(CONFIG_CPU_CACHE_V7)	+= cache-v7.o
 obj-$(CONFIG_CPU_CACHE_FA)	+= cache-fa.o
arch/arm/mm/cache-v4wb-init.c new file +89 -0

89 lines not on this page · raw message

arch/arm/mm/cache-v4wb.S +5 -26
index f40c696..bff5fec 100644
@@ -19,17 +19,6 @@
 #define CACHE_DLINESIZE	32
 
 /*
- * The total size of the data cache.
- */
-#if defined(CONFIG_CPU_SA110)
-# define CACHE_DSIZE	16384
-#elif defined(CONFIG_CPU_SA1100)
-# define CACHE_DSIZE	8192
-#else
-# error Unknown cache size
-#endif
-
-/*
  * This is the size at which it becomes more efficient to
  * clean the whole cache, rather than using the individual
  * cache line maintenance instructions.
@@ -43,11 +32,8 @@
  * 131072  591 591 591   656 657 651
  *  Whole  132 136 132   221 217 207 <---
  */
-#define CACHE_DLIMIT	(CACHE_DSIZE * 4)
+#define CACHE_DLIMIT	32768
 
-	.data
-flush_base:
-	.long	FLUSH_BASE
 	.text
 
 /*
@@ -78,21 +64,14 @@ ENTRY(v4wb_flush_kern_cache_all)
 	mov	ip, #0
 	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
 __flush_whole_cache:
-	ldr	r3, =flush_base
-	ldr	r1, [r3, #0]
-	eor	r1, r1, #CACHE_DSIZE
+	ldr	r3, =cache_v4wb_params
+	ldmia	r3, {r1, r2}
+	eor	r1, r1, #32768			@ FLUSH_OFF_ALT
 	str	r1, [r3, #0]
-	add	r2, r1, #CACHE_DSIZE
-1:	ldr	r3, [r1], #32
-	cmp	r1, r2
-	blo	1b
-#ifdef FLUSH_BASE_MINICACHE
-	add	r2, r2, #FLUSH_BASE_MINICACHE - FLUSH_BASE
-	sub	r1, r2, #512			@ only 512 bytes
+	add	r2, r1, r2
 1:	ldr	r3, [r1], #32
 	cmp	r1, r2
 	blo	1b
-#endif
 	mcr	p15, 0, ip, c7, c10, 4		@ drain write buffer
 	mov	pc, lr
 
arch/arm/mm/mmu.c +10 -33

76 lines not on this page · raw message

arch/arm/mm/proc-sa110.S +5 -0
index 46f09ed..e8c44a2 100644
@@ -30,6 +30,11 @@
  */
 #define DCACHELINESIZE	32
 
+/*
+ * Address used for uncached access (mapping set up in cache-v4wb-init.c)
+ */
+#define UNCACHEABLE_ADDR 0xfffee000
+
 	.text
 
 /*
arch/arm/mm/proc-sa1100.S +5 -0
index 184a9c9..2d805ae 100644
@@ -34,6 +34,11 @@
  */
 #define DCACHELINESIZE	32
 
+/*
+ * Address used for uncached access (mapping set up in cache-v4wb-init.c)
+ */
+#define UNCACHEABLE_ADDR 0xfffee000
+
 	__INIT
 
 /*
#11 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 1 line · Nicolas Pitre

So here is this patch again with all fixes folded in:

Thanks. I didn't get a chance to test the original on anything but Assabet yet. I'll try to make some time for the other platforms this week.

#12 lore raw

PATCH 1/1 ARM: get rid of a few StrongARM cache-related build time constants

Quoted 6 lines · Russell King - ARM Linux
Quoted 1 line · Nicolas Pitre

So here is this patch again with all fixes folded in:

Thanks. I didn't get a chance to test the original on anything but Assabet yet. I'll try to make some time for the other platforms this week.

You've put it in the patch system. I still haven't tested it, and I'm not going to test it this side of the merge window, so I'm not applying it yet.