iwlagn: use huge command for beacon
[linux/fpc-iii.git] / arch / x86 / lib / msr-smp.c
bloba6b1b86d225358f05e58a649fdadedc4eafdb87e
1 #include <linux/module.h>
2 #include <linux/preempt.h>
3 #include <linux/smp.h>
4 #include <asm/msr.h>
6 static void __rdmsr_on_cpu(void *info)
8 struct msr_info *rv = info;
9 struct msr *reg;
10 int this_cpu = raw_smp_processor_id();
12 if (rv->msrs)
13 reg = per_cpu_ptr(rv->msrs, this_cpu);
14 else
15 reg = &rv->reg;
17 rdmsr(rv->msr_no, reg->l, reg->h);
20 static void __wrmsr_on_cpu(void *info)
22 struct msr_info *rv = info;
23 struct msr *reg;
24 int this_cpu = raw_smp_processor_id();
26 if (rv->msrs)
27 reg = per_cpu_ptr(rv->msrs, this_cpu);
28 else
29 reg = &rv->reg;
31 wrmsr(rv->msr_no, reg->l, reg->h);
34 int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
36 int err;
37 struct msr_info rv;
39 memset(&rv, 0, sizeof(rv));
41 rv.msr_no = msr_no;
42 err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
43 *l = rv.reg.l;
44 *h = rv.reg.h;
46 return err;
48 EXPORT_SYMBOL(rdmsr_on_cpu);
50 int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
52 int err;
53 struct msr_info rv;
55 memset(&rv, 0, sizeof(rv));
57 rv.msr_no = msr_no;
58 rv.reg.l = l;
59 rv.reg.h = h;
60 err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
62 return err;
64 EXPORT_SYMBOL(wrmsr_on_cpu);
66 static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
67 struct msr *msrs,
68 void (*msr_func) (void *info))
70 struct msr_info rv;
71 int this_cpu;
73 memset(&rv, 0, sizeof(rv));
75 rv.msrs = msrs;
76 rv.msr_no = msr_no;
78 this_cpu = get_cpu();
80 if (cpumask_test_cpu(this_cpu, mask))
81 msr_func(&rv);
83 smp_call_function_many(mask, msr_func, &rv, 1);
84 put_cpu();
87 /* rdmsr on a bunch of CPUs
89 * @mask: which CPUs
90 * @msr_no: which MSR
91 * @msrs: array of MSR values
94 void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
96 __rwmsr_on_cpus(mask, msr_no, msrs, __rdmsr_on_cpu);
98 EXPORT_SYMBOL(rdmsr_on_cpus);
101 * wrmsr on a bunch of CPUs
103 * @mask: which CPUs
104 * @msr_no: which MSR
105 * @msrs: array of MSR values
108 void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
110 __rwmsr_on_cpus(mask, msr_no, msrs, __wrmsr_on_cpu);
112 EXPORT_SYMBOL(wrmsr_on_cpus);
114 /* These "safe" variants are slower and should be used when the target MSR
115 may not actually exist. */
116 static void __rdmsr_safe_on_cpu(void *info)
118 struct msr_info *rv = info;
120 rv->err = rdmsr_safe(rv->msr_no, &rv->reg.l, &rv->reg.h);
123 static void __wrmsr_safe_on_cpu(void *info)
125 struct msr_info *rv = info;
127 rv->err = wrmsr_safe(rv->msr_no, rv->reg.l, rv->reg.h);
130 int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
132 int err;
133 struct msr_info rv;
135 memset(&rv, 0, sizeof(rv));
137 rv.msr_no = msr_no;
138 err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
139 *l = rv.reg.l;
140 *h = rv.reg.h;
142 return err ? err : rv.err;
144 EXPORT_SYMBOL(rdmsr_safe_on_cpu);
146 int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
148 int err;
149 struct msr_info rv;
151 memset(&rv, 0, sizeof(rv));
153 rv.msr_no = msr_no;
154 rv.reg.l = l;
155 rv.reg.h = h;
156 err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
158 return err ? err : rv.err;
160 EXPORT_SYMBOL(wrmsr_safe_on_cpu);
163 * These variants are significantly slower, but allows control over
164 * the entire 32-bit GPR set.
166 static void __rdmsr_safe_regs_on_cpu(void *info)
168 struct msr_regs_info *rv = info;
170 rv->err = rdmsr_safe_regs(rv->regs);
173 static void __wrmsr_safe_regs_on_cpu(void *info)
175 struct msr_regs_info *rv = info;
177 rv->err = wrmsr_safe_regs(rv->regs);
180 int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
182 int err;
183 struct msr_regs_info rv;
185 rv.regs = regs;
186 rv.err = -EIO;
187 err = smp_call_function_single(cpu, __rdmsr_safe_regs_on_cpu, &rv, 1);
189 return err ? err : rv.err;
191 EXPORT_SYMBOL(rdmsr_safe_regs_on_cpu);
193 int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
195 int err;
196 struct msr_regs_info rv;
198 rv.regs = regs;
199 rv.err = -EIO;
200 err = smp_call_function_single(cpu, __wrmsr_safe_regs_on_cpu, &rv, 1);
202 return err ? err : rv.err;
204 EXPORT_SYMBOL(wrmsr_safe_regs_on_cpu);