device_fsm.c 33 KB

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