[S390] dasd: fix device shutdown process.
[deliverable/linux.git] / drivers / s390 / cio / device_fsm.c
CommitLineData
1da177e4
LT
1/*
2 * drivers/s390/cio/device_fsm.c
3 * finite state machine for device handling
4 *
5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
6 * IBM Corporation
4ce3b30c 7 * Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
1da177e4
LT
8 * Martin Schwidefsky (schwidefsky@de.ibm.com)
9 */
10
11#include <linux/module.h>
1da177e4 12#include <linux/init.h>
4e57b681
TS
13#include <linux/jiffies.h>
14#include <linux/string.h>
1da177e4
LT
15
16#include <asm/ccwdev.h>
4c24da79 17#include <asm/cio.h>
1da177e4
LT
18
19#include "cio.h"
20#include "cio_debug.h"
21#include "css.h"
22#include "device.h"
23#include "chsc.h"
24#include "ioasm.h"
1da177e4
LT
25
26int
27device_is_online(struct subchannel *sch)
28{
29 struct ccw_device *cdev;
30
31 if (!sch->dev.driver_data)
32 return 0;
33 cdev = sch->dev.driver_data;
34 return (cdev->private->state == DEV_STATE_ONLINE);
35}
36
37int
38device_is_disconnected(struct subchannel *sch)
39{
40 struct ccw_device *cdev;
41
42 if (!sch->dev.driver_data)
43 return 0;
44 cdev = sch->dev.driver_data;
45 return (cdev->private->state == DEV_STATE_DISCONNECTED ||
46 cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID);
47}
48
49void
50device_set_disconnected(struct subchannel *sch)
51{
52 struct ccw_device *cdev;
53
54 if (!sch->dev.driver_data)
55 return;
56 cdev = sch->dev.driver_data;
57 ccw_device_set_timeout(cdev, 0);
58 cdev->private->flags.fake_irb = 0;
59 cdev->private->state = DEV_STATE_DISCONNECTED;
60}
61
62void
63device_set_waiting(struct subchannel *sch)
64{
65 struct ccw_device *cdev;
66
67 if (!sch->dev.driver_data)
68 return;
69 cdev = sch->dev.driver_data;
70 ccw_device_set_timeout(cdev, 10*HZ);
71 cdev->private->state = DEV_STATE_WAIT4IO;
72}
73
74/*
75 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT.
76 */
77static void
78ccw_device_timeout(unsigned long data)
79{
80 struct ccw_device *cdev;
81
82 cdev = (struct ccw_device *) data;
83 spin_lock_irq(cdev->ccwlock);
84 dev_fsm_event(cdev, DEV_EVENT_TIMEOUT);
85 spin_unlock_irq(cdev->ccwlock);
86}
87
88/*
89 * Set timeout
90 */
91void
92ccw_device_set_timeout(struct ccw_device *cdev, int expires)
93{
94 if (expires == 0) {
95 del_timer(&cdev->private->timer);
96 return;
97 }
98 if (timer_pending(&cdev->private->timer)) {
99 if (mod_timer(&cdev->private->timer, jiffies + expires))
100 return;
101 }
102 cdev->private->timer.function = ccw_device_timeout;
103 cdev->private->timer.data = (unsigned long) cdev;
104 cdev->private->timer.expires = jiffies + expires;
105 add_timer(&cdev->private->timer);
106}
107
108/* Kill any pending timers after machine check. */
109void
110device_kill_pending_timer(struct subchannel *sch)
111{
112 struct ccw_device *cdev;
113
114 if (!sch->dev.driver_data)
115 return;
116 cdev = sch->dev.driver_data;
117 ccw_device_set_timeout(cdev, 0);
118}
119
120/*
121 * Cancel running i/o. This is called repeatedly since halt/clear are
122 * asynchronous operations. We do one try with cio_cancel, two tries
123 * with cio_halt, 255 tries with cio_clear. If everythings fails panic.
124 * Returns 0 if device now idle, -ENODEV for device not operational and
125 * -EBUSY if an interrupt is expected (either from halt/clear or from a
126 * status pending).
127 */
128int
129ccw_device_cancel_halt_clear(struct ccw_device *cdev)
130{
131 struct subchannel *sch;
132 int ret;
133
134 sch = to_subchannel(cdev->dev.parent);
a8237fc4 135 ret = stsch(sch->schid, &sch->schib);
1da177e4
LT
136 if (ret || !sch->schib.pmcw.dnv)
137 return -ENODEV;
138 if (!sch->schib.pmcw.ena || sch->schib.scsw.actl == 0)
139 /* Not operational or no activity -> done. */
140 return 0;
141 /* Stage 1: cancel io. */
142 if (!(sch->schib.scsw.actl & SCSW_ACTL_HALT_PEND) &&
143 !(sch->schib.scsw.actl & SCSW_ACTL_CLEAR_PEND)) {
144 ret = cio_cancel(sch);
145 if (ret != -EINVAL)
146 return ret;
147 /* cancel io unsuccessful. From now on it is asynchronous. */
148 cdev->private->iretry = 3; /* 3 halt retries. */
149 }
150 if (!(sch->schib.scsw.actl & SCSW_ACTL_CLEAR_PEND)) {
151 /* Stage 2: halt io. */
152 if (cdev->private->iretry) {
153 cdev->private->iretry--;
154 ret = cio_halt(sch);
ba4ba8a6
PO
155 if (ret != -EBUSY)
156 return (ret == 0) ? -EBUSY : ret;
1da177e4
LT
157 }
158 /* halt io unsuccessful. */
159 cdev->private->iretry = 255; /* 255 clear retries. */
160 }
161 /* Stage 3: clear io. */
162 if (cdev->private->iretry) {
163 cdev->private->iretry--;
164 ret = cio_clear (sch);
165 return (ret == 0) ? -EBUSY : ret;
166 }
167 panic("Can't stop i/o on subchannel.\n");
168}
169
170static int
171ccw_device_handle_oper(struct ccw_device *cdev)
172{
173 struct subchannel *sch;
174
175 sch = to_subchannel(cdev->dev.parent);
176 cdev->private->flags.recog_done = 1;
177 /*
178 * Check if cu type and device type still match. If
179 * not, it is certainly another device and we have to
180 * de- and re-register. Also check here for non-matching devno.
181 */
182 if (cdev->id.cu_type != cdev->private->senseid.cu_type ||
183 cdev->id.cu_model != cdev->private->senseid.cu_model ||
184 cdev->id.dev_type != cdev->private->senseid.dev_type ||
185 cdev->id.dev_model != cdev->private->senseid.dev_model ||
186 cdev->private->devno != sch->schib.pmcw.dev) {
187 PREPARE_WORK(&cdev->private->kick_work,
188 ccw_device_do_unreg_rereg, (void *)cdev);
189 queue_work(ccw_device_work, &cdev->private->kick_work);
190 return 0;
191 }
192 cdev->private->flags.donotify = 1;
193 return 1;
194}
195
196/*
197 * The machine won't give us any notification by machine check if a chpid has
198 * been varied online on the SE so we have to find out by magic (i. e. driving
199 * the channel subsystem to device selection and updating our path masks).
200 */
201static inline void
202__recover_lost_chpids(struct subchannel *sch, int old_lpm)
203{
204 int mask, i;
205
206 for (i = 0; i<8; i++) {
207 mask = 0x80 >> i;
208 if (!(sch->lpm & mask))
209 continue;
210 if (old_lpm & mask)
211 continue;
212 chpid_is_actually_online(sch->schib.pmcw.chpid[i]);
213 }
214}
215
216/*
217 * Stop device recognition.
218 */
219static void
220ccw_device_recog_done(struct ccw_device *cdev, int state)
221{
222 struct subchannel *sch;
223 int notify, old_lpm, same_dev;
224
225 sch = to_subchannel(cdev->dev.parent);
226
227 ccw_device_set_timeout(cdev, 0);
228 cio_disable_subchannel(sch);
229 /*
230 * Now that we tried recognition, we have performed device selection
231 * through ssch() and the path information is up to date.
232 */
233 old_lpm = sch->lpm;
a8237fc4 234 stsch(sch->schid, &sch->schib);
1da177e4
LT
235 sch->lpm = sch->schib.pmcw.pim &
236 sch->schib.pmcw.pam &
237 sch->schib.pmcw.pom &
238 sch->opm;
4ffa9234
CH
239 /* Check since device may again have become not operational. */
240 if (!sch->schib.pmcw.dnv)
241 state = DEV_STATE_NOT_OPER;
1da177e4
LT
242 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID)
243 /* Force reprobe on all chpids. */
244 old_lpm = 0;
245 if (sch->lpm != old_lpm)
246 __recover_lost_chpids(sch, old_lpm);
247 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
248 if (state == DEV_STATE_NOT_OPER) {
249 cdev->private->flags.recog_done = 1;
250 cdev->private->state = DEV_STATE_DISCONNECTED;
251 return;
252 }
253 /* Boxed devices don't need extra treatment. */
254 }
255 notify = 0;
256 same_dev = 0; /* Keep the compiler quiet... */
257 switch (state) {
258 case DEV_STATE_NOT_OPER:
259 CIO_DEBUG(KERN_WARNING, 2,
fb6958a5
CH
260 "SenseID : unknown device %04x on subchannel "
261 "0.%x.%04x\n", cdev->private->devno,
262 sch->schid.ssid, sch->schid.sch_no);
1da177e4
LT
263 break;
264 case DEV_STATE_OFFLINE:
265 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
266 same_dev = ccw_device_handle_oper(cdev);
267 notify = 1;
268 }
269 /* fill out sense information */
270 cdev->id = (struct ccw_device_id) {
271 .cu_type = cdev->private->senseid.cu_type,
272 .cu_model = cdev->private->senseid.cu_model,
273 .dev_type = cdev->private->senseid.dev_type,
274 .dev_model = cdev->private->senseid.dev_model,
275 };
276 if (notify) {
277 cdev->private->state = DEV_STATE_OFFLINE;
278 if (same_dev) {
279 /* Get device online again. */
280 ccw_device_online(cdev);
281 wake_up(&cdev->private->wait_q);
282 }
283 return;
284 }
285 /* Issue device info message. */
fb6958a5 286 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: "
1da177e4 287 "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
fb6958a5
CH
288 "%04X/%02X\n",
289 cdev->private->ssid, cdev->private->devno,
1da177e4
LT
290 cdev->id.cu_type, cdev->id.cu_model,
291 cdev->id.dev_type, cdev->id.dev_model);
292 break;
293 case DEV_STATE_BOXED:
294 CIO_DEBUG(KERN_WARNING, 2,
fb6958a5
CH
295 "SenseID : boxed device %04x on subchannel "
296 "0.%x.%04x\n", cdev->private->devno,
297 sch->schid.ssid, sch->schid.sch_no);
1da177e4
LT
298 break;
299 }
300 cdev->private->state = state;
301 io_subchannel_recog_done(cdev);
302 if (state != DEV_STATE_NOT_OPER)
303 wake_up(&cdev->private->wait_q);
304}
305
306/*
307 * Function called from device_id.c after sense id has completed.
308 */
309void
310ccw_device_sense_id_done(struct ccw_device *cdev, int err)
311{
312 switch (err) {
313 case 0:
314 ccw_device_recog_done(cdev, DEV_STATE_OFFLINE);
315 break;
316 case -ETIME: /* Sense id stopped by timeout. */
317 ccw_device_recog_done(cdev, DEV_STATE_BOXED);
318 break;
319 default:
320 ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
321 break;
322 }
323}
324
325static void
326ccw_device_oper_notify(void *data)
327{
328 struct ccw_device *cdev;
329 struct subchannel *sch;
330 int ret;
331
332 cdev = (struct ccw_device *)data;
333 sch = to_subchannel(cdev->dev.parent);
334 ret = (sch->driver && sch->driver->notify) ?
335 sch->driver->notify(&sch->dev, CIO_OPER) : 0;
336 if (!ret)
337 /* Driver doesn't want device back. */
338 ccw_device_do_unreg_rereg((void *)cdev);
94bb0633
CH
339 else {
340 /* Reenable channel measurements, if needed. */
341 cmf_reenable(cdev);
1da177e4 342 wake_up(&cdev->private->wait_q);
94bb0633 343 }
1da177e4
LT
344}
345
346/*
347 * Finished with online/offline processing.
348 */
349static void
350ccw_device_done(struct ccw_device *cdev, int state)
351{
352 struct subchannel *sch;
353
354 sch = to_subchannel(cdev->dev.parent);
355
356 if (state != DEV_STATE_ONLINE)
357 cio_disable_subchannel(sch);
358
359 /* Reset device status. */
360 memset(&cdev->private->irb, 0, sizeof(struct irb));
361
362 cdev->private->state = state;
363
364
365 if (state == DEV_STATE_BOXED)
366 CIO_DEBUG(KERN_WARNING, 2,
367 "Boxed device %04x on subchannel %04x\n",
a8237fc4 368 cdev->private->devno, sch->schid.sch_no);
1da177e4
LT
369
370 if (cdev->private->flags.donotify) {
371 cdev->private->flags.donotify = 0;
372 PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify,
373 (void *)cdev);
374 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
375 }
376 wake_up(&cdev->private->wait_q);
377
378 if (css_init_done && state != DEV_STATE_ONLINE)
379 put_device (&cdev->dev);
380}
381
7e560814
CH
382static inline int cmp_pgid(struct pgid *p1, struct pgid *p2)
383{
384 char *c1;
385 char *c2;
386
387 c1 = (char *)p1;
388 c2 = (char *)p2;
389
390 return memcmp(c1 + 1, c2 + 1, sizeof(struct pgid) - 1);
391}
392
393static void __ccw_device_get_common_pgid(struct ccw_device *cdev)
394{
395 int i;
396 int last;
397
398 last = 0;
399 for (i = 0; i < 8; i++) {
400 if (cdev->private->pgid[i].inf.ps.state1 == SNID_STATE1_RESET)
401 /* No PGID yet */
402 continue;
403 if (cdev->private->pgid[last].inf.ps.state1 ==
404 SNID_STATE1_RESET) {
405 /* First non-zero PGID */
406 last = i;
407 continue;
408 }
409 if (cmp_pgid(&cdev->private->pgid[i],
410 &cdev->private->pgid[last]) == 0)
411 /* Non-conflicting PGIDs */
412 continue;
413
414 /* PGID mismatch, can't pathgroup. */
415 CIO_MSG_EVENT(0, "SNID - pgid mismatch for device "
416 "0.%x.%04x, can't pathgroup\n",
417 cdev->private->ssid, cdev->private->devno);
418 cdev->private->options.pgroup = 0;
419 return;
420 }
421 if (cdev->private->pgid[last].inf.ps.state1 ==
422 SNID_STATE1_RESET)
423 /* No previous pgid found */
424 memcpy(&cdev->private->pgid[0], &css[0]->global_pgid,
425 sizeof(struct pgid));
426 else
427 /* Use existing pgid */
428 memcpy(&cdev->private->pgid[0], &cdev->private->pgid[last],
429 sizeof(struct pgid));
430}
431
1da177e4
LT
432/*
433 * Function called from device_pgid.c after sense path ground has completed.
434 */
435void
436ccw_device_sense_pgid_done(struct ccw_device *cdev, int err)
437{
438 struct subchannel *sch;
439
440 sch = to_subchannel(cdev->dev.parent);
441 switch (err) {
7e560814
CH
442 case -EOPNOTSUPP: /* path grouping not supported, use nop instead. */
443 cdev->private->options.pgroup = 0;
444 break;
445 case 0: /* success */
446 case -EACCES: /* partial success, some paths not operational */
447 /* Check if all pgids are equal or 0. */
448 __ccw_device_get_common_pgid(cdev);
1da177e4
LT
449 break;
450 case -ETIME: /* Sense path group id stopped by timeout. */
451 case -EUSERS: /* device is reserved for someone else. */
452 ccw_device_done(cdev, DEV_STATE_BOXED);
7e560814 453 return;
1da177e4
LT
454 default:
455 ccw_device_done(cdev, DEV_STATE_NOT_OPER);
7e560814 456 return;
1da177e4 457 }
7e560814
CH
458 /* Start Path Group verification. */
459 sch->vpm = 0; /* Start with no path groups set. */
460 cdev->private->state = DEV_STATE_VERIFY;
461 ccw_device_verify_start(cdev);
1da177e4
LT
462}
463
464/*
465 * Start device recognition.
466 */
467int
468ccw_device_recognition(struct ccw_device *cdev)
469{
470 struct subchannel *sch;
471 int ret;
472
473 if ((cdev->private->state != DEV_STATE_NOT_OPER) &&
474 (cdev->private->state != DEV_STATE_BOXED))
475 return -EINVAL;
476 sch = to_subchannel(cdev->dev.parent);
477 ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc);
478 if (ret != 0)
479 /* Couldn't enable the subchannel for i/o. Sick device. */
480 return ret;
481
482 /* After 60s the device recognition is considered to have failed. */
483 ccw_device_set_timeout(cdev, 60*HZ);
484
485 /*
486 * We used to start here with a sense pgid to find out whether a device
487 * is locked by someone else. Unfortunately, the sense pgid command
488 * code has other meanings on devices predating the path grouping
489 * algorithm, so we start with sense id and box the device after an
490 * timeout (or if sense pgid during path verification detects the device
491 * is locked, as may happen on newer devices).
492 */
493 cdev->private->flags.recog_done = 0;
494 cdev->private->state = DEV_STATE_SENSE_ID;
495 ccw_device_sense_id_start(cdev);
496 return 0;
497}
498
499/*
500 * Handle timeout in device recognition.
501 */
502static void
503ccw_device_recog_timeout(struct ccw_device *cdev, enum dev_event dev_event)
504{
505 int ret;
506
507 ret = ccw_device_cancel_halt_clear(cdev);
508 switch (ret) {
509 case 0:
510 ccw_device_recog_done(cdev, DEV_STATE_BOXED);
511 break;
512 case -ENODEV:
513 ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
514 break;
515 default:
516 ccw_device_set_timeout(cdev, 3*HZ);
517 }
518}
519
520
521static void
522ccw_device_nopath_notify(void *data)
523{
524 struct ccw_device *cdev;
525 struct subchannel *sch;
526 int ret;
527
528 cdev = (struct ccw_device *)data;
529 sch = to_subchannel(cdev->dev.parent);
530 /* Extra sanity. */
531 if (sch->lpm)
532 return;
533 ret = (sch->driver && sch->driver->notify) ?
534 sch->driver->notify(&sch->dev, CIO_NO_PATH) : 0;
535 if (!ret) {
536 if (get_device(&sch->dev)) {
537 /* Driver doesn't want to keep device. */
538 cio_disable_subchannel(sch);
539 if (get_device(&cdev->dev)) {
540 PREPARE_WORK(&cdev->private->kick_work,
541 ccw_device_call_sch_unregister,
542 (void *)cdev);
543 queue_work(ccw_device_work,
544 &cdev->private->kick_work);
545 } else
546 put_device(&sch->dev);
547 }
548 } else {
549 cio_disable_subchannel(sch);
550 ccw_device_set_timeout(cdev, 0);
551 cdev->private->flags.fake_irb = 0;
552 cdev->private->state = DEV_STATE_DISCONNECTED;
553 wake_up(&cdev->private->wait_q);
554 }
555}
556
557void
558ccw_device_verify_done(struct ccw_device *cdev, int err)
559{
560 cdev->private->flags.doverify = 0;
561 switch (err) {
562 case -EOPNOTSUPP: /* path grouping not supported, just set online. */
563 cdev->private->options.pgroup = 0;
564 case 0:
565 ccw_device_done(cdev, DEV_STATE_ONLINE);
566 /* Deliver fake irb to device driver, if needed. */
567 if (cdev->private->flags.fake_irb) {
568 memset(&cdev->private->irb, 0, sizeof(struct irb));
569 cdev->private->irb.scsw = (struct scsw) {
570 .cc = 1,
571 .fctl = SCSW_FCTL_START_FUNC,
572 .actl = SCSW_ACTL_START_PEND,
573 .stctl = SCSW_STCTL_STATUS_PEND,
574 };
575 cdev->private->flags.fake_irb = 0;
576 if (cdev->handler)
577 cdev->handler(cdev, cdev->private->intparm,
578 &cdev->private->irb);
579 memset(&cdev->private->irb, 0, sizeof(struct irb));
580 }
581 break;
582 case -ETIME:
583 ccw_device_done(cdev, DEV_STATE_BOXED);
584 break;
585 default:
586 PREPARE_WORK(&cdev->private->kick_work,
587 ccw_device_nopath_notify, (void *)cdev);
588 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
589 ccw_device_done(cdev, DEV_STATE_NOT_OPER);
590 break;
591 }
592}
593
594/*
595 * Get device online.
596 */
597int
598ccw_device_online(struct ccw_device *cdev)
599{
600 struct subchannel *sch;
601 int ret;
602
603 if ((cdev->private->state != DEV_STATE_OFFLINE) &&
604 (cdev->private->state != DEV_STATE_BOXED))
605 return -EINVAL;
606 sch = to_subchannel(cdev->dev.parent);
607 if (css_init_done && !get_device(&cdev->dev))
608 return -ENODEV;
609 ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc);
610 if (ret != 0) {
611 /* Couldn't enable the subchannel for i/o. Sick device. */
612 if (ret == -ENODEV)
613 dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
614 return ret;
615 }
616 /* Do we want to do path grouping? */
617 if (!cdev->private->options.pgroup) {
7e560814
CH
618 /* Start initial path verification. */
619 cdev->private->state = DEV_STATE_VERIFY;
620 ccw_device_verify_start(cdev);
1da177e4
LT
621 return 0;
622 }
623 /* Do a SensePGID first. */
624 cdev->private->state = DEV_STATE_SENSE_PGID;
625 ccw_device_sense_pgid_start(cdev);
626 return 0;
627}
628
629void
630ccw_device_disband_done(struct ccw_device *cdev, int err)
631{
632 switch (err) {
633 case 0:
634 ccw_device_done(cdev, DEV_STATE_OFFLINE);
635 break;
636 case -ETIME:
637 ccw_device_done(cdev, DEV_STATE_BOXED);
638 break;
639 default:
640 ccw_device_done(cdev, DEV_STATE_NOT_OPER);
641 break;
642 }
643}
644
645/*
646 * Shutdown device.
647 */
648int
649ccw_device_offline(struct ccw_device *cdev)
650{
651 struct subchannel *sch;
652
653 sch = to_subchannel(cdev->dev.parent);
a8237fc4 654 if (stsch(sch->schid, &sch->schib) || !sch->schib.pmcw.dnv)
1da177e4
LT
655 return -ENODEV;
656 if (cdev->private->state != DEV_STATE_ONLINE) {
657 if (sch->schib.scsw.actl != 0)
658 return -EBUSY;
659 return -EINVAL;
660 }
661 if (sch->schib.scsw.actl != 0)
662 return -EBUSY;
663 /* Are we doing path grouping? */
664 if (!cdev->private->options.pgroup) {
665 /* No, set state offline immediately. */
7e560814 666 sch->vpm = 0;
1da177e4
LT
667 ccw_device_done(cdev, DEV_STATE_OFFLINE);
668 return 0;
669 }
670 /* Start Set Path Group commands. */
671 cdev->private->state = DEV_STATE_DISBAND_PGID;
672 ccw_device_disband_start(cdev);
673 return 0;
674}
675
676/*
677 * Handle timeout in device online/offline process.
678 */
679static void
680ccw_device_onoff_timeout(struct ccw_device *cdev, enum dev_event dev_event)
681{
682 int ret;
683
684 ret = ccw_device_cancel_halt_clear(cdev);
685 switch (ret) {
686 case 0:
687 ccw_device_done(cdev, DEV_STATE_BOXED);
688 break;
689 case -ENODEV:
690 ccw_device_done(cdev, DEV_STATE_NOT_OPER);
691 break;
692 default:
693 ccw_device_set_timeout(cdev, 3*HZ);
694 }
695}
696
697/*
698 * Handle not oper event in device recognition.
699 */
700static void
701ccw_device_recog_notoper(struct ccw_device *cdev, enum dev_event dev_event)
702{
703 ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
704}
705
706/*
707 * Handle not operational event while offline.
708 */
709static void
710ccw_device_offline_notoper(struct ccw_device *cdev, enum dev_event dev_event)
711{
712 struct subchannel *sch;
713
714 cdev->private->state = DEV_STATE_NOT_OPER;
715 sch = to_subchannel(cdev->dev.parent);
716 if (get_device(&cdev->dev)) {
717 PREPARE_WORK(&cdev->private->kick_work,
718 ccw_device_call_sch_unregister, (void *)cdev);
719 queue_work(ccw_device_work, &cdev->private->kick_work);
720 }
721 wake_up(&cdev->private->wait_q);
722}
723
724/*
725 * Handle not operational event while online.
726 */
727static void
728ccw_device_online_notoper(struct ccw_device *cdev, enum dev_event dev_event)
729{
730 struct subchannel *sch;
731
732 sch = to_subchannel(cdev->dev.parent);
733 if (sch->driver->notify &&
734 sch->driver->notify(&sch->dev, sch->lpm ? CIO_GONE : CIO_NO_PATH)) {
735 ccw_device_set_timeout(cdev, 0);
736 cdev->private->flags.fake_irb = 0;
737 cdev->private->state = DEV_STATE_DISCONNECTED;
738 wake_up(&cdev->private->wait_q);
739 return;
740 }
741 cdev->private->state = DEV_STATE_NOT_OPER;
742 cio_disable_subchannel(sch);
743 if (sch->schib.scsw.actl != 0) {
744 // FIXME: not-oper indication to device driver ?
745 ccw_device_call_handler(cdev);
746 }
747 if (get_device(&cdev->dev)) {
748 PREPARE_WORK(&cdev->private->kick_work,
749 ccw_device_call_sch_unregister, (void *)cdev);
750 queue_work(ccw_device_work, &cdev->private->kick_work);
751 }
752 wake_up(&cdev->private->wait_q);
753}
754
755/*
756 * Handle path verification event.
757 */
758static void
759ccw_device_online_verify(struct ccw_device *cdev, enum dev_event dev_event)
760{
761 struct subchannel *sch;
762
1da177e4
LT
763 if (cdev->private->state == DEV_STATE_W4SENSE) {
764 cdev->private->flags.doverify = 1;
765 return;
766 }
767 sch = to_subchannel(cdev->dev.parent);
768 /*
769 * Since we might not just be coming from an interrupt from the
770 * subchannel we have to update the schib.
771 */
a8237fc4 772 stsch(sch->schid, &sch->schib);
1da177e4
LT
773
774 if (sch->schib.scsw.actl != 0 ||
65200c29 775 (sch->schib.scsw.stctl & SCSW_STCTL_STATUS_PEND) ||
1da177e4
LT
776 (cdev->private->irb.scsw.stctl & SCSW_STCTL_STATUS_PEND)) {
777 /*
778 * No final status yet or final status not yet delivered
779 * to the device driver. Can't do path verfication now,
780 * delay until final status was delivered.
781 */
782 cdev->private->flags.doverify = 1;
783 return;
784 }
785 /* Device is idle, we can do the path verification. */
786 cdev->private->state = DEV_STATE_VERIFY;
787 ccw_device_verify_start(cdev);
788}
789
790/*
791 * Got an interrupt for a normal io (state online).
792 */
793static void
794ccw_device_irq(struct ccw_device *cdev, enum dev_event dev_event)
795{
796 struct irb *irb;
797
798 irb = (struct irb *) __LC_IRB;
799 /* Check for unsolicited interrupt. */
800 if ((irb->scsw.stctl ==
801 (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS))
802 && (!irb->scsw.cc)) {
803 if ((irb->scsw.dstat & DEV_STAT_UNIT_CHECK) &&
804 !irb->esw.esw0.erw.cons) {
805 /* Unit check but no sense data. Need basic sense. */
806 if (ccw_device_do_sense(cdev, irb) != 0)
807 goto call_handler_unsol;
e0ec5749 808 memcpy(&cdev->private->irb, irb, sizeof(struct irb));
1da177e4
LT
809 cdev->private->state = DEV_STATE_W4SENSE;
810 cdev->private->intparm = 0;
811 return;
812 }
813call_handler_unsol:
814 if (cdev->handler)
815 cdev->handler (cdev, 0, irb);
816 return;
817 }
818 /* Accumulate status and find out if a basic sense is needed. */
819 ccw_device_accumulate_irb(cdev, irb);
820 if (cdev->private->flags.dosense) {
821 if (ccw_device_do_sense(cdev, irb) == 0) {
822 cdev->private->state = DEV_STATE_W4SENSE;
823 }
824 return;
825 }
826 /* Call the handler. */
827 if (ccw_device_call_handler(cdev) && cdev->private->flags.doverify)
828 /* Start delayed path verification. */
829 ccw_device_online_verify(cdev, 0);
830}
831
832/*
833 * Got an timeout in online state.
834 */
835static void
836ccw_device_online_timeout(struct ccw_device *cdev, enum dev_event dev_event)
837{
838 int ret;
839
840 ccw_device_set_timeout(cdev, 0);
841 ret = ccw_device_cancel_halt_clear(cdev);
842 if (ret == -EBUSY) {
843 ccw_device_set_timeout(cdev, 3*HZ);
844 cdev->private->state = DEV_STATE_TIMEOUT_KILL;
845 return;
846 }
847 if (ret == -ENODEV) {
848 struct subchannel *sch;
849
850 sch = to_subchannel(cdev->dev.parent);
851 if (!sch->lpm) {
852 PREPARE_WORK(&cdev->private->kick_work,
853 ccw_device_nopath_notify, (void *)cdev);
854 queue_work(ccw_device_notify_work,
855 &cdev->private->kick_work);
856 } else
857 dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
858 } else if (cdev->handler)
859 cdev->handler(cdev, cdev->private->intparm,
860 ERR_PTR(-ETIMEDOUT));
861}
862
863/*
864 * Got an interrupt for a basic sense.
865 */
866void
867ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
868{
869 struct irb *irb;
870
871 irb = (struct irb *) __LC_IRB;
872 /* Check for unsolicited interrupt. */
873 if (irb->scsw.stctl ==
874 (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) {
875 if (irb->scsw.cc == 1)
876 /* Basic sense hasn't started. Try again. */
877 ccw_device_do_sense(cdev, irb);
878 else {
879 printk("Huh? %s(%s): unsolicited interrupt...\n",
880 __FUNCTION__, cdev->dev.bus_id);
881 if (cdev->handler)
882 cdev->handler (cdev, 0, irb);
883 }
884 return;
885 }
3ba1998e
CH
886 /*
887 * Check if a halt or clear has been issued in the meanwhile. If yes,
888 * only deliver the halt/clear interrupt to the device driver as if it
889 * had killed the original request.
890 */
891 if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC | SCSW_FCTL_HALT_FUNC)) {
892 cdev->private->flags.dosense = 0;
893 memset(&cdev->private->irb, 0, sizeof(struct irb));
894 ccw_device_accumulate_irb(cdev, irb);
895 goto call_handler;
896 }
1da177e4
LT
897 /* Add basic sense info to irb. */
898 ccw_device_accumulate_basic_sense(cdev, irb);
899 if (cdev->private->flags.dosense) {
900 /* Another basic sense is needed. */
901 ccw_device_do_sense(cdev, irb);
902 return;
903 }
3ba1998e 904call_handler:
1da177e4
LT
905 cdev->private->state = DEV_STATE_ONLINE;
906 /* Call the handler. */
907 if (ccw_device_call_handler(cdev) && cdev->private->flags.doverify)
908 /* Start delayed path verification. */
909 ccw_device_online_verify(cdev, 0);
910}
911
912static void
913ccw_device_clear_verify(struct ccw_device *cdev, enum dev_event dev_event)
914{
915 struct irb *irb;
916
917 irb = (struct irb *) __LC_IRB;
918 /* Accumulate status. We don't do basic sense. */
919 ccw_device_accumulate_irb(cdev, irb);
b4f7b1ee
CH
920 /* Remember to clear irb to avoid residuals. */
921 memset(&cdev->private->irb, 0, sizeof(struct irb));
1da177e4
LT
922 /* Try to start delayed device verification. */
923 ccw_device_online_verify(cdev, 0);
924 /* Note: Don't call handler for cio initiated clear! */
925}
926
927static void
928ccw_device_killing_irq(struct ccw_device *cdev, enum dev_event dev_event)
929{
930 struct subchannel *sch;
931
932 sch = to_subchannel(cdev->dev.parent);
933 ccw_device_set_timeout(cdev, 0);
934 /* OK, i/o is dead now. Call interrupt handler. */
935 cdev->private->state = DEV_STATE_ONLINE;
936 if (cdev->handler)
937 cdev->handler(cdev, cdev->private->intparm,
938 ERR_PTR(-ETIMEDOUT));
939 if (!sch->lpm) {
940 PREPARE_WORK(&cdev->private->kick_work,
941 ccw_device_nopath_notify, (void *)cdev);
942 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
943 } else if (cdev->private->flags.doverify)
944 /* Start delayed path verification. */
945 ccw_device_online_verify(cdev, 0);
946}
947
948static void
949ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
950{
951 int ret;
952
953 ret = ccw_device_cancel_halt_clear(cdev);
954 if (ret == -EBUSY) {
955 ccw_device_set_timeout(cdev, 3*HZ);
956 return;
957 }
958 if (ret == -ENODEV) {
959 struct subchannel *sch;
960
961 sch = to_subchannel(cdev->dev.parent);
962 if (!sch->lpm) {
963 PREPARE_WORK(&cdev->private->kick_work,
964 ccw_device_nopath_notify, (void *)cdev);
965 queue_work(ccw_device_notify_work,
966 &cdev->private->kick_work);
967 } else
968 dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
969 return;
970 }
971 //FIXME: Can we get here?
972 cdev->private->state = DEV_STATE_ONLINE;
973 if (cdev->handler)
974 cdev->handler(cdev, cdev->private->intparm,
975 ERR_PTR(-ETIMEDOUT));
976}
977
978static void
979ccw_device_wait4io_irq(struct ccw_device *cdev, enum dev_event dev_event)
980{
981 struct irb *irb;
982 struct subchannel *sch;
983
984 irb = (struct irb *) __LC_IRB;
985 /*
986 * Accumulate status and find out if a basic sense is needed.
987 * This is fine since we have already adapted the lpm.
988 */
989 ccw_device_accumulate_irb(cdev, irb);
990 if (cdev->private->flags.dosense) {
991 if (ccw_device_do_sense(cdev, irb) == 0) {
992 cdev->private->state = DEV_STATE_W4SENSE;
993 }
994 return;
995 }
996
997 /* Iff device is idle, reset timeout. */
998 sch = to_subchannel(cdev->dev.parent);
a8237fc4 999 if (!stsch(sch->schid, &sch->schib))
1da177e4
LT
1000 if (sch->schib.scsw.actl == 0)
1001 ccw_device_set_timeout(cdev, 0);
1002 /* Call the handler. */
1003 ccw_device_call_handler(cdev);
1004 if (!sch->lpm) {
1005 PREPARE_WORK(&cdev->private->kick_work,
1006 ccw_device_nopath_notify, (void *)cdev);
1007 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
1008 } else if (cdev->private->flags.doverify)
1009 ccw_device_online_verify(cdev, 0);
1010}
1011
1012static void
1013ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1014{
1015 int ret;
1016 struct subchannel *sch;
1017
1018 sch = to_subchannel(cdev->dev.parent);
1019 ccw_device_set_timeout(cdev, 0);
1020 ret = ccw_device_cancel_halt_clear(cdev);
1021 if (ret == -EBUSY) {
1022 ccw_device_set_timeout(cdev, 3*HZ);
1023 cdev->private->state = DEV_STATE_TIMEOUT_KILL;
1024 return;
1025 }
1026 if (ret == -ENODEV) {
1027 if (!sch->lpm) {
1028 PREPARE_WORK(&cdev->private->kick_work,
1029 ccw_device_nopath_notify, (void *)cdev);
1030 queue_work(ccw_device_notify_work,
1031 &cdev->private->kick_work);
1032 } else
1033 dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
1034 return;
1035 }
1036 if (cdev->handler)
1037 cdev->handler(cdev, cdev->private->intparm,
1038 ERR_PTR(-ETIMEDOUT));
1039 if (!sch->lpm) {
1040 PREPARE_WORK(&cdev->private->kick_work,
1041 ccw_device_nopath_notify, (void *)cdev);
1042 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
1043 } else if (cdev->private->flags.doverify)
1044 /* Start delayed path verification. */
1045 ccw_device_online_verify(cdev, 0);
1046}
1047
1048static void
1049ccw_device_wait4io_verify(struct ccw_device *cdev, enum dev_event dev_event)
1050{
1051 /* When the I/O has terminated, we have to start verification. */
7e560814 1052 cdev->private->flags.doverify = 1;
1da177e4
LT
1053}
1054
1055static void
1056ccw_device_stlck_done(struct ccw_device *cdev, enum dev_event dev_event)
1057{
1058 struct irb *irb;
1059
1060 switch (dev_event) {
1061 case DEV_EVENT_INTERRUPT:
1062 irb = (struct irb *) __LC_IRB;
1063 /* Check for unsolicited interrupt. */
1064 if ((irb->scsw.stctl ==
1065 (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) &&
1066 (!irb->scsw.cc))
1067 /* FIXME: we should restart stlck here, but this
1068 * is extremely unlikely ... */
1069 goto out_wakeup;
1070
1071 ccw_device_accumulate_irb(cdev, irb);
1072 /* We don't care about basic sense etc. */
1073 break;
1074 default: /* timeout */
1075 break;
1076 }
1077out_wakeup:
1078 wake_up(&cdev->private->wait_q);
1079}
1080
1081static void
1082ccw_device_start_id(struct ccw_device *cdev, enum dev_event dev_event)
1083{
1084 struct subchannel *sch;
1085
1086 sch = to_subchannel(cdev->dev.parent);
1087 if (cio_enable_subchannel(sch, sch->schib.pmcw.isc) != 0)
1088 /* Couldn't enable the subchannel for i/o. Sick device. */
1089 return;
1090
1091 /* After 60s the device recognition is considered to have failed. */
1092 ccw_device_set_timeout(cdev, 60*HZ);
1093
1094 cdev->private->state = DEV_STATE_DISCONNECTED_SENSE_ID;
1095 ccw_device_sense_id_start(cdev);
1096}
1097
1098void
1099device_trigger_reprobe(struct subchannel *sch)
1100{
1101 struct ccw_device *cdev;
1102
1103 if (!sch->dev.driver_data)
1104 return;
1105 cdev = sch->dev.driver_data;
1106 if (cdev->private->state != DEV_STATE_DISCONNECTED)
1107 return;
1108
1109 /* Update some values. */
a8237fc4 1110 if (stsch(sch->schid, &sch->schib))
1da177e4
LT
1111 return;
1112
1113 /*
1114 * The pim, pam, pom values may not be accurate, but they are the best
1115 * we have before performing device selection :/
1116 */
1117 sch->lpm = sch->schib.pmcw.pim &
1118 sch->schib.pmcw.pam &
1119 sch->schib.pmcw.pom &
1120 sch->opm;
1121 /* Re-set some bits in the pmcw that were lost. */
1122 sch->schib.pmcw.isc = 3;
1123 sch->schib.pmcw.csense = 1;
1124 sch->schib.pmcw.ena = 0;
1125 if ((sch->lpm & (sch->lpm - 1)) != 0)
1126 sch->schib.pmcw.mp = 1;
1127 sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
1128 /* We should also udate ssd info, but this has to wait. */
1129 ccw_device_start_id(cdev, 0);
1130}
1131
1132static void
1133ccw_device_offline_irq(struct ccw_device *cdev, enum dev_event dev_event)
1134{
1135 struct subchannel *sch;
1136
1137 sch = to_subchannel(cdev->dev.parent);
1138 /*
1139 * An interrupt in state offline means a previous disable was not
1140 * successful. Try again.
1141 */
1142 cio_disable_subchannel(sch);
1143}
1144
1145static void
1146ccw_device_change_cmfstate(struct ccw_device *cdev, enum dev_event dev_event)
1147{
1148 retry_set_schib(cdev);
1149 cdev->private->state = DEV_STATE_ONLINE;
1150 dev_fsm_event(cdev, dev_event);
1151}
1152
94bb0633
CH
1153static void ccw_device_update_cmfblock(struct ccw_device *cdev,
1154 enum dev_event dev_event)
1155{
1156 cmf_retry_copy_block(cdev);
1157 cdev->private->state = DEV_STATE_ONLINE;
1158 dev_fsm_event(cdev, dev_event);
1159}
1da177e4
LT
1160
1161static void
1162ccw_device_quiesce_done(struct ccw_device *cdev, enum dev_event dev_event)
1163{
1164 ccw_device_set_timeout(cdev, 0);
1165 if (dev_event == DEV_EVENT_NOTOPER)
1166 cdev->private->state = DEV_STATE_NOT_OPER;
1167 else
1168 cdev->private->state = DEV_STATE_OFFLINE;
1169 wake_up(&cdev->private->wait_q);
1170}
1171
1172static void
1173ccw_device_quiesce_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1174{
1175 int ret;
1176
1177 ret = ccw_device_cancel_halt_clear(cdev);
1178 switch (ret) {
1179 case 0:
1180 cdev->private->state = DEV_STATE_OFFLINE;
1181 wake_up(&cdev->private->wait_q);
1182 break;
1183 case -ENODEV:
1184 cdev->private->state = DEV_STATE_NOT_OPER;
1185 wake_up(&cdev->private->wait_q);
1186 break;
1187 default:
1188 ccw_device_set_timeout(cdev, HZ/10);
1189 }
1190}
1191
1192/*
1193 * No operation action. This is used e.g. to ignore a timeout event in
1194 * state offline.
1195 */
1196static void
1197ccw_device_nop(struct ccw_device *cdev, enum dev_event dev_event)
1198{
1199}
1200
1201/*
1202 * Bug operation action.
1203 */
1204static void
1205ccw_device_bug(struct ccw_device *cdev, enum dev_event dev_event)
1206{
1207 printk(KERN_EMERG "dev_jumptable[%i][%i] == NULL\n",
1208 cdev->private->state, dev_event);
1209 BUG();
1210}
1211
1212/*
1213 * device statemachine
1214 */
1215fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS] = {
1216 [DEV_STATE_NOT_OPER] = {
1217 [DEV_EVENT_NOTOPER] = ccw_device_nop,
1218 [DEV_EVENT_INTERRUPT] = ccw_device_bug,
1219 [DEV_EVENT_TIMEOUT] = ccw_device_nop,
1220 [DEV_EVENT_VERIFY] = ccw_device_nop,
1221 },
1222 [DEV_STATE_SENSE_PGID] = {
1223 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1224 [DEV_EVENT_INTERRUPT] = ccw_device_sense_pgid_irq,
1225 [DEV_EVENT_TIMEOUT] = ccw_device_onoff_timeout,
1226 [DEV_EVENT_VERIFY] = ccw_device_nop,
1227 },
1228 [DEV_STATE_SENSE_ID] = {
1229 [DEV_EVENT_NOTOPER] = ccw_device_recog_notoper,
1230 [DEV_EVENT_INTERRUPT] = ccw_device_sense_id_irq,
1231 [DEV_EVENT_TIMEOUT] = ccw_device_recog_timeout,
1232 [DEV_EVENT_VERIFY] = ccw_device_nop,
1233 },
1234 [DEV_STATE_OFFLINE] = {
1235 [DEV_EVENT_NOTOPER] = ccw_device_offline_notoper,
1236 [DEV_EVENT_INTERRUPT] = ccw_device_offline_irq,
1237 [DEV_EVENT_TIMEOUT] = ccw_device_nop,
1238 [DEV_EVENT_VERIFY] = ccw_device_nop,
1239 },
1240 [DEV_STATE_VERIFY] = {
1241 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1242 [DEV_EVENT_INTERRUPT] = ccw_device_verify_irq,
1243 [DEV_EVENT_TIMEOUT] = ccw_device_onoff_timeout,
1244 [DEV_EVENT_VERIFY] = ccw_device_nop,
1245 },
1246 [DEV_STATE_ONLINE] = {
1247 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1248 [DEV_EVENT_INTERRUPT] = ccw_device_irq,
1249 [DEV_EVENT_TIMEOUT] = ccw_device_online_timeout,
1250 [DEV_EVENT_VERIFY] = ccw_device_online_verify,
1251 },
1252 [DEV_STATE_W4SENSE] = {
1253 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1254 [DEV_EVENT_INTERRUPT] = ccw_device_w4sense,
1255 [DEV_EVENT_TIMEOUT] = ccw_device_nop,
1256 [DEV_EVENT_VERIFY] = ccw_device_online_verify,
1257 },
1258 [DEV_STATE_DISBAND_PGID] = {
1259 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1260 [DEV_EVENT_INTERRUPT] = ccw_device_disband_irq,
1261 [DEV_EVENT_TIMEOUT] = ccw_device_onoff_timeout,
1262 [DEV_EVENT_VERIFY] = ccw_device_nop,
1263 },
1264 [DEV_STATE_BOXED] = {
1265 [DEV_EVENT_NOTOPER] = ccw_device_offline_notoper,
1266 [DEV_EVENT_INTERRUPT] = ccw_device_stlck_done,
1267 [DEV_EVENT_TIMEOUT] = ccw_device_stlck_done,
1268 [DEV_EVENT_VERIFY] = ccw_device_nop,
1269 },
1270 /* states to wait for i/o completion before doing something */
1271 [DEV_STATE_CLEAR_VERIFY] = {
1272 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1273 [DEV_EVENT_INTERRUPT] = ccw_device_clear_verify,
1274 [DEV_EVENT_TIMEOUT] = ccw_device_nop,
1275 [DEV_EVENT_VERIFY] = ccw_device_nop,
1276 },
1277 [DEV_STATE_TIMEOUT_KILL] = {
1278 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1279 [DEV_EVENT_INTERRUPT] = ccw_device_killing_irq,
1280 [DEV_EVENT_TIMEOUT] = ccw_device_killing_timeout,
1281 [DEV_EVENT_VERIFY] = ccw_device_nop, //FIXME
1282 },
1283 [DEV_STATE_WAIT4IO] = {
1284 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1285 [DEV_EVENT_INTERRUPT] = ccw_device_wait4io_irq,
1286 [DEV_EVENT_TIMEOUT] = ccw_device_wait4io_timeout,
1287 [DEV_EVENT_VERIFY] = ccw_device_wait4io_verify,
1288 },
1289 [DEV_STATE_QUIESCE] = {
1290 [DEV_EVENT_NOTOPER] = ccw_device_quiesce_done,
1291 [DEV_EVENT_INTERRUPT] = ccw_device_quiesce_done,
1292 [DEV_EVENT_TIMEOUT] = ccw_device_quiesce_timeout,
1293 [DEV_EVENT_VERIFY] = ccw_device_nop,
1294 },
1295 /* special states for devices gone not operational */
1296 [DEV_STATE_DISCONNECTED] = {
1297 [DEV_EVENT_NOTOPER] = ccw_device_nop,
1298 [DEV_EVENT_INTERRUPT] = ccw_device_start_id,
1299 [DEV_EVENT_TIMEOUT] = ccw_device_bug,
1300 [DEV_EVENT_VERIFY] = ccw_device_nop,
1301 },
1302 [DEV_STATE_DISCONNECTED_SENSE_ID] = {
1303 [DEV_EVENT_NOTOPER] = ccw_device_recog_notoper,
1304 [DEV_EVENT_INTERRUPT] = ccw_device_sense_id_irq,
1305 [DEV_EVENT_TIMEOUT] = ccw_device_recog_timeout,
1306 [DEV_EVENT_VERIFY] = ccw_device_nop,
1307 },
1308 [DEV_STATE_CMFCHANGE] = {
1309 [DEV_EVENT_NOTOPER] = ccw_device_change_cmfstate,
1310 [DEV_EVENT_INTERRUPT] = ccw_device_change_cmfstate,
1311 [DEV_EVENT_TIMEOUT] = ccw_device_change_cmfstate,
1312 [DEV_EVENT_VERIFY] = ccw_device_change_cmfstate,
1313 },
94bb0633
CH
1314 [DEV_STATE_CMFUPDATE] = {
1315 [DEV_EVENT_NOTOPER] = ccw_device_update_cmfblock,
1316 [DEV_EVENT_INTERRUPT] = ccw_device_update_cmfblock,
1317 [DEV_EVENT_TIMEOUT] = ccw_device_update_cmfblock,
1318 [DEV_EVENT_VERIFY] = ccw_device_update_cmfblock,
1319 },
1da177e4
LT
1320};
1321
1322/*
1323 * io_subchannel_irq is called for "real" interrupts or for status
1324 * pending conditions on msch.
1325 */
1326void
1327io_subchannel_irq (struct device *pdev)
1328{
1329 struct ccw_device *cdev;
1330
1331 cdev = to_subchannel(pdev)->dev.driver_data;
1332
1333 CIO_TRACE_EVENT (3, "IRQ");
1334 CIO_TRACE_EVENT (3, pdev->bus_id);
1335 if (cdev)
1336 dev_fsm_event(cdev, DEV_EVENT_INTERRUPT);
1337}
1338
1339EXPORT_SYMBOL_GPL(ccw_device_set_timeout);
This page took 0.195605 seconds and 5 git commands to generate.