Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 55169
b: refs/heads/master
c: 78a62d2
h: refs/heads/master
i:
  55167: fdc8757
v: v3
  • Loading branch information
Nicolas Boichat authored and Jean Delvare committed May 8, 2007
1 parent 1eefca8 commit 72ee04c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 103 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4e9baad8f5cb2040e802eff484fad7e721b21c0b
refs/heads/master: 78a62d2c9817dc1adfc563f5a7654df2c89be416
106 changes: 4 additions & 102 deletions trunk/arch/i386/kernel/msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,104 +45,6 @@

static struct class *msr_class;

static inline int wrmsr_eio(u32 reg, u32 eax, u32 edx)
{
int err;

err = wrmsr_safe(reg, eax, edx);
if (err)
err = -EIO;
return err;
}

static inline int rdmsr_eio(u32 reg, u32 *eax, u32 *edx)
{
int err;

err = rdmsr_safe(reg, eax, edx);
if (err)
err = -EIO;
return err;
}

#ifdef CONFIG_SMP

struct msr_command {
int err;
u32 reg;
u32 data[2];
};

static void msr_smp_wrmsr(void *cmd_block)
{
struct msr_command *cmd = (struct msr_command *)cmd_block;

cmd->err = wrmsr_eio(cmd->reg, cmd->data[0], cmd->data[1]);
}

static void msr_smp_rdmsr(void *cmd_block)
{
struct msr_command *cmd = (struct msr_command *)cmd_block;

cmd->err = rdmsr_eio(cmd->reg, &cmd->data[0], &cmd->data[1]);
}

static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
{
struct msr_command cmd;
int ret;

preempt_disable();
if (cpu == smp_processor_id()) {
ret = wrmsr_eio(reg, eax, edx);
} else {
cmd.reg = reg;
cmd.data[0] = eax;
cmd.data[1] = edx;

smp_call_function_single(cpu, msr_smp_wrmsr, &cmd, 1, 1);
ret = cmd.err;
}
preempt_enable();
return ret;
}

static inline int do_rdmsr(int cpu, u32 reg, u32 * eax, u32 * edx)
{
struct msr_command cmd;
int ret;

preempt_disable();
if (cpu == smp_processor_id()) {
ret = rdmsr_eio(reg, eax, edx);
} else {
cmd.reg = reg;

smp_call_function_single(cpu, msr_smp_rdmsr, &cmd, 1, 1);

*eax = cmd.data[0];
*edx = cmd.data[1];

ret = cmd.err;
}
preempt_enable();
return ret;
}

#else /* ! CONFIG_SMP */

static inline int do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
{
return wrmsr_eio(reg, eax, edx);
}

static inline int do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx)
{
return rdmsr_eio(reg, eax, edx);
}

#endif /* ! CONFIG_SMP */

static loff_t msr_seek(struct file *file, loff_t offset, int orig)
{
loff_t ret = -EINVAL;
Expand Down Expand Up @@ -174,9 +76,9 @@ static ssize_t msr_read(struct file *file, char __user * buf,
return -EINVAL; /* Invalid chunk size */

for (; count; count -= 8) {
err = do_rdmsr(cpu, reg, &data[0], &data[1]);
err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
if (err)
return err;
return -EIO;
if (copy_to_user(tmp, &data, 8))
return -EFAULT;
tmp += 2;
Expand All @@ -200,9 +102,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
for (; count; count -= 8) {
if (copy_from_user(&data, tmp, 8))
return -EFAULT;
err = do_wrmsr(cpu, reg, data[0], data[1]);
err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]);
if (err)
return err;
return -EIO;
tmp += 2;
}

Expand Down

0 comments on commit 72ee04c

Please sign in to comment.