OMAP: Add new function to check wether there is irq pending
[linux-ginger.git] / arch / x86 / lib / msr-on-cpu.c
blob321cf720dbb637895074315967a9c49d982b14b2
1 #include <linux/module.h>
2 #include <linux/preempt.h>
3 #include <linux/smp.h>
4 #include <asm/msr.h>
6 struct msr_info {
7 u32 msr_no;
8 u32 l, h;
9 int err;
12 static void __rdmsr_on_cpu(void *info)
14 struct msr_info *rv = info;
16 rdmsr(rv->msr_no, rv->l, rv->h);
19 static void __wrmsr_on_cpu(void *info)
21 struct msr_info *rv = info;
23 wrmsr(rv->msr_no, rv->l, rv->h);
26 int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
28 int err;
29 struct msr_info rv;
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;
36 return err;
39 int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
41 int err;
42 struct msr_info rv;
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);
49 return err;
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)
56 struct msr_info *rv = info;
58 rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h);
61 static void __wrmsr_safe_on_cpu(void *info)
63 struct msr_info *rv = info;
65 rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h);
68 int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
70 int err;
71 struct msr_info rv;
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;
78 return err ? err : rv.err;
81 int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
83 int err;
84 struct msr_info rv;
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);
91 return err ? err : rv.err;
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);