device_fsm.c 34 KB

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