Release 4.12 drivers/edac/amd64_edac_inj.c
  
  
  
#include "amd64_edac.h"
static ssize_t amd64_inject_section_show(struct device *dev,
					 struct device_attribute *mattr,
					 char *buf)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	return sprintf(buf, "0x%x\n", pvt->injection.section);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Borislav Petkov | 36 | 67.92% | 1 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 32.08% | 1 | 50.00% | 
| Total | 53 | 100.00% | 2 | 100.00% | 
/*
 * store error injection section value which refers to one of 4 16-byte sections
 * within a 64-byte cacheline
 *
 * range: 0..3
 */
static ssize_t amd64_inject_section_store(struct device *dev,
					  struct device_attribute *mattr,
					  const char *data, size_t count)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	unsigned long value;
	int ret;
	ret = kstrtoul(data, 10, &value);
	if (ret < 0)
		return ret;
	if (value > 3) {
		amd64_warn("%s: invalid section 0x%lx\n", __func__, value);
		return -EINVAL;
	}
	pvt->injection.section = (u32) value;
	return count;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Doug Thompson | 62 | 58.49% | 1 | 16.67% | 
| Borislav Petkov | 26 | 24.53% | 3 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 16.04% | 1 | 16.67% | 
| Jingoo Han | 1 | 0.94% | 1 | 16.67% | 
| Total | 106 | 100.00% | 6 | 100.00% | 
static ssize_t amd64_inject_word_show(struct device *dev,
					struct device_attribute *mattr,
					char *buf)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	return sprintf(buf, "0x%x\n", pvt->injection.word);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Borislav Petkov | 36 | 67.92% | 1 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 32.08% | 1 | 50.00% | 
| Total | 53 | 100.00% | 2 | 100.00% | 
/*
 * store error injection word value which refers to one of 9 16-bit word of the
 * 16-byte (128-bit + ECC bits) section
 *
 * range: 0..8
 */
static ssize_t amd64_inject_word_store(struct device *dev,
				       struct device_attribute *mattr,
				       const char *data, size_t count)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	unsigned long value;
	int ret;
	ret = kstrtoul(data, 10, &value);
	if (ret < 0)
		return ret;
	if (value > 8) {
		amd64_warn("%s: invalid word 0x%lx\n", __func__, value);
		return -EINVAL;
	}
	pvt->injection.word = (u32) value;
	return count;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Doug Thompson | 66 | 62.26% | 1 | 16.67% | 
| Borislav Petkov | 22 | 20.75% | 3 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 16.04% | 1 | 16.67% | 
| Jingoo Han | 1 | 0.94% | 1 | 16.67% | 
| Total | 106 | 100.00% | 6 | 100.00% | 
static ssize_t amd64_inject_ecc_vector_show(struct device *dev,
					    struct device_attribute *mattr,
					    char *buf)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	return sprintf(buf, "0x%x\n", pvt->injection.bit_map);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Borislav Petkov | 36 | 67.92% | 1 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 32.08% | 1 | 50.00% | 
| Total | 53 | 100.00% | 2 | 100.00% | 
/*
 * store 16 bit error injection vector which enables injecting errors to the
 * corresponding bit within the error injection word above. When used during a
 * DRAM ECC read, it holds the contents of the of the DRAM ECC bits.
 */
static ssize_t amd64_inject_ecc_vector_store(struct device *dev,
				       struct device_attribute *mattr,
				       const char *data, size_t count)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	unsigned long value;
	int ret;
	ret = kstrtoul(data, 16, &value);
	if (ret < 0)
		return ret;
	if (value & 0xFFFF0000) {
		amd64_warn("%s: invalid EccVector: 0x%lx\n", __func__, value);
		return -EINVAL;
	}
	pvt->injection.bit_map = (u32) value;
	return count;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Doug Thompson | 62 | 58.49% | 1 | 16.67% | 
| Borislav Petkov | 26 | 24.53% | 3 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 16.04% | 1 | 16.67% | 
| Jingoo Han | 1 | 0.94% | 1 | 16.67% | 
| Total | 106 | 100.00% | 6 | 100.00% | 
/*
 * Do a DRAM ECC read. Assemble staged values in the pvt area, format into
 * fields needed by the injection registers and read the NB Array Data Port.
 */
static ssize_t amd64_inject_read_store(struct device *dev,
				       struct device_attribute *mattr,
				       const char *data, size_t count)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	unsigned long value;
	u32 section, word_bits;
	int ret;
	ret = kstrtoul(data, 10, &value);
	if (ret < 0)
		return ret;
	/* Form value to choose 16-byte section of cacheline */
	section = F10_NB_ARRAY_DRAM | SET_NB_ARRAY_ADDR(pvt->injection.section);
	amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_ADDR, section);
	word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection);
	/* Issue 'word' and 'bit' along with the READ request */
	amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
	edac_dbg(0, "section=0x%x word_bits=0x%x\n", section, word_bits);
	return count;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Doug Thompson | 104 | 76.47% | 1 | 14.29% | 
