Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc32: move xxxxx_dcache_range() functions inline

flush/clean/invalidate _dcache_range() functions are all very
similar and are quite short. They are mainly used in __dma_sync()
perf_event locate them in the top 3 consumming functions during
heavy ethernet activity

They are good candidate for inlining, as __dma_sync() does
almost nothing but calling them

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Scott Wood <oss@buserror.net>

authored by

Christophe Leroy and committed by
Scott Wood
affe587b 5736f96d

+51 -68
+49 -3
arch/powerpc/include/asm/cacheflush.h
··· 45 45 } 46 46 #endif 47 47 48 - extern void flush_dcache_range(unsigned long start, unsigned long stop); 49 48 #ifdef CONFIG_PPC32 50 - extern void clean_dcache_range(unsigned long start, unsigned long stop); 51 - extern void invalidate_dcache_range(unsigned long start, unsigned long stop); 49 + /* 50 + * Write any modified data cache blocks out to memory and invalidate them. 51 + * Does not invalidate the corresponding instruction cache blocks. 52 + */ 53 + static inline void flush_dcache_range(unsigned long start, unsigned long stop) 54 + { 55 + void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1)); 56 + unsigned long size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1); 57 + unsigned long i; 58 + 59 + for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES) 60 + dcbf(addr); 61 + mb(); /* sync */ 62 + } 63 + 64 + /* 65 + * Write any modified data cache blocks out to memory. 66 + * Does not invalidate the corresponding cache lines (especially for 67 + * any corresponding instruction cache). 68 + */ 69 + static inline void clean_dcache_range(unsigned long start, unsigned long stop) 70 + { 71 + void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1)); 72 + unsigned long size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1); 73 + unsigned long i; 74 + 75 + for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES) 76 + dcbst(addr); 77 + mb(); /* sync */ 78 + } 79 + 80 + /* 81 + * Like above, but invalidate the D-cache. This is used by the 8xx 82 + * to invalidate the cache so the PPC core doesn't get stale data 83 + * from the CPM (no cache snooping here :-). 84 + */ 85 + static inline void invalidate_dcache_range(unsigned long start, 86 + unsigned long stop) 87 + { 88 + void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1)); 89 + unsigned long size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1); 90 + unsigned long i; 91 + 92 + for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES) 93 + dcbi(addr); 94 + mb(); /* sync */ 95 + } 96 + 52 97 #endif /* CONFIG_PPC32 */ 53 98 #ifdef CONFIG_PPC64 99 + extern void flush_dcache_range(unsigned long start, unsigned long stop); 54 100 extern void flush_inval_dcache_range(unsigned long start, unsigned long stop); 55 101 extern void flush_dcache_phys_range(unsigned long start, unsigned long stop); 56 102 #endif
-65
arch/powerpc/kernel/misc_32.S
··· 375 375 isync 376 376 blr 377 377 /* 378 - * Write any modified data cache blocks out to memory. 379 - * Does not invalidate the corresponding cache lines (especially for 380 - * any corresponding instruction cache). 381 - * 382 - * clean_dcache_range(unsigned long start, unsigned long stop) 383 - */ 384 - _GLOBAL(clean_dcache_range) 385 - li r5,L1_CACHE_BYTES-1 386 - andc r3,r3,r5 387 - subf r4,r3,r4 388 - add r4,r4,r5 389 - srwi. r4,r4,L1_CACHE_SHIFT 390 - beqlr 391 - mtctr r4 392 - 393 - 1: dcbst 0,r3 394 - addi r3,r3,L1_CACHE_BYTES 395 - bdnz 1b 396 - sync /* wait for dcbst's to get to ram */ 397 - blr 398 - 399 - /* 400 - * Write any modified data cache blocks out to memory and invalidate them. 401 - * Does not invalidate the corresponding instruction cache blocks. 402 - * 403 - * flush_dcache_range(unsigned long start, unsigned long stop) 404 - */ 405 - _GLOBAL(flush_dcache_range) 406 - li r5,L1_CACHE_BYTES-1 407 - andc r3,r3,r5 408 - subf r4,r3,r4 409 - add r4,r4,r5 410 - srwi. r4,r4,L1_CACHE_SHIFT 411 - beqlr 412 - mtctr r4 413 - 414 - 1: dcbf 0,r3 415 - addi r3,r3,L1_CACHE_BYTES 416 - bdnz 1b 417 - sync /* wait for dcbst's to get to ram */ 418 - blr 419 - 420 - /* 421 - * Like above, but invalidate the D-cache. This is used by the 8xx 422 - * to invalidate the cache so the PPC core doesn't get stale data 423 - * from the CPM (no cache snooping here :-). 424 - * 425 - * invalidate_dcache_range(unsigned long start, unsigned long stop) 426 - */ 427 - _GLOBAL(invalidate_dcache_range) 428 - li r5,L1_CACHE_BYTES-1 429 - andc r3,r3,r5 430 - subf r4,r3,r4 431 - add r4,r4,r5 432 - srwi. r4,r4,L1_CACHE_SHIFT 433 - beqlr 434 - mtctr r4 435 - 436 - 1: dcbi 0,r3 437 - addi r3,r3,L1_CACHE_BYTES 438 - bdnz 1b 439 - sync /* wait for dcbi's to get to ram */ 440 - blr 441 - 442 - /* 443 378 * Flush a particular page from the data cache to RAM. 444 379 * Note: this is necessary because the instruction cache does *not* 445 380 * snoop from the data cache.
+2
arch/powerpc/kernel/ppc_ksyms.c
··· 6 6 #include <asm/cacheflush.h> 7 7 #include <asm/epapr_hcalls.h> 8 8 9 + #ifdef CONFIG_PPC64 9 10 EXPORT_SYMBOL(flush_dcache_range); 11 + #endif 10 12 EXPORT_SYMBOL(flush_icache_range); 11 13 12 14 EXPORT_SYMBOL(empty_zero_page);