Skip to contentSkip to conversation

armv7m: cache: cleanup before linux booting

PATCH New Vikas Manocha 2 participants 6 messages May 3, 2017 – May 12, 2017 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover armv7m: cache: cleanup before linux booting

This patchset:
- add all data cache flushing & invalidation functions as declared in the common header file.
- adds cleanup before linux booting.

Vikas Manocha (2):
armv7m: cache: add flush & invalidate all dcache
arvm7m: add cleanup before linux booting

 arch/arm/cpu/armv7m/cache.c | 15 +++++++++++++++
 arch/arm/cpu/armv7m/cpu.c   | 19 +++++++++++++++++++
 2 files changed, 34 insertions(+)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/2 armv7m: cache: add flush & invalidate all dcache

Add functionality to flush & invalidate all the dcache using the prototype declared in common header file.

---
 arch/arm/cpu/armv7m/cache.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/cpu/armv7m/cache.c +15 -0
index 162cfe3..84f658d 100644
@@ -253,6 +253,21 @@ void flush_dcache_range(unsigned long start, unsigned long stop)
 		return;
 	}
 }
+void flush_dcache_all(void)
+{
+	if (action_dcache_all(FLUSH_SET_WAY)) {
+		printf("ERR: D-cache not flushed\n");
+		return;
+	}
+}
+
+void invalidate_dcache_all(void)
+{
+	if (action_dcache_all(INVALIDATE_SET_WAY)) {
+		printf("ERR: D-cache not invalidated\n");
+		return;
+	}
+}
 #else
 void dcache_enable(void)
 {
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/2 armv7m: cache: add flush & invalidate all dcache

Quoted 4 lines · Vikas Manocha

Add functionality to flush & invalidate all the dcache using the prototype declared in common header file.

After adding dummy functions for the cache not enabled side (to match other CPU families, ie armv7, and not break stm32f429-discovery builds), applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170512/90b81554/attachment.sig>
#3 lore raw

PATCH 1/2 armv7m: cache: add flush & invalidate all dcache

Hi,

Quoted 9 lines

-----Original Message-----
From: Tom Rini [mailto:trini at konsulko.com]
Sent: Friday, May 12, 2017 10:18 AM
To: Vikas MANOCHA <[email protected]>
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot,1/2] armv7m: cache: add flush & invalidate all dcache

On Wed, May 03, 2017 at 03:48:25PM -0700, Vikas Manocha wrote:

Quoted 7 lines
Quoted 4 lines

Add functionality to flush & invalidate all the dcache using the prototype declared in common header file.

After adding dummy functions for the cache not enabled side (to match other CPU families, ie armv7, and not break stm32f429- discovery builds), applied to u-boot/master, thanks!

Thanks Tom.

Cheers,
Vikas

Quoted 3 lines

--
Tom

#4 lore raw

PATCH 2/2 arvm7m: add cleanup before linux booting

In reply to Vikas Manocha

Data cache memory needs to be disabled before handing over control to linux kernel. This patch populates the cleanup_before_linux stub.

---
 arch/arm/cpu/armv7m/cpu.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/cpu/armv7m/cpu.c +19 -0
index 58cde93..a424bab 100644
@@ -18,6 +18,25 @@
  */
 int cleanup_before_linux(void)
 {
+	/*
+	 * this function is called just before we call linux
+	 * it prepares the processor for linux
+	 *
+	 * disable interrupt and turn off caches etc ...
+	 */
+	disable_interrupts();
+	/*
+	 * turn off D-cache
+	 * dcache_disable() in turn flushes the d-cache
+	 * MPU is still enabled & can't be disabled as the u-boot
+	 * code might be running in sdram which by default is not
+	 * executable area.
+	 */
+	dcache_disable();
+	/* invalidate to make sure no cache line gets dirty between
+	 * dcache flushing and disabling dcache */
+	invalidate_dcache_all();
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#5 lore raw

PATCH 2/2 arvm7m: add cleanup before linux booting

Quoted 4 lines · Vikas Manocha

Data cache memory needs to be disabled before handing over control to linux kernel. This patch populates the cleanup_before_linux stub.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170512/6b790fb0/attachment.sig>