3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-20 22:25:54 +00:00

37 lines
843 B
C
Raw Normal View History

2022-04-02 18:08:56 +05:00
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __ASM_VDSO_PROCESSOR_H
#define __ASM_VDSO_PROCESSOR_H
#ifndef __ASSEMBLY__
2022-09-13 23:14:27 +05:00
#include <linux/jump_label.h>
2022-04-02 18:08:56 +05:00
#include <asm/barrier.h>
2022-09-13 23:14:27 +05:00
#include <asm/hwcap.h>
2022-04-02 18:08:56 +05:00
static inline void cpu_relax(void)
{
2022-09-13 23:14:27 +05:00
if (!static_branch_likely(&riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_ZIHINTPAUSE])) {
2022-04-02 18:08:56 +05:00
#ifdef __riscv_muldiv
2022-09-13 23:14:27 +05:00
int dummy;
/* In lieu of a halt instruction, induce a long-latency stall. */
__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
2022-04-02 18:08:56 +05:00
#endif
2022-09-13 23:14:27 +05:00
} else {
/*
* Reduce instruction retirement.
* This assumes the PC changes.
*/
2022-12-14 10:45:59 +05:00
#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
2022-09-13 23:14:27 +05:00
__asm__ __volatile__ ("pause");
#else
/* Encoding of the pause instruction */
__asm__ __volatile__ (".4byte 0x100000F");
#endif
}
2022-04-02 18:08:56 +05:00
barrier();
}
#endif /* __ASSEMBLY__ */
#endif /* __ASM_VDSO_PROCESSOR_H */