device_fsm.c 34 KB

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