Commit 04012e30 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'please-pull-bp-edac' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras

Pull EDAC fix from Tony Luck:
 "Fix EDAC lockdep splat"

* tag 'please-pull-bp-edac' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras:
  EDAC: Fix lockdep splat
parents a474902c 88d84ac9
...@@ -48,6 +48,8 @@ static LIST_HEAD(mc_devices); ...@@ -48,6 +48,8 @@ static LIST_HEAD(mc_devices);
*/ */
static void const *edac_mc_owner; static void const *edac_mc_owner;
static struct bus_type mc_bus[EDAC_MAX_MCS];
unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf, unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
unsigned len) unsigned len)
{ {
...@@ -723,6 +725,11 @@ int edac_mc_add_mc(struct mem_ctl_info *mci) ...@@ -723,6 +725,11 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
int ret = -EINVAL; int ret = -EINVAL;
edac_dbg(0, "\n"); edac_dbg(0, "\n");
if (mci->mc_idx >= EDAC_MAX_MCS) {
pr_warn_once("Too many memory controllers: %d\n", mci->mc_idx);
return -ENODEV;
}
#ifdef CONFIG_EDAC_DEBUG #ifdef CONFIG_EDAC_DEBUG
if (edac_debug_level >= 3) if (edac_debug_level >= 3)
edac_mc_dump_mci(mci); edac_mc_dump_mci(mci);
...@@ -762,6 +769,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci) ...@@ -762,6 +769,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
/* set load time so that error rate can be tracked */ /* set load time so that error rate can be tracked */
mci->start_time = jiffies; mci->start_time = jiffies;
mci->bus = &mc_bus[mci->mc_idx];
if (edac_create_sysfs_mci_device(mci)) { if (edac_create_sysfs_mci_device(mci)) {
edac_mc_printk(mci, KERN_WARNING, edac_mc_printk(mci, KERN_WARNING,
"failed to create sysfs device\n"); "failed to create sysfs device\n");
......
...@@ -370,7 +370,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, ...@@ -370,7 +370,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
return -ENODEV; return -ENODEV;
csrow->dev.type = &csrow_attr_type; csrow->dev.type = &csrow_attr_type;
csrow->dev.bus = &mci->bus; csrow->dev.bus = mci->bus;
device_initialize(&csrow->dev); device_initialize(&csrow->dev);
csrow->dev.parent = &mci->dev; csrow->dev.parent = &mci->dev;
csrow->mci = mci; csrow->mci = mci;
...@@ -605,7 +605,7 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci, ...@@ -605,7 +605,7 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci,
dimm->mci = mci; dimm->mci = mci;
dimm->dev.type = &dimm_attr_type; dimm->dev.type = &dimm_attr_type;
dimm->dev.bus = &mci->bus; dimm->dev.bus = mci->bus;
device_initialize(&dimm->dev); device_initialize(&dimm->dev);
dimm->dev.parent = &mci->dev; dimm->dev.parent = &mci->dev;
...@@ -975,11 +975,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) ...@@ -975,11 +975,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
* The memory controller needs its own bus, in order to avoid * The memory controller needs its own bus, in order to avoid
* namespace conflicts at /sys/bus/edac. * namespace conflicts at /sys/bus/edac.
*/ */
mci->bus.name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx); mci->bus->name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
if (!mci->bus.name) if (!mci->bus->name)
return -ENOMEM; return -ENOMEM;
edac_dbg(0, "creating bus %s\n", mci->bus.name);
err = bus_register(&mci->bus); edac_dbg(0, "creating bus %s\n", mci->bus->name);
err = bus_register(mci->bus);
if (err < 0) if (err < 0)
return err; return err;
...@@ -988,7 +990,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) ...@@ -988,7 +990,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
device_initialize(&mci->dev); device_initialize(&mci->dev);
mci->dev.parent = mci_pdev; mci->dev.parent = mci_pdev;
mci->dev.bus = &mci->bus; mci->dev.bus = mci->bus;
dev_set_name(&mci->dev, "mc%d", mci->mc_idx); dev_set_name(&mci->dev, "mc%d", mci->mc_idx);
dev_set_drvdata(&mci->dev, mci); dev_set_drvdata(&mci->dev, mci);
pm_runtime_forbid(&mci->dev); pm_runtime_forbid(&mci->dev);
...@@ -997,8 +999,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) ...@@ -997,8 +999,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
err = device_add(&mci->dev); err = device_add(&mci->dev);
if (err < 0) { if (err < 0) {
edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev)); edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
bus_unregister(&mci->bus); bus_unregister(mci->bus);
kfree(mci->bus.name); kfree(mci->bus->name);
return err; return err;
} }
...@@ -1064,8 +1066,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) ...@@ -1064,8 +1066,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
} }
fail2: fail2:
device_unregister(&mci->dev); device_unregister(&mci->dev);
bus_unregister(&mci->bus); bus_unregister(mci->bus);
kfree(mci->bus.name); kfree(mci->bus->name);
return err; return err;
} }
...@@ -1098,8 +1100,8 @@ void edac_unregister_sysfs(struct mem_ctl_info *mci) ...@@ -1098,8 +1100,8 @@ void edac_unregister_sysfs(struct mem_ctl_info *mci)
{ {
edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev)); edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev));
device_unregister(&mci->dev); device_unregister(&mci->dev);
bus_unregister(&mci->bus); bus_unregister(mci->bus);
kfree(mci->bus.name); kfree(mci->bus->name);
} }
static void mc_attr_release(struct device *dev) static void mc_attr_release(struct device *dev)
......
...@@ -974,7 +974,7 @@ static int i5100_setup_debugfs(struct mem_ctl_info *mci) ...@@ -974,7 +974,7 @@ static int i5100_setup_debugfs(struct mem_ctl_info *mci)
if (!i5100_debugfs) if (!i5100_debugfs)
return -ENODEV; return -ENODEV;
priv->debugfs = debugfs_create_dir(mci->bus.name, i5100_debugfs); priv->debugfs = debugfs_create_dir(mci->bus->name, i5100_debugfs);
if (!priv->debugfs) if (!priv->debugfs)
return -ENOMEM; return -ENOMEM;
......
...@@ -622,7 +622,7 @@ struct edac_raw_error_desc { ...@@ -622,7 +622,7 @@ struct edac_raw_error_desc {
*/ */
struct mem_ctl_info { struct mem_ctl_info {
struct device dev; struct device dev;
struct bus_type bus; struct bus_type *bus;
struct list_head link; /* for global list of mem_ctl_info structs */ struct list_head link; /* for global list of mem_ctl_info structs */
...@@ -742,4 +742,9 @@ struct mem_ctl_info { ...@@ -742,4 +742,9 @@ struct mem_ctl_info {
#endif #endif
}; };
/*
* Maximum number of memory controllers in the coherent fabric.
*/
#define EDAC_MAX_MCS 16
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment