From e19f4d12f4146df8a2c79b9af02b06d815b2be15 Mon Sep 17 00:00:00 2001 From: Xiaoguang Xing Date: Thu, 29 Aug 2024 20:51:23 +0800 Subject: [PATCH] lib: Invalid all tlb entries to workaroud c920 bug Signed-off-by: Xiaoguang Xing --- lib/sbi/sbi_tlb.c | 7 ++++++- platform/generic/Kconfig | 2 ++ platform/generic/thead/Kconfig | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index 1aaf686729..9cac7c81a6 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,10 @@ 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) @@ -161,7 +166,7 @@ static void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo) return; } -#if 0 +#ifndef CONFIG_THEAD_C9XX_ERRATA_JTLB for (i = 0; i < size; i += PAGE_SIZE) { __asm__ __volatile__("sfence.vma %0, %1" : 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