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