Commit 1c3631ff authored by Douglas Thompson's avatar Douglas Thompson Committed by Linus Torvalds

drivers/edac: fix edac_device sysfs completion code

With feedback, this patch corrects operation of the kobject release operation
on kobjects, attributes and controls for the edac_device.

Cc: Alan Cox alan@lxorguk.ukuu.org.uk
Signed-off-by: default avatarDoug Thompson <dougthompson@xmission.com>
Acked-by: default avatarGreg KH <greg@kroah.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8096cfaf
...@@ -337,6 +337,9 @@ struct mcidev_sysfs_attribute { ...@@ -337,6 +337,9 @@ struct mcidev_sysfs_attribute {
*/ */
struct mem_ctl_info { struct mem_ctl_info {
struct list_head link; /* for global list of mem_ctl_info structs */ struct list_head link; /* for global list of mem_ctl_info structs */
struct module *owner; /* Module owner of this control struct */
unsigned long mtype_cap; /* memory types supported by mc */ unsigned long mtype_cap; /* memory types supported by mc */
unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */ unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */
unsigned long edac_cap; /* configuration capabilities - this is unsigned long edac_cap; /* configuration capabilities - this is
...@@ -510,7 +513,6 @@ struct edac_device_block { ...@@ -510,7 +513,6 @@ struct edac_device_block {
/* edac sysfs device control */ /* edac sysfs device control */
struct kobject kobj; struct kobject kobj;
struct completion kobj_complete;
}; };
/* device instance control structure */ /* device instance control structure */
...@@ -525,7 +527,6 @@ struct edac_device_instance { ...@@ -525,7 +527,6 @@ struct edac_device_instance {
/* edac sysfs device control */ /* edac sysfs device control */
struct kobject kobj; struct kobject kobj;
struct completion kobj_complete;
}; };
...@@ -537,6 +538,8 @@ struct edac_device_ctl_info { ...@@ -537,6 +538,8 @@ struct edac_device_ctl_info {
/* for global list of edac_device_ctl_info structs */ /* for global list of edac_device_ctl_info structs */
struct list_head link; struct list_head link;
struct module *owner; /* Module owner of this control struct */
int dev_idx; int dev_idx;
/* Per instance controls for this edac_device */ /* Per instance controls for this edac_device */
...@@ -587,7 +590,7 @@ struct edac_device_ctl_info { ...@@ -587,7 +590,7 @@ struct edac_device_ctl_info {
* NMI handlers may be traversing list * NMI handlers may be traversing list
*/ */
struct rcu_head rcu; struct rcu_head rcu;
struct completion complete; struct completion removal_complete;
/* sysfs top name under 'edac' directory /* sysfs top name under 'edac' directory
* and instance name: * and instance name:
...@@ -611,7 +614,6 @@ struct edac_device_ctl_info { ...@@ -611,7 +614,6 @@ struct edac_device_ctl_info {
* device this structure controls * device this structure controls
*/ */
struct kobject kobj; struct kobject kobj;
struct completion kobj_complete;
}; };
/* To get from the instance's wq to the beginning of the ctl structure */ /* To get from the instance's wq to the beginning of the ctl structure */
......
...@@ -48,6 +48,7 @@ static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev) ...@@ -48,6 +48,7 @@ static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
} }
#endif /* CONFIG_EDAC_DEBUG */ #endif /* CONFIG_EDAC_DEBUG */
/* /*
* edac_device_alloc_ctl_info() * edac_device_alloc_ctl_info()
* Allocate a new edac device control info structure * Allocate a new edac device control info structure
...@@ -78,6 +79,7 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info( ...@@ -78,6 +79,7 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
unsigned count; unsigned count;
unsigned instance, block, attr; unsigned instance, block, attr;
void *pvt; void *pvt;
int err;
debugf1("%s() instances=%d blocks=%d\n", debugf1("%s() instances=%d blocks=%d\n",
__func__, nr_instances, nr_blocks); __func__, nr_instances, nr_blocks);
...@@ -208,6 +210,22 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info( ...@@ -208,6 +210,22 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
/* Mark this instance as merely ALLOCATED */ /* Mark this instance as merely ALLOCATED */
dev_ctl->op_state = OP_ALLOC; dev_ctl->op_state = OP_ALLOC;
/*
* Initialize the 'root' kobj for the edac_device controller
*/
err = edac_device_register_sysfs_main_kobj(dev_ctl);
if (err) {
kfree(dev_ctl);
return NULL;
}
/* at this point, the root kobj is valid, and in order to
* 'free' the object, then the function:
* edac_device_unregister_sysfs_main_kobj() must be called
* which will perform kobj unregistration and the actual free
* will occur during the kobject callback operation
*/
return dev_ctl; return dev_ctl;
} }
EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info); EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info);
...@@ -219,7 +237,7 @@ EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info); ...@@ -219,7 +237,7 @@ EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info);
*/ */
void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info) void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info)
{ {
kfree(ctl_info); edac_device_unregister_sysfs_main_kobj(ctl_info);
} }
EXPORT_SYMBOL_GPL(edac_device_free_ctl_info); EXPORT_SYMBOL_GPL(edac_device_free_ctl_info);
...@@ -315,22 +333,23 @@ static void complete_edac_device_list_del(struct rcu_head *head) ...@@ -315,22 +333,23 @@ static void complete_edac_device_list_del(struct rcu_head *head)
edac_dev = container_of(head, struct edac_device_ctl_info, rcu); edac_dev = container_of(head, struct edac_device_ctl_info, rcu);
INIT_LIST_HEAD(&edac_dev->link); INIT_LIST_HEAD(&edac_dev->link);
complete(&edac_dev->complete); complete(&edac_dev->removal_complete);
} }
/* /*
* del_edac_device_from_global_list * del_edac_device_from_global_list
* *
* remove the RCU, setup for a callback call, then wait for the * remove the RCU, setup for a callback call,
* callback to occur * then wait for the callback to occur
*/ */
static void del_edac_device_from_global_list(struct edac_device_ctl_info static void del_edac_device_from_global_list(struct edac_device_ctl_info
*edac_device) *edac_device)
{ {
list_del_rcu(&edac_device->link); list_del_rcu(&edac_device->link);
init_completion(&edac_device->complete);
init_completion(&edac_device->removal_complete);
call_rcu(&edac_device->rcu, complete_edac_device_list_del); call_rcu(&edac_device->rcu, complete_edac_device_list_del);
wait_for_completion(&edac_device->complete); wait_for_completion(&edac_device->removal_complete);
} }
/** /**
...@@ -542,14 +561,14 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev) ...@@ -542,14 +561,14 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
/* clear workq processing on this instance */ /* clear workq processing on this instance */
edac_device_workq_teardown(edac_dev); edac_device_workq_teardown(edac_dev);
/* Tear down the sysfs entries for this instance */
edac_device_remove_sysfs(edac_dev);
/* deregister from global list */ /* deregister from global list */
del_edac_device_from_global_list(edac_dev); del_edac_device_from_global_list(edac_dev);
mutex_unlock(&device_ctls_mutex); mutex_unlock(&device_ctls_mutex);
/* Tear down the sysfs entries for this instance */
edac_device_remove_sysfs(edac_dev);
edac_printk(KERN_INFO, EDAC_MC, edac_printk(KERN_INFO, EDAC_MC,
"Removed device %d for %s %s: DEV %s\n", "Removed device %d for %s %s: DEV %s\n",
edac_dev->dev_idx, edac_dev->dev_idx,
......
This diff is collapsed.
...@@ -37,6 +37,10 @@ extern int edac_mc_get_panic_on_ue(void); ...@@ -37,6 +37,10 @@ extern int edac_mc_get_panic_on_ue(void);
extern int edac_get_poll_msec(void); extern int edac_get_poll_msec(void);
extern int edac_mc_get_poll_msec(void); extern int edac_mc_get_poll_msec(void);
extern int edac_device_register_sysfs_main_kobj(
struct edac_device_ctl_info *edac_dev);
extern void edac_device_unregister_sysfs_main_kobj(
struct edac_device_ctl_info *edac_dev);
extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev); extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev);
extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev); extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev);
extern struct sysdev_class *edac_get_edac_class(void); extern struct sysdev_class *edac_get_edac_class(void);
......
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