| Mauro Carvalho Chehab | 17 | 12.50% | 1 | 14.29% | 
| Borislav Petkov | 11 | 8.09% | 3 | 42.86% | 
| Joe Perches | 3 | 2.21% | 1 | 14.29% | 
| Jingoo Han | 1 | 0.74% | 1 | 14.29% | 
| Total | 136 | 100.00% | 7 | 100.00% | 
/*
 * Do a DRAM ECC write. Assemble staged values in the pvt area and format into
 * fields needed by the injection registers.
 */
static ssize_t amd64_inject_write_store(struct device *dev,
					struct device_attribute *mattr,
					const char *data, size_t count)
{
	struct mem_ctl_info *mci = to_mci(dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	u32 section, word_bits, tmp;
	unsigned long value;
	int ret;
	ret = kstrtoul(data, 10, &value);
	if (ret < 0)
		return ret;
	/* Form value to choose 16-byte section of cacheline */
	section = F10_NB_ARRAY_DRAM | SET_NB_ARRAY_ADDR(pvt->injection.section);
	amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_ADDR, section);
	word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection);
	pr_notice_once("Don't forget to decrease MCE polling interval in\n"
			"/sys/bus/machinecheck/devices/machinecheck<CPUNUM>/check_interval\n"
			"so that you can get the error report faster.\n");
	on_each_cpu(disable_caches, NULL, 1);
	/* Issue 'word' and 'bit' along with the READ request */
	amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
 retry:
	/* wait until injection happens */
	amd64_read_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, &tmp);
	if (tmp & F10_NB_ARR_ECC_WR_REQ) {
		cpu_relax();
		goto retry;
	}
	on_each_cpu(enable_caches, NULL, 1);
	edac_dbg(0, "section=0x%x word_bits=0x%x\n", section, word_bits);
	return count;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Doug Thompson | 100 | 52.08% | 1 | 12.50% | 
| Borislav Petkov | 71 | 36.98% | 4 | 50.00% | 
| Mauro Carvalho Chehab | 17 | 8.85% | 1 | 12.50% | 
| Joe Perches | 3 | 1.56% | 1 | 12.50% | 
| Jingoo Han | 1 | 0.52% | 1 | 12.50% | 
| Total | 192 | 100.00% | 8 | 100.00% | 
/*
 * update NUM_INJ_ATTRS in case you add new members
 */
static DEVICE_ATTR(inject_section, S_IRUGO | S_IWUSR,
		   amd64_inject_section_show, amd64_inject_section_store);
static DEVICE_ATTR(inject_word, S_IRUGO | S_IWUSR,
		   amd64_inject_word_show, amd64_inject_word_store);
static DEVICE_ATTR(inject_ecc_vector, S_IRUGO | S_IWUSR,
		   amd64_inject_ecc_vector_show, amd64_inject_ecc_vector_store);
static DEVICE_ATTR(inject_write, S_IWUSR,
		   NULL, amd64_inject_write_store);
static DEVICE_ATTR(inject_read,  S_IWUSR,
		   NULL, amd64_inject_read_store);
static struct attribute *amd64_edac_inj_attrs[] = {
	&dev_attr_inject_section.attr,
	&dev_attr_inject_word.attr,
	&dev_attr_inject_ecc_vector.attr,
	&dev_attr_inject_write.attr,
	&dev_attr_inject_read.attr,
	NULL
};
static umode_t amd64_edac_inj_is_visible(struct kobject *kobj,
					 struct attribute *attr, int idx)
{
	struct device *dev = kobj_to_dev(kobj);
	struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev);
	struct amd64_pvt *pvt = mci->pvt_info;
	if (pvt->fam < 0x10)
		return 0;
	return attr->mode;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Takashi Iwai | 53 | 76.81% | 1 | 50.00% | 
| Mauro Carvalho Chehab | 16 | 23.19% | 1 | 50.00% | 
| Total | 69 | 100.00% | 2 | 100.00% | 
const struct attribute_group amd64_edac_inj_group = {
	.attrs = amd64_edac_inj_attrs,
	.is_visible = amd64_edac_inj_is_visible,
};
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Doug Thompson | 421 | 42.02% | 1 | 9.09% | 
| Borislav Petkov | 267 | 26.65% | 6 | 54.55% | 
| Mauro Carvalho Chehab | 211 | 21.06% | 1 | 9.09% | 
| Takashi Iwai | 92 | 9.18% | 1 | 9.09% | 
| Joe Perches | 6 | 0.60% | 1 | 9.09% | 
| Jingoo Han | 5 | 0.50% | 1 | 9.09% | 
| Total | 1002 | 100.00% | 11 | 100.00% | 
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.