Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a370f4c authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull EDAC updates from Borislav Petkov:

 - convert a bunch of drivers to static attribute groups (Takashi Iwai)

 - misc cleanups

* tag 'edac_for_4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp:
  EDAC: Constify of_device_id array
  EDAC, i82443bxgx: Don't export static symbol
  EDAC, amd64_edac: Get rid of per-node driver instances
  EDAC: Properly unwind on failure path in edac_init()
  EDAC: highbank: Use static attribute groups for sysfs entries
  EDAC: octeon: Use static attribute groups for sysfs entries
  EDAC: mpc85xx: Use static attribute groups for sysfs entries
  EDAC: i7core: Use static attribute groups for sysfs entries
  EDAC: i7core: Return proper error codes for kzalloc() errors
  EDAC: amd64: Use static attribute groups
  EDAC: Allow to pass driver-specific attribute groups
  EDAC: Use static attribute groups for managing sysfs entries
  EDAC: Delete unnecessary checks before pci_dev_put()
parents 4b5ca741 1afaa055
Loading
Loading
Loading
Loading
+24 −56
Original line number Original line Diff line number Diff line
@@ -20,8 +20,7 @@ static struct msr __percpu *msrs;
 */
 */
static atomic_t drv_instances = ATOMIC_INIT(0);
static atomic_t drv_instances = ATOMIC_INIT(0);


/* Per-node driver instances */
/* Per-node stuff */
static struct mem_ctl_info **mcis;
static struct ecc_settings **ecc_stngs;
static struct ecc_settings **ecc_stngs;


/*
/*
@@ -903,9 +902,17 @@ static int k8_early_channel_count(struct amd64_pvt *pvt)
/* On F10h and later ErrAddr is MC4_ADDR[47:1] */
/* On F10h and later ErrAddr is MC4_ADDR[47:1] */
static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m)
static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m)
{
{
	u64 addr;
	u16 mce_nid = amd_get_nb_id(m->extcpu);
	struct mem_ctl_info *mci;
	u8 start_bit = 1;
	u8 start_bit = 1;
	u8 end_bit   = 47;
	u8 end_bit   = 47;
	u64 addr;

	mci = edac_mc_find(mce_nid);
	if (!mci)
		return 0;

	pvt = mci->pvt_info;


	if (pvt->fam == 0xf) {
	if (pvt->fam == 0xf) {
		start_bit = 3;
		start_bit = 3;
@@ -918,17 +925,13 @@ static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m)
	 * Erratum 637 workaround
	 * Erratum 637 workaround
	 */
	 */
	if (pvt->fam == 0x15) {
	if (pvt->fam == 0x15) {
		struct amd64_pvt *pvt;
		u64 cc6_base, tmp_addr;
		u64 cc6_base, tmp_addr;
		u32 tmp;
		u32 tmp;
		u16 mce_nid;
		u8 intlv_en;
		u8 intlv_en;


		if ((addr & GENMASK_ULL(47, 24)) >> 24 != 0x00fdf7)
		if ((addr & GENMASK_ULL(47, 24)) >> 24 != 0x00fdf7)
			return addr;
			return addr;


		mce_nid	= amd_get_nb_id(m->extcpu);
		pvt	= mcis[mce_nid]->pvt_info;


		amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_LIM, &tmp);
		amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_LIM, &tmp);
		intlv_en = tmp >> 21 & 0x7;
		intlv_en = tmp >> 21 & 0x7;
@@ -1511,7 +1514,7 @@ static int f1x_lookup_addr_in_dct(u64 in_addr, u8 nid, u8 dct)
	int cs_found = -EINVAL;
	int cs_found = -EINVAL;
	int csrow;
	int csrow;


	mci = mcis[nid];
	mci = edac_mc_find(nid);
	if (!mci)
	if (!mci)
		return cs_found;
		return cs_found;


@@ -2663,34 +2666,6 @@ static bool ecc_enabled(struct pci_dev *F3, u16 nid)
	return true;
	return true;
}
}


static int set_mc_sysfs_attrs(struct mem_ctl_info *mci)
{
	struct amd64_pvt *pvt = mci->pvt_info;
	int rc;

	rc = amd64_create_sysfs_dbg_files(mci);
	if (rc < 0)
		return rc;

	if (pvt->fam >= 0x10) {
		rc = amd64_create_sysfs_inject_files(mci);
		if (rc < 0)
			return rc;
	}

	return 0;
}

static void del_mc_sysfs_attrs(struct mem_ctl_info *mci)
{
	struct amd64_pvt *pvt = mci->pvt_info;

	amd64_remove_sysfs_dbg_files(mci);

	if (pvt->fam >= 0x10)
		amd64_remove_sysfs_inject_files(mci);
}

static void setup_mci_misc_attrs(struct mem_ctl_info *mci,
static void setup_mci_misc_attrs(struct mem_ctl_info *mci,
				 struct amd64_family_type *fam)
				 struct amd64_family_type *fam)
{
{
@@ -2778,6 +2753,16 @@ static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt)
	return fam_type;
	return fam_type;
}
}


