device_fsm.c 34 KB

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