Re: [PATCH v2] lib: sbi: Allow platforms to override local TLB operations
Xiang W <[email protected]> Thu, 18 Jun 2026 08:44:40 +0800
| Newsgroups | org.infradead.lists.opensbi |
|---|---|
| Message-ID | <[email protected]> |
在 2026-06-17三的 09:13 -0500,Samuel Holland写道: > Hi, > > On 2026-06-17 6:29 AM, Xiang W wrote: > > Some T-Head based processors, for example the Sophgo SG2044, have a > > JTLB errata that requires special handling of certain TLB maintenance > > instructions (sfence.vma). > > > > Introduce a sbi_tlb_local_operations structure so platforms can provide > > custom local TLB flush implementations. Use it to implement the JTLB > > workaround on affected SoCs (currently Sophgo SG2044). > > > > Signed-off-by: Xiang W <[email protected]> > > Signed-off-by: Han Gao <[email protected]> > > --- > > include/sbi/sbi_tlb.h | 31 +++++++++++++ > > lib/sbi/sbi_tlb.c | 46 +++++++++++++++++--- > > platform/generic/include/thead/c9xx_errata.h | 1 + > > platform/generic/thead/thead-generic.c | 31 ++++++++++++- > > 4 files changed, 101 insertions(+), 8 deletions(-) > > > > [...] > > +static void thead_jtlb_local_sfence_vma(struct sbi_tlb_info *tinfo) > > +{ > > + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_RCVD); > > + __asm__ __volatile__("sfence.vma"); > > +} > > + > > +static void thead_jtlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) > > +{ > > + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_RCVD); > > + /* Flush entire MM context for a given ASID */ > > + __asm__ __volatile__("sfence.vma x0, %0" > > + : > > + : "r"(tinfo->asid) > > + : "memory"); > > +} > > This looks similar to the bug seen on older SiFive chips, where we must always > flush the full address space. If so, there is already a much simpler workaround > available, using get_tlbr_flush_limit. See platform/generic/sifive/fu540.c. > > Regards, > Samuel Hi Samuel, Thanks for the feedback. We did consider `get_tlbr_flush_limit`, and it can indeed solve the SG2044 JTLB issue. However, for SG2044 we only need to override the local `sfence.vma` and `sfence.vma` with ASID cases (i.e. `local_sfence_vma` and `local_sfence_vma_asid`), while leaving the other TLB operations on the default implementation. The more general local TLB operations override mechanism gives us the flexibility to do exactly that without forcing a full TLB flush limit for all operations. Regards, Xiang W -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi