Skip to contentSkip to conversation

ARM: Thumb-2: Enable ARM/Thumb interworking for v7 cache maintenance

PATCH New Dave Martin 3 participants 4 messages Feb 15, 2011 – Feb 16, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Thumb-2: Enable ARM/Thumb interworking for v7 cache maintenance

Cache maintenence functions may need to be called from low-level platform code (such as for omap3).

Some low-level code may need to be built as ARM code even in a Thumb-2 kernel, if the code needs to talk to a non-Thumb-2-aware bootloader or firmware (again, omap3 is an example).

In order to avoid the need for complex hacks to make calling these cache maintenance routines work, simply use "bx lr" to return from these functions.

There's no risk of build failures, since mm/*-v7.S are by definition built with -march=armv7-a.

bx lr always does the right thing for a pure ARM kernel, so we shouldn't need any conditional assembly here.

---
 arch/arm/mm/cache-v7.S |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
arch/arm/mm/cache-v7.S +10 -10
index 6136e68..a5e5aa1 100644
@@ -29,7 +29,7 @@ ENTRY(v7_flush_icache_all)
 	mov	r0, #0
 	ALT_SMP(mcr	p15, 0, r0, c7, c1, 0)		@ invalidate I-cache inner shareable
 	ALT_UP(mcr	p15, 0, r0, c7, c5, 0)		@ I+BTB cache invalidate
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_icache_all)
 
 /*
@@ -87,7 +87,7 @@ finished:
 	mcr	p15, 2, r10, c0, c0, 0		@ select current cache level in cssr
 	dsb
 	isb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_dcache_all)
 
 /*
@@ -110,7 +110,7 @@ ENTRY(v7_flush_kern_cache_all)
 	ALT_UP(mcr	p15, 0, r0, c7, c5, 0)	@ I+BTB cache invalidate
  ARM(	ldmfd	sp!, {r4-r5, r7, r9-r11, lr}	)
  THUMB(	ldmfd	sp!, {r4-r7, r9-r11, lr}	)
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_kern_cache_all)
 
 /*
@@ -136,7 +136,7 @@ ENTRY(v7_flush_user_cache_all)
  *	- we have a VIPT cache.
  */
 ENTRY(v7_flush_user_cache_range)
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_user_cache_all)
 ENDPROC(v7_flush_user_cache_range)
 
@@ -194,7 +194,7 @@ ENTRY(v7_coherent_user_range)
 	ALT_UP(mcr	p15, 0, r0, c7, c5, 6)	@ invalidate BTB
 	dsb
 	isb
