aboutsummaryrefslogtreecommitdiff
path: root/drivers/s390/cio/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/cio/device.c')
-rw-r--r--drivers/s390/cio/device.c265
1 files changed, 4 insertions, 261 deletions
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index b29fe8d50baf..e0005a4fc978 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -149,19 +149,6 @@ static struct css_device_id io_subchannel_ids[] = {
{ /* end of list */ },
};
-static int io_subchannel_prepare(struct subchannel *sch)
-{
- struct ccw_device *cdev;
- /*
- * Don't allow suspend while a ccw device registration
- * is still outstanding.
- */
- cdev = sch_get_cdev(sch);
- if (cdev && !device_is_registered(&cdev->dev))
- return -EAGAIN;
- return 0;
-}
-
static int io_subchannel_settle(void)
{
int ret;
@@ -186,7 +173,6 @@ static struct css_driver io_subchannel_driver = {
.probe = io_subchannel_probe,
.remove = io_subchannel_remove,
.shutdown = io_subchannel_shutdown,
- .prepare = io_subchannel_prepare,
.settle = io_subchannel_settle,
};
@@ -1422,7 +1408,7 @@ static enum io_sch_action sch_get_action(struct subchannel *sch)
}
if (device_is_disconnected(cdev))
return IO_SCH_REPROBE;
- if (cdev->online && !cdev->private->flags.resuming)
+ if (cdev->online)
return IO_SCH_VERIFY;
if (cdev->private->state == DEV_STATE_NOT_OPER)
return IO_SCH_UNREG_ATTACH;
@@ -1514,11 +1500,6 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
break;
case IO_SCH_UNREG_ATTACH:
spin_lock_irqsave(sch->lock, flags);
- if (cdev->private->flags.resuming) {
- /* Device will be handled later. */
- rc = 0;
- goto out_unlock;
- }
sch_set_cdev(sch, NULL);
spin_unlock_irqrestore(sch->lock, flags);
/* Unregister ccw device. */
@@ -1531,7 +1512,7 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
switch (action) {
case IO_SCH_ORPH_UNREG:
case IO_SCH_UNREG:
- if (!cdev || !cdev->private->flags.resuming)
+ if (!cdev)
css_sch_device_unregister(sch);
break;
case IO_SCH_ORPH_ATTACH:
@@ -1664,10 +1645,10 @@ void __init ccw_device_destroy_console(struct ccw_device *cdev)
struct io_subchannel_private *io_priv = to_io_private(sch);
set_io_private(sch, NULL);
- put_device(&sch->dev);
- put_device(&cdev->dev);
dma_free_coherent(&sch->dev, sizeof(*io_priv->dma_area),
io_priv->dma_area, io_priv->dma_area_dma);
+ put_device(&sch->dev);
+ put_device(&cdev->dev);
kfree(io_priv);
}
@@ -1690,14 +1671,6 @@ void ccw_device_wait_idle(struct ccw_device *cdev)
udelay_simple(100);
}
}
-
-static int ccw_device_pm_restore(struct device *dev);
-
-int ccw_device_force_console(struct ccw_device *cdev)
-{
- return ccw_device_pm_restore(&cdev->dev);
-}
-EXPORT_SYMBOL_GPL(ccw_device_force_console);
#endif
/**
@@ -1798,235 +1771,6 @@ static void ccw_device_shutdown(struct device *dev)
__disable_cmf(cdev);
}
-static int ccw_device_pm_prepare(struct device *dev)
-{
- struct ccw_device *cdev = to_ccwdev(dev);
-
- if (work_pending(&cdev->private->todo_work))
- return -EAGAIN;
- /* Fail while device is being set online/offline. */
- if (atomic_read(&cdev->private->onoff))
- return -EAGAIN;
-
- if (cdev->online && cdev->drv && cdev->drv->prepare)
- return cdev->drv->prepare(cdev);
-
- return 0;
-}
-
-static void ccw_device_pm_complete(struct device *dev)
-{
- struct ccw_device *cdev = to_ccwdev(dev);
-
- if (cdev->online && cdev->drv && cdev->drv->complete)
- cdev->drv->complete(cdev);
-}
-
-static int ccw_device_pm_freeze(struct device *dev)
-{
- struct ccw_device *cdev = to_ccwdev(dev);
- struct subchannel *sch = to_subchannel(cdev->dev.parent);
- int ret, cm_enabled;
-
- /* Fail suspend while device is in transistional state. */
- if (!dev_fsm_final_state(cdev))
- return -EAGAIN;
- if (!cdev->online)
- return 0;
- if (cdev->drv && cdev->drv->freeze) {
- ret = cdev->drv->freeze(cdev);
- if (ret)
- return ret;
- }
-
- spin_lock_irq(sch->lock);
- cm_enabled = cdev->private->cmb != NULL;
- spin_unlock_irq(sch->lock);
- if (cm_enabled) {
- /* Don't have the css write on memory. */
- ret = ccw_set_cmf(cdev, 0);
- if (ret)
- return ret;
- }
- /* From here on, disallow device driver I/O. */
- spin_lock_irq(sch->lock);
- ret = cio_disable_subchannel(sch);
- spin_unlock_irq(sch->lock);
-
- return ret;
-}
-
-static int ccw_device_pm_thaw(struct device *dev)
-{
- struct ccw_device *cdev = to_ccwdev(dev);
- struct subchannel *sch = to_subchannel(cdev->dev.parent);
- int ret, cm_enabled;
-
- if (!cdev->online)
- return 0;
-
- spin_lock_irq(sch->lock);
- /* Allow device driver I/O again. */
- ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
- cm_enabled = cdev->private->cmb != NULL;
- spin_unlock_irq(sch->lock);
- if (ret)
- return ret;
-
- if (cm_enabled) {
- ret = ccw_set_cmf(cdev, 1);
- if (ret)
- return ret;
- }
-
- if (cdev->drv && cdev->drv->thaw)
- ret = cdev->drv->thaw(cdev);
-
- return ret;
-}
-
-static void __ccw_device_pm_restore(struct ccw_device *cdev)
-{
- struct subchannel *sch = to_subchannel(cdev->dev.parent);
-
- spin_lock_irq(sch->lock);
- if (cio_is_console(sch->schid)) {
- cio_enable_subchannel(sch, (u32)(addr_t)sch);
- goto out_unlock;
- }
- /*
- * While we were sleeping, devices may have gone or become
- * available again. Kick re-detection.
- */
- cdev->private->flags.resuming = 1;
- cdev->private->path_new_mask = LPM_ANYPATH;
- css_sched_sch_todo(sch, SCH_TODO_EVAL);
- spin_unlock_irq(sch->lock);
- css_wait_for_slow_path();
-
- /* cdev may have been moved to a different subchannel. */
- sch = to_subchannel(cdev->dev.parent);
- spin_lock_irq(sch->lock);
- if (cdev->private->state != DEV_STATE_ONLINE &&
- cdev->private->state != DEV_STATE_OFFLINE)
- goto out_unlock;
-
- ccw_device_recognition(cdev);
- spin_unlock_irq(sch->lock);
- wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev) ||
- cdev->private->state == DEV_STATE_DISCONNECTED);
- spin_lock_irq(sch->lock);
-
-out_unlock:
- cdev->private->flags.resuming = 0;
- spin_unlock_irq(sch->lock);
-}
-
-static int resume_handle_boxed(struct ccw_device *cdev)
-{
- cdev->private->state = DEV_STATE_BOXED;
- if (ccw_device_notify(cdev, CIO_BOXED) == NOTIFY_OK)
- return 0;
- ccw_device_sched_todo(cdev, CDEV_TODO_UNREG);
- return -ENODEV;
-}
-
-static int resume_handle_disc(struct ccw_device *cdev)
-{
- cdev->private->state = DEV_STATE_DISCONNECTED;
- if (ccw_device_notify(cdev, CIO_GONE) == NOTIFY_OK)
- return 0;
- ccw_device_sched_todo(cdev, CDEV_TODO_UNREG);
- return -ENODEV;
-}
-
-static int ccw_device_pm_restore(struct device *dev)
-{
- struct ccw_device *cdev = to_ccwdev(dev);
- struct subchannel *sch;
- int ret = 0;
-
- __ccw_device_pm_restore(cdev);
- sch = to_subchannel(cdev->dev.parent);
- spin_lock_irq(sch->lock);
- if (cio_is_console(sch->schid))
- goto out_restore;
-
- /* check recognition results */
- switch (cdev->private->state) {
- case DEV_STATE_OFFLINE:
- case DEV_STATE_ONLINE:
- cdev->private->flags.donotify = 0;
- break;
- case DEV_STATE_BOXED:
- ret = resume_handle_boxed(cdev);
- if (ret)
- goto out_unlock;
- goto out_restore;
- default:
- ret = resume_handle_disc(cdev);
- if (ret)
- goto out_unlock;
- goto out_restore;
- }
- /* check if the device type has changed */
- if (!ccw_device_test_sense_data(cdev)) {
- ccw_device_update_sense_data(cdev);
- ccw_device_sched_todo(cdev, CDEV_TODO_REBIND);
- ret = -ENODEV;
- goto out_unlock;
- }
- if (!cdev->online)
- goto out_unlock;
-
- if (ccw_device_online(cdev)) {
- ret = resume_handle_disc(cdev);
- if (ret)
- goto out_unlock;
- goto out_restore;
- }
- spin_unlock_irq(sch->lock);
- wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
- spin_lock_irq(sch->lock);
-
- if (ccw_device_notify(cdev, CIO_OPER) == NOTIFY_BAD) {
- ccw_device_sched_todo(cdev, CDEV_TODO_UNREG);
- ret = -ENODEV;
- goto out_unlock;
- }
-
- /* reenable cmf, if needed */
- if (cdev->private->cmb) {
- spin_unlock_irq(sch->lock);
- ret = ccw_set_cmf(cdev, 1);
- spin_lock_irq(sch->lock);
- if (ret) {
- CIO_MSG_EVENT(2, "resume: cdev 0.%x.%04x: cmf failed "
- "(rc=%d)\n", cdev->private->dev_id.ssid,
- cdev->private->dev_id.devno, ret);
- ret = 0;
- }
- }
-
-out_restore:
- spin_unlock_irq(sch->lock);
- if (cdev->online && cdev->drv && cdev->drv->restore)
- ret = cdev->drv->restore(cdev);
- return ret;
-
-out_unlock:
- spin_unlock_irq(sch->lock);
- return ret;
-}
-
-static const struct dev_pm_ops ccw_pm_ops = {
- .prepare = ccw_device_pm_prepare,
- .complete = ccw_device_pm_complete,
- .freeze = ccw_device_pm_freeze,
- .thaw = ccw_device_pm_thaw,
- .restore = ccw_device_pm_restore,
-};
-
static struct bus_type ccw_bus_type = {
.name = "ccw",
.match = ccw_bus_match,
@@ -2034,7 +1778,6 @@ static struct bus_type ccw_bus_type = {
.probe = ccw_device_probe,
.remove = ccw_device_remove,
.shutdown = ccw_device_shutdown,
- .pm = &ccw_pm_ops,
};
/**