parisc: Avoid calling SMP cache flush functions on cache-less machines
Helge Deller
maintainerPATCH v3 1/1 parisc: Avoid calling SMP cache flush functions on cache-less machines
At least the qemu virtual machine does not provide D- and I-caches, so skip triggering SMP irqs to flush caches on such machines.
Further optimize the caching code by using static branches and making some functions static.
Signed-off-by Helge Deller <[email protected]>
---
v3: re-introduce flush_data_cache()
v2: rewrite with static keys as suggested by Sven Schnelle, and rework all
cache functions (e.g. make many static)
arch/parisc/include/asm/cacheflush.h +5 -10
@@ -9,16 +9,11 @@/* The usual comment is "Caches aren't brain-dead on the <architecture>". * Unfortunately, that doesn't apply to PA-RISC. */ -/* Internal implementation */ -void flush_data_cache_local (void *);/* flushes local data-cache only */ -void flush_instruction_cache_local (void *);/* flushes local code-cache only */ -#ifdef CONFIG_SMP -void flush_data_cache (void );/* flushes data-cache only (all processors) */ -void flush_instruction_cache (void );/* flushes i-cache only (all processors) */ -#else -#define flush_data_cache () flush_data_cache_local(NULL) -#define flush_instruction_cache () flush_instruction_cache_local(NULL) -#endif +#include <linux/jump_label.h> + +DECLARE_STATIC_KEY_TRUE (parisc_has_cache); +DECLARE_STATIC_KEY_TRUE (parisc_has_dcache); +DECLARE_STATIC_KEY_TRUE (parisc_has_icache);#define flush_cache_dup_mm (mm) flush_cache_mm(mm)
arch/parisc/kernel/alternative.c +10 -0
@@ -8,6 +8,7 @@#include <asm/processor.h> #include <asm/sections.h> #include <asm/alternative.h> +#include <asm/cacheflush.h> #include <linux/module.h>
@@ -107,5 +108,14 @@ void __init apply_alternatives_all(void)apply_alternatives ((struct alt_instr *) &__alt_instructions, (struct alt_instr *) &__alt_instructions_end,NULL ); +if (cache_info.dc_size ==0 && cache_info.ic_size ==0 ) { +pr_info ("alternatives: optimizing cache-flushes.\n" ); +static_branch_disable (&parisc_has_cache); + } +if (cache_info.dc_size ==0 ) +static_branch_disable (&parisc_has_dcache); +if (cache_info.ic_size ==0 ) +static_branch_disable (&parisc_has_icache); +set_kernel_text_rw (0 ); }
arch/parisc/kernel/cache.c +25 -24
80 lines not on this page · raw message