diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index 01b31f4e76..80a74c4f64 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -79,6 +79,7 @@ static void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo) static void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo) { +#ifndef CONFIG_THEAD_C9XX_ERRATA_JTLB unsigned long start = tinfo->start; unsigned long size = tinfo->size; unsigned long i; @@ -96,6 +97,11 @@ static void sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo) : "r"(start + i) : "memory"); } +#else + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_RCVD); + + tlb_flush_all(); +#endif } static void sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo) @@ -145,6 +151,7 @@ static void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo) static void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) { +#ifndef CONFIG_THEAD_C9XX_ERRATA_JTLB unsigned long start = tinfo->start; unsigned long size = tinfo->size; unsigned long asid = tinfo->asid; @@ -167,6 +174,16 @@ static void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) : "r"(start + i), "r"(asid) : "memory"); } +#else + unsigned long asid = tinfo->asid; + + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_RCVD); + + __asm__ __volatile__("sfence.vma x0, %0" + : + : "r"(asid) + : "memory"); +#endif } static void sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo) diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig index c28ec88b1d..9c979a5df9 100644 --- a/platform/generic/Kconfig +++ b/platform/generic/Kconfig @@ -60,6 +60,8 @@ config PLATFORM_SOPHGO_SG2042 config PLATFORM_SOPHGO_SG2044 bool "Sophgo sg2044 support" + select THEAD_C9XX_ERRATA + select THEAD_C9XX_ERRATA_JTLB select THEAD_C9XX_PMU default n diff --git a/platform/generic/thead/Kconfig b/platform/generic/thead/Kconfig index c50d38ee6e..7ac60d3b95 100644 --- a/platform/generic/thead/Kconfig +++ b/platform/generic/thead/Kconfig @@ -7,3 +7,7 @@ config THEAD_C9XX_PMU config THEAD_C9XX_ERRATA bool "T-HEAD c9xx errata support" default n + +config THEAD_C9XX_ERRATA_JTLB + bool "T-HEAD c9xx errata(JTLB) support" + default n