^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) 2019 Google LLC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __ASM_RWONCE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define __ASM_RWONCE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/barrier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Alpha is apparently daft enough to reorder address-dependent loads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * on some CPU implementations. Knock some common sense into it with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * a memory barrier in READ_ONCE().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * For the curious, more information about this unusual reordering is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * available in chapter 15 of the "perfbook":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * https://kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define __READ_ONCE(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) __unqual_scalar_typeof(x) __x = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) (*(volatile typeof(__x) *)(&(x))); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) mb(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) (typeof(x))__x; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #endif /* CONFIG_SMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <asm-generic/rwonce.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #endif /* __ASM_RWONCE_H */