RISC-V: Use IPIs for remote icache flush when possible
authorAnup Patel <apatel@ventanamicro.com>
Tue, 28 Mar 2023 03:52:22 +0000 (09:22 +0530)
committerMarc Zyngier <maz@kernel.org>
Sat, 8 Apr 2023 10:26:24 +0000 (11:26 +0100)
If we have specialized interrupt controller (such as AIA IMSIC) which
allows supervisor mode to directly inject IPIs without any assistance
from M-mode or HS-mode then using such specialized interrupt controller,
we can do remote icache flushe directly from supervisor mode instead of
using the SBI RFENCE calls.

This patch extends remote icache flush functions to use supervisor mode
IPIs whenever direct supervisor mode IPIs.are supported by interrupt
controller.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230328035223.1480939-7-apatel@ventanamicro.com
arch/riscv/mm/cacheflush.c

index fcd6145fbeadce85a3de645e384b73c52146432a..20cec5e7cdbfde4a9f7ecd3cf3ff2c5c6fd9629f 100644 (file)
@@ -19,7 +19,7 @@ void flush_icache_all(void)
 {
        local_flush_icache_all();
 
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
+       if (IS_ENABLED(CONFIG_RISCV_SBI) && !riscv_use_ipi_for_rfence())
                sbi_remote_fence_i(NULL);
        else
                on_each_cpu(ipi_remote_fence_i, NULL, 1);
@@ -67,7 +67,8 @@ void flush_icache_mm(struct mm_struct *mm, bool local)
                 * with flush_icache_deferred().
                 */
                smp_mb();
-       } else if (IS_ENABLED(CONFIG_RISCV_SBI)) {
+       } else if (IS_ENABLED(CONFIG_RISCV_SBI) &&
+                  !riscv_use_ipi_for_rfence()) {
                sbi_remote_fence_i(&others);
        } else {
                on_each_cpu_mask(&others, ipi_remote_fence_i, NULL, 1);