lkml.org 
[lkml]   [2009]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 14/21] amd64_edac: add msr accessors operating on all cpus
On Tue, 28 Apr 2009 17:06:06 +0200
Borislav Petkov <borislav.petkov@amd.com> wrote:

> From: Doug Thompson <dougthompson@xmission.com>
>
> Signed-off-by: Doug Thompson <dougthompson@xmission.com>
> Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
> ---
> drivers/edac/amd64_edac.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index ac4e265..49c0ce0 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -3121,4 +3121,46 @@ static struct pci_dev *pci_get_related_function(unsigned int vendor,
> return dev;
> }
>
> +/* stolen from msr.c - the calls in msr.c could be exported */

It would be preferable to export the functions from msr.c! We do have a number
of exported MSR manipulation functions in x86.

> +struct msr_command {
> + int cpu;
> + int err;
> + u32 reg;
> + u32 data[2];
> +};
> +
> +static void smp_wrmsr(void *cmd_block)
> +{
> + struct msr_command *cmd = cmd_block;
> + wrmsr(cmd->reg, cmd->data[0], cmd->data[1]);
> +}
> +
> +static void smp_rdmsr(void *cmd_block)
> +{
> + struct msr_command *cmd = cmd_block;
> + rdmsr(cmd->reg, cmd->data[0], cmd->data[1]);
> +}
> +
> +static void do_wrmsr(int cpu, u32 reg, u32 eax, u32 edx)
> +{
> + struct msr_command cmd;
> +
> + cmd.cpu = raw_smp_processor_id();
> + cmd.reg = reg;
> + cmd.data[0] = eax;
> + cmd.data[1] = edx;
> + on_each_cpu(smp_wrmsr, &cmd, 1);
> +}
> +
> +static void do_rdmsr(int cpu, u32 reg, u32 *eax, u32 *edx)
> +{
> + struct msr_command cmd;
> +
> + cmd.cpu = raw_smp_processor_id();
> + cmd.reg = reg;
> + on_each_cpu(smp_rdmsr, &cmd, 1);
> + *eax = cmd.data[0];
> + *edx = cmd.data[1];
> +}

I'm all confused. We interrupt _all_ CPUs and get each one of them to
write to cmd.data[0] and cmd.data[1]. So what we end up returning is
the result which was provided by the last CPU which got there,
whichever CPU that was.

Am I mising something, or is this all totally screwy?



\
 
 \ /
  Last update: 2009-04-28 20:29    [W:0.150 / U:44.944 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site