2020-06-09 22:14:48 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
|
#ifndef __ASM_VDSO_PROCESSOR_H
|
|
|
|
|
#define __ASM_VDSO_PROCESSOR_H
|
|
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
2022-06-20 13:15:25 -07:00
|
|
|
#include <linux/jump_label.h>
|
2020-11-16 17:39:51 -08:00
|
|
|
#include <asm/barrier.h>
|
2022-06-20 13:15:25 -07:00
|
|
|
#include <asm/hwcap.h>
|
2020-11-16 17:39:51 -08:00
|
|
|
|
2020-06-09 22:14:48 +08:00
|
|
|
static inline void cpu_relax(void)
|
|
|
|
|
{
|
2022-06-20 13:15:25 -07:00
|
|
|
if (!static_branch_likely(&riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_ZIHINTPAUSE])) {
|
2020-06-09 22:14:48 +08:00
|
|
|
#ifdef __riscv_muldiv
|
2022-06-20 13:15:25 -07:00
|
|
|
int dummy;
|
|
|
|
|
/* In lieu of a halt instruction, induce a long-latency stall. */
|
|
|
|
|
__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
|
2020-06-09 22:14:48 +08:00
|
|
|
#endif
|
2022-06-20 13:15:25 -07:00
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* Reduce instruction retirement.
|
|
|
|
|
* This assumes the PC changes.
|
|
|
|
|
*/
|
|
|
|
|
#ifdef __riscv_zihintpause
|
|
|
|
|
__asm__ __volatile__ ("pause");
|
|
|
|
|
#else
|
|
|
|
|
/* Encoding of the pause instruction */
|
|
|
|
|
__asm__ __volatile__ (".4byte 0x100000F");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2020-06-09 22:14:48 +08:00
|
|
|
barrier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
|
|
#endif /* __ASM_VDSO_PROCESSOR_H */
|