/*
* drivers/s390/cio/css.c
* driver for channel subsystem
- * $Revision: 1.73 $
+ * $Revision: 1.77 $
*
* Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
* IBM Corporation
if (sch && sch->schib.pmcw.dnv &&
(schib.pmcw.dev != sch->schib.pmcw.dev))
return CIO_REVALIDATE;
+ if (sch && !sch->lpm)
+ return CIO_NO_PATH;
return CIO_OPER;
}
-static inline int
+static int
css_evaluate_subchannel(int irq, int slow)
{
int event, ret, disc;
return -EAGAIN; /* Will be done on the slow path. */
}
event = css_get_subchannel_status(sch, irq);
+ CIO_MSG_EVENT(4, "Evaluating schid %04x, event %d, %s, %s path.\n",
+ irq, event, sch?(disc?"disconnected":"normal"):"unknown",
+ slow?"slow":"fast");
switch (event) {
+ case CIO_NO_PATH:
case CIO_GONE:
if (!sch) {
/* Never used this subchannel. Ignore. */
break;
}
if (sch->driver && sch->driver->notify &&
- sch->driver->notify(&sch->dev, CIO_GONE)) {
+ sch->driver->notify(&sch->dev, event)) {
+ cio_disable_subchannel(sch);
device_set_disconnected(sch);
ret = 0;
break;
* Unregister subchannel.
* The device will be killed automatically.
*/
+ cio_disable_subchannel(sch);
device_unregister(&sch->dev);
/* Reset intparm to zeroes. */
sch->schib.pmcw.intparm = 0;
* We don't notify the driver since we have to throw the device
* away in any case.
*/
- device_unregister(&sch->dev);
- /* Reset intparm to zeroes. */
- sch->schib.pmcw.intparm = 0;
- cio_modify(sch);
- put_device(&sch->dev);
- ret = css_probe_device(irq);
+ if (!disc) {
+ device_unregister(&sch->dev);
+ /* Reset intparm to zeroes. */
+ sch->schib.pmcw.intparm = 0;
+ cio_modify(sch);
+ put_device(&sch->dev);
+ ret = css_probe_device(irq);
+ } else {
+ /*
+ * We can't immediately deregister the disconnected
+ * device since it might block.
+ */
+ device_trigger_reprobe(sch);
+ ret = 0;
+ }
break;
case CIO_OPER:
if (disc)
}
}
-static void
-css_evaluate_slow_subchannel(unsigned long schid)
-{
- css_evaluate_subchannel(schid, 1);
-}
+struct slow_subchannel {
+ struct list_head slow_list;
+ unsigned long schid;
+};
-void
+static LIST_HEAD(slow_subchannels_head);
+static spinlock_t slow_subchannel_lock = SPIN_LOCK_UNLOCKED;
+
+static void
css_trigger_slow_path(void)
{
+ CIO_TRACE_EVENT(4, "slowpath");
+
if (need_rescan) {
need_rescan = 0;
css_rescan_devices();
return;
}
- css_walk_subchannel_slow_list(css_evaluate_slow_subchannel);
+
+ spin_lock_irq(&slow_subchannel_lock);
+ while (!list_empty(&slow_subchannels_head)) {
+ struct slow_subchannel *slow_sch =
+ list_entry(slow_subchannels_head.next,
+ struct slow_subchannel, slow_list);
+
+ list_del_init(slow_subchannels_head.next);
+ spin_unlock_irq(&slow_subchannel_lock);
+ css_evaluate_subchannel(slow_sch->schid, 1);
+ spin_lock_irq(&slow_subchannel_lock);
+ kfree(slow_sch);
+ }
+ spin_unlock_irq(&slow_subchannel_lock);
}
+typedef void (*workfunc)(void *);
+DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL);
+struct workqueue_struct *slow_path_wq;
+
/*
* Rescan for new devices. FIXME: This is slow.
* This function is called when we have lost CRWs due to overflows and we have
device_unregister(dev);
}
-struct slow_subchannel {
- struct list_head slow_list;
- unsigned long schid;
-};
-
-static LIST_HEAD(slow_subchannels_head);
-static spinlock_t slow_subchannel_lock = SPIN_LOCK_UNLOCKED;
-
int
css_enqueue_subchannel_slow(unsigned long schid)
{
spin_unlock_irqrestore(&slow_subchannel_lock, flags);
}
-void
-css_walk_subchannel_slow_list(void (*fn)(unsigned long))
-{
- unsigned long flags;
-
- spin_lock_irqsave(&slow_subchannel_lock, flags);
- while (!list_empty(&slow_subchannels_head)) {
- struct slow_subchannel *slow_sch =
- list_entry(slow_subchannels_head.next,
- struct slow_subchannel, slow_list);
- list_del_init(slow_subchannels_head.next);
- spin_unlock_irqrestore(&slow_subchannel_lock, flags);
- fn(slow_sch->schid);
- spin_lock_irqsave(&slow_subchannel_lock, flags);
- kfree(slow_sch);
- }
- spin_unlock_irqrestore(&slow_subchannel_lock, flags);
-}
int
css_slow_subchannels_exist(void)