processor.h 694 B

1234567891011121314151617181920212223242526272829303132
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __ASM_VDSO_PROCESSOR_H
  3. #define __ASM_VDSO_PROCESSOR_H
  4. #ifndef __ASSEMBLY__
  5. #include <asm-generic/barrier.h>
  6. static inline void cpu_relax(void)
  7. {
  8. #ifdef __riscv_muldiv
  9. int dummy;
  10. /* In lieu of a halt instruction, induce a long-latency stall. */
  11. __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
  12. #endif
  13. #ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
  14. /*
  15. * Reduce instruction retirement.
  16. * This assumes the PC changes.
  17. */
  18. __asm__ __volatile__ ("pause");
  19. #else
  20. /* Encoding of the pause instruction */
  21. __asm__ __volatile__ (".4byte 0x100000F");
  22. #endif
  23. barrier();
  24. }
  25. #endif /* __ASSEMBLY__ */
  26. #endif /* __ASM_VDSO_PROCESSOR_H */