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

cache: sifive_ccache: Optimize cache flushes

Fence instructions are required only at the beginning and the end of
a flush operation, not separately for each cache line being flushed.
Speed up cache flushes by about 15% by removing the extra fences.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>

authored by

Samuel Holland and committed by
Conor Dooley
941327ca 4fab69dd

+4 -4
+4 -4
drivers/cache/sifive_ccache.c
··· 151 151 if (!len) 152 152 return; 153 153 154 - mb(); 154 + mb(); /* complete earlier memory accesses before the cache flush */ 155 155 for (line = ALIGN_DOWN(start, SIFIVE_CCACHE_LINE_SIZE); line < end; 156 156 line += SIFIVE_CCACHE_LINE_SIZE) { 157 157 #ifdef CONFIG_32BIT 158 - writel(line >> 4, ccache_base + SIFIVE_CCACHE_FLUSH32); 158 + writel_relaxed(line >> 4, ccache_base + SIFIVE_CCACHE_FLUSH32); 159 159 #else 160 - writeq(line, ccache_base + SIFIVE_CCACHE_FLUSH64); 160 + writeq_relaxed(line, ccache_base + SIFIVE_CCACHE_FLUSH64); 161 161 #endif 162 - mb(); 163 162 } 163 + mb(); /* issue later memory accesses after the cache flush */ 164 164 } 165 165 166 166 static const struct riscv_nonstd_cache_ops ccache_mgmt_ops __initconst = {