static const struct attribute_group *amd64_edac_attr_groups[] = {
#ifdef CONFIG_EDAC_DEBUG
	&amd64_edac_dbg_group,
#endif
#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION
	&amd64_edac_inj_group,
#endif
	NULL
};

static int init_one_instance(struct pci_dev *F2)
static int init_one_instance(struct pci_dev *F2)
{
{
	struct amd64_pvt *pvt = NULL;
	struct amd64_pvt *pvt = NULL;
@@ -2844,14 +2829,10 @@ static int init_one_instance(struct pci_dev *F2)
		mci->edac_cap = EDAC_FLAG_NONE;
		mci->edac_cap = EDAC_FLAG_NONE;


	ret = -ENODEV;
	ret = -ENODEV;
	if (edac_mc_add_mc(mci)) {
	if (edac_mc_add_mc_with_groups(mci, amd64_edac_attr_groups)) {
		edac_dbg(1, "failed edac_mc_add_mc()\n");
		edac_dbg(1, "failed edac_mc_add_mc()\n");
		goto err_add_mc;
		goto err_add_mc;
	}
	}
	if (set_mc_sysfs_attrs(mci)) {
		edac_dbg(1, "failed edac_mc_add_mc()\n");
		goto err_add_sysfs;
	}


	/* register stuff with EDAC MCE */
	/* register stuff with EDAC MCE */
	if (report_gart_errors)
	if (report_gart_errors)
@@ -2859,14 +2840,10 @@ static int init_one_instance(struct pci_dev *F2)


	amd_register_ecc_decoder(decode_bus_error);
	amd_register_ecc_decoder(decode_bus_error);


	mcis[nid] = mci;

	atomic_inc(&drv_instances);
	atomic_inc(&drv_instances);


	return 0;
	return 0;


err_add_sysfs:
	edac_mc_del_mc(mci->pdev);
err_add_mc:
err_add_mc:
	edac_mc_free(mci);
	edac_mc_free(mci);


@@ -2940,7 +2917,6 @@ static void remove_one_instance(struct pci_dev *pdev)
	mci = find_mci_by_dev(&pdev->dev);
	mci = find_mci_by_dev(&pdev->dev);
	WARN_ON(!mci);
	WARN_ON(!mci);


	del_mc_sysfs_attrs(mci);
	/* Remove from EDAC CORE tracking list */
	/* Remove from EDAC CORE tracking list */
	mci = edac_mc_del_mc(&pdev->dev);
	mci = edac_mc_del_mc(&pdev->dev);
	if (!mci)
	if (!mci)
@@ -2961,7 +2937,6 @@ static void remove_one_instance(struct pci_dev *pdev)


	/* Free the EDAC CORE resources */
	/* Free the EDAC CORE resources */
	mci->pvt_info = NULL;
	mci->pvt_info = NULL;
	mcis[nid] = NULL;


	kfree(pvt);
	kfree(pvt);
	edac_mc_free(mci);
	edac_mc_free(mci);
@@ -2999,7 +2974,7 @@ static void setup_pci_device(void)
	if (pci_ctl)
	if (pci_ctl)
		return;
		return;


	mci = mcis[0];
	mci = edac_mc_find(0);
	if (!mci)
	if (!mci)
		return;
		return;


@@ -3023,9 +2998,8 @@ static int __init amd64_edac_init(void)
		goto err_ret;
		goto err_ret;


	err = -ENOMEM;
	err = -ENOMEM;
	mcis	  = kzalloc(amd_nb_num() * sizeof(mcis[0]), GFP_KERNEL);
	ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
	ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
	if (!(mcis && ecc_stngs))
	if (!ecc_stngs)
		goto err_free;
		goto err_free;


	msrs = msrs_alloc();
	msrs = msrs_alloc();
@@ -3056,9 +3030,6 @@ static int __init amd64_edac_init(void)
	msrs = NULL;
	msrs = NULL;


err_free:
err_free:
	kfree(mcis);
	mcis = NULL;

	kfree(ecc_stngs);
	kfree(ecc_stngs);
	ecc_stngs = NULL;
	ecc_stngs = NULL;


@@ -3076,9 +3047,6 @@ static void __exit amd64_edac_exit(void)
	kfree(ecc_stngs);
	kfree(ecc_stngs);
	ecc_stngs = NULL;
	ecc_stngs = NULL;


	kfree(mcis);
	mcis = NULL;

	msrs_free(msrs);
	msrs_free(msrs);
	msrs = NULL;
	msrs = NULL;
}
}
+2 −22
Original line number Original line Diff line number Diff line
@@ -453,31 +453,11 @@ struct ecc_settings {
};
};


#ifdef CONFIG_EDAC_DEBUG
#ifdef CONFIG_EDAC_DEBUG
int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci);
extern const struct attribute_group amd64_edac_dbg_group;
void amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci);

#else
static inline int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci)
{
	return 0;
}
static void inline amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci)
{
}
#endif
#endif


#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION
#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION
int amd64_create_sysfs_inject_files(struct mem_ctl_info *mci);
extern const struct attribute_group amd64_edac_inj_group;
void amd64_remove_sysfs_inject_files(struct mem_ctl_info *mci);

