device_fsm.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  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. ret = stsch(sch->schid, &sch->schib);
  128. if (ret || !sch->schib.pmcw.dnv)
  129. return -ENODEV;
  130. if (!sch->schib.pmcw.ena)
  131. /* Not operational -> done. */
  132. return 0;
  133. /* Stage 1: cancel io. */
  134. if (!(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_HALT_PEND) &&
  135. !(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_CLEAR_PEND)) {
  136. if (!scsw_is_tm(&sch->schib.scsw)) {
  137. ret = cio_cancel(sch);
  138. if (ret != -EINVAL)
  139. return ret;
  140. }
  141. /* cancel io unsuccessful or not applicable (transport mode).
  142. * Continue with asynchronous instructions. */
  143. cdev->private->iretry = 3; /* 3 halt retries. */
  144. }
  145. if (!(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_CLEAR_PEND)) {
  146. /* Stage 2: halt io. */
  147. if (cdev->private->iretry) {
  148. cdev->private->iretry--;
  149. ret = cio_halt(sch);
  150. if (ret != -EBUSY)
  151. return (ret == 0) ? -EBUSY : ret;
  152. }
  153. /* halt io unsuccessful. */
  154. cdev->private->iretry = 255; /* 255 clear retries. */
  155. }
  156. /* Stage 3: clear io. */
  157. if (cdev->private->iretry) {
  158. cdev->private->iretry--;
  159. ret = cio_clear (sch);
  160. return (ret == 0) ? -EBUSY : ret;
  161. }
  162. panic("Can't stop i/o on subchannel.\n");
  163. }
  164. static int
  165. ccw_device_handle_oper(struct ccw_device *cdev)
  166. {
  167. struct subchannel *sch;
  168. sch = to_subchannel(cdev->dev.parent);
  169. cdev->private->flags.recog_done = 1;
  170. /*
  171. * Check if cu type and device type still match. If
  172. * not, it is certainly another device and we have to
  173. * de- and re-register.
  174. */
  175. if (cdev->id.cu_type != cdev->private->senseid.cu_type ||
  176. cdev->id.cu_model != cdev->private->senseid.cu_model ||
  177. cdev->id.dev_type != cdev->private->senseid.dev_type ||
  178. cdev->id.dev_model != cdev->private->senseid.dev_model) {
  179. PREPARE_WORK(&cdev->private->kick_work,
  180. ccw_device_do_unreg_rereg);
  181. queue_work(ccw_device_work, &cdev->private->kick_work);
  182. return 0;
  183. }
  184. cdev->private->flags.donotify = 1;
  185. return 1;
  186. }
  187. /*
  188. * The machine won't give us any notification by machine check if a chpid has
  189. * been varied online on the SE so we have to find out by magic (i. e. driving
  190. * the channel subsystem to device selection and updating our path masks).
  191. */
  192. static void
  193. __recover_lost_chpids(struct subchannel *sch, int old_lpm)
  194. {
  195. int mask, i;
  196. struct chp_id chpid;
  197. chp_id_init(&chpid);
  198. for (i = 0; i<8; i++) {
  199. mask = 0x80 >> i;
  200. if (!(sch->lpm & mask))
  201. continue;
  202. if (old_lpm & mask)
  203. continue;
  204. chpid.id = sch->schib.pmcw.chpid[i];
  205. if (!chp_is_registered(chpid))
  206. css_schedule_eval_all();
  207. }
  208. }
  209. /*
  210. * Stop device recognition.
  211. */
  212. static void
  213. ccw_device_recog_done(struct ccw_device *cdev, int state)
  214. {
  215. struct subchannel *sch;
  216. int notify, old_lpm, same_dev;
  217. sch = to_subchannel(cdev->dev.parent);
  218. ccw_device_set_timeout(cdev, 0);
  219. cio_disable_subchannel(sch);
  220. /*
  221. * Now that we tried recognition, we have performed device selection
  222. * through ssch() and the path information is up to date.
  223. */
  224. old_lpm = sch->lpm;
  225. stsch(sch->schid, &sch->schib);
  226. sch->lpm = sch->schib.pmcw.pam & sch->opm;
  227. /* Check since device may again have become not operational. */
  228. if (!sch->schib.pmcw.dnv)
  229. state = DEV_STATE_NOT_OPER;
  230. if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID)
  231. /* Force reprobe on all chpids. */
  232. old_lpm = 0;
  233. if (sch->lpm != old_lpm)
  234. __recover_lost_chpids(sch, old_lpm);
  235. if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
  236. if (state == DEV_STATE_NOT_OPER) {
  237. cdev->private->flags.recog_done = 1;
  238. cdev->private->state = DEV_STATE_DISCONNECTED;
  239. return;
  240. }
  241. /* Boxed devices don't need extra treatment. */
  242. }
  243. notify = 0;
  244. same_dev = 0; /* Keep the compiler quiet... */
  245. switch (state) {
  246. case DEV_STATE_NOT_OPER:
  247. CIO_MSG_EVENT(2, "SenseID : unknown device %04x on "
  248. "subchannel 0.%x.%04x\n",
  249. cdev->private->dev_id.devno,
  250. sch->schid.ssid, sch->schid.sch_no);
  251. break;
  252. case DEV_STATE_OFFLINE:
  253. if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
  254. same_dev = ccw_device_handle_oper(cdev);
  255. notify = 1;
  256. }
  257. /* fill out sense information */
  258. memset(&cdev->id, 0, sizeof(cdev->id));
  259. cdev->id.cu_type = cdev->private->senseid.cu_type;
  260. cdev->id.cu_model = cdev->private->senseid.cu_model;
  261. cdev->id.dev_type = cdev->private->senseid.dev_type;
  262. cdev->id.dev_model = cdev->private->senseid.dev_model;
  263. if (notify) {
  264. cdev->private->state = DEV_STATE_OFFLINE;
  265. if (same_dev) {
  266. /* Get device online again. */
  267. ccw_device_online(cdev);
  268. wake_up(&cdev->private->wait_q);
  269. }
  270. return;
  271. }
  272. /* Issue device info message. */
  273. CIO_MSG_EVENT(4, "SenseID : device 0.%x.%04x reports: "
  274. "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
  275. "%04X/%02X\n",
  276. cdev->private->dev_id.ssid,
  277. cdev->private->dev_id.devno,
  278. cdev->id.cu_type, cdev->id.cu_model,
  279. cdev->id.dev_type, cdev->id.dev_model);
  280. break;
  281. case DEV_STATE_BOXED:
  282. CIO_MSG_EVENT(0, "SenseID : boxed device %04x on "
  283. " subchannel 0.%x.%04x\n",
  284. cdev->private->dev_id.devno,
  285. sch->schid.ssid, sch->schid.sch_no);
  286. break;
  287. }
  288. cdev->private->state = state;
  289. io_subchannel_recog_done(cdev);
  290. if (state != DEV_STATE_NOT_OPER)
  291. wake_up(&cdev->private->wait_q);
  292. }
  293. /*
  294. * Function called from device_id.c after sense id has completed.
  295. */
  296. void
  297. ccw_device_sense_id_done(struct ccw_device *cdev, int err)
  298. {
  299. switch (err) {
  300. case 0:
  301. ccw_device_recog_done(cdev, DEV_STATE_OFFLINE);
  302. break;
  303. case -ETIME: /* Sense id stopped by timeout. */
  304. ccw_device_recog_done(cdev, DEV_STATE_BOXED);
  305. break;
  306. default:
  307. ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
  308. break;
  309. }
  310. }
  311. int ccw_device_notify(struct ccw_device *cdev, int event)
  312. {
  313. if (!cdev->drv)
  314. return 0;
  315. if (!cdev->online)
  316. return 0;
  317. CIO_MSG_EVENT(2, "notify called for 0.%x.%04x, event=%d\n",
  318. cdev->private->dev_id.ssid, cdev->private->dev_id.devno,
  319. event);
  320. return cdev->drv->notify ? cdev->drv->notify(cdev, event) : 0;
  321. }
  322. static void cmf_reenable_delayed(struct work_struct *work)
  323. {
  324. struct ccw_device_private *priv;
  325. struct ccw_device *cdev;
  326. priv = container_of(work, struct ccw_device_private, kick_work);
  327. cdev = priv->cdev;
  328. cmf_reenable(cdev);
  329. }
  330. static void ccw_device_oper_notify(struct ccw_device *cdev)
  331. {
  332. if (ccw_device_notify(cdev, CIO_OPER)) {
  333. /* Reenable channel measurements, if needed. */
  334. PREPARE_WORK(&cdev->private->kick_work, cmf_reenable_delayed);
  335. queue_work(ccw_device_work, &cdev->private->kick_work);
  336. return;
  337. }
  338. /* Driver doesn't want device back. */
  339. ccw_device_set_notoper(cdev);
  340. PREPARE_WORK(&cdev->private->kick_work, ccw_device_do_unreg_rereg);
  341. queue_work(ccw_device_work, &cdev->private->kick_work);
  342. }
  343. /*
  344. * Finished with online/offline processing.
  345. */
  346. static void
  347. ccw_device_done(struct ccw_device *cdev, int state)
  348. {
  349. struct subchannel *sch;
  350. sch = to_subchannel(cdev->dev.parent);
  351. ccw_device_set_timeout(cdev, 0);
  352. if (state != DEV_STATE_ONLINE)
  353. cio_disable_subchannel(sch);
  354. /* Reset device status. */
  355. memset(&cdev->private->irb, 0, sizeof(struct irb));
  356. cdev->private->state = state;
  357. if (state == DEV_STATE_BOXED)
  358. CIO_MSG_EVENT(0, "Boxed device %04x on subchannel %04x\n",
  359. cdev->private->dev_id.devno, sch->schid.sch_no);
  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. if (css_init_done && state != DEV_STATE_ONLINE)
  366. put_device (&cdev->dev);
  367. }
  368. static int cmp_pgid(struct pgid *p1, struct pgid *p2)
  369. {
  370. char *c1;
  371. char *c2;
  372. c1 = (char *)p1;
  373. c2 = (char *)p2;
  374. return memcmp(c1 + 1, c2 + 1, sizeof(struct pgid) - 1);
  375. }
  376. static void __ccw_device_get_common_pgid(struct ccw_device *cdev)
  377. {
  378. int i;
  379. int last;
  380. last = 0;
  381. for (i = 0; i < 8; i++) {
  382. if (cdev->private->pgid[i].inf.ps.state1 == SNID_STATE1_RESET)
  383. /* No PGID yet */
  384. continue;
  385. if (cdev->private->pgid[last].inf.ps.state1 ==
  386. SNID_STATE1_RESET) {
  387. /* First non-zero PGID */
  388. last = i;
  389. continue;
  390. }
  391. if (cmp_pgid(&cdev->private->pgid[i],
  392. &cdev->private->pgid[last]) == 0)
  393. /* Non-conflicting PGIDs */
  394. continue;
  395. /* PGID mismatch, can't pathgroup. */
  396. CIO_MSG_EVENT(0, "SNID - pgid mismatch for device "
  397. "0.%x.%04x, can't pathgroup\n",
  398. cdev->private->dev_id.ssid,
  399. cdev->private->dev_id.devno);
  400. cdev->private->options.pgroup = 0;
  401. return;
  402. }
  403. if (cdev->private->pgid[last].inf.ps.state1 ==
  404. SNID_STATE1_RESET)
  405. /* No previous pgid found */
  406. memcpy(&cdev->private->pgid[0],
  407. &channel_subsystems[0]->global_pgid,
  408. sizeof(struct pgid));
  409. else
  410. /* Use existing pgid */
  411. memcpy(&cdev->private->pgid[0], &cdev->private->pgid[last],
  412. sizeof(struct pgid));
  413. }
  414. /*
  415. * Function called from device_pgid.c after sense path ground has completed.
  416. */
  417. void
  418. ccw_device_sense_pgid_done(struct ccw_device *cdev, int err)
  419. {
  420. struct subchannel *sch;
  421. sch = to_subchannel(cdev->dev.parent);
  422. switch (err) {
  423. case -EOPNOTSUPP: /* path grouping not supported, use nop instead. */
  424. cdev->private->options.pgroup = 0;
  425. break;
  426. case 0: /* success */
  427. case -EACCES: /* partial success, some paths not operational */
  428. /* Check if all pgids are equal or 0. */
  429. __ccw_device_get_common_pgid(cdev);
  430. break;
  431. case -ETIME: /* Sense path group id stopped by timeout. */
  432. case -EUSERS: /* device is reserved for someone else. */
  433. ccw_device_done(cdev, DEV_STATE_BOXED);
  434. return;
  435. default:
  436. ccw_device_done(cdev, DEV_STATE_NOT_OPER);
  437. return;
  438. }
  439. /* Start Path Group verification. */
  440. cdev->private->state = DEV_STATE_VERIFY;
  441. cdev->private->flags.doverify = 0;
  442. ccw_device_verify_start(cdev);
  443. }
  444. /*
  445. * Start device recognition.
  446. */
  447. int
  448. ccw_device_recognition(struct ccw_device *cdev)
  449. {
  450. struct subchannel *sch;
  451. int ret;
  452. if ((cdev->private->state != DEV_STATE_NOT_OPER) &&
  453. (cdev->private->state != DEV_STATE_BOXED))
  454. return -EINVAL;
  455. sch = to_subchannel(cdev->dev.parent);
  456. ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
  457. if (ret != 0)
  458. /* Couldn't enable the subchannel for i/o. Sick device. */
  459. return ret;
  460. /* After 60s the device recognition is considered to have failed. */
  461. ccw_device_set_timeout(cdev, 60*HZ);
  462. /*
  463. * We used to start here with a sense pgid to find out whether a device
  464. * is locked by someone else. Unfortunately, the sense pgid command
  465. * code has other meanings on devices predating the path grouping
  466. * algorithm, so we start with sense id and box the device after an
  467. * timeout (or if sense pgid during path verification detects the device
  468. * is locked, as may happen on newer devices).
  469. */
  470. cdev->private->flags.recog_done = 0;
  471. cdev->private->state = DEV_STATE_SENSE_ID;
  472. ccw_device_sense_id_start(cdev);
  473. return 0;
  474. }
  475. /*
  476. * Handle timeout in device recognition.
  477. */
  478. static void
  479. ccw_device_recog_timeout(struct ccw_device *cdev, enum dev_event dev_event)
  480. {
  481. int ret;
  482. ret = ccw_device_cancel_halt_clear(cdev);
  483. switch (ret) {
  484. case 0:
  485. ccw_device_recog_done(cdev, DEV_STATE_BOXED);
  486. break;
  487. case -ENODEV:
  488. ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
  489. break;
  490. default:
  491. ccw_device_set_timeout(cdev, 3*HZ);
  492. }
  493. }
  494. void
  495. ccw_device_verify_done(struct ccw_device *cdev, int err)
  496. {
  497. struct subchannel *sch;
  498. sch = to_subchannel(cdev->dev.parent);
  499. /* Update schib - pom may have changed. */
  500. stsch(sch->schid, &sch->schib);
  501. /* Update lpm with verified path mask. */
  502. sch->lpm = sch->vpm;
  503. /* Repeat path verification? */
  504. if (cdev->private->flags.doverify) {
  505. cdev->private->flags.doverify = 0;
  506. ccw_device_verify_start(cdev);
  507. return;
  508. }
  509. switch (err) {
  510. case -EOPNOTSUPP: /* path grouping not supported, just set online. */
  511. cdev->private->options.pgroup = 0;
  512. case 0:
  513. ccw_device_done(cdev, DEV_STATE_ONLINE);
  514. /* Deliver fake irb to device driver, if needed. */
  515. if (cdev->private->flags.fake_irb) {
  516. memset(&cdev->private->irb, 0, sizeof(struct irb));
  517. cdev->private->irb.scsw.cmd.cc = 1;
  518. cdev->private->irb.scsw.cmd.fctl = SCSW_FCTL_START_FUNC;
  519. cdev->private->irb.scsw.cmd.actl = SCSW_ACTL_START_PEND;
  520. cdev->private->irb.scsw.cmd.stctl =
  521. SCSW_STCTL_STATUS_PEND;
  522. cdev->private->flags.fake_irb = 0;
  523. if (cdev->handler)
  524. cdev->handler(cdev, cdev->private->intparm,
  525. &cdev->private->irb);
  526. memset(&cdev->private->irb, 0, sizeof(struct irb));
  527. }
  528. break;
  529. case -ETIME:
  530. /* Reset oper notify indication after verify error. */
  531. cdev->private->flags.donotify = 0;
  532. ccw_device_done(cdev, DEV_STATE_BOXED);
  533. break;
  534. default:
  535. /* Reset oper notify indication after verify error. */
  536. cdev->private->flags.donotify = 0;
  537. if (cdev->online) {
  538. ccw_device_set_timeout(cdev, 0);
  539. dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
  540. } else
  541. ccw_device_done(cdev, DEV_STATE_NOT_OPER);
  542. break;
  543. }
  544. }
  545. /*
  546. * Get device online.
  547. */
  548. int
  549. ccw_device_online(struct ccw_device *cdev)
  550. {
  551. struct subchannel *sch;
  552. int ret;
  553. if ((cdev->private->state != DEV_STATE_OFFLINE) &&
  554. (cdev->private->state != DEV_STATE_BOXED))
  555. return -EINVAL;
  556. sch = to_subchannel(cdev->dev.parent);
  557. if (css_init_done && !get_device(&cdev->dev))
  558. return -ENODEV;
  559. ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
  560. if (ret != 0) {
  561. /* Couldn't enable the subchannel for i/o. Sick device. */
  562. if (ret == -ENODEV)
  563. dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
  564. return ret;
  565. }
  566. /* Do we want to do path grouping? */
  567. if (!cdev->private->options.pgroup) {
  568. /* Start initial path verification. */
  569. cdev->private->state = DEV_STATE_VERIFY;
  570. cdev->private->flags.doverify = 0;
  571. ccw_device_verify_start(cdev);
  572. return 0;
  573. }
  574. /* Do a SensePGID first. */
  575. cdev->private->state = DEV_STATE_SENSE_PGID;
  576. ccw_device_sense_pgid_start(cdev);
  577. return 0;
  578. }
  579. void
  580. ccw_device_disband_done(struct ccw_device *cdev, int err)
  581. {
  582. switch (err) {
  583. case 0:
  584. ccw_device_done(cdev, DEV_STATE_OFFLINE);
  585. break;
  586. case -ETIME:
  587. ccw_device_done(cdev, DEV_STATE_BOXED);
  588. break;
  589. default:
  590. cdev->private->flags.donotify = 0;
  591. dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
  592. ccw_device_done(cdev, DEV_STATE_NOT_OPER);
  593. break;
  594. }
  595. }
  596. /*
  597. * Shutdown device.
  598. */
  599. int
  600. ccw_device_offline(struct ccw_device *cdev)
  601. {
  602. struct subchannel *sch;
  603. /* Allow ccw_device_offline while disconnected. */
  604. if (cdev->private->state == DEV_STATE_DISCONNECTED ||
  605. cdev->private->state == DEV_STATE_NOT_OPER) {
  606. cdev->private->flags.donotify = 0;
  607. ccw_device_done(cdev, DEV_STATE_NOT_OPER);
  608. return 0;
  609. }
  610. if (ccw_device_is_orphan(cdev)) {
  611. ccw_device_done(cdev, DEV_STATE_OFFLINE);
  612. return 0;
  613. }
  614. sch = to_subchannel(cdev->dev.parent);
  615. if (stsch(sch->schid, &sch->schib) || !sch->schib.pmcw.dnv)
  616. return -ENODEV;
  617. if (scsw_actl(&sch->schib.scsw) != 0)
  618. return -EBUSY;
  619. if (cdev->private->state != DEV_STATE_ONLINE)
  620. return -EINVAL;
  621. /* Are we doing path grouping? */
  622. if (!cdev->private->options.pgroup) {
  623. /* No, set state offline immediately. */
  624. ccw_device_done(cdev, DEV_STATE_OFFLINE);
  625. return 0;
  626. }
  627. /* Start Set Path Group commands. */
  628. cdev->private->state = DEV_STATE_DISBAND_PGID;
  629. ccw_device_disband_start(cdev);
  630. return 0;
  631. }
  632. /*
  633. * Handle timeout in device online/offline process.
  634. */
  635. static void
  636. ccw_device_onoff_timeout(struct ccw_device *cdev, enum dev_event dev_event)
  637. {
  638. int ret;
  639. ret = ccw_device_cancel_halt_clear(cdev);
  640. switch (ret) {
  641. case 0:
  642. ccw_device_done(cdev, DEV_STATE_BOXED);
  643. break;
  644. case -ENODEV:
  645. ccw_device_done(cdev, DEV_STATE_NOT_OPER);
  646. break;
  647. default:
  648. ccw_device_set_timeout(cdev, 3*HZ);
  649. }
  650. }
  651. /*
  652. * Handle not oper event in device recognition.
  653. */
  654. static void
  655. ccw_device_recog_notoper(struct ccw_device *cdev, enum dev_event dev_event)
  656. {
  657. ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
  658. }
  659. /*
  660. * Handle not operational event in non-special state.
  661. */
  662. static void ccw_device_generic_notoper(struct ccw_device *cdev,
  663. enum dev_event dev_event)
  664. {
  665. struct subchannel *sch;
  666. cdev->private->state = DEV_STATE_NOT_OPER;
  667. sch = to_subchannel(cdev->dev.parent);
  668. css_schedule_eval(sch->schid);
  669. }
  670. /*
  671. * Handle path verification event.
  672. */
  673. static void
  674. ccw_device_online_verify(struct ccw_device *cdev, enum dev_event dev_event)
  675. {
  676. struct subchannel *sch;
  677. if (cdev->private->state == DEV_STATE_W4SENSE) {
  678. cdev->private->flags.doverify = 1;
  679. return;
  680. }
  681. sch = to_subchannel(cdev->dev.parent);
  682. /*
  683. * Since we might not just be coming from an interrupt from the
  684. * subchannel we have to update the schib.
  685. */
  686. stsch(sch->schid, &sch->schib);
  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 (stsch(sch->schid, &sch->schib))
  927. return;
  928. if (!sch->schib.pmcw.dnv)
  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. /* Re-set some bits in the pmcw that were lost. */
  936. sch->schib.pmcw.csense = 1;
  937. sch->schib.pmcw.ena = 0;
  938. if ((sch->lpm & (sch->lpm - 1)) != 0)
  939. sch->schib.pmcw.mp = 1;
  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. Try 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);