-	mov	pc, lr
+	bx	lr
 
 /*
  * Fault handling for the cache operation above. If the virtual address in r0
@@ -227,7 +227,7 @@ ENTRY(v7_flush_kern_dcache_area)
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_kern_dcache_area)
 
 /*
@@ -256,7 +256,7 @@ v7_dma_inv_range:
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_inv_range)
 
 /*
@@ -274,7 +274,7 @@ v7_dma_clean_range:
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_clean_range)
 
 /*
@@ -292,7 +292,7 @@ ENTRY(v7_dma_flush_range)
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_flush_range)
 
 /*
@@ -318,7 +318,7 @@ ENTRY(v7_dma_unmap_area)
 	add	r1, r1, r0
 	teq	r2, #DMA_TO_DEVICE
 	bne	v7_dma_inv_range
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_unmap_area)
 
 	__INITDATA
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 ARM: Thumb-2: Enable ARM/Thumb interworking for v7 cache maintenance

Quoted 2 lines · Dave Martin

Cache maintenence functions may need to be called from low-level platform code (such as for omap3).

I'd rather wait until we have the suspend stuff sorted out. I'm waiting for OMAP folk to sort out what's happening with the sleep*.S code so that it can have the generic CPU suspend code integrated. That could result in this change not being required.

#2 lore raw

PATCH 1/1 ARM: Thumb-2: Enable ARM/Thumb interworking for v7 cache maintenance

Quoted 9 lines · Russell King - ARM Linux
Quoted 2 lines · Dave Martin

Cache maintenence functions may need to be called from low-level platform code (such as for omap3).

I'd rather wait until we have the suspend stuff sorted out. ?I'm waiting for OMAP folk to sort out what's happening with the sleep*.S code so that it can have the generic CPU suspend code integrated. That could result in this change not being required.

OK; I guess we can work around this in the omap BSP for the time being.

---Dave

#3 lore raw

PATCH 1/1 ARM: Thumb-2: Enable ARM/Thumb interworking for v7 cache maintenance

In reply to Dave Martin
Quoted 11 lines · Dave Martin

Cache maintenence functions may need to be called from low-level platform code (such as for omap3).

Some low-level code may need to be built as ARM code even in a Thumb-2 kernel, if the code needs to talk to a non-Thumb-2-aware bootloader or firmware (again, omap3 is an example).

In order to avoid the need for complex hacks to make calling these cache maintenance routines work, simply use "bx lr" to return from these functions.

Quoted 7 lines

There's no risk of build failures, since mm/*-v7.S are by definition built with -march=armv7-a.

bx lr always does the right thing for a pure ARM kernel, so we shouldn't need any conditional assembly here.

Quoted 107 lines
---
 arch/arm/mm/cache-v7.S |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
arch/arm/mm/cache-v7.S +10 -10
index 6136e68..a5e5aa1 100644
@@ -29,7 +29,7 @@ ENTRY(v7_flush_icache_all)
 	mov	r0, #0
 	ALT_SMP(mcr	p15, 0, r0, c7, c1, 0)		@ invalidate I-cache inner shareable
 	ALT_UP(mcr	p15, 0, r0, c7, c5, 0)		@ I+BTB cache invalidate
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_icache_all)
 
 /*
@@ -87,7 +87,7 @@ finished:
 	mcr	p15, 2, r10, c0, c0, 0		@ select current cache level in cssr
 	dsb
 	isb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_dcache_all)
 
 /*
@@ -110,7 +110,7 @@ ENTRY(v7_flush_kern_cache_all)
 	ALT_UP(mcr	p15, 0, r0, c7, c5, 0)	@ I+BTB cache invalidate
  ARM(	ldmfd	sp!, {r4-r5, r7, r9-r11, lr}	)
  THUMB(	ldmfd	sp!, {r4-r7, r9-r11, lr}	)
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_kern_cache_all)
 
 /*
@@ -136,7 +136,7 @@ ENTRY(v7_flush_user_cache_all)
  *	- we have a VIPT cache.
  */
 ENTRY(v7_flush_user_cache_range)
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_user_cache_all)
 ENDPROC(v7_flush_user_cache_range)
 
@@ -194,7 +194,7 @@ ENTRY(v7_coherent_user_range)
 	ALT_UP(mcr	p15, 0, r0, c7, c5, 6)	@ invalidate BTB
 	dsb
 	isb
-	mov	pc, lr
+	bx	lr
 
 /*
  * Fault handling for the cache operation above. If the virtual address in r0
@@ -227,7 +227,7 @@ ENTRY(v7_flush_kern_dcache_area)
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_flush_kern_dcache_area)
 
 /*
@@ -256,7 +256,7 @@ v7_dma_inv_range:
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_inv_range)
 
 /*
@@ -274,7 +274,7 @@ v7_dma_clean_range:
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_clean_range)
 
 /*
@@ -292,7 +292,7 @@ ENTRY(v7_dma_flush_range)
 	cmp	r0, r1
 	blo	1b
 	dsb
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_flush_range)
 
 /*
@@ -318,7 +318,7 @@ ENTRY(v7_dma_unmap_area)
 	add	r1, r1, r0
 	teq	r2, #DMA_TO_DEVICE
 	bne	v7_dma_inv_range
-	mov	pc, lr
+	bx	lr
 ENDPROC(v7_dma_unmap_area)
 
 	__INITDATA
Signature · 7 lines
1.7.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel