device_fsm.c 34 KB

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