From d79173b4b7519b537cf64c984d27daa26aad23c0 Mon Sep 17 00:00:00 2001 From: Atish Patra Date: Tue, 4 Feb 2020 15:09:14 -0800 Subject: [PATCH] platform: Add an platform ops to return platform specific tlb flush limit If a platform requires to perform a tlb full flush, they should set the tlb_range_flush_limit value to zero. However, corresponding platform API ignore the value and continue to return the default value. Add a platform ops to retrieve platform specific tlb range flush limit. The platform variable becomes redundant in presence of the platform ops. Take this opportunity to remove the variable as well. The default is still set to smallest page size in RISC-V (4KB), as there is no way to figure out a best value for all platforms. Individual platform should set it to the optimal value for their platform. Signed-off-by: Atish Patra Reviewed-by: Anup Patel --- include/sbi/sbi_platform.h | 15 +++++++-------- platform/template/platform.c | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 0de8be4d..ba1d95f4 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -30,12 +30,10 @@ #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 (0x68) +#define SBI_PLATFORM_OPS_OFFSET (0x60) /** Offset of firmware_context in struct sbi_platform */ -#define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x68 + __SIZEOF_POINTER__) +#define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x60 + __SIZEOF_POINTER__) #define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT (1UL << 12) @@ -121,6 +119,9 @@ struct sbi_platform_operations { /** Exit IPI for current HART */ void (*ipi_exit)(void); + /** Get tlb flush limit value **/ + u64 (*get_tlbr_flush_limit)(void); + /** Get platform timer value */ u64 (*timer_value)(void); /** Start platform timer event for current HART */ @@ -170,8 +171,6 @@ 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 */ @@ -247,8 +246,8 @@ static inline bool sbi_platform_hart_disabled(const struct sbi_platform *plat, */ static inline u64 sbi_platform_tlbr_flush_limit(const struct sbi_platform *plat) { - if (plat && plat->tlb_range_flush_limit) - return plat->tlb_range_flush_limit; + if (plat && sbi_platform_ops(plat)->get_tlbr_flush_limit) + return sbi_platform_ops(plat)->get_tlbr_flush_limit(); return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; } diff --git a/platform/template/platform.c b/platform/template/platform.c index 1646c8c6..f959a111 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -224,6 +224,5 @@ const struct sbi_platform platform = { .hart_count = 1, .hart_stack_size = 4096, .disabled_hart_mask = 0, - .tlb_range_flush_limit = 0, .platform_ops_addr = (unsigned long)&platform_ops };