device_fsm.c 34 KB

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