device_fsm.c 33 KB

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