device_fsm.c 32 KB

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