From patchwork Sat May 2 08:59:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 244767 List-Id: U-Boot discussion From: sr at denx.de (Stefan Roese) Date: Sat, 2 May 2020 10:59:37 +0200 Subject: [PATCH v1 03/10] mips: cache: Don't use cache operations with CONFIG_MIPS_CACHE_COHERENT In-Reply-To: <20200502085944.13444-1-sr@denx.de> References: <20200502085944.13444-1-sr@denx.de> Message-ID: <20200502085944.13444-4-sr@denx.de> The Octeon platform is cache coherent and cache flushes and invalidates are not needed. This patch makes use of the newly introduced Kconfig option CONFIG_MIPS_CACHE_COHERENT to effectively disable all the cache operations. Signed-off-by: Stefan Roese --- arch/mips/lib/cache.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/mips/lib/cache.c b/arch/mips/lib/cache.c index 9e20b39608..e27826cbb1 100644 --- a/arch/mips/lib/cache.c +++ b/arch/mips/lib/cache.c @@ -118,6 +118,7 @@ static inline unsigned long scache_line_size(void) } \ } while (0) +#if !defined(CONFIG_MIPS_CACHE_COHERENT) void flush_cache(ulong start_addr, ulong size) { unsigned long ilsize = icache_line_size(); @@ -188,6 +189,35 @@ void invalidate_dcache_range(ulong start_addr, ulong stop) sync(); } +void dcache_disable(void) +{ + /* change CCA to uncached */ + change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED); + + /* ensure the pipeline doesn't contain now-invalid instructions */ + instruction_hazard_barrier(); +} + +#else /* CONFIG_MIPS_CACHE_COHERENT */ + +void flush_cache(ulong start_addr, ulong size) +{ +} + +void __weak flush_dcache_range(ulong start_addr, ulong stop) +{ +} + +void invalidate_dcache_range(ulong start_addr, ulong stop) +{ +} + +void dcache_disable(void) +{ +} + +#endif /* CONFIG_MIPS_CACHE_COHERENT */ + int dcache_status(void) { unsigned int cca = read_c0_config() & CONF_CM_CMASK; @@ -199,11 +229,3 @@ void dcache_enable(void) puts("Not supported!\n"); } -void dcache_disable(void) -{ - /* change CCA to uncached */ - change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED); - - /* ensure the pipeline doesn't contain now-invalid instructions */ - instruction_hazard_barrier(); -}