From 98ee15ca3adcf7bc22695897cd63a3ce8c5c53ff Mon Sep 17 00:00:00 2001 From: Atish Patra Date: Tue, 10 Sep 2019 03:40:38 -0700 Subject: lib: provide a platform specific tlb range flush threshold Currently, the tlb range flush threshold is fixed and set to 4k for all platforms. However, it should be platform specific as it completely depends upon how platform actually implements sfence instruction. Define a platform feature that allows every individual platform to set different values. If a platform doesn't define it, just use a page size as the threshold. Signed-off-by: Atish Patra Reviewed-by: Bin Meng Reviewed-by: Anup Patel --- include/sbi/sbi_platform.h | 26 ++++++++++++++++++++++++-- include/sbi/sbi_tlb.h | 1 - 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 97195c41..7f5dd29b 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -30,10 +30,14 @@ #define SBI_PLATFORM_HART_STACK_SIZE_OFFSET (0x54) /** Offset of disabled_hart_mask in struct sbi_platform */ #define SBI_PLATFORM_DISABLED_HART_OFFSET (0x58) +/** Offset of tlb_range_flush_limit in struct sbi_platform */ +#define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_OFFSET (0x60) /** Offset of platform_ops_addr in struct sbi_platform */ -#define SBI_PLATFORM_OPS_OFFSET (0x60) +#define SBI_PLATFORM_OPS_OFFSET (0x68) /** Offset of firmware_context in struct sbi_platform */ -#define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x60 + __SIZEOF_POINTER__) +#define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x68 + __SIZEOF_POINTER__) + +#define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT (1UL << 12) #ifndef __ASSEMBLY__ @@ -134,6 +138,8 @@ struct sbi_platform { u32 hart_stack_size; /** Mask representing the set of disabled HARTs */ u64 disabled_hart_mask; + /* Maximum value of tlb flush range request*/ + u64 tlb_range_flush_limit; /** Pointer to sbi platform operations */ unsigned long platform_ops_addr; /** Pointer to system firmware specific context */ @@ -198,6 +204,22 @@ static inline bool sbi_platform_hart_disabled(const struct sbi_platform *plat, return FALSE; } +/** + * Get platform specific tlb range flush maximum value. Any request with size + * higher than this is upgraded to a full flush. + * + * @param plat pointer to struct sbi_platform + * + * @return tlb range flush limit value. Returns a default (page size) if not + * defined by platform. + */ +static inline u64 sbi_platform_tlbr_flush_limit(const struct sbi_platform *plat) +{ + if (plat) + return plat->tlb_range_flush_limit; + return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; +} + /** * Get total number of HARTs supported by the platform * diff --git a/include/sbi/sbi_tlb.h b/include/sbi/sbi_tlb.h index cd52c12f..d1d6f225 100644 --- a/include/sbi/sbi_tlb.h +++ b/include/sbi/sbi_tlb.h @@ -16,7 +16,6 @@ /* clang-format off */ #define SBI_TLB_FLUSH_ALL ((unsigned long)-1) -#define SBI_TLB_FLUSH_MAX_SIZE (1UL << 12) /* clang-format on */ -- cgit v1.3.1