Skip to content

Commit

Permalink
lib: Invalid all tlb entries to workaroud c920 bug
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoguang Xing <[email protected]>
  • Loading branch information
xingxg2022 committed Aug 30, 2024
1 parent 3361818 commit 7c1f91a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/sbi/sbi_tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions platform/generic/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions platform/generic/thead/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7c1f91a

Please sign in to comment.