Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv: mm: Add support for Svinval extension #176

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions arch/riscv/mm/tlbflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
#include <linux/sched.h>
#include <asm/sbi.h>
#include <asm/mmu_context.h>
#include <asm/cpufeature.h>

#define has_svinval() riscv_has_extension_unlikely(RISCV_ISA_EXT_SVINVAL)

static inline void local_sfence_inval_ir(void)
{
asm volatile(SFENCE_INVAL_IR() ::: "memory");
}

static inline void local_sfence_w_inval(void)
{
asm volatile(SFENCE_W_INVAL() ::: "memory");
}

static inline void local_sinval_vma(unsigned long vma, unsigned long asid)
{
if (asid != FLUSH_TLB_NO_ASID)
asm volatile(SINVAL_VMA( %0, %1) : : "r" (vma), "r" (asid) : "memory");

Check failure on line 25 in arch/riscv/mm/tlbflush.c

View workflow job for this annotation

GitHub Actions / checkpatch

ERROR: need consistent spacing around '%' (ctx:WxV)

Check failure on line 25 in arch/riscv/mm/tlbflush.c

View workflow job for this annotation

GitHub Actions / checkpatch

ERROR: need consistent spacing around '%' (ctx:WxV)

Check failure on line 25 in arch/riscv/mm/tlbflush.c

View workflow job for this annotation

GitHub Actions / checkpatch

ERROR: space prohibited after that open parenthesis '('
else
asm volatile(SINVAL_VMA( %0, zero) : : "r" (vma) : "memory");

Check failure on line 27 in arch/riscv/mm/tlbflush.c

View workflow job for this annotation

GitHub Actions / checkpatch

ERROR: need consistent spacing around '%' (ctx:WxV)

Check failure on line 27 in arch/riscv/mm/tlbflush.c

View workflow job for this annotation

GitHub Actions / checkpatch

ERROR: space prohibited after that open parenthesis '('
}

static inline void local_flush_tlb_all_asid(unsigned long asid)
{
Expand Down Expand Up @@ -48,6 +69,16 @@
return;
}

if (has_svinval()) {
local_sfence_w_inval();
for (i = 0; i < nr_ptes_in_range; ++i) {
local_sinval_vma(start, asid);
start += stride;
}
local_sfence_inval_ir();
return;
}

for (i = 0; i < nr_ptes_in_range; ++i) {
local_flush_tlb_page_asid(start, asid);
start += stride;
Expand Down