diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-11 13:33:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-11 13:33:36 -0400 |
commit | c29f5ec022451546be1e0b24c330a0368e63e4a7 (patch) | |
tree | af3c2fc0ba3236fd4c1c2d1a4303fb5a3dc396ab /arch/x86 | |
parent | d3d07d941fd80c173b6d690ded00ee5fb8302e06 (diff) | |
parent | c476c23b45a41eb4e3ea63af786cc4d74762fe11 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp: (26 commits)
amd64_edac: add MAINTAINERS entry
EDAC: do not enable modules by default
amd64_edac: do not enable module by default
amd64_edac: add module registration routines
amd64_edac: add ECC reporting initializers
amd64_edac: add EDAC core-related initializers
amd64_edac: add error decoding logic
amd64_edac: add ECC chipkill syndrome mapping table
amd64_edac: add per-family descriptors
amd64_edac: add F10h-and-later methods-p3
amd64_edac: add F10h-and-later methods-p2
amd64_edac: add F10h-and-later methods-p1
amd64_edac: add k8-specific methods
amd64_edac: assign DRAM chip select base and mask in a family-specific way
amd64_edac: add helper to dump relevant registers
amd64_edac: add DRAM address type conversion facilities
amd64_edac: add functionality to compute the DRAM hole
amd64_edac: add sys addr to memory controller mapping helpers
amd64_edac: add memory scrubber interface
amd64_edac: add MCA error types
...
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/msr.h | 23 | ||||
-rw-r--r-- | arch/x86/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/lib/msr-on-cpu.c | 97 | ||||
-rw-r--r-- | arch/x86/lib/msr.c | 183 |
4 files changed, 207 insertions, 98 deletions
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index 638bf6241807..22603764e7db 100644 --- a/arch/x86/include/asm/msr.h +++ b/arch/x86/include/asm/msr.h | |||
@@ -12,6 +12,17 @@ | |||
12 | 12 | ||
13 | #include <asm/asm.h> | 13 | #include <asm/asm.h> |
14 | #include <asm/errno.h> | 14 | #include <asm/errno.h> |
15 | #include <asm/cpumask.h> | ||
16 | |||
17 | struct msr { | ||
18 | union { | ||
19 | struct { | ||
20 | u32 l; | ||
21 | u32 h; | ||
22 | }; | ||
23 | u64 q; | ||
24 | }; | ||
25 | }; | ||
15 | 26 | ||
16 | static inline unsigned long long native_read_tscp(unsigned int *aux) | 27 | static inline unsigned long long native_read_tscp(unsigned int *aux) |
17 | { | 28 | { |
@@ -216,6 +227,8 @@ do { \ | |||
216 | #ifdef CONFIG_SMP | 227 | #ifdef CONFIG_SMP |
217 | int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); | 228 | int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); |
218 | int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); | 229 | int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); |
230 | void rdmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs); | ||
231 | void wrmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs); | ||
219 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); | 232 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); |
220 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); | 233 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); |
221 | #else /* CONFIG_SMP */ | 234 | #else /* CONFIG_SMP */ |
@@ -229,6 +242,16 @@ static inline int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | |||
229 | wrmsr(msr_no, l, h); | 242 | wrmsr(msr_no, l, h); |
230 | return 0; | 243 | return 0; |
231 | } | 244 | } |
245 | static inline void rdmsr_on_cpus(const cpumask_t *m, u32 msr_no, | ||
246 | struct msr *msrs) | ||
247 | { | ||
248 | rdmsr_on_cpu(0, msr_no, &(msrs[0].l), &(msrs[0].h)); | ||
249 | } | ||
250 | static inline void wrmsr_on_cpus(const cpumask_t *m, u32 msr_no, | ||
251 | struct msr *msrs) | ||
252 | { | ||
253 | wrmsr_on_cpu(0, msr_no, msrs[0].l, msrs[0].h); | ||
254 | } | ||
232 | static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, | 255 | static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, |
233 | u32 *l, u32 *h) | 256 | u32 *l, u32 *h) |
234 | { | 257 | { |
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 55e11aa6d66c..f9d35632666b 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for x86 specific library files. | 2 | # Makefile for x86 specific library files. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_SMP) := msr-on-cpu.o | 5 | obj-$(CONFIG_SMP) := msr.o |
6 | 6 | ||
7 | lib-y := delay.o | 7 | lib-y := delay.o |
8 | lib-y += thunk_$(BITS).o | 8 | lib-y += thunk_$(BITS).o |
diff --git a/arch/x86/lib/msr-on-cpu.c b/arch/x86/lib/msr-on-cpu.c deleted file mode 100644 index 321cf720dbb6..000000000000 --- a/arch/x86/lib/msr-on-cpu.c +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/preempt.h> | ||
3 | #include <linux/smp.h> | ||
4 | #include <asm/msr.h> | ||
5 | |||
6 | struct msr_info { | ||
7 | u32 msr_no; | ||
8 | u32 l, h; | ||
9 | int err; | ||
10 | }; | ||
11 | |||
12 | static void __rdmsr_on_cpu(void *info) | ||
13 | { | ||
14 | struct msr_info *rv = info; | ||
15 | |||
16 | rdmsr(rv->msr_no, rv->l, rv->h); | ||
17 | } | ||
18 | |||
19 | static void __wrmsr_on_cpu(void *info) | ||
20 | { | ||
21 | struct msr_info *rv = info; | ||
22 | |||
23 | wrmsr(rv->msr_no, rv->l, rv->h); | ||
24 | } | ||
25 | |||
26 | int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
27 | { | ||
28 | int err; | ||
29 | struct msr_info rv; | ||
30 | |||
31 | rv.msr_no = msr_no; | ||
32 | err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1); | ||
33 | *l = rv.l; | ||
34 | *h = rv.h; | ||
35 | |||
36 | return err; | ||
37 | } | ||
38 | |||
39 | int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
40 | { | ||
41 | int err; | ||
42 | struct msr_info rv; | ||
43 | |||
44 | rv.msr_no = msr_no; | ||
45 | rv.l = l; | ||
46 | rv.h = h; | ||
47 | err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1); | ||
48 | |||
49 | return err; | ||
50 | } | ||
51 | |||
52 | /* These "safe" variants are slower and should be used when the target MSR | ||
53 | may not actually exist. */ | ||
54 | static void __rdmsr_safe_on_cpu(void *info) | ||
55 | { | ||
56 | struct msr_info *rv = info; | ||
57 | |||
58 | rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h); | ||
59 | } | ||
60 | |||
61 | static void __wrmsr_safe_on_cpu(void *info) | ||
62 | { | ||
63 | struct msr_info *rv = info; | ||
64 | |||
65 | rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h); | ||
66 | } | ||
67 | |||
68 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
69 | { | ||
70 | int err; | ||
71 | struct msr_info rv; | ||
72 | |||
73 | rv.msr_no = msr_no; | ||
74 | err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1); | ||
75 | *l = rv.l; | ||
76 | *h = rv.h; | ||
77 | |||
78 | return err ? err : rv.err; | ||
79 | } | ||
80 | |||
81 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
82 | { | ||
83 | int err; | ||
84 | struct msr_info rv; | ||
85 | |||
86 | rv.msr_no = msr_no; | ||
87 | rv.l = l; | ||
88 | rv.h = h; | ||
89 | err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1); | ||
90 | |||
91 | return err ? err : rv.err; | ||
92 | } | ||
93 | |||
94 | EXPORT_SYMBOL(rdmsr_on_cpu); | ||
95 | EXPORT_SYMBOL(wrmsr_on_cpu); | ||
96 | EXPORT_SYMBOL(rdmsr_safe_on_cpu); | ||
97 | EXPORT_SYMBOL(wrmsr_safe_on_cpu); | ||
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c new file mode 100644 index 000000000000..1440b9c0547e --- /dev/null +++ b/arch/x86/lib/msr.c | |||
@@ -0,0 +1,183 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/preempt.h> | ||
3 | #include <linux/smp.h> | ||
4 | #include <asm/msr.h> | ||
5 | |||
6 | struct msr_info { | ||
7 | u32 msr_no; | ||
8 | struct msr reg; | ||
9 | struct msr *msrs; | ||
10 | int off; | ||
11 | int err; | ||
12 | }; | ||
13 | |||
14 | static void __rdmsr_on_cpu(void *info) | ||
15 | { | ||
16 | struct msr_info *rv = info; | ||
17 | struct msr *reg; | ||
18 | int this_cpu = raw_smp_processor_id(); | ||
19 | |||
20 | if (rv->msrs) | ||
21 | reg = &rv->msrs[this_cpu - rv->off]; | ||
22 | else | ||
23 | reg = &rv->reg; | ||
24 | |||
25 | rdmsr(rv->msr_no, reg->l, reg->h); | ||
26 | } | ||
27 | |||
28 | static void __wrmsr_on_cpu(void *info) | ||
29 | { | ||
30 | struct msr_info *rv = info; | ||
31 | struct msr *reg; | ||
32 | int this_cpu = raw_smp_processor_id(); | ||
33 | |||
34 | if (rv->msrs) | ||
35 | reg = &rv->msrs[this_cpu - rv->off]; | ||
36 | else | ||
37 | reg = &rv->reg; | ||
38 | |||
39 | wrmsr(rv->msr_no, reg->l, reg->h); | ||
40 | } | ||
41 | |||
42 | int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
43 | { | ||
44 | int err; | ||
45 | struct msr_info rv; | ||
46 | |||
47 | memset(&rv, 0, sizeof(rv)); | ||
48 | |||
49 | rv.msr_no = msr_no; | ||
50 | err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1); | ||
51 | *l = rv.reg.l; | ||
52 | *h = rv.reg.h; | ||
53 | |||
54 | return err; | ||
55 | } | ||
56 | EXPORT_SYMBOL(rdmsr_on_cpu); | ||
57 | |||
58 | int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
59 | { | ||
60 | int err; | ||
61 | struct msr_info rv; | ||
62 | |||
63 | memset(&rv, 0, sizeof(rv)); | ||
64 | |||
65 | rv.msr_no = msr_no; | ||
66 | rv.reg.l = l; | ||
67 | rv.reg.h = h; | ||
68 | err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1); | ||
69 | |||
70 | return err; | ||
71 | } | ||
72 | EXPORT_SYMBOL(wrmsr_on_cpu); | ||
73 | |||
74 | /* rdmsr on a bunch of CPUs | ||
75 | * | ||
76 | * @mask: which CPUs | ||
77 | * @msr_no: which MSR | ||
78 | * @msrs: array of MSR values | ||
79 | * | ||
80 | */ | ||
81 | void rdmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs) | ||
82 | { | ||
83 | struct msr_info rv; | ||
84 | int this_cpu; | ||
85 | |||
86 | memset(&rv, 0, sizeof(rv)); | ||
87 | |||
88 | rv.off = cpumask_first(mask); | ||
89 | rv.msrs = msrs; | ||
90 | rv.msr_no = msr_no; | ||
91 | |||
92 | preempt_disable(); | ||
93 | /* | ||
94 | * FIXME: handle the CPU we're executing on separately for now until | ||
95 | * smp_call_function_many has been fixed to not skip it. | ||
96 | */ | ||
97 | this_cpu = raw_smp_processor_id(); | ||
98 | smp_call_function_single(this_cpu, __rdmsr_on_cpu, &rv, 1); | ||
99 | |||
100 | smp_call_function_many(mask, __rdmsr_on_cpu, &rv, 1); | ||
101 | preempt_enable(); | ||
102 | } | ||
103 | EXPORT_SYMBOL(rdmsr_on_cpus); | ||
104 | |||
105 | /* | ||
106 | * wrmsr on a bunch of CPUs | ||
107 | * | ||
108 | * @mask: which CPUs | ||
109 | * @msr_no: which MSR | ||
110 | * @msrs: array of MSR values | ||
111 | * | ||
112 | */ | ||
113 | void wrmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs) | ||
114 | { | ||
115 | struct msr_info rv; | ||
116 | int this_cpu; | ||
117 | |||
118 | memset(&rv, 0, sizeof(rv)); | ||
119 | |||
120 | rv.off = cpumask_first(mask); | ||
121 | rv.msrs = msrs; | ||
122 | rv.msr_no = msr_no; | ||
123 | |||
124 | preempt_disable(); | ||
125 | /* | ||
126 | * FIXME: handle the CPU we're executing on separately for now until | ||
127 | * smp_call_function_many has been fixed to not skip it. | ||
128 | */ | ||
129 | this_cpu = raw_smp_processor_id(); | ||
130 | smp_call_function_single(this_cpu, __wrmsr_on_cpu, &rv, 1); | ||
131 | |||
132 | smp_call_function_many(mask, __wrmsr_on_cpu, &rv, 1); | ||
133 | preempt_enable(); | ||
134 | } | ||
135 | EXPORT_SYMBOL(wrmsr_on_cpus); | ||
136 | |||
137 | /* These "safe" variants are slower and should be used when the target MSR | ||
138 | may not actually exist. */ | ||
139 | static void __rdmsr_safe_on_cpu(void *info) | ||
140 | { | ||
141 | struct msr_info *rv = info; | ||
142 | |||
143 | rv->err = rdmsr_safe(rv->msr_no, &rv->reg.l, &rv->reg.h); | ||
144 | } | ||
145 | |||
146 | static void __wrmsr_safe_on_cpu(void *info) | ||
147 | { | ||
148 | struct msr_info *rv = info; | ||
149 | |||
150 | rv->err = wrmsr_safe(rv->msr_no, rv->reg.l, rv->reg.h); | ||
151 | } | ||
152 | |||
153 | int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) | ||
154 | { | ||
155 | int err; | ||
156 | struct msr_info rv; | ||
157 | |||
158 | memset(&rv, 0, sizeof(rv)); | ||
159 | |||
160 | rv.msr_no = msr_no; | ||
161 | err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1); | ||
162 | *l = rv.reg.l; | ||
163 | *h = rv.reg.h; | ||
164 | |||
165 | return err ? err : rv.err; | ||
166 | } | ||
167 | EXPORT_SYMBOL(rdmsr_safe_on_cpu); | ||
168 | |||
169 | int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) | ||
170 | { | ||
171 | int err; | ||
172 | struct msr_info rv; | ||
173 | |||
174 | memset(&rv, 0, sizeof(rv)); | ||
175 | |||
176 | rv.msr_no = msr_no; | ||
177 | rv.reg.l = l; | ||
178 | rv.reg.h = h; | ||
179 | err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1); | ||
180 | |||
181 | return err ? err : rv.err; | ||
182 | } | ||
183 | EXPORT_SYMBOL(wrmsr_safe_on_cpu); | ||