device_fsm.c 33 KB

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