diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-05-04 10:58:07 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-05-07 08:55:38 +0530 |
commit | 5338679ff043d68f5c26265de144e5ec54109724 (patch) | |
tree | 40d77f564ade03e63ce5e6a39bd2d7af9270dcf3 /lib/sbi/sbi_tlb.c | |
parent | 7993ca2c8e092428eb59febea13a31659450850c (diff) |
lib: sbi_tlb: Fix remote TLB HFENCE VVMA implementation
The HFENCE VVMA instructions flushes TLB based on the VMID
present in HGATP CSR. To handle this, we get the current
VMID for SBI HFENCE VVMA call and we use this current VMID
to do remote TLB HFENCE VVMA on desired set of HARTs.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_tlb.c')
-rw-r--r-- | lib/sbi/sbi_tlb.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index d857162..c6ca7b1 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -36,16 +36,23 @@ static void sbi_tlb_hfence_vvma(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; - unsigned long i; + unsigned long vmid = tinfo->vmid; + unsigned long i, hgatp; + + hgatp = csr_swap(CSR_HGATP, + (vmid << HGATP_VMID_SHIFT) & HGATP_VMID_MASK); if ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) { __sbi_hfence_vvma_all(); - return; + goto done; } for (i = 0; i < size; i += PAGE_SIZE) { __sbi_hfence_vvma_va(start+i); } + +done: + csr_write(CSR_HGATP, hgatp); } static void sbi_tlb_hfence_gvma(struct sbi_tlb_info *tinfo) @@ -88,28 +95,35 @@ static void sbi_tlb_hfence_vvma_asid(struct sbi_tlb_info *tinfo) unsigned long start = tinfo->start; unsigned long size = tinfo->size; unsigned long asid = tinfo->asid; - unsigned long i; + unsigned long vmid = tinfo->vmid; + unsigned long i, hgatp; + + hgatp = csr_swap(CSR_HGATP, + (vmid << HGATP_VMID_SHIFT) & HGATP_VMID_MASK); if (start == 0 && size == 0) { __sbi_hfence_vvma_all(); - return; + goto done; } if (size == SBI_TLB_FLUSH_ALL) { __sbi_hfence_vvma_asid(asid); - return; + goto done; } for (i = 0; i < size; i += PAGE_SIZE) { __sbi_hfence_vvma_asid_va(asid, start + i); } + +done: + csr_write(CSR_HGATP, hgatp); } static void sbi_tlb_hfence_gvma_vmid(struct sbi_tlb_info *tinfo) { unsigned long start = tinfo->start; unsigned long size = tinfo->size; - unsigned long vmid = tinfo->asid; + unsigned long vmid = tinfo->vmid; unsigned long i; if (start == 0 && size == 0) { |