#else
static inline int amd64_create_sysfs_inject_files(struct mem_ctl_info *mci)
{
	return 0;
}
static inline void amd64_remove_sysfs_inject_files(struct mem_ctl_info *mci)
{
}
#endif
#endif


/*
/*
+12 −31
Original line number Original line Diff line number Diff line
@@ -40,34 +40,15 @@ static DEVICE_ATTR(topmem, S_IRUGO, amd64_top_mem_show, NULL);
static DEVICE_ATTR(topmem2, S_IRUGO, amd64_top_mem2_show, NULL);
static DEVICE_ATTR(topmem2, S_IRUGO, amd64_top_mem2_show, NULL);
static DEVICE_ATTR(dram_hole, S_IRUGO, amd64_hole_show, NULL);
static DEVICE_ATTR(dram_hole, S_IRUGO, amd64_hole_show, NULL);


int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci)
static struct attribute *amd64_edac_dbg_attrs[] = {
{
	&dev_attr_dhar.attr,
	int rc;
	&dev_attr_dbam.attr,

	&dev_attr_topmem.attr,
	rc = device_create_file(&mci->dev, &dev_attr_dhar);
	&dev_attr_topmem2.attr,
	if (rc < 0)
	&dev_attr_dram_hole.attr,
		return rc;
	NULL
	rc = device_create_file(&mci->dev, &dev_attr_dbam);
};
	if (rc < 0)

		return rc;
const struct attribute_group amd64_edac_dbg_group = {
	rc = device_create_file(&mci->dev, &dev_attr_topmem);
	.attrs = amd64_edac_dbg_attrs,
	if (rc < 0)
};
		return rc;
	rc = device_create_file(&mci->dev, &dev_attr_topmem2);
	if (rc < 0)
		return rc;
	rc = device_create_file(&mci->dev, &dev_attr_dram_hole);
	if (rc < 0)
		return rc;

	return 0;
}

void amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci)
{
	device_remove_file(&mci->dev, &dev_attr_dhar);
	device_remove_file(&mci->dev, &dev_attr_dbam);
	device_remove_file(&mci->dev, &dev_attr_topmem);
	device_remove_file(&mci->dev, &dev_attr_topmem2);
	device_remove_file(&mci->dev, &dev_attr_dram_hole);
}
+22 −29
Original line number Original line Diff line number Diff line
@@ -207,35 +207,28 @@ static DEVICE_ATTR(inject_write, S_IWUSR,
static DEVICE_ATTR(inject_read,  S_IWUSR,
static DEVICE_ATTR(inject_read,  S_IWUSR,
		   NULL, amd64_inject_read_store);
		   NULL, amd64_inject_read_store);



static struct attribute *amd64_edac_inj_attrs[] = {
int amd64_create_sysfs_inject_files(struct mem_ctl_info *mci)
	&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)
{
{
	int rc;
	struct device *dev = kobj_to_dev(kobj);

	struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev);
	rc = device_create_file(&mci->dev, &dev_attr_inject_section);
	struct amd64_pvt *pvt = mci->pvt_info;
	if (rc < 0)
		return rc;
	rc = device_create_file(&mci->dev, &dev_attr_inject_word);
	if (rc < 0)
		return rc;
	rc = device_create_file(&mci->dev, &dev_attr_inject_ecc_vector);
	if (rc < 0)
		return rc;
	rc = device_create_file(&mci->dev, &dev_attr_inject_write);
	if (rc < 0)
		return rc;
	rc = device_create_file(&mci->dev, &dev_attr_inject_read);
	if (rc < 0)
		return rc;


	if (pvt->fam < 0x10)
		return 0;
		return 0;
	return attr->mode;
}
}


void amd64_remove_sysfs_inject_files(struct mem_ctl_info *mci)
const struct attribute_group amd64_edac_inj_group = {
{
	.attrs = amd64_edac_inj_attrs,
	device_remove_file(&mci->dev, &dev_attr_inject_section);
	.is_visible = amd64_edac_inj_is_visible,
	device_remove_file(&mci->dev, &dev_attr_inject_word);
};
	device_remove_file(&mci->dev, &dev_attr_inject_ecc_vector);
	device_remove_file(&mci->dev, &dev_attr_inject_write);
	device_remove_file(&mci->dev, &dev_attr_inject_read);
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -446,7 +446,9 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
				   unsigned n_layers,
				   unsigned n_layers,
				   struct edac_mc_layer *layers,
				   struct edac_mc_layer *layers,
				   unsigned sz_pvt);
				   unsigned sz_pvt);
extern int edac_mc_add_mc(struct mem_ctl_info *mci);
extern int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci,
				      const struct attribute_group **groups);
#define edac_mc_add_mc(mci)	edac_mc_add_mc_with_groups(mci, NULL)
extern void edac_mc_free(struct mem_ctl_info *mci);
extern void edac_mc_free(struct mem_ctl_info *mci);
extern struct mem_ctl_info *edac_mc_find(int idx);
extern struct mem_ctl_info *edac_mc_find(int idx);
extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);
extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);
Loading