[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1323878670-26079-2-git-send-email-niklas.soderlund@ericsson.com>
Date: Wed, 14 Dec 2011 17:04:27 +0100
From: Niklas Söderlund <niklas.soderlund@...csson.com>
To: <lucas.demarchi@...fusion.mobi>, <borislav.petkov@....com>,
<tony.luck@...el.com>
CC: <linux-kernel@...r.kernel.org>, <linux-edac@...r.kernel.org>,
Niklas Söderlund <niklas.soderlund@...csson.com>
Subject: [PATCH 1/4] edac: i5100 add sysfs nodes for fault injection
Add sysfs nodes to /sys/devices/system/edac/mc/mcX to control fault
injection.
Signed-off-by: Niklas Söderlund <niklas.soderlund@...csson.com>
---
drivers/edac/i5100_edac.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 94 insertions(+), 0 deletions(-)
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index bcbdeec..1319e59 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -338,6 +338,15 @@ struct i5100_priv {
struct delayed_work i5100_scrubbing;
int scrub_enable;
+
+ /* Error injection */
+ u32 inject_enable;
+ u32 inject_channel;
+ u32 inject_hlinesel;
+ u32 inject_deviceptr1;
+ u32 inject_deviceptr2;
+ u32 inject_eccmask1;
+ u32 inject_eccmask2;
};
/* map a rank/chan to a slot number on the mainboard */
@@ -879,6 +888,80 @@ static void __devinit i5100_init_csrows(struct mem_ctl_info *mci)
}
}
+#define DECLARE_INJECT_PARAM(param, limit_low, limit_high) \
+static ssize_t i5100_inject_store_##param( \
+ struct mem_ctl_info *mci, \
+ const char *data, \
+ size_t count) \
+{ \
+ struct i5100_priv *priv = mci->pvt_info; \
+ unsigned long value; \
+ int rc; \
+ \
+ rc = kstrtoul(data, 10, &value); \
+ if (rc < 0 || value < limit_low || value > limit_high) \
+ return -EIO; \
+ \
+ priv->param = value; \
+ \
+ return count; \
+} \
+ \
+static ssize_t i5100_inject_show_##param( \
+ struct mem_ctl_info *mci, \
+ char *data) \
+{ \
+ struct i5100_priv *priv = mci->pvt_info; \
+ return sprintf(data, "%d\n", priv->param); \
+}
+
+#define ATTR_INJECT(param) \
+ { \
+ .attr = { \
+ .name = #param, \
+ .mode = (S_IRUGO | S_IWUSR) \
+ }, \
+ .show = i5100_inject_show_##param, \
+ .store = i5100_inject_store_##param, \
+ }
+
+DECLARE_INJECT_PARAM(inject_channel, 0, 1);
+DECLARE_INJECT_PARAM(inject_hlinesel, 1, 3);
+DECLARE_INJECT_PARAM(inject_deviceptr1, 0, 17);
+DECLARE_INJECT_PARAM(inject_deviceptr2, 0, 17);
+DECLARE_INJECT_PARAM(inject_eccmask1, 0, 0xFFFF);
+DECLARE_INJECT_PARAM(inject_eccmask2, 0, 0xFFFF);
+
+static ssize_t i5100_inject_store_inject_enable(struct mem_ctl_info *mci,
+ const char *data, size_t count)
+{
+ unsigned long value;
+
+ if (kstrtoul(data, 10, &value) < 0)
+ return -EIO;
+
+ return count;
+}
+
+static ssize_t i5100_inject_show_inject_enable(struct mem_ctl_info *mci,
+ char *data)
+{
+ struct i5100_priv *priv = mci->pvt_info;
+ return sprintf(data, "%d\n", priv->inject_enable);
+}
+
+static const struct mcidev_sysfs_attribute i5100_sysfs_attrs[] = {
+ ATTR_INJECT(inject_enable),
+ ATTR_INJECT(inject_channel),
+ ATTR_INJECT(inject_hlinesel),
+ ATTR_INJECT(inject_deviceptr1),
+ ATTR_INJECT(inject_deviceptr2),
+ ATTR_INJECT(inject_eccmask1),
+ ATTR_INJECT(inject_eccmask2),
+
+ { } /* End of list */
+};
+
static int __devinit i5100_init_one(struct pci_dev *pdev,
const struct pci_device_id *id)
{
@@ -984,6 +1067,17 @@ static int __devinit i5100_init_one(struct pci_dev *pdev,
mci->set_sdram_scrub_rate = i5100_set_scrub_rate;
mci->get_sdram_scrub_rate = i5100_get_scrub_rate;
+ priv->inject_enable = 0;
+ priv->inject_channel = 0;
+ priv->inject_hlinesel = 1;
+ priv->inject_deviceptr1 = 0;
+ priv->inject_deviceptr2 = 0;
+ priv->inject_eccmask1 = 0;
+ priv->inject_eccmask2 = 0;
+
+ /* Configure sysfs */
+ mci->mc_driver_sysfs_attributes = i5100_sysfs_attrs;
+
i5100_init_csrows(mci);
/* this strange construction seems to be in every driver, dunno why */
--
1.7.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists