Skip to content

Commit 434b266

Browse files
committed
s390/rwonce: add READ_ONCE_ALIGNED_128() macro
Add an s390 specific READ_ONCE_ALIGNED_128() helper, which can be used for fast block concurrent (atomic) 128-bit accesses. The used lpq instruction requires 128-bit alignment. This is also the reason why the compiler doesn't emit this instruction if __READ_ONCE() is used for 128-bit accesses. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent ebf95e8 commit 434b266

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

arch/s390/include/asm/rwonce.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef __ASM_S390_RWONCE_H
4+
#define __ASM_S390_RWONCE_H
5+
6+
#include <linux/compiler_types.h>
7+
8+
/*
9+
* Use READ_ONCE_ALIGNED_128() for 128-bit block concurrent (atomic) read
10+
* accesses. Note that x must be 128-bit aligned, otherwise a specification
11+
* exception is generated.
12+
*/
13+
#define READ_ONCE_ALIGNED_128(x) \
14+
({ \
15+
union { \
16+
typeof(x) __x; \
17+
__uint128_t val; \
18+
} __u; \
19+
\
20+
BUILD_BUG_ON(sizeof(x) != 16); \
21+
asm volatile( \
22+
" lpq %[val],%[_x]\n" \
23+
: [val] "=d" (__u.val) \
24+
: [_x] "QS" (x) \
25+
: "memory"); \
26+
__u.__x; \
27+
})
28+
29+
#include <asm-generic/rwonce.h>
30+
31+
#endif /* __ASM_S390_RWONCE_H */

0 commit comments

Comments
 (0)