device_fsm.c 33 KB

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