From: Borislav Petkov <borislav.petkov@amd.com>
To: <akpm@linux-foundation.org>, <greg@kroah.com>, <mingo@elte.hu>
Cc: <norsk5@yahoo.com>, <tglx@linutronix.de>, <hpa@zytor.com>,
<mchehab@redhat.com>, <aris@redhat.com>,
edt@aei.ca, <linux-kernel@vger.kernel.org>,
Doug Thompson <dougthompson@xmission.com>,
Borislav Petkov <borislav.petkov@amd.com>
Subject: [PATCH 04/21] amd64_edac: add DRAM error injection logic using sysfs
Date: Thu, 7 May 2009 15:49:26 +0200 [thread overview]
Message-ID: <1241704183-29223-5-git-send-email-borislav.petkov@amd.com> (raw)
In-Reply-To: <1241704183-29223-1-git-send-email-borislav.petkov@amd.com>
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_inj.c | 200 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 200 insertions(+), 0 deletions(-)
create mode 100644 drivers/edac/amd64_edac_inj.c
diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
new file mode 100644
index 0000000..7f978cb
--- /dev/null
+++ b/drivers/edac/amd64_edac_inj.c
@@ -0,0 +1,200 @@
+#include "amd64_edac.h"
+
+/*
+ * amd64_inject_section_store
+ *
+ * accept and store error injection section value
+ * range: 0..3
+ * value refers to one of 4 16-byte sections
+ * within a 64-byte cacheline
+ */
+static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int rc;
+
+ rc = strict_strtoul(data, 10, &value);
+ if (rc != -EINVAL) {
+
+ /* save the 16-byte cache section */
+ pvt->injection.section = (u32) value;
+
+ return count;
+ }
+ return 0;
+}
+
+/*
+ * amd64_inject_word_store
+ *
+ * accept and store error injection word value
+ * range: 0..8
+ * value refers to one of 9 16-bit word of the 16-byte section
+ * 128-bit + ECC bits
+ */
+static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int rc;
+
+ rc = strict_strtoul(data, 10, &value);
+ if (rc != -EINVAL) {
+
+ /* save the 16-bit word */
+ value = (value <= 8) ? value : 0;
+ pvt->injection.word = (u32) value;
+
+ return count;
+ }
+ return 0;
+}
+
+/*
+ * amd64_inject_bit_store
+ *
+ * accept and store error injection hexidecimal bit value
+ * 16-bits of a bit-vector marking which bits to error-out on
+ */
+static ssize_t amd64_inject_bit_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ int rc;
+
+ rc = strict_strtoul(data, 16, &value);
+ if (rc != -EINVAL) {
+
+ /* save the bit within the 16-bit word */
+ pvt->injection.bit_map = (u32) value & 0xFFFF;
+
+ return count;
+ }
+ return 0;
+}
+
+/*
+ * amd64_inject_read_store
+ *
+ * READ action. When called, assemble staged values in the pvt
+ * area and format into fields needed by the Injection hardware
+ * Output to hardware and issue a READ operation
+ */
+static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ u32 section, word_bits;
+ int rc;
+
+ rc = strict_strtoul(data, 10, &value);
+ if (rc != -EINVAL) {
+
+ /* Form value to choose 16-byte section of cacheline */
+ section = F10_NB_ARRAY_DRAM_ECC |
+ SET_NB_ARRAY_ADDRESS(pvt->injection.section);
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_ADDR, section);
+
+ word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
+ pvt->injection.bit_map);
+
+ /* Issue 'word' and 'bit' along with the READ request now */
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_DATA, word_bits);
+
+ debugf0("%s() section=0x%x word_bits=0x%x\n", __func__,
+ section, word_bits);
+
+ return count;
+ }
+ return 0;
+}
+
+/*
+ * amd64_inject_write_store
+ *
+ * WRITE action. When called, assemble staged values in the pvt
+ * area and format into fields needed by the Injection hardware
+ * Output to hardware and issue a WRITE operation
+ */
+static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ struct amd64_pvt *pvt = mci->pvt_info;
+ unsigned long value;
+ u32 section, word_bits;
+ int rc;
+
+ rc = strict_strtoul(data, 10, &value);
+ if (rc != -EINVAL) {
+
+ /* Form value to choose 16-byte section of cacheline */
+ section = F10_NB_ARRAY_DRAM_ECC |
+ SET_NB_ARRAY_ADDRESS(pvt->injection.section);
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_ADDR, section);
+
+ word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
+ pvt->injection.bit_map);
+
+ /* Issue 'word' and 'bit' along with the READ request now */
+ pci_write_config_dword(pvt->misc_f3_ctl,
+ F10_NB_ARRAY_DATA, word_bits);
+
+ debugf0("%s() section=0x%x word_bits=0x%x\n", __func__,
+ section, word_bits);
+
+ return count;
+ }
+ return 0;
+}
+
+struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
+
+ {
+ .attr = {
+ .name = "z_inject_section",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_section_store,
+ },
+ {
+ .attr = {
+ .name = "z_inject_word",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_word_store,
+ },
+ {
+ .attr = {
+ .name = "z_inject_bit_map",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_bit_store,
+ },
+ {
+ .attr = {
+ .name = "z_inject_write",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_write_store,
+ },
+ {
+ .attr = {
+ .name = "z_inject_read",
+ .mode = (S_IRUGO | S_IWUSR)
+ },
+ .show = NULL,
+ .store = amd64_inject_read_store,
+ },
+};
--
1.6.2.4
next prev parent reply other threads:[~2009-05-07 13:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 13:49 [RFC PATCH 00/21 v3] amd64_edac: EDAC module for AMD64 Borislav Petkov
2009-05-07 13:49 ` [PATCH 01/21] x86: add methods for writing of an MSR on several CPUs Borislav Petkov
2009-05-07 13:49 ` [PATCH 02/21] amd64_edac: add driver header Borislav Petkov
2009-05-07 13:49 ` [PATCH 03/21] amd64_edac: add debugging/testing code Borislav Petkov
2009-05-08 10:01 ` Mauro Carvalho Chehab
2009-05-07 13:49 ` Borislav Petkov [this message]
2009-05-08 10:01 ` [PATCH 04/21] amd64_edac: add DRAM error injection logic using sysfs Mauro Carvalho Chehab
2009-05-07 13:49 ` [PATCH 05/21] amd64_edac: add MCA error types Borislav Petkov
2009-05-08 10:01 ` Mauro Carvalho Chehab
2009-05-07 13:49 ` [PATCH 06/21] amd64_edac: add memory scrubber interface Borislav Petkov
2009-05-07 13:49 ` [PATCH 07/21] amd64_edac: add sys addr to memory controller mapping helpers Borislav Petkov
2009-05-07 13:49 ` [PATCH 08/21] amd64_edac: add functionality to compute the DRAM hole Borislav Petkov
2009-05-07 13:49 ` [PATCH 09/21] amd64_edac: add DRAM address type conversion facilities Borislav Petkov
2009-05-07 13:49 ` [PATCH 10/21] amd64_edac: add helper to dump relevant registers Borislav Petkov
2009-05-07 13:49 ` [PATCH 11/21] amd64_edac: assign DRAM chip select base and mask in a family-specific way Borislav Petkov
2009-05-07 13:49 ` [PATCH 12/21] amd64_edac: add k8-specific methods Borislav Petkov
2009-05-07 13:49 ` [PATCH 13/21] amd64_edac: add F10h-and-later methods-p1 Borislav Petkov
2009-05-07 13:49 ` [PATCH 14/21] amd64_edac: add F10h-and-later methods-p2 Borislav Petkov
2009-05-07 13:49 ` [PATCH 15/21] amd64_edac: add F10h-and-later methods-p3 Borislav Petkov
2009-05-08 9:39 ` Mauro Carvalho Chehab
2009-05-07 13:49 ` [PATCH 16/21] amd64_edac: add per-family descriptors Borislav Petkov
2009-05-07 13:49 ` [PATCH 17/21] amd64_edac: add ECC chipkill syndrome mapping table Borislav Petkov
2009-05-08 9:40 ` Mauro Carvalho Chehab
2009-05-07 13:49 ` [PATCH 18/21] amd64_edac: add error decoding logic Borislav Petkov
2009-05-07 13:49 ` [PATCH 19/21] amd64_edac: add EDAC core-related initializers Borislav Petkov
2009-05-07 13:49 ` [PATCH 20/21] amd64_edac: add ECC reporting initializers Borislav Petkov
2009-05-07 22:00 ` Ingo Molnar
2009-05-07 13:49 ` [PATCH 21/21] amd64_edac: add module registration routines Borislav Petkov
2009-05-07 21:58 ` Ingo Molnar
2009-05-14 17:52 ` Borislav Petkov
2009-05-14 18:43 ` Doug Thompson
2009-05-08 10:00 ` Mauro Carvalho Chehab
2009-05-07 14:27 ` [RFC PATCH 00/21 v3] amd64_edac: EDAC module for AMD64 Ingo Molnar
2009-05-07 14:38 ` Borislav Petkov
2009-05-07 20:52 ` Andrew Morton
2009-05-07 21:18 ` Ingo Molnar
2009-05-08 10:07 ` Borislav Petkov
2009-05-08 10:32 ` Mauro Carvalho Chehab
2009-05-08 10:46 ` Ingo Molnar
2009-05-07 20:51 ` Andrew Morton
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=1241704183-29223-5-git-send-email-borislav.petkov@amd.com \
--to=borislav.petkov@amd.com \
--cc=akpm@linux-foundation.org \
--cc=aris@redhat.com \
--cc=dougthompson@xmission.com \
--cc=edt@aei.ca \
--cc=greg@kroah.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=mingo@elte.hu \
--cc=norsk5@yahoo.com \
--cc=tglx@linutronix.de \
/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
Powered by JetHome