Commit ef99516c authored by Cornelia Huck's avatar Cornelia Huck Committed by Martin Schwidefsky

[S390] cio: Unregister ccw devices directly.

We used to unregister ccw devices not directly from the I/O
subchannel remove function in order to avoid lifelocks on the
css bus semaphore. This semaphore is gone, and there is no reason
to not unregister the ccw device directly (it is even better since
it is more in keeping with the goal of immediate disconnect).
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 8c4941c5
...@@ -290,16 +290,10 @@ int ccw_device_is_orphan(struct ccw_device *cdev) ...@@ -290,16 +290,10 @@ int ccw_device_is_orphan(struct ccw_device *cdev)
return sch_is_pseudo_sch(to_subchannel(cdev->dev.parent)); return sch_is_pseudo_sch(to_subchannel(cdev->dev.parent));
} }
static void ccw_device_unregister(struct work_struct *work) static void ccw_device_unregister(struct ccw_device *cdev)
{ {
struct ccw_device_private *priv;
struct ccw_device *cdev;
priv = container_of(work, struct ccw_device_private, kick_work);
cdev = priv->cdev;
if (test_and_clear_bit(1, &cdev->private->registered)) if (test_and_clear_bit(1, &cdev->private->registered))
device_unregister(&cdev->dev); device_del(&cdev->dev);
put_device(&cdev->dev);
} }
static void static void
...@@ -316,11 +310,8 @@ ccw_device_remove_disconnected(struct ccw_device *cdev) ...@@ -316,11 +310,8 @@ ccw_device_remove_disconnected(struct ccw_device *cdev)
spin_lock_irqsave(cdev->ccwlock, flags); spin_lock_irqsave(cdev->ccwlock, flags);
cdev->private->state = DEV_STATE_NOT_OPER; cdev->private->state = DEV_STATE_NOT_OPER;
spin_unlock_irqrestore(cdev->ccwlock, flags); spin_unlock_irqrestore(cdev->ccwlock, flags);
if (get_device(&cdev->dev)) { ccw_device_unregister(cdev);
PREPARE_WORK(&cdev->private->kick_work, put_device(&cdev->dev);
ccw_device_unregister);
queue_work(ccw_device_work, &cdev->private->kick_work);
}
return ; return ;
} }
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
...@@ -555,17 +546,10 @@ static struct attribute_group ccwdev_attr_group = { ...@@ -555,17 +546,10 @@ static struct attribute_group ccwdev_attr_group = {
.attrs = ccwdev_attrs, .attrs = ccwdev_attrs,
}; };
static int struct attribute_group *ccwdev_attr_groups[] = {
device_add_files (struct device *dev) &ccwdev_attr_group,
{ NULL,
return sysfs_create_group(&dev->kobj, &ccwdev_attr_group); };
}
static void
device_remove_files(struct device *dev)
{
sysfs_remove_group(&dev->kobj, &ccwdev_attr_group);
}
/* this is a simple abstraction for device_register that sets the /* this is a simple abstraction for device_register that sets the
* correct bus type and adds the bus specific files */ * correct bus type and adds the bus specific files */
...@@ -580,10 +564,6 @@ static int ccw_device_register(struct ccw_device *cdev) ...@@ -580,10 +564,6 @@ static int ccw_device_register(struct ccw_device *cdev)
return ret; return ret;
set_bit(1, &cdev->private->registered); set_bit(1, &cdev->private->registered);
if ((ret = device_add_files(dev))) {
if (test_and_clear_bit(1, &cdev->private->registered))
device_del(dev);
}
return ret; return ret;
} }
...@@ -655,10 +635,6 @@ ccw_device_add_changed(struct work_struct *work) ...@@ -655,10 +635,6 @@ ccw_device_add_changed(struct work_struct *work)
return; return;
} }
set_bit(1, &cdev->private->registered); set_bit(1, &cdev->private->registered);
if (device_add_files(&cdev->dev)) {
if (test_and_clear_bit(1, &cdev->private->registered))
device_unregister(&cdev->dev);
}
} }
void ccw_device_do_unreg_rereg(struct work_struct *work) void ccw_device_do_unreg_rereg(struct work_struct *work)
...@@ -671,9 +647,7 @@ void ccw_device_do_unreg_rereg(struct work_struct *work) ...@@ -671,9 +647,7 @@ void ccw_device_do_unreg_rereg(struct work_struct *work)
cdev = priv->cdev; cdev = priv->cdev;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
device_remove_files(&cdev->dev); ccw_device_unregister(cdev);
if (test_and_clear_bit(1, &cdev->private->registered))
device_del(&cdev->dev);
PREPARE_WORK(&cdev->private->kick_work, PREPARE_WORK(&cdev->private->kick_work,
ccw_device_add_changed); ccw_device_add_changed);
queue_work(ccw_device_work, &cdev->private->kick_work); queue_work(ccw_device_work, &cdev->private->kick_work);
...@@ -712,6 +686,7 @@ static int io_subchannel_initialize_dev(struct subchannel *sch, ...@@ -712,6 +686,7 @@ static int io_subchannel_initialize_dev(struct subchannel *sch,
cdev->dev.parent = &sch->dev; cdev->dev.parent = &sch->dev;
cdev->dev.release = ccw_device_release; cdev->dev.release = ccw_device_release;
INIT_LIST_HEAD(&cdev->private->kick_work.entry); INIT_LIST_HEAD(&cdev->private->kick_work.entry);
cdev->dev.groups = ccwdev_attr_groups;
/* Do first half of device_register. */ /* Do first half of device_register. */
device_initialize(&cdev->dev); device_initialize(&cdev->dev);
if (!get_device(&sch->dev)) { if (!get_device(&sch->dev)) {
...@@ -1141,15 +1116,8 @@ io_subchannel_remove (struct subchannel *sch) ...@@ -1141,15 +1116,8 @@ io_subchannel_remove (struct subchannel *sch)
sch->dev.driver_data = NULL; sch->dev.driver_data = NULL;
cdev->private->state = DEV_STATE_NOT_OPER; cdev->private->state = DEV_STATE_NOT_OPER;
spin_unlock_irqrestore(cdev->ccwlock, flags); spin_unlock_irqrestore(cdev->ccwlock, flags);
/* ccw_device_unregister(cdev);
* Put unregistration on workqueue to avoid livelocks on the css bus put_device(&cdev->dev);
* semaphore.
*/
if (get_device(&cdev->dev)) {
PREPARE_WORK(&cdev->private->kick_work,
ccw_device_unregister);
queue_work(ccw_device_work, &cdev->private->kick_work);
}
return 0; return 0;
} }
......
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