Skip to content

Commit

Permalink
riscv: errata: thead: use pa based instructions for CMO
Browse files Browse the repository at this point in the history
T-HEAD CPUs such as C906/C910/C920 support phy address based CMO, use
them so that we don't need to convert to virt address.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
  • Loading branch information
xhackerustc authored and RevySR committed Oct 9, 2023
1 parent 86a5be7 commit 6959635
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions arch/riscv/errata/thead/errata.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ static bool errata_probe_pbmt(unsigned int stage,
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
* 0000000 11001 00000 000 00000 0001011
*/
#define THEAD_inval_A0 ".long 0x0265000b"
#define THEAD_clean_A0 ".long 0x0255000b"
#define THEAD_flush_A0 ".long 0x0275000b"
#define THEAD_inval_A0 ".long 0x02a5000b"
#define THEAD_clean_A0 ".long 0x0295000b"
#define THEAD_flush_A0 ".long 0x02b5000b"
#define THEAD_SYNC_S ".long 0x0190000b"

#define THEAD_CMO_OP(_op, _start, _size, _cachesize) \
Expand All @@ -79,23 +79,17 @@ asm volatile("mv a0, %1\n\t" \

static void thead_errata_cache_inv(phys_addr_t paddr, size_t size)
{
void *vaddr = phys_to_virt(paddr);

THEAD_CMO_OP(inval, vaddr, size, riscv_cbom_block_size);
THEAD_CMO_OP(inval, paddr, size, riscv_cbom_block_size);
}

static void thead_errata_cache_wback(phys_addr_t paddr, size_t size)
{
void *vaddr = phys_to_virt(paddr);

THEAD_CMO_OP(clean, vaddr, size, riscv_cbom_block_size);
THEAD_CMO_OP(clean, paddr, size, riscv_cbom_block_size);
}

static void thead_errata_cache_wback_inv(phys_addr_t paddr, size_t size)
{
void *vaddr = phys_to_virt(paddr);

THEAD_CMO_OP(flush, vaddr, size, riscv_cbom_block_size);
THEAD_CMO_OP(flush, paddr, size, riscv_cbom_block_size);
}

static const struct riscv_nonstd_cache_ops thead_errata_cmo_ops = {
Expand Down

0 comments on commit 6959635

Please sign in to comment.