device_fsm.c 33 KB

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