public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <borislav.petkov@amd.com>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>, x86 <x86@kernel.org>
Cc: Doug Thompson <norsk5@yahoo.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] amd64_edac: load syndrome table through firmware API
Date: Wed, 28 Oct 2009 17:37:06 +0100	[thread overview]
Message-ID: <20091028163706.GB625@aftab> (raw)
In-Reply-To: <20091028163534.GA625@aftab>

>From 8fd92e05c26d5d086990e356297c8e69c2325cc6 Mon Sep 17 00:00:00 2001
From: Borislav Petkov <borislav.petkov@amd.com>
Date: Wed, 28 Oct 2009 13:24:34 +0100
Subject: [PATCH 1/2] amd64_edac: load syndrome table through firmware API

Add a facility for loading binary syndrome tables using the
request_firmware API instead of carrying static tables with the driver
code (esp. the x8 monster).

Not-Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 drivers/edac/amd64_edac.c |   32 ++++++++++++++++++++++++++++++++
 drivers/edac/amd64_edac.h |   14 ++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index c492721..6222a2c 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1,4 +1,5 @@
 #include "amd64_edac.h"
+#include <linux/firmware.h>
 #include <asm/k8.h>
 
 static struct edac_pci_ctl_info *amd64_ctl_pci;
@@ -1982,6 +1983,37 @@ static const unsigned short ecc_chipkill_syndromes[NUMBER_ECC_ROWS][16] = {
 	   0x6f88, 0x19a9, 0xf4ba, 0x829b, 0xb5cc, 0xc3ed, 0x2efe, 0x58df }
 };
 
+static int amd64_load_syndrome_binary(char *fw_name, struct syndrome_table *s,
+				      struct device *dev)
+{
+	const struct firmware *fw;
+	struct syndrome_table tmp_s;
+
+	if (request_firmware(&fw, fw_name, dev)) {
+		amd64_printk(KERN_ERR, "Failure loading %s syndromes\n",
+			     fw_name);
+		return -EINVAL;
+	}
+
+	/* copy only the header */
+	memcpy(&tmp_s, fw->data, sizeof(*s) - sizeof(s->data));
+
+	if (tmp_s.magic != 0x00414d44 ||
+	    tmp_s.type  != s->type ||
+	    tmp_s.rows  != s->rows ||
+	    tmp_s.cols  != s->cols) {
+		amd64_printk(KERN_ERR, "Invalid syndromes binary!\n");
+		return -EINVAL;
+	}
+
+	memcpy(s->data,
+	       fw->data + offsetof(struct syndrome_table, data),
+	       s->rows * s->cols * sizeof(u16));
+
+	release_firmware(fw);
+	return 0;
+}
+
 /*
  * Given the syndrome argument, scan each of the channel tables for a syndrome
  * match. Depending on which table it is found, return the channel number.
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index db6c0a1..94f58d7 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -409,6 +409,20 @@ struct error_injection {
 	u32	bit_map;
 };
 
+enum syndrome_type {
+	SYNDROME_ECC			= (1 << 0),
+	SYNDROME_X4			= (1 << 1),
+	SYNDROME_X8			= (1 << 2),
+};
+
+struct syndrome_table {
+	 u32 magic;			/* should be 0x00414d44 */
+	 enum syndrome_type type;	/* ECC, X4, X8, etc */
+	 u32 rows;			/* dimensions of the syndromes table */
+	 u32 cols;
+	 u16 *data;			/* the actual syndrome table */
+} __attribute__((packed));
+
 struct amd64_pvt {
 	/* pci_device handles which we utilize */
 	struct pci_dev *addr_f1_ctl;
-- 
1.6.4.3

-- 
Regards/Gruss,
Boris.

Operating | Advanced Micro Devices GmbH
  System  | Karl-Hammerschmidt-Str. 34, 85609 Dornach b. München, Germany
 Research | Geschäftsführer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
  Center  | Sitz: Dornach, Gemeinde Aschheim, Landkreis München
  (OSRC)  | Registergericht München, HRB Nr. 43632


  reply	other threads:[~2009-10-28 16:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28 16:35 [RFC] amd64_edac: syndromes loading Borislav Petkov
2009-10-28 16:37 ` Borislav Petkov [this message]
2009-10-28 16:38 ` [PATCH 2/2] amd64_edac: syndromes housekeeping Borislav Petkov
2009-10-28 17:15 ` [RFC] amd64_edac: syndromes loading Doug Thompson
2009-10-28 17:28   ` Borislav Petkov
2009-11-01 21:13     ` Pavel Machek
2009-11-01 22:33       ` H. Peter Anvin
2009-11-05 13:27         ` Borislav Petkov
2009-11-05 21:15           ` Doug Thompson
2009-11-05 22:17           ` Pavel Machek
2009-11-06 13:20             ` Borislav Petkov
2009-11-12 18:40               ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091028163706.GB625@aftab \
    --to=borislav.petkov@amd.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=norsk5@yahoo.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox