Message ID | IA1PR20MB4953F3CC7ED87825F69B50CEBBCFA@IA1PR20MB4953.namprd20.prod.outlook.com |
---|---|
State | Changes Requested |
Headers | show |
Series | platform: generic: Add Sophgo sg2042 support | expand |
在 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@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; > } >
>在 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@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; > Thx. >If returning hart_count directly is appropriate, is it possible to remove >SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES and generic_plat->tlb_num_entries? > I think replacing SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES with hart_count is reasonable. For the override functions, it gives a chance for platform to setting up a new entry number. I suggest to perserve it, so the platform can define its own if needed. >This patch does not seem to belong to sg2042 and should be sent separately. > Yes, The only reason I added it is that sg2042 require the new default value. I will send it 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; >> } >>
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); + 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; }
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@outlook.com> --- platform/generic/platform.c | 7 +++++++ 1 file changed, 7 insertions(+)