device_fsm.c 33 KB

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