blob: 5c8db3ce61c8e34009a5f236a378e81783c57e98 [file] [log] [blame]
David Howellsa0616cd2012-03-28 18:30:02 +01001/*
2 * Copyright IBM Corp. 1999, 2009
3 *
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 */
6
7#ifndef __ASM_BARRIER_H
8#define __ASM_BARRIER_H
9
10/*
11 * Force strict CPU ordering.
12 * And yes, this is required on UP too when we're talking
13 * to devices.
David Howellsa0616cd2012-03-28 18:30:02 +010014 */
15
Heiko Carstense5b8d752012-05-14 12:41:54 +020016#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
Heiko Carstense06ef372013-01-30 13:56:14 +010017/* Fast-BCR without checkpoint synchronization */
Heiko Carstens44230282014-09-08 08:20:43 +020018#define __ASM_BARRIER "bcr 14,0\n"
Heiko Carstense5b8d752012-05-14 12:41:54 +020019#else
Heiko Carstens44230282014-09-08 08:20:43 +020020#define __ASM_BARRIER "bcr 15,0\n"
Heiko Carstense5b8d752012-05-14 12:41:54 +020021#endif
David Howellsa0616cd2012-03-28 18:30:02 +010022
Heiko Carstens44230282014-09-08 08:20:43 +020023#define mb() do { asm volatile(__ASM_BARRIER : : : "memory"); } while (0)
24
Christian Borntraeger1afc82a2015-09-11 16:32:24 +020025#define rmb() barrier()
26#define wmb() barrier()
27#define dma_rmb() mb()
28#define dma_wmb() mb()
Michael S. Tsirkin82b44492015-12-27 15:04:42 +020029#define __smp_mb() mb()
30#define __smp_rmb() rmb()
31#define __smp_wmb() wmb()
Alexander Duyck8a449712014-12-11 15:01:55 -080032
Michael S. Tsirkin82b44492015-12-27 15:04:42 +020033#define __smp_store_release(p, v) \
Peter Zijlstra47933ad2013-11-06 14:57:36 +010034do { \
35 compiletime_assert_atomic_type(*p); \
36 barrier(); \
Andrey Konovalov76695af2015-08-02 17:11:04 +020037 WRITE_ONCE(*p, v); \
Peter Zijlstra47933ad2013-11-06 14:57:36 +010038} while (0)
39
Michael S. Tsirkin82b44492015-12-27 15:04:42 +020040#define __smp_load_acquire(p) \
Peter Zijlstra47933ad2013-11-06 14:57:36 +010041({ \
Andrey Konovalov76695af2015-08-02 17:11:04 +020042 typeof(*p) ___p1 = READ_ONCE(*p); \
Peter Zijlstra47933ad2013-11-06 14:57:36 +010043 compiletime_assert_atomic_type(*p); \
44 barrier(); \
45 ___p1; \
46})
47
Michael S. Tsirkin779a6a32016-01-10 13:19:38 +020048#define __smp_mb__before_atomic() barrier()
49#define __smp_mb__after_atomic() barrier()
50
Michael S. Tsirkin21535aa2015-12-21 09:22:18 +020051#include <asm-generic/barrier.h>
52
David Howellsa0616cd2012-03-28 18:30:02 +010053#endif /* __ASM_BARRIER_H */