arch/riscv: use UP_DSB, UP_DMB, UP_ISB as barrier standard API

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
This commit is contained in:
lipengfei28
2024-12-10 17:48:17 +08:00
committed by Xiang Xiao
parent 82cf59bff5
commit d3e3993682
13 changed files with 29 additions and 30 deletions
+6 -6
View File
@@ -27,16 +27,16 @@
#define __FENCE(p, s) __asm__ __volatile__ ("fence "#p", "#s ::: "memory")
/* __DMB() is used to flush local data caches (memory) */
/* UP_DMB() is used to flush local data caches (memory) */
#define __DMB() __FENCE(rw, rw)
#define UP_DMB() __FENCE(rw, rw)
/* __MB() is a full memory barrier */
/* UP_DSB() is a full memory barrier */
#define __MB() __FENCE(iorw, iorw)
#define UP_DSB() __FENCE(iorw, iorw)
/* __ISB() is used to synchronize the instruction and data streams */
/* UP_ISB() is used to synchronize the instruction and data streams */
#define __ISB() __asm__ __volatile__ ("fence.i" ::: "memory")
#define UP_ISB() __asm__ __volatile__ ("fence.i" ::: "memory")
#endif /* __ARCH_RISCV_INCLUDE_BARRIERS_H */
+2 -3
View File
@@ -31,6 +31,8 @@
# include <stdint.h>
#endif /* __ASSEMBLY__ */
#include <arch/barriers.h>
/* Include RISC-V architecture-specific IRQ definitions (including register
* save structure and up_irq_save()/up_irq_restore() functions)
*/
@@ -61,9 +63,6 @@
*
*/
#define UP_DSB() __asm__ __volatile__ ("fence")
#define UP_DMB() __asm__ __volatile__ ("fence")
/****************************************************************************
* Public Types
****************************************************************************/
+8 -8
View File
@@ -176,7 +176,7 @@ static int create_spgtables(arch_addrenv_t *addrenv)
/* Flush the data cache, so the changes are committed to memory */
__DMB();
UP_DMB();
return i;
}
@@ -312,7 +312,7 @@ static int create_region(arch_addrenv_t *addrenv, uintptr_t vaddr,
/* Flush the data cache, so the changes are committed to memory */
__DMB();
UP_DMB();
return npages;
}
@@ -486,8 +486,8 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize,
/* When all is set and done, flush the data caches */
__ISB();
__DMB();
UP_ISB();
UP_DMB();
return OK;
@@ -528,8 +528,8 @@ int up_addrenv_destroy(arch_addrenv_t *addrenv)
/* Make sure the caches are flushed before doing this */
__ISB();
__DMB();
UP_ISB();
UP_DMB();
/* Things start from the beginning of the user virtual memory */
@@ -583,8 +583,8 @@ int up_addrenv_destroy(arch_addrenv_t *addrenv)
/* When all is set and done, flush the caches */
__ISB();
__DMB();
UP_ISB();
UP_DMB();
memset(addrenv, 0, sizeof(arch_addrenv_t));
return OK;
+2 -2
View File
@@ -97,8 +97,8 @@ static int modify_region(uintptr_t vstart, uintptr_t vend, uintptr_t setmask)
/* When all is set and done, flush the data caches */
__ISB();
__DMB();
UP_ISB();
UP_DMB();
return OK;
}
+1 -1
View File
@@ -215,7 +215,7 @@ int up_addrenv_kmap_init(void)
/* When all is set and done, flush the data caches */
__DMB();
UP_DMB();
return OK;
}
+3 -3
View File
@@ -108,7 +108,7 @@ uintptr_t riscv_get_pgtable(arch_addrenv_t *addrenv, uintptr_t vaddr)
/* Flush the data cache, so the changes are committed to memory */
__DMB();
UP_DMB();
return paddr;
}
@@ -164,7 +164,7 @@ int riscv_map_pages(arch_addrenv_t *addrenv, uintptr_t *pages,
/* Flush the data cache, so the changes are committed to memory */
__DMB();
UP_DMB();
return OK;
}
@@ -225,7 +225,7 @@ int riscv_unmap_pages(arch_addrenv_t *addrenv, uintptr_t vaddr,
/* Flush the data cache, so the changes are committed to memory */
__DMB();
UP_DMB();
return OK;
}
+1 -1
View File
@@ -128,7 +128,7 @@ static void riscv_mtimer_set_mtimecmp(struct riscv_mtimer_lowerhalf_s *priv,
/* Make sure it sticks */
__MB();
UP_DSB();
}
#else
+1 -1
View File
@@ -154,7 +154,7 @@ void riscv_percpu_add_hart(uintptr_t hartid)
/* Make sure it sticks */
__MB();
UP_DSB();
}
/****************************************************************************
+1 -1
View File
@@ -158,7 +158,7 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
/* Flush the data cache, so the changes are committed to memory */
__DMB();
UP_DMB();
return brkaddr;
}
+1 -1
View File
@@ -102,7 +102,7 @@ static struct gpio_callback_s g_mss_gpio_callbacks[GPIO_BANK0_NUM_PINS +
static void mpfs_gpio_irq_clear(int bank, int pin)
{
putreg32(1 << pin, g_gpio_base[bank] + MPFS_GPIO_INTR_OFFSET);
__MB();
UP_DSB();
}
/****************************************************************************
+1 -1
View File
@@ -83,5 +83,5 @@ void sbi_mscratch_assign(uintptr_t hartid)
/* Make sure mscratch is updated before continuing */
__MB();
UP_DSB();
}
+1 -1
View File
@@ -99,5 +99,5 @@ void sbi_set_mtimecmp(uint64_t value)
/* Make sure it sticks */
__MB();
UP_DSB();
}
+1 -1
View File
@@ -130,7 +130,7 @@ static void _set_val(uint16_t *addr, uint32_t val)
/* NOTE: Ensure relocation before execution */
__ISB();
UP_ISB();
}
static void _add_val(uint16_t *addr, uint32_t val)