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

MIPS: c-r4k: Invalidate BMIPS5000 ZSCM prefetch lines

Zephyr secondary cache is 256KB, 128B lines. 32B sectors. A secondary cache
line can contain two instruction cache lines (64B), or four data cache
lines (32B). Hardware prefetch Cache detects stream access, and prefetches
ahead of processor access. Add support to invalidate BMIPS5000 cpu zephyr
secondary cache module (ZSCM) on DMA from device so that data returned is
coherent during DMA read operations.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Kamal Dasu and committed by
Thomas Bogendoerfer
be280764 49e6e07e

+29
+29
arch/mips/mm/c-r4k.c
··· 901 901 __sync(); 902 902 } 903 903 904 + static void prefetch_cache_inv(unsigned long addr, unsigned long size) 905 + { 906 + unsigned int linesz = cpu_scache_line_size(); 907 + unsigned long addr0 = addr, addr1; 908 + 909 + addr0 &= ~(linesz - 1); 910 + addr1 = (addr0 + size - 1) & ~(linesz - 1); 911 + 912 + protected_writeback_scache_line(addr0); 913 + if (likely(addr1 != addr0)) 914 + protected_writeback_scache_line(addr1); 915 + else 916 + return; 917 + 918 + addr0 += linesz; 919 + if (likely(addr1 != addr0)) 920 + protected_writeback_scache_line(addr0); 921 + else 922 + return; 923 + 924 + addr1 -= linesz; 925 + if (likely(addr1 > addr0)) 926 + protected_writeback_scache_line(addr0); 927 + } 928 + 904 929 static void r4k_dma_cache_inv(unsigned long addr, unsigned long size) 905 930 { 906 931 /* Catch bad driver code */ ··· 933 908 return; 934 909 935 910 preempt_disable(); 911 + 912 + if (current_cpu_type() == CPU_BMIPS5000) 913 + prefetch_cache_inv(addr, size); 914 + 936 915 if (cpu_has_inclusive_pcaches) { 937 916 if (size >= scache_size) { 938 917 if (current_cpu_type() != CPU_LOONGSON64)