^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef _ASM_POWERPC_RUNLATCH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define _ASM_POWERPC_RUNLATCH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) extern void __ppc64_runlatch_on(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) extern void __ppc64_runlatch_off(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * We manually hard enable-disable, this is called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * in the idle loop and we don't want to mess up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * with soft-disable/enable & interrupt replay.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define ppc64_runlatch_off() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if (cpu_has_feature(CPU_FTR_CTRL) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) test_thread_local_flags(_TLF_RUNLATCH)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long msr = mfmsr(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) __hard_irq_disable(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) __ppc64_runlatch_off(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if (msr & MSR_EE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __hard_irq_enable(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define ppc64_runlatch_on() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (cpu_has_feature(CPU_FTR_CTRL) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) !test_thread_local_flags(_TLF_RUNLATCH)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned long msr = mfmsr(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __hard_irq_disable(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __ppc64_runlatch_on(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (msr & MSR_EE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) __hard_irq_enable(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define ppc64_runlatch_on()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define ppc64_runlatch_off()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #endif /* CONFIG_PPC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif /* _ASM_POWERPC_RUNLATCH_H */