ARM: add clean and flush_dcache_all to ARM cache API
Subsystems (2)
PATCH 1/1 ARM: add clean and flush_dcache_all to ARM cache API
From: Srinidhi KASAGAR <[email protected]>
This patch adds functions to flush and clean the entire data cache. Since the existing flush/clean range functions take more time to flush/clean the entire data cache, they cannot be used in performance-critical situations:
Whenever the range of data to be flushed/cleaned from the data cache is more than some threshold value, it is better to do the entire data flush/clean, this will reduce the time taken and effectively increases the performance of the system.
The actual cache clean/flush is only implemented for v7 in this patch, the other cpu versions are just dummy functions.
---
Since we cannot easily test CPU < v7 this is a bit of RFC. Maybe ARM people would like to take this over?
We really need this stuff, the usecase is buffer handling in contigous memory for graphic buffers, which is being discussed over at the V4L2 mailing list.
--- arch/arm/include/asm/cacheflush.h | 17 ++++++ arch/arm/mm/cache-fa.S | 20 ++++++++ arch/arm/mm/cache-v3.S | 20 ++++++++ arch/arm/mm/cache-v4.S | 20 ++++++++ arch/arm/mm/cache-v4wb.S | 20 ++++++++ arch/arm/mm/cache-v4wt.S | 20 ++++++++ arch/arm/mm/cache-v6.S | 20 ++++++++ arch/arm/mm/cache-v7.S | 98 ++++++++++++++++++++++++++++++++++--- arch/arm/mm/proc-v7.S | 2 +- 9 files changed, 228 insertions(+), 9 deletions(-)
arch/arm/include/asm/cacheflush.h +17 -0
@@ -201,6 +201,14 @@* - kaddr - page address * - size - region size * +* clean_dcache_all() +* +* Cleans the entire d-cache. +* +* flush_dcache_all() +* +* Flushes the entire d-cache. +* * DMA Cache Coherency * =================== *
@@ -221,6 +229,9 @@ struct cpu_cache_fns {void (*coherent_user_range)(unsigned long ,unsigned long );void (*flush_kern_dcache_area)(void *,size_t ); +void (*clean_dcache_all)(void ); +void (*flush_dcache_all)(void ); +void (*dma_map_area)(const void *,size_t ,int );void (*dma_unmap_area)(const void *,size_t ,int );
@@ -241,6 +252,8 @@ extern struct cpu_cache_fns cpu_cache;#define __cpuc_coherent_kern_range cpu_cache.coherent_kern_range#define __cpuc_coherent_user_range cpu_cache.coherent_user_range#define __cpuc_flush_dcache_area cpu_cache.flush_kern_dcache_area +#define __cpuc_clean_dcache_all cpu_cache.clean_dcache_all +#define __cpuc_flush_dcache_all cpu_cache.flush_dcache_all/* * These are private to the dma-mapping API. Do not use directly.
@@ -261,6 +274,8 @@ extern struct cpu_cache_fns cpu_cache;#define __cpuc_coherent_kern_range __glue(_CACHE,_coherent_kern_range)#define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range)#define __cpuc_flush_dcache_area __glue(_CACHE,_flush_kern_dcache_area) +#define __cpuc_clean_dcache_all __glue(_CACHE,_clean_dcache_all) +#define __cpuc_flush_dcache_all __glue(_CACHE,_flush_dcache_all)extern void __cpuc_flush_icache_all (void );extern void __cpuc_flush_kern_all (void );
@@ -269,6 +284,8 @@ extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);extern void __cpuc_coherent_kern_range (unsigned long ,unsigned long );extern void __cpuc_coherent_user_range (unsigned long ,unsigned long );extern void __cpuc_flush_dcache_area (void *,size_t ); +extern void __cpuc_clean_dcache_all (void ); +extern void __cpuc_flush_dcache_all (void );/* * These are private to the dma-mapping API. Do not use directly.
arch/arm/mm/cache-fa.S +20 -0
@@ -240,6 +240,24 @@ ENTRY(fa_dma_unmap_area) mov pc, lr ENDPROC(fa_dma_unmap_area) +/* + * clean_dcache_all() + * + * Clean the whole D-cache. + */ +ENTRY(fa_clean_dcache_all) + mov pc, lr +ENDPROC(fa_clean_dcache_all) + +/* + * flush_dcache_all() + * + * Flush the whole D-cache. + */ +ENTRY(fa_flush_dcache_all) + mov pc, lr +ENDPROC(fa_flush_dcache_all) + __INITDATA .type fa_cache_fns, #object
@@ -251,6 +269,8 @@ ENTRY(fa_cache_fns) .long fa_coherent_kern_range .long fa_coherent_user_range .long fa_flush_kern_dcache_area + .long fa_clean_dcache_all + .long fa_flush_dcache_all .long fa_dma_map_area .long fa_dma_unmap_area .long fa_dma_flush_range
arch/arm/mm/cache-v3.S +20 -0
@@ -127,6 +127,24 @@ ENTRY(v3_dma_map_area) ENDPROC(v3_dma_unmap_area) ENDPROC(v3_dma_map_area) +/* + * clean_dcache_all() + * + * Clean the whole D-cache. + */ +ENTRY(v3_clean_dcache_all) + mov pc, lr +ENDPROC(v3_clean_dcache_all) + +/* + * flush_dcache_all() + * + * Flush the whole D-cache. + */ +ENTRY(v3_flush_dcache_all) + mov pc, lr +ENDPROC(v3_flush_dcache_all) + __INITDATA .type v3_cache_fns, #object
@@ -138,6 +156,8 @@ ENTRY(v3_cache_fns) .long v3_coherent_kern_range .long v3_coherent_user_range .long v3_flush_kern_dcache_area + .long v3_clean_dcache_all + .long v3_flush_dcache_all .long v3_dma_map_area .long v3_dma_unmap_area .long v3_dma_flush_range
arch/arm/mm/cache-v4.S +20 -0
@@ -139,6 +139,24 @@ ENTRY(v4_dma_map_area) ENDPROC(v4_dma_unmap_area) ENDPROC(v4_dma_map_area) +/* + * clean_dcache_all() + * + * Clean the whole D-cache. + */ +ENTRY(v4_clean_dcache_all) + mov pc, lr +ENDPROC(v4_clean_dcache_all) + +/* + * flush_dcache_all() + * + * Flush the whole D-cache. + */ +ENTRY(v4_flush_dcache_all) + mov pc, lr +ENDPROC(v4_flush_dcache_all) + __INITDATA .type v4_cache_fns, #object
@@ -150,6 +168,8 @@ ENTRY(v4_cache_fns) .long v4_coherent_kern_range .long v4_coherent_user_range .long v4_flush_kern_dcache_area + .long v4_clean_dcache_all + .long v4_flush_dcache_all .long v4_dma_map_area .long v4_dma_unmap_area .long v4_dma_flush_range
arch/arm/mm/cache-v4wb.S +20 -0
@@ -251,6 +251,24 @@ ENTRY(v4wb_dma_unmap_area) mov pc, lr ENDPROC(v4wb_dma_unmap_area) +/* + * clean_dcache_all() + * + * Clean the whole D-cache. + */ +ENTRY(v4wb_clean_dcache_all) + mov pc, lr +ENDPROC(v4wb_clean_dcache_all) + +/* + * flush_dcache_all() + * + * Flush the whole D-cache. + */ +ENTRY(v4wb_flush_dcache_all) + mov pc, lr +ENDPROC(v4wb_flush_dcache_all) + __INITDATA .type v4wb_cache_fns, #object
@@ -262,6 +280,8 @@ ENTRY(v4wb_cache_fns) .long v4wb_coherent_kern_range .long v4wb_coherent_user_range .long v4wb_flush_kern_dcache_area + .long v4wb_clean_dcache_all + .long v4wb_flush_dcache_all .long v4wb_dma_map_area .long v4wb_dma_unmap_area .long v4wb_dma_flush_range
arch/arm/mm/cache-v4wt.S +20 -0
@@ -195,6 +195,24 @@ ENTRY(v4wt_dma_map_area) ENDPROC(v4wt_dma_unmap_area) ENDPROC(v4wt_dma_map_area) +/* + * clean_dcache_all() + * + * Clean the whole D-cache. + */ +ENTRY(v4wt_clean_dcache_all) + mov pc, lr +ENDPROC(v4wt_clean_dcache_all) + +/* + * flush_dcache_all() + * + * Flush the whole D-cache. + */ +ENTRY(v4wt_flush_dcache_all) + mov pc, lr +ENDPROC(v4wt_flush_dcache_all) + __INITDATA .type v4wt_cache_fns, #object
@@ -206,6 +224,8 @@ ENTRY(v4wt_cache_fns) .long v4wt_coherent_kern_range .long v4wt_coherent_user_range .long v4wt_flush_kern_dcache_area + .long v4wt_clean_dcache_all + .long v4wt_flush_dcache_all .long v4wt_dma_map_area .long v4wt_dma_unmap_area .long v4wt_dma_flush_range
arch/arm/mm/cache-v6.S +20 -0
@@ -315,6 +315,24 @@ ENTRY(v6_dma_unmap_area) mov pc, lr ENDPROC(v6_dma_unmap_area) +/* + * clean_dcache_all() + * + * Clean the whole D-cache. + */ +ENTRY(v6_clean_dcache_all) + mov pc, lr +ENDPROC(v6_clean_dcache_all) + +/* + * flush_dcache_all() + * + * Flush the whole D-cache. + */ +ENTRY(v6_flush_dcache_all) + mov pc, lr +ENDPROC(v6_flush_dcache_all) + __INITDATA .type v6_cache_fns, #object
@@ -326,6 +344,8 @@ ENTRY(v6_cache_fns) .long v6_coherent_kern_range .long v6_coherent_user_range .long v6_flush_kern_dcache_area + .long v6_clean_dcache_all + .long v6_flush_dcache_all .long v6_dma_map_area .long v6_dma_unmap_area .long v6_dma_flush_range
arch/arm/mm/cache-v7.S +90 -8
134 lines not on this page · raw message
arch/arm/mm/proc-v7.S +1 -1
@@ -196,7 +196,7 @@ __v7_ca9mp_setup: __v7_setup: adr r12, __v7_setup_stack @ the local stack stmia r12, {r0-r5, r7, r9, r11, lr} - bl v7_flush_dcache_all + bl __v7_flush_dcache_all ldmia r12, {r0-r5, r7, r9, r11, lr} mrc p15, 0, r0, c0, c0, 0 @ read main ID register
Signature · 1 line
1.6.3.3
PATCH 1/1 ARM: add clean and flush_dcache_all to ARM cache API
Quoted 4 lines · Linus Walleij
This patch adds functions to flush and clean the entire data cache. Since the existing flush/clean range functions take more time to flush/clean the entire data cache, they cannot be used in performance-critical situations:
This is something that should be decided (as we already do for some processors) inside those methods. There's no need for new methods.
PATCH 1/1 ARM: add clean and flush_dcache_all to ARM cache API
Quoted 8 lines · Russell King - ARM Linux
Quoted 4 lines · Linus Walleij
This patch adds functions to flush and clean the entire data cache. Since the existing flush/clean range functions take more time to flush/clean the entire data cache, they cannot be used in performance-critical situations:
This is something that should be decided (as we already do for some processors) inside those methods. There's no need for new methods.
Aha so we should check the size of the buffer in the normal cache clean_range/flush_range operations and if it exceeds a certain watermark that we know for this specific arch we clean/flush all cache instead?
Sounds like it could be done if I get it right.
Yours,
Linus Walleij