device_fsm.c 34 KB

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