device_fsm.c 32 KB

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