device_fsm.c 34 KB

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