Commit 0a575497 authored by Helge Deller's avatar Helge Deller

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: default avatarHelge Deller <deller@gmx.de>
parent a58e9d09
...@@ -9,16 +9,11 @@ ...@@ -9,16 +9,11 @@
/* The usual comment is "Caches aren't brain-dead on the <architecture>". /* The usual comment is "Caches aren't brain-dead on the <architecture>".
* Unfortunately, that doesn't apply to PA-RISC. */ * Unfortunately, that doesn't apply to PA-RISC. */
/* Internal implementation */ #include <linux/jump_label.h>
void flush_data_cache_local(void *); /* flushes local data-cache only */
void flush_instruction_cache_local(void *); /* flushes local code-cache only */ DECLARE_STATIC_KEY_TRUE(parisc_has_cache);
#ifdef CONFIG_SMP DECLARE_STATIC_KEY_TRUE(parisc_has_dcache);
void flush_data_cache(void); /* flushes data-cache only (all processors) */ DECLARE_STATIC_KEY_TRUE(parisc_has_icache);
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
#define flush_cache_dup_mm(mm) flush_cache_mm(mm) #define flush_cache_dup_mm(mm) flush_cache_mm(mm)
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/alternative.h> #include <asm/alternative.h>
#include <asm/cacheflush.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -107,5 +108,14 @@ void __init apply_alternatives_all(void) ...@@ -107,5 +108,14 @@ void __init apply_alternatives_all(void)
apply_alternatives((struct alt_instr *) &__alt_instructions, apply_alternatives((struct alt_instr *) &__alt_instructions,
(struct alt_instr *) &__alt_instructions_end, NULL); (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); set_kernel_text_rw(0);
} }
...@@ -38,6 +38,9 @@ EXPORT_SYMBOL(flush_dcache_page_asm); ...@@ -38,6 +38,9 @@ EXPORT_SYMBOL(flush_dcache_page_asm);
void purge_dcache_page_asm(unsigned long phys_addr, unsigned long vaddr); void purge_dcache_page_asm(unsigned long phys_addr, unsigned long vaddr);
void flush_icache_page_asm(unsigned long phys_addr, unsigned long vaddr); void flush_icache_page_asm(unsigned long phys_addr, unsigned long vaddr);
/* Internal implementation in arch/parisc/kernel/pacache.S */
void flush_data_cache_local(void *); /* flushes local data-cache only */
void flush_instruction_cache_local(void); /* flushes local code-cache only */
/* On some machines (i.e., ones with the Merced bus), there can be /* On some machines (i.e., ones with the Merced bus), there can be
* only a single PxTLB broadcast at a time; this must be guaranteed * only a single PxTLB broadcast at a time; this must be guaranteed
...@@ -58,26 +61,35 @@ struct pdc_cache_info cache_info __ro_after_init; ...@@ -58,26 +61,35 @@ struct pdc_cache_info cache_info __ro_after_init;
static struct pdc_btlb_info btlb_info __ro_after_init; static struct pdc_btlb_info btlb_info __ro_after_init;
#endif #endif
#ifdef CONFIG_SMP DEFINE_STATIC_KEY_TRUE(parisc_has_cache);
void DEFINE_STATIC_KEY_TRUE(parisc_has_dcache);
flush_data_cache(void) DEFINE_STATIC_KEY_TRUE(parisc_has_icache);
static void cache_flush_local_cpu(void *dummy)
{ {
on_each_cpu(flush_data_cache_local, NULL, 1); if (static_branch_likely(&parisc_has_icache))
flush_instruction_cache_local();
if (static_branch_likely(&parisc_has_dcache))
flush_data_cache_local(NULL);
} }
void
flush_instruction_cache(void) void flush_cache_all_local(void)
{ {
on_each_cpu(flush_instruction_cache_local, NULL, 1); cache_flush_local_cpu(NULL);
} }
#endif
void void flush_cache_all(void)
flush_cache_all_local(void) {
if (static_branch_likely(&parisc_has_cache))
on_each_cpu(cache_flush_local_cpu, NULL, 1);
}
static inline void flush_data_cache(void)
{ {
flush_instruction_cache_local(NULL); if (static_branch_likely(&parisc_has_dcache))
flush_data_cache_local(NULL); on_each_cpu(flush_data_cache_local, NULL, 1);
} }
EXPORT_SYMBOL(flush_cache_all_local);
/* Virtual address of pfn. */ /* Virtual address of pfn. */
#define pfn_va(pfn) __va(PFN_PHYS(pfn)) #define pfn_va(pfn) __va(PFN_PHYS(pfn))
...@@ -375,7 +387,6 @@ EXPORT_SYMBOL(flush_dcache_page); ...@@ -375,7 +387,6 @@ EXPORT_SYMBOL(flush_dcache_page);
/* Defined in arch/parisc/kernel/pacache.S */ /* Defined in arch/parisc/kernel/pacache.S */
EXPORT_SYMBOL(flush_kernel_dcache_range_asm); EXPORT_SYMBOL(flush_kernel_dcache_range_asm);
EXPORT_SYMBOL(flush_data_cache_local);
EXPORT_SYMBOL(flush_kernel_icache_range_asm); EXPORT_SYMBOL(flush_kernel_icache_range_asm);
#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */ #define FLUSH_THRESHOLD 0x80000 /* 0.5MB */
...@@ -517,16 +528,6 @@ int __flush_tlb_range(unsigned long sid, unsigned long start, ...@@ -517,16 +528,6 @@ int __flush_tlb_range(unsigned long sid, unsigned long start,
return 0; return 0;
} }
static void cacheflush_h_tmp_function(void *dummy)
{
flush_cache_all_local();
}
void flush_cache_all(void)
{
on_each_cpu(cacheflush_h_tmp_function, NULL, 1);
}
static inline unsigned long mm_total_size(struct mm_struct *mm) static inline unsigned long mm_total_size(struct mm_struct *mm)
{ {
struct vm_area_struct *vma; struct vm_area_struct *vma;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment