fix a kmap leak in virtio_console
[linux/fpc-iii.git] / include / asm-generic / barrier.h
blob6f692f8ac664565eda7f0e2f7a551d1f5ebc1df4
1 /*
2 * Generic barrier definitions, originally based on MN10300 definitions.
4 * It should be possible to use these on really simple architectures,
5 * but it serves more as a starting point for new ports.
7 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
8 * Written by David Howells (dhowells@redhat.com)
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public Licence
12 * as published by the Free Software Foundation; either version
13 * 2 of the Licence, or (at your option) any later version.
15 #ifndef __ASM_GENERIC_BARRIER_H
16 #define __ASM_GENERIC_BARRIER_H
18 #ifndef __ASSEMBLY__
20 #include <linux/compiler.h>
22 #ifndef nop
23 #define nop() asm volatile ("nop")
24 #endif
27 * Force strict CPU ordering. And yes, this is required on UP too when we're
28 * talking to devices.
30 * Fall back to compiler barriers if nothing better is provided.
33 #ifndef mb
34 #define mb() barrier()
35 #endif
37 #ifndef rmb
38 #define rmb() mb()
39 #endif
41 #ifndef wmb
42 #define wmb() mb()
43 #endif
45 #ifndef read_barrier_depends
46 #define read_barrier_depends() do { } while (0)
47 #endif
49 #ifdef CONFIG_SMP
50 #define smp_mb() mb()
51 #define smp_rmb() rmb()
52 #define smp_wmb() wmb()
53 #define smp_read_barrier_depends() read_barrier_depends()
54 #else
55 #define smp_mb() barrier()
56 #define smp_rmb() barrier()
57 #define smp_wmb() barrier()
58 #define smp_read_barrier_depends() do { } while (0)
59 #endif
61 #ifndef set_mb
62 #define set_mb(var, value) do { (var) = (value); mb(); } while (0)
63 #endif
65 #define smp_store_release(p, v) \
66 do { \
67 compiletime_assert_atomic_type(*p); \
68 smp_mb(); \
69 ACCESS_ONCE(*p) = (v); \
70 } while (0)
72 #define smp_load_acquire(p) \
73 ({ \
74 typeof(*p) ___p1 = ACCESS_ONCE(*p); \
75 compiletime_assert_atomic_type(*p); \
76 smp_mb(); \
77 ___p1; \
80 #endif /* !__ASSEMBLY__ */
81 #endif /* __ASM_GENERIC_BARRIER_H */