aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 18:58:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 18:58:21 -0400
commit0195c00244dc2e9f522475868fa278c473ba7339 (patch)
treef97ca98ae64ede2c33ad3de05ed7bbfa4f4495ed /include/asm-generic
parentf21ce8f8447c8be8847dadcfdbcc76b0d7365fa5 (diff)
parent141124c02059eee9dbc5c86ea797b1ca888e77f7 (diff)
Merge tag 'split-asm_system_h-for-linus-20120328' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-asm_system
Pull "Disintegrate and delete asm/system.h" from David Howells: "Here are a bunch of patches to disintegrate asm/system.h into a set of separate bits to relieve the problem of circular inclusion dependencies. I've built all the working defconfigs from all the arches that I can and made sure that they don't break. The reason for these patches is that I recently encountered a circular dependency problem that came about when I produced some patches to optimise get_order() by rewriting it to use ilog2(). This uses bitops - and on the SH arch asm/bitops.h drags in asm-generic/get_order.h by a circuituous route involving asm/system.h. The main difficulty seems to be asm/system.h. It holds a number of low level bits with no/few dependencies that are commonly used (eg. memory barriers) and a number of bits with more dependencies that aren't used in many places (eg. switch_to()). These patches break asm/system.h up into the following core pieces: (1) asm/barrier.h Move memory barriers here. This already done for MIPS and Alpha. (2) asm/switch_to.h Move switch_to() and related stuff here. (3) asm/exec.h Move arch_align_stack() here. Other process execution related bits could perhaps go here from asm/processor.h. (4) asm/cmpxchg.h Move xchg() and cmpxchg() here as they're full word atomic ops and frequently used by atomic_xchg() and atomic_cmpxchg(). (5) asm/bug.h Move die() and related bits. (6) asm/auxvec.h Move AT_VECTOR_SIZE_ARCH here. Other arch headers are created as needed on a per-arch basis." Fixed up some conflicts from other header file cleanups and moving code around that has happened in the meantime, so David's testing is somewhat weakened by that. We'll find out anything that got broken and fix it.. * tag 'split-asm_system_h-for-linus-20120328' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-asm_system: (38 commits) Delete all instances of asm/system.h Remove all #inclusions of asm/system.h Add #includes needed to permit the removal of asm/system.h Move all declarations of free_initmem() to linux/mm.h Disintegrate asm/system.h for OpenRISC Split arch_align_stack() out from asm-generic/system.h Split the switch_to() wrapper out of asm-generic/system.h Move the asm-generic/system.h xchg() implementation to asm-generic/cmpxchg.h Create asm-generic/barrier.h Make asm-generic/cmpxchg.h #include asm-generic/cmpxchg-local.h Disintegrate asm/system.h for Xtensa Disintegrate asm/system.h for Unicore32 [based on ver #3, changed by gxt] Disintegrate asm/system.h for Tile Disintegrate asm/system.h for Sparc Disintegrate asm/system.h for SH Disintegrate asm/system.h for Score Disintegrate asm/system.h for S390 Disintegrate asm/system.h for PowerPC Disintegrate asm/system.h for PA-RISC Disintegrate asm/system.h for MN10300 ...
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/atomic.h3
-rw-r--r--include/asm-generic/barrier.h50
-rw-r--r--include/asm-generic/bitops/atomic.h2
-rw-r--r--include/asm-generic/cmpxchg.h87
-rw-r--r--include/asm-generic/exec.h19
-rw-r--r--include/asm-generic/switch_to.h30
-rw-r--r--include/asm-generic/system.h141
7 files changed, 183 insertions, 149 deletions
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index e37963c1df4d..1ced6413ea03 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -15,6 +15,8 @@
15#ifndef __ASM_GENERIC_ATOMIC_H 15#ifndef __ASM_GENERIC_ATOMIC_H
16#define __ASM_GENERIC_ATOMIC_H 16#define __ASM_GENERIC_ATOMIC_H
17 17
18#include <asm/cmpxchg.h>
19
18#ifdef CONFIG_SMP 20#ifdef CONFIG_SMP
19/* Force people to define core atomics */ 21/* Force people to define core atomics */
20# if !defined(atomic_add_return) || !defined(atomic_sub_return) || \ 22# if !defined(atomic_add_return) || !defined(atomic_sub_return) || \
@@ -52,7 +54,6 @@
52#define atomic_set(v, i) (((v)->counter) = (i)) 54#define atomic_set(v, i) (((v)->counter) = (i))
53 55
54#include <linux/irqflags.h> 56#include <linux/irqflags.h>
55#include <asm/system.h>
56 57
57/** 58/**
58 * atomic_add_return - add integer to atomic variable 59 * atomic_add_return - add integer to atomic variable
diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
new file mode 100644
index 000000000000..639d7a4d033b
--- /dev/null
+++ b/include/asm-generic/barrier.h
@@ -0,0 +1,50 @@
1/* Generic barrier definitions, based on MN10300 definitions.
2 *
3 * It should be possible to use these on really simple architectures,
4 * but it serves more as a starting point for new ports.
5 *
6 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public Licence
11 * as published by the Free Software Foundation; either version
12 * 2 of the Licence, or (at your option) any later version.
13 */
14#ifndef __ASM_GENERIC_BARRIER_H
15#define __ASM_GENERIC_BARRIER_H
16
17#ifndef __ASSEMBLY__
18
19#define nop() asm volatile ("nop")
20
21/*
22 * Force strict CPU ordering.
23 * And yes, this is required on UP too when we're talking
24 * to devices.
25 *
26 * This implementation only contains a compiler barrier.
27 */
28
29#define mb() asm volatile ("": : :"memory")
30#define rmb() mb()
31#define wmb() asm volatile ("": : :"memory")
32
33#ifdef CONFIG_SMP
34#define smp_mb() mb()
35#define smp_rmb() rmb()
36#define smp_wmb() wmb()
37#else
38#define smp_mb() barrier()
39#define smp_rmb() barrier()
40#define smp_wmb() barrier()
41#endif
42
43#define set_mb(var, value) do { var = value; mb(); } while (0)
44#define set_wmb(var, value) do { var = value; wmb(); } while (0)
45
46#define read_barrier_depends() do {} while (0)
47#define smp_read_barrier_depends() do {} while (0)
48
49#endif /* !__ASSEMBLY__ */
50#endif /* __ASM_GENERIC_BARRIER_H */
diff --git a/include/asm-generic/bitops/atomic.h b/include/asm-generic/bitops/atomic.h
index ecc44a8e2b44..9ae6c34dc191 100644
--- a/include/asm-generic/bitops/atomic.h
+++ b/include/asm-generic/bitops/atomic.h
@@ -2,7 +2,7 @@
2#define _ASM_GENERIC_BITOPS_ATOMIC_H_ 2#define _ASM_GENERIC_BITOPS_ATOMIC_H_
3 3
4#include <asm/types.h> 4#include <asm/types.h>
5#include <asm/system.h> 5#include <linux/irqflags.h>
6 6
7#ifdef CONFIG_SMP 7#ifdef CONFIG_SMP
8#include <asm/spinlock.h> 8#include <asm/spinlock.h>
diff --git a/include/asm-generic/cmpxchg.h b/include/asm-generic/cmpxchg.h
index 213ac6e8fe39..8a361834dc25 100644
--- a/include/asm-generic/cmpxchg.h
+++ b/include/asm-generic/cmpxchg.h
@@ -1,22 +1,97 @@
1/*
2 * Generic UP xchg and cmpxchg using interrupt disablement. Does not
3 * support SMP.
4 */
5
1#ifndef __ASM_GENERIC_CMPXCHG_H 6#ifndef __ASM_GENERIC_CMPXCHG_H
2#define __ASM_GENERIC_CMPXCHG_H 7#define __ASM_GENERIC_CMPXCHG_H
3 8
4/*
5 * Generic cmpxchg
6 *
7 * Uses the local cmpxchg. Does not support SMP.
8 */
9#ifdef CONFIG_SMP 9#ifdef CONFIG_SMP
10#error "Cannot use generic cmpxchg on SMP" 10#error "Cannot use generic cmpxchg on SMP"
11#endif 11#endif
12 12
13#include <linux/irqflags.h>
14
15#ifndef xchg
16
17/*
18 * This function doesn't exist, so you'll get a linker error if
19 * something tries to do an invalidly-sized xchg().
20 */
21extern void __xchg_called_with_bad_pointer(void);
22
23static inline
24unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
25{
26 unsigned long ret, flags;
27
28 switch (size) {
29 case 1:
30#ifdef __xchg_u8
31 return __xchg_u8(x, ptr);
32#else
33 local_irq_save(flags);
34 ret = *(volatile u8 *)ptr;
35 *(volatile u8 *)ptr = x;
36 local_irq_restore(flags);
37 return ret;
38#endif /* __xchg_u8 */
39
40 case 2:
41#ifdef __xchg_u16
42 return __xchg_u16(x, ptr);
43#else
44 local_irq_save(flags);
45 ret = *(volatile u16 *)ptr;
46 *(volatile u16 *)ptr = x;
47 local_irq_restore(flags);
48 return ret;
49#endif /* __xchg_u16 */
50
51 case 4:
52#ifdef __xchg_u32
53 return __xchg_u32(x, ptr);
54#else
55 local_irq_save(flags);
56 ret = *(volatile u32 *)ptr;
57 *(volatile u32 *)ptr = x;
58 local_irq_restore(flags);
59 return ret;
60#endif /* __xchg_u32 */
61
62#ifdef CONFIG_64BIT
63 case 8:
64#ifdef __xchg_u64
65 return __xchg_u64(x, ptr);
66#else
67 local_irq_save(flags);
68 ret = *(volatile u64 *)ptr;
69 *(volatile u64 *)ptr = x;
70 local_irq_restore(flags);
71 return ret;
72#endif /* __xchg_u64 */
73#endif /* CONFIG_64BIT */
74
75 default:
76 __xchg_called_with_bad_pointer();
77 return x;
78 }
79}
80
81#define xchg(ptr, x) \
82 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
83
84#endif /* xchg */
85
13/* 86/*
14 * Atomic compare and exchange. 87 * Atomic compare and exchange.
15 * 88 *
16 * Do not define __HAVE_ARCH_CMPXCHG because we want to use it to check whether 89 * Do not define __HAVE_ARCH_CMPXCHG because we want to use it to check whether
17 * a cmpxchg primitive faster than repeated local irq save/restore exists. 90 * a cmpxchg primitive faster than repeated local irq save/restore exists.
18 */ 91 */
92#include <asm-generic/cmpxchg-local.h>
93
19#define cmpxchg(ptr, o, n) cmpxchg_local((ptr), (o), (n)) 94#define cmpxchg(ptr, o, n) cmpxchg_local((ptr), (o), (n))
20#define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n)) 95#define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n))
21 96
22#endif 97#endif /* __ASM_GENERIC_CMPXCHG_H */
diff --git a/include/asm-generic/exec.h b/include/asm-generic/exec.h
new file mode 100644
index 000000000000..567766b0074a
--- /dev/null
+++ b/include/asm-generic/exec.h
@@ -0,0 +1,19 @@
1/* Generic process execution definitions, based on MN10300 definitions.
2 *
3 * It should be possible to use these on really simple architectures,
4 * but it serves more as a starting point for new ports.
5 *
6 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public Licence
11 * as published by the Free Software Foundation; either version
12 * 2 of the Licence, or (at your option) any later version.
13 */
14#ifndef __ASM_GENERIC_EXEC_H
15#define __ASM_GENERIC_EXEC_H
16
17#define arch_align_stack(x) (x)
18
19#endif /* __ASM_GENERIC_EXEC_H */
diff --git a/include/asm-generic/switch_to.h b/include/asm-generic/switch_to.h
new file mode 100644
index 000000000000..052c4ac04fd5
--- /dev/null
+++ b/include/asm-generic/switch_to.h
@@ -0,0 +1,30 @@
1/* Generic task switch macro wrapper, based on MN10300 definitions.
2 *
3 * It should be possible to use these on really simple architectures,
4 * but it serves more as a starting point for new ports.
5 *
6 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public Licence
11 * as published by the Free Software Foundation; either version
12 * 2 of the Licence, or (at your option) any later version.
13 */
14#ifndef __ASM_GENERIC_SWITCH_TO_H
15#define __ASM_GENERIC_SWITCH_TO_H
16
17#include <linux/thread_info.h>
18
19/*
20 * Context switching is now performed out-of-line in switch_to.S
21 */
22extern struct task_struct *__switch_to(struct task_struct *,
23 struct task_struct *);
24
25#define switch_to(prev, next, last) \
26 do { \
27 ((last) = __switch_to((prev), (next))); \
28 } while (0)
29
30#endif /* __ASM_GENERIC_SWITCH_TO_H */
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
deleted file mode 100644
index 215efa74f5a2..000000000000
--- a/include/asm-generic/system.h
+++ /dev/null
@@ -1,141 +0,0 @@
1/* Generic system definitions, based on MN10300 definitions.
2 *
3 * It should be possible to use these on really simple architectures,
4 * but it serves more as a starting point for new ports.
5 *
6 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public Licence
11 * as published by the Free Software Foundation; either version
12 * 2 of the Licence, or (at your option) any later version.
13 */
14#ifndef __ASM_GENERIC_SYSTEM_H
15#define __ASM_GENERIC_SYSTEM_H
16
17#ifndef __ASSEMBLY__
18
19#include <linux/types.h>
20#include <linux/irqflags.h>
21
22#include <asm/cmpxchg-local.h>
23#include <asm/cmpxchg.h>
24
25struct task_struct;
26
27/* context switching is now performed out-of-line in switch_to.S */
28extern struct task_struct *__switch_to(struct task_struct *,
29 struct task_struct *);
30#define switch_to(prev, next, last) \
31 do { \
32 ((last) = __switch_to((prev), (next))); \
33 } while (0)
34
35#define arch_align_stack(x) (x)
36
37#define nop() asm volatile ("nop")
38
39#endif /* !__ASSEMBLY__ */
40
41/*
42 * Force strict CPU ordering.
43 * And yes, this is required on UP too when we're talking
44 * to devices.
45 *
46 * This implementation only contains a compiler barrier.
47 */
48
49#define mb() asm volatile ("": : :"memory")
50#define rmb() mb()
51#define wmb() asm volatile ("": : :"memory")
52
53#ifdef CONFIG_SMP
54#define smp_mb() mb()
55#define smp_rmb() rmb()
56#define smp_wmb() wmb()
57#else
58#define smp_mb() barrier()
59#define smp_rmb() barrier()
60#define smp_wmb() barrier()
61#endif
62
63#define set_mb(var, value) do { var = value; mb(); } while (0)
64#define set_wmb(var, value) do { var = value; wmb(); } while (0)
65
66#define read_barrier_depends() do {} while (0)
67#define smp_read_barrier_depends() do {} while (0)
68
69/*
70 * we make sure local_irq_enable() doesn't cause priority inversion
71 */
72#ifndef __ASSEMBLY__
73
74/* This function doesn't exist, so you'll get a linker error
75 * if something tries to do an invalid xchg(). */
76extern void __xchg_called_with_bad_pointer(void);
77
78static inline
79unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
80{
81 unsigned long ret, flags;
82
83 switch (size) {
84 case 1:
85#ifdef __xchg_u8
86 return __xchg_u8(x, ptr);
87#else
88 local_irq_save(flags);
89 ret = *(volatile u8 *)ptr;
90 *(volatile u8 *)ptr = x;
91 local_irq_restore(flags);
92 return ret;
93#endif /* __xchg_u8 */
94
95 case 2:
96#ifdef __xchg_u16
97 return __xchg_u16(x, ptr);
98#else
99 local_irq_save(flags);
100 ret = *(volatile u16 *)ptr;
101 *(volatile u16 *)ptr = x;
102 local_irq_restore(flags);
103 return ret;
104#endif /* __xchg_u16 */
105
106 case 4:
107#ifdef __xchg_u32
108 return __xchg_u32(x, ptr);
109#else
110 local_irq_save(flags);
111 ret = *(volatile u32 *)ptr;
112 *(volatile u32 *)ptr = x;
113 local_irq_restore(flags);
114 return ret;
115#endif /* __xchg_u32 */
116
117#ifdef CONFIG_64BIT
118 case 8:
119#ifdef __xchg_u64
120 return __xchg_u64(x, ptr);
121#else
122 local_irq_save(flags);
123 ret = *(volatile u64 *)ptr;
124 *(volatile u64 *)ptr = x;
125 local_irq_restore(flags);
126 return ret;
127#endif /* __xchg_u64 */
128#endif /* CONFIG_64BIT */
129
130 default:
131 __xchg_called_with_bad_pointer();
132 return x;
133 }
134}
135
136#define xchg(ptr, x) \
137 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
138
139#endif /* !__ASSEMBLY__ */
140
141#endif /* __ASM_GENERIC_SYSTEM_H */