mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
include: Use more consistent name for atomic xchg() and cmpxchg()
We should remove the "arch_" prefix from atomic xchg() and cmpxchg() function names to have consistent naming of all atomic functions. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
@@ -29,9 +29,9 @@ long atomic_add_return(atomic_t *atom, long value);
|
|||||||
|
|
||||||
long atomic_sub_return(atomic_t *atom, long value);
|
long atomic_sub_return(atomic_t *atom, long value);
|
||||||
|
|
||||||
long arch_atomic_cmpxchg(atomic_t *atom, long oldval, long newval);
|
long atomic_cmpxchg(atomic_t *atom, long oldval, long newval);
|
||||||
|
|
||||||
long arch_atomic_xchg(atomic_t *atom, long newval);
|
long atomic_xchg(atomic_t *atom, long newval);
|
||||||
|
|
||||||
unsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,
|
unsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,
|
||||||
unsigned int newval);
|
unsigned int newval);
|
||||||
|
@@ -167,7 +167,7 @@ long atomic_sub_return(atomic_t *atom, long value)
|
|||||||
__cmpxchg((ptr), _o_, _n_, sizeof(*(ptr))); \
|
__cmpxchg((ptr), _o_, _n_, sizeof(*(ptr))); \
|
||||||
})
|
})
|
||||||
|
|
||||||
long arch_atomic_cmpxchg(atomic_t *atom, long oldval, long newval)
|
long atomic_cmpxchg(atomic_t *atom, long oldval, long newval)
|
||||||
{
|
{
|
||||||
#ifdef __riscv_atomic
|
#ifdef __riscv_atomic
|
||||||
return __sync_val_compare_and_swap(&atom->counter, oldval, newval);
|
return __sync_val_compare_and_swap(&atom->counter, oldval, newval);
|
||||||
@@ -176,7 +176,7 @@ long arch_atomic_cmpxchg(atomic_t *atom, long oldval, long newval)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
long arch_atomic_xchg(atomic_t *atom, long newval)
|
long atomic_xchg(atomic_t *atom, long newval)
|
||||||
{
|
{
|
||||||
/* Atomically set new value and return old value. */
|
/* Atomically set new value and return old value. */
|
||||||
#ifdef __riscv_atomic
|
#ifdef __riscv_atomic
|
||||||
|
@@ -110,7 +110,7 @@ void sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
|
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
|
||||||
hart_data_offset);
|
hart_data_offset);
|
||||||
|
|
||||||
oldstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STARTING,
|
oldstate = atomic_cmpxchg(&hdata->state, SBI_HART_STARTING,
|
||||||
SBI_HART_STARTED);
|
SBI_HART_STARTED);
|
||||||
if (oldstate != SBI_HART_STARTING)
|
if (oldstate != SBI_HART_STARTING)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
@@ -178,7 +178,7 @@ void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch)
|
|||||||
hart_data_offset);
|
hart_data_offset);
|
||||||
void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr;
|
void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr;
|
||||||
|
|
||||||
hstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STOPPING,
|
hstate = atomic_cmpxchg(&hdata->state, SBI_HART_STOPPING,
|
||||||
SBI_HART_STOPPED);
|
SBI_HART_STOPPED);
|
||||||
if (hstate != SBI_HART_STOPPING)
|
if (hstate != SBI_HART_STOPPING)
|
||||||
goto fail_exit;
|
goto fail_exit;
|
||||||
@@ -216,7 +216,7 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid,
|
|||||||
if (!rscratch)
|
if (!rscratch)
|
||||||
return SBI_EINVAL;
|
return SBI_EINVAL;
|
||||||
hdata = sbi_scratch_offset_ptr(rscratch, hart_data_offset);
|
hdata = sbi_scratch_offset_ptr(rscratch, hart_data_offset);
|
||||||
hstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STOPPED,
|
hstate = atomic_cmpxchg(&hdata->state, SBI_HART_STOPPED,
|
||||||
SBI_HART_STARTING);
|
SBI_HART_STARTING);
|
||||||
if (hstate == SBI_HART_STARTED)
|
if (hstate == SBI_HART_STARTED)
|
||||||
return SBI_EALREADY_STARTED;
|
return SBI_EALREADY_STARTED;
|
||||||
@@ -258,7 +258,7 @@ int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow)
|
|||||||
if (!sbi_hsm_hart_started(hartid))
|
if (!sbi_hsm_hart_started(hartid))
|
||||||
return SBI_EINVAL;
|
return SBI_EINVAL;
|
||||||
|
|
||||||
oldstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STARTED,
|
oldstate = atomic_cmpxchg(&hdata->state, SBI_HART_STARTED,
|
||||||
SBI_HART_STOPPING);
|
SBI_HART_STOPPING);
|
||||||
if (oldstate != SBI_HART_STARTED) {
|
if (oldstate != SBI_HART_STARTED) {
|
||||||
sbi_printf("%s: ERR: The hart is in invalid state [%u]\n",
|
sbi_printf("%s: ERR: The hart is in invalid state [%u]\n",
|
||||||
|
@@ -285,7 +285,7 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
|
|||||||
sbi_platform_hart_invalid(plat, hartid))
|
sbi_platform_hart_invalid(plat, hartid))
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
|
||||||
if (arch_atomic_xchg(&coldboot_lottery, 1) == 0)
|
if (atomic_xchg(&coldboot_lottery, 1) == 0)
|
||||||
coldboot = TRUE;
|
coldboot = TRUE;
|
||||||
|
|
||||||
if (coldboot)
|
if (coldboot)
|
||||||
|
Reference in New Issue
Block a user