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