[PATCH v2 3/4] platform: Allow platform uses hart count as the size of tlb info

Xiang W wxjstz at 126.com
Sun Oct 8 09:20:28 PDT 2023


在 2023-10-08星期日的 20:17 +0800,Inochi Amaoto写道:
> For platform with high number of harts, it is better to auto detect a
> suitable number of entries in tlb fifo. Since allocating tlb entry for
> all online harts can reduce the wait time significantly, using the
> number of the online harts can make most platforms happy. This auto
> detection can avoid most duplicate code for setting tlb fifo size if
> the hart count of platform is big.
> 
> Signed-off-by: Inochi Amaoto <inochiama at outlook.com>
> ---
>  platform/generic/platform.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/platform/generic/platform.c b/platform/generic/platform.c
> index 66a0b77..9397afc 100644
> --- a/platform/generic/platform.c
> +++ b/platform/generic/platform.c
> @@ -258,8 +258,15 @@ static u64 generic_tlbr_flush_limit(void)
>  
>  static u32 generic_tlb_num_entries(void)
>  {
> +	const struct sbi_platform *plat = sbi_platform_thishart_ptr();
> +	u32 hart_count = sbi_platform_hart_count(plat);
The two lines above can be replaced with:
	u32 hart_count = sbi_scratch_last_hartindex() + 1;

If returning hart_count directly is appropriate, is it possible to remove
SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES and generic_plat->tlb_num_entries?

This patch does not seem to belong to sg2042 and should be sent separately.

Regards,
Xiang W

> +
>  	if (generic_plat && generic_plat->tlb_num_entries)
>  		return generic_plat->tlb_num_entries(generic_plat_match);
> +
> +	/* for platform with too many harts, use hart count instead */
> +	if (hart_count > SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES)
> +		return hart_count;
>  	return SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES;
>  }
>  




More information about the opensbi mailing list