aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/i5100_edac.c
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ericsson.com>2012-08-08 11:30:58 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-21 09:06:34 -0500
commit9cbc6d38f25ae8fb3efd0b1c14f4f18c1d9f0369 (patch)
tree64e47865660991de08be713eea8f1d1dc57da9c0 /drivers/edac/i5100_edac.c
parent53ceafd6a27f3e15dc83e8865f9f20029f6dfc66 (diff)
i5100_edac: connect fault injection to debugfs node
Create a debugfs direcotry i5100_edac/mcX for each memory controller and add nodes to control how fault injection is preformed. After configuring an injection using inject_channel, inject_deviceptr1, inject_deviceptr2, inject_eccmask1, inject_eccmask2 and inject_hlinesel trigger the injection by writing anything to inject_enable. Example of a CE injection: echo 0 > /sys/kernel/debug/i5100_edac/mc0/inject_channel echo 1 > /sys/kernel/debug/i5100_edac/mc0/inject_hlinesel echo 61440 > /sys/kernel/debug/i5100_edac/mc0/inject_eccmask1 echo 1 > /sys/kernel/debug/i5100_edac/mc0/inject_enable Example of UE injection: echo 0 > /sys/kernel/debug/i5100_edac/mc0/inject_channel echo 2 > /sys/kernel/debug/i5100_edac/mc0/inject_hlinesel echo 65535 > /sys/kernel/debug/i5100_edac/mc0/inject_eccmask1 echo 65535 > /sys/kernel/debug/i5100_edac/mc0/inject_eccmask2 echo 17 > /sys/kernel/debug/i5100_edac/mc0/inject_deviceptr1 echo 0 > /sys/kernel/debug/i5100_edac/mc0/inject_deviceptr2 echo 1 > /sys/kernel/debug/i5100_edac/mc0/inject_enable Sometimes it is needed to enable the injection more then once (echo to the inject_enable node) for the injection to happen, I am not sure why. Signed-off-by: Niklas Söderlund <niklas.soderlund@ericsson.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac/i5100_edac.c')
-rw-r--r--drivers/edac/i5100_edac.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index 0a0345bd7432..ad4cc898dc60 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -27,6 +27,7 @@
27#include <linux/edac.h> 27#include <linux/edac.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/mmzone.h> 29#include <linux/mmzone.h>
30#include <linux/debugfs.h>
30 31
31#include "edac_core.h" 32#include "edac_core.h"
32 33
@@ -360,8 +361,12 @@ struct i5100_priv {
360 u8 inject_deviceptr2; 361 u8 inject_deviceptr2;
361 u16 inject_eccmask1; 362 u16 inject_eccmask1;
362 u16 inject_eccmask2; 363 u16 inject_eccmask2;
364
365 struct dentry *debugfs;
363}; 366};
364 367
368static struct dentry *i5100_debugfs;
369
365/* map a rank/chan to a slot number on the mainboard */ 370/* map a rank/chan to a slot number on the mainboard */
366static int i5100_rank_to_slot(const struct mem_ctl_info *mci, 371static int i5100_rank_to_slot(const struct mem_ctl_info *mci,
367 int chan, int rank) 372 int chan, int rank)
@@ -944,6 +949,61 @@ static void i5100_do_inject(struct mem_ctl_info *mci)
944 pci_write_config_byte(priv->einj, I5100_DINJ0, 0xab); 949 pci_write_config_byte(priv->einj, I5100_DINJ0, 0xab);
945} 950}
946 951
952#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
953static ssize_t inject_enable_write(struct file *file, const char __user *data,
954 size_t count, loff_t *ppos)
955{
956 struct device *dev = file->private_data;
957 struct mem_ctl_info *mci = to_mci(dev);
958
959 i5100_do_inject(mci);
960
961 return count;
962}
963
964static int inject_enable_open(struct inode *inode, struct file *file)
965{
966 file->private_data = inode->i_private;
967 return 0;
968}
969
970static const struct file_operations i5100_inject_enable_fops = {
971 .open = inject_enable_open,
972 .write = inject_enable_write,
973 .llseek = generic_file_llseek,
974};
975
976static int i5100_setup_debugfs(struct mem_ctl_info *mci)
977{
978 struct i5100_priv *priv = mci->pvt_info;
979
980 if (!i5100_debugfs)
981 return -ENODEV;
982
983 priv->debugfs = debugfs_create_dir(mci->bus.name, i5100_debugfs);
984
985 if (!priv->debugfs)
986 return -ENOMEM;
987
988 debugfs_create_x8("inject_channel", S_IRUGO | S_IWUSR, priv->debugfs,
989 &priv->inject_channel);
990 debugfs_create_x8("inject_hlinesel", S_IRUGO | S_IWUSR, priv->debugfs,
991 &priv->inject_hlinesel);
992 debugfs_create_x8("inject_deviceptr1", S_IRUGO | S_IWUSR, priv->debugfs,
993 &priv->inject_deviceptr1);
994 debugfs_create_x8("inject_deviceptr2", S_IRUGO | S_IWUSR, priv->debugfs,
995 &priv->inject_deviceptr2);
996 debugfs_create_x16("inject_eccmask1", S_IRUGO | S_IWUSR, priv->debugfs,
997 &priv->inject_eccmask1);
998 debugfs_create_x16("inject_eccmask2", S_IRUGO | S_IWUSR, priv->debugfs,
999 &priv->inject_eccmask2);
1000 debugfs_create_file("inject_enable", S_IWUSR, priv->debugfs,
1001 &mci->dev, &i5100_inject_enable_fops);
1002
1003 return 0;
1004
1005}
1006
947static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 1007static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
948{ 1008{
949 int rc; 1009 int rc;
@@ -1097,6 +1157,8 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1097 goto bail_scrub; 1157 goto bail_scrub;
1098 } 1158 }
1099 1159
1160 i5100_setup_debugfs(mci);
1161
1100 return ret; 1162 return ret;
1101 1163
1102bail_scrub: 1164bail_scrub:
@@ -1141,6 +1203,9 @@ static void i5100_remove_one(struct pci_dev *pdev)
1141 1203
1142 priv = mci->pvt_info; 1204 priv = mci->pvt_info;
1143 1205
1206 if (priv->debugfs)
1207 debugfs_remove_recursive(priv->debugfs);
1208
1144 priv->scrub_enable = 0; 1209 priv->scrub_enable = 0;
1145 cancel_delayed_work_sync(&(priv->i5100_scrubbing)); 1210 cancel_delayed_work_sync(&(priv->i5100_scrubbing));
1146 1211
@@ -1173,13 +1238,17 @@ static int __init i5100_init(void)
1173{ 1238{
1174 int pci_rc; 1239 int pci_rc;
1175 1240
1176 pci_rc = pci_register_driver(&i5100_driver); 1241 i5100_debugfs = debugfs_create_dir("i5100_edac", NULL);
1177 1242
1243 pci_rc = pci_register_driver(&i5100_driver);
1178 return (pci_rc < 0) ? pci_rc : 0; 1244 return (pci_rc < 0) ? pci_rc : 0;
1179} 1245}
1180 1246
1181static void __exit i5100_exit(void) 1247static void __exit i5100_exit(void)
1182{ 1248{
1249 if (i5100_debugfs)
1250 debugfs_remove(i5100_debugfs);
1251
1183 pci_unregister_driver(&i5100_driver); 1252 pci_unregister_driver(&i5100_driver);
1184} 1253}
1185 1254