From 12394a269b8b60e2d37b56afb2fa39fde6a3a4b8 Mon Sep 17 00:00:00 2001 From: Anup Patel <anup.patel@wdc.com> Date: Tue, 29 Dec 2020 13:51:06 +0530 Subject: lib: sbi: Allow custom local TLB flush function Currently, we have fixed TLB flush types supported by the remote TLB library. This approach is not flexible and does not allow custom local TLB flush function. For example, after updating PMP entries on a set of HARTs at runtime, we have to flush TLB on these HARTs as well. To support custom local TLB flush function, we replace the "type" field of "struct sbi_tlb_info" with a local TLB flush function pointer. We also provide definitions of standard TLB flush operations (such as fence_i, sfence.vma, hfence.vvma, hfence.gvma, etc). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> --- include/sbi/sbi_tlb.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/sbi/sbi_tlb.h b/include/sbi/sbi_tlb.h index 6ee64a9..48f1962 100644 --- a/include/sbi/sbi_tlb.h +++ b/include/sbi/sbi_tlb.h @@ -22,16 +22,6 @@ #define SBI_TLB_FIFO_NUM_ENTRIES 8 -enum sbi_tlb_info_types { - SBI_TLB_FLUSH_VMA, - SBI_TLB_FLUSH_VMA_ASID, - SBI_TLB_FLUSH_GVMA, - SBI_TLB_FLUSH_GVMA_VMID, - SBI_TLB_FLUSH_VVMA, - SBI_TLB_FLUSH_VVMA_ASID, - SBI_ITLB_FLUSH -}; - struct sbi_scratch; struct sbi_tlb_info { @@ -39,17 +29,25 @@ struct sbi_tlb_info { unsigned long size; unsigned long asid; unsigned long vmid; - unsigned long type; + void (*local_fn)(struct sbi_tlb_info *tinfo); struct sbi_hartmask smask; }; -#define SBI_TLB_INFO_INIT(__p, __start, __size, __asid, __vmid, __type, __src) \ +void sbi_tlb_local_hfence_vvma(struct sbi_tlb_info *tinfo); +void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo); +void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo); +void sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo); +void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo); +void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo); +void sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo); + +#define SBI_TLB_INFO_INIT(__p, __start, __size, __asid, __vmid, __lfn, __src) \ do { \ (__p)->start = (__start); \ (__p)->size = (__size); \ (__p)->asid = (__asid); \ (__p)->vmid = (__vmid); \ - (__p)->type = (__type); \ + (__p)->local_fn = (__lfn); \ SBI_HARTMASK_INIT_EXCEPT(&(__p)->smask, (__src)); \ } while (0) -- cgit v1.2.3