tape_34xx.c 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  1. /*
  2. * drivers/s390/char/tape_34xx.c
  3. * tape device discipline for 3480/3490 tapes.
  4. *
  5. * Copyright IBM Corp. 2001, 2009
  6. * Author(s): Carsten Otte <cotte@de.ibm.com>
  7. * Tuan Ngo-Anh <ngoanh@de.ibm.com>
  8. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  9. */
  10. #define KMSG_COMPONENT "tape_34xx"
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/bio.h>
  14. #include <linux/workqueue.h>
  15. #define TAPE_DBF_AREA tape_34xx_dbf
  16. #include "tape.h"
  17. #include "tape_std.h"
  18. /*
  19. * Pointer to debug area.
  20. */
  21. debug_info_t *TAPE_DBF_AREA = NULL;
  22. EXPORT_SYMBOL(TAPE_DBF_AREA);
  23. #define TAPE34XX_FMT_3480 0
  24. #define TAPE34XX_FMT_3480_2_XF 1
  25. #define TAPE34XX_FMT_3480_XF 2
  26. struct tape_34xx_block_id {
  27. unsigned int wrap : 1;
  28. unsigned int segment : 7;
  29. unsigned int format : 2;
  30. unsigned int block : 22;
  31. };
  32. /*
  33. * A list of block ID's is used to faster seek blocks.
  34. */
  35. struct tape_34xx_sbid {
  36. struct list_head list;
  37. struct tape_34xx_block_id bid;
  38. };
  39. static void tape_34xx_delete_sbid_from(struct tape_device *, int);
  40. /*
  41. * Medium sense for 34xx tapes. There is no 'real' medium sense call.
  42. * So we just do a normal sense.
  43. */
  44. static int
  45. tape_34xx_medium_sense(struct tape_device *device)
  46. {
  47. struct tape_request *request;
  48. unsigned char *sense;
  49. int rc;
  50. request = tape_alloc_request(1, 32);
  51. if (IS_ERR(request)) {
  52. DBF_EXCEPTION(6, "MSEN fail\n");
  53. return PTR_ERR(request);
  54. }
  55. request->op = TO_MSEN;
  56. tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata);
  57. rc = tape_do_io_interruptible(device, request);
  58. if (request->rc == 0) {
  59. sense = request->cpdata;
  60. /*
  61. * This isn't quite correct. But since INTERVENTION_REQUIRED
  62. * means that the drive is 'neither ready nor on-line' it is
  63. * only slightly inaccurate to say there is no tape loaded if
  64. * the drive isn't online...
  65. */
  66. if (sense[0] & SENSE_INTERVENTION_REQUIRED)
  67. tape_med_state_set(device, MS_UNLOADED);
  68. else
  69. tape_med_state_set(device, MS_LOADED);
  70. if (sense[1] & SENSE_WRITE_PROTECT)
  71. device->tape_generic_status |= GMT_WR_PROT(~0);
  72. else
  73. device->tape_generic_status &= ~GMT_WR_PROT(~0);
  74. } else {
  75. DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n",
  76. request->rc);
  77. }
  78. tape_free_request(request);
  79. return rc;
  80. }
  81. struct tape_34xx_work {
  82. struct tape_device *device;
  83. enum tape_op op;
  84. struct work_struct work;
  85. };
  86. /*
  87. * These functions are currently used only to schedule a medium_sense for
  88. * later execution. This is because we get an interrupt whenever a medium
  89. * is inserted but cannot call tape_do_io* from an interrupt context.
  90. * Maybe that's useful for other actions we want to start from the
  91. * interrupt handler.
  92. */
  93. static void
  94. tape_34xx_work_handler(struct work_struct *work)
  95. {
  96. struct tape_34xx_work *p =
  97. container_of(work, struct tape_34xx_work, work);
  98. struct tape_device *device = p->device;
  99. switch(p->op) {
  100. case TO_MSEN:
  101. tape_34xx_medium_sense(device);
  102. break;
  103. default:
  104. DBF_EVENT(3, "T34XX: internal error: unknown work\n");
  105. }
  106. tape_put_device(device);
  107. kfree(p);
  108. }
  109. static int
  110. tape_34xx_schedule_work(struct tape_device *device, enum tape_op op)
  111. {
  112. struct tape_34xx_work *p;
  113. if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
  114. return -ENOMEM;
  115. INIT_WORK(&p->work, tape_34xx_work_handler);
  116. p->device = tape_get_device(device);
  117. p->op = op;
  118. schedule_work(&p->work);
  119. return 0;
  120. }
  121. /*
  122. * Done Handler is called when dev stat = DEVICE-END (successful operation)
  123. */
  124. static inline int
  125. tape_34xx_done(struct tape_request *request)
  126. {
  127. DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
  128. switch (request->op) {
  129. case TO_DSE:
  130. case TO_RUN:
  131. case TO_WRI:
  132. case TO_WTM:
  133. case TO_ASSIGN:
  134. case TO_UNASSIGN:
  135. tape_34xx_delete_sbid_from(request->device, 0);
  136. break;
  137. default:
  138. ;
  139. }
  140. return TAPE_IO_SUCCESS;
  141. }
  142. static inline int
  143. tape_34xx_erp_failed(struct tape_request *request, int rc)
  144. {
  145. DBF_EVENT(3, "Error recovery failed for %s (RC=%d)\n",
  146. tape_op_verbose[request->op], rc);
  147. return rc;
  148. }
  149. static inline int
  150. tape_34xx_erp_succeeded(struct tape_request *request)
  151. {
  152. DBF_EVENT(3, "Error Recovery successful for %s\n",
  153. tape_op_verbose[request->op]);
  154. return tape_34xx_done(request);
  155. }
  156. static inline int
  157. tape_34xx_erp_retry(struct tape_request *request)
  158. {
  159. DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]);
  160. return TAPE_IO_RETRY;
  161. }
  162. /*
  163. * This function is called, when no request is outstanding and we get an
  164. * interrupt
  165. */
  166. static int
  167. tape_34xx_unsolicited_irq(struct tape_device *device, struct irb *irb)
  168. {
  169. if (irb->scsw.cmd.dstat == 0x85) { /* READY */
  170. /* A medium was inserted in the drive. */
  171. DBF_EVENT(6, "xuud med\n");
  172. tape_34xx_delete_sbid_from(device, 0);
  173. tape_34xx_schedule_work(device, TO_MSEN);
  174. } else {
  175. DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
  176. tape_dump_sense_dbf(device, NULL, irb);
  177. }
  178. return TAPE_IO_SUCCESS;
  179. }
  180. /*
  181. * Read Opposite Error Recovery Function:
  182. * Used, when Read Forward does not work
  183. */
  184. static int
  185. tape_34xx_erp_read_opposite(struct tape_device *device,
  186. struct tape_request *request)
  187. {
  188. if (request->op == TO_RFO) {
  189. /*
  190. * We did read forward, but the data could not be read
  191. * *correctly*. We transform the request to a read backward
  192. * and try again.
  193. */
  194. tape_std_read_backward(device, request);
  195. return tape_34xx_erp_retry(request);
  196. }
  197. /*
  198. * We tried to read forward and backward, but hat no
  199. * success -> failed.
  200. */
  201. return tape_34xx_erp_failed(request, -EIO);
  202. }
  203. static int
  204. tape_34xx_erp_bug(struct tape_device *device, struct tape_request *request,
  205. struct irb *irb, int no)
  206. {
  207. if (request->op != TO_ASSIGN) {
  208. dev_err(&device->cdev->dev, "An unexpected condition %d "
  209. "occurred in tape error recovery\n", no);
  210. tape_dump_sense_dbf(device, request, irb);
  211. }
  212. return tape_34xx_erp_failed(request, -EIO);
  213. }
  214. /*
  215. * Handle data overrun between cu and drive. The channel speed might
  216. * be too slow.
  217. */
  218. static int
  219. tape_34xx_erp_overrun(struct tape_device *device, struct tape_request *request,
  220. struct irb *irb)
  221. {
  222. if (irb->ecw[3] == 0x40) {
  223. dev_warn (&device->cdev->dev, "A data overrun occurred between"
  224. " the control unit and tape unit\n");
  225. return tape_34xx_erp_failed(request, -EIO);
  226. }
  227. return tape_34xx_erp_bug(device, request, irb, -1);
  228. }
  229. /*
  230. * Handle record sequence error.
  231. */
  232. static int
  233. tape_34xx_erp_sequence(struct tape_device *device,
  234. struct tape_request *request, struct irb *irb)
  235. {
  236. if (irb->ecw[3] == 0x41) {
  237. /*
  238. * cu detected incorrect block-id sequence on tape.
  239. */
  240. dev_warn (&device->cdev->dev, "The block ID sequence on the "
  241. "tape is incorrect\n");
  242. return tape_34xx_erp_failed(request, -EIO);
  243. }
  244. /*
  245. * Record sequence error bit is set, but erpa does not
  246. * show record sequence error.
  247. */
  248. return tape_34xx_erp_bug(device, request, irb, -2);
  249. }
  250. /*
  251. * This function analyses the tape's sense-data in case of a unit-check.
  252. * If possible, it tries to recover from the error. Else the user is
  253. * informed about the problem.
  254. */
  255. static int
  256. tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
  257. struct irb *irb)
  258. {
  259. int inhibit_cu_recovery;
  260. __u8* sense;
  261. inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0;
  262. sense = irb->ecw;
  263. #ifdef CONFIG_S390_TAPE_BLOCK
  264. if (request->op == TO_BLOCK) {
  265. /*
  266. * Recovery for block device requests. Set the block_position
  267. * to something invalid and retry.
  268. */
  269. device->blk_data.block_position = -1;
  270. if (request->retries-- <= 0)
  271. return tape_34xx_erp_failed(request, -EIO);
  272. else
  273. return tape_34xx_erp_retry(request);
  274. }
  275. #endif
  276. if (
  277. sense[0] & SENSE_COMMAND_REJECT &&
  278. sense[1] & SENSE_WRITE_PROTECT
  279. ) {
  280. if (
  281. request->op == TO_DSE ||
  282. request->op == TO_WRI ||
  283. request->op == TO_WTM
  284. ) {
  285. /* medium is write protected */
  286. return tape_34xx_erp_failed(request, -EACCES);
  287. } else {
  288. return tape_34xx_erp_bug(device, request, irb, -3);
  289. }
  290. }
  291. /*
  292. * Special cases for various tape-states when reaching
  293. * end of recorded area
  294. *
  295. * FIXME: Maybe a special case of the special case:
  296. * sense[0] == SENSE_EQUIPMENT_CHECK &&
  297. * sense[1] == SENSE_DRIVE_ONLINE &&
  298. * sense[3] == 0x47 (Volume Fenced)
  299. *
  300. * This was caused by continued FSF or FSR after an
  301. * 'End Of Data'.
  302. */
  303. if ((
  304. sense[0] == SENSE_DATA_CHECK ||
  305. sense[0] == SENSE_EQUIPMENT_CHECK ||
  306. sense[0] == SENSE_EQUIPMENT_CHECK + SENSE_DEFERRED_UNIT_CHECK
  307. ) && (
  308. sense[1] == SENSE_DRIVE_ONLINE ||
  309. sense[1] == SENSE_BEGINNING_OF_TAPE + SENSE_WRITE_MODE
  310. )) {
  311. switch (request->op) {
  312. /*
  313. * sense[0] == SENSE_DATA_CHECK &&
  314. * sense[1] == SENSE_DRIVE_ONLINE
  315. * sense[3] == 0x36 (End Of Data)
  316. *
  317. * Further seeks might return a 'Volume Fenced'.
  318. */
  319. case TO_FSF:
  320. case TO_FSB:
  321. /* Trying to seek beyond end of recorded area */
  322. return tape_34xx_erp_failed(request, -ENOSPC);
  323. case TO_BSB:
  324. return tape_34xx_erp_retry(request);
  325. /*
  326. * sense[0] == SENSE_DATA_CHECK &&
  327. * sense[1] == SENSE_DRIVE_ONLINE &&
  328. * sense[3] == 0x36 (End Of Data)
  329. */
  330. case TO_LBL:
  331. /* Block could not be located. */
  332. tape_34xx_delete_sbid_from(device, 0);
  333. return tape_34xx_erp_failed(request, -EIO);
  334. case TO_RFO:
  335. /* Read beyond end of recorded area -> 0 bytes read */
  336. return tape_34xx_erp_failed(request, 0);
  337. /*
  338. * sense[0] == SENSE_EQUIPMENT_CHECK &&
  339. * sense[1] == SENSE_DRIVE_ONLINE &&
  340. * sense[3] == 0x38 (Physical End Of Volume)
  341. */
  342. case TO_WRI:
  343. /* Writing at physical end of volume */
  344. return tape_34xx_erp_failed(request, -ENOSPC);
  345. default:
  346. return tape_34xx_erp_failed(request, 0);
  347. }
  348. }
  349. /* Sensing special bits */
  350. if (sense[0] & SENSE_BUS_OUT_CHECK)
  351. return tape_34xx_erp_retry(request);
  352. if (sense[0] & SENSE_DATA_CHECK) {
  353. /*
  354. * hardware failure, damaged tape or improper
  355. * operating conditions
  356. */
  357. switch (sense[3]) {
  358. case 0x23:
  359. /* a read data check occurred */
  360. if ((sense[2] & SENSE_TAPE_SYNC_MODE) ||
  361. inhibit_cu_recovery)
  362. // data check is not permanent, may be
  363. // recovered. We always use async-mode with
  364. // cu-recovery, so this should *never* happen.
  365. return tape_34xx_erp_bug(device, request,
  366. irb, -4);
  367. /* data check is permanent, CU recovery has failed */
  368. dev_warn (&device->cdev->dev, "A read error occurred "
  369. "that cannot be recovered\n");
  370. return tape_34xx_erp_failed(request, -EIO);
  371. case 0x25:
  372. // a write data check occurred
  373. if ((sense[2] & SENSE_TAPE_SYNC_MODE) ||
  374. inhibit_cu_recovery)
  375. // data check is not permanent, may be
  376. // recovered. We always use async-mode with
  377. // cu-recovery, so this should *never* happen.
  378. return tape_34xx_erp_bug(device, request,
  379. irb, -5);
  380. // data check is permanent, cu-recovery has failed
  381. dev_warn (&device->cdev->dev, "A write error on the "
  382. "tape cannot be recovered\n");
  383. return tape_34xx_erp_failed(request, -EIO);
  384. case 0x26:
  385. /* Data Check (read opposite) occurred. */
  386. return tape_34xx_erp_read_opposite(device, request);
  387. case 0x28:
  388. /* ID-Mark at tape start couldn't be written */
  389. dev_warn (&device->cdev->dev, "Writing the ID-mark "
  390. "failed\n");
  391. return tape_34xx_erp_failed(request, -EIO);
  392. case 0x31:
  393. /* Tape void. Tried to read beyond end of device. */
  394. dev_warn (&device->cdev->dev, "Reading the tape beyond"
  395. " the end of the recorded area failed\n");
  396. return tape_34xx_erp_failed(request, -ENOSPC);
  397. case 0x41:
  398. /* Record sequence error. */
  399. dev_warn (&device->cdev->dev, "The tape contains an "
  400. "incorrect block ID sequence\n");
  401. return tape_34xx_erp_failed(request, -EIO);
  402. default:
  403. /* all data checks for 3480 should result in one of
  404. * the above erpa-codes. For 3490, other data-check
  405. * conditions do exist. */
  406. if (device->cdev->id.driver_info == tape_3480)
  407. return tape_34xx_erp_bug(device, request,
  408. irb, -6);
  409. }
  410. }
  411. if (sense[0] & SENSE_OVERRUN)
  412. return tape_34xx_erp_overrun(device, request, irb);
  413. if (sense[1] & SENSE_RECORD_SEQUENCE_ERR)
  414. return tape_34xx_erp_sequence(device, request, irb);
  415. /* Sensing erpa codes */
  416. switch (sense[3]) {
  417. case 0x00:
  418. /* Unit check with erpa code 0. Report and ignore. */
  419. return TAPE_IO_SUCCESS;
  420. case 0x21:
  421. /*
  422. * Data streaming not operational. CU will switch to
  423. * interlock mode. Reissue the command.
  424. */
  425. return tape_34xx_erp_retry(request);
  426. case 0x22:
  427. /*
  428. * Path equipment check. Might be drive adapter error, buffer
  429. * error on the lower interface, internal path not usable,
  430. * or error during cartridge load.
  431. */
  432. dev_warn (&device->cdev->dev, "A path equipment check occurred"
  433. " for the tape device\n");
  434. return tape_34xx_erp_failed(request, -EIO);
  435. case 0x24:
  436. /*
  437. * Load display check. Load display was command was issued,
  438. * but the drive is displaying a drive check message. Can
  439. * be threated as "device end".
  440. */
  441. return tape_34xx_erp_succeeded(request);
  442. case 0x27:
  443. /*
  444. * Command reject. May indicate illegal channel program or
  445. * buffer over/underrun. Since all channel programs are
  446. * issued by this driver and ought be correct, we assume a
  447. * over/underrun situation and retry the channel program.
  448. */
  449. return tape_34xx_erp_retry(request);
  450. case 0x29:
  451. /*
  452. * Function incompatible. Either the tape is idrc compressed
  453. * but the hardware isn't capable to do idrc, or a perform
  454. * subsystem func is issued and the CU is not on-line.
  455. */
  456. return tape_34xx_erp_failed(request, -EIO);
  457. case 0x2a:
  458. /*
  459. * Unsolicited environmental data. An internal counter
  460. * overflows, we can ignore this and reissue the cmd.
  461. */
  462. return tape_34xx_erp_retry(request);
  463. case 0x2b:
  464. /*
  465. * Environmental data present. Indicates either unload
  466. * completed ok or read buffered log command completed ok.
  467. */
  468. if (request->op == TO_RUN) {
  469. /* Rewind unload completed ok. */
  470. tape_med_state_set(device, MS_UNLOADED);
  471. return tape_34xx_erp_succeeded(request);
  472. }
  473. /* tape_34xx doesn't use read buffered log commands. */
  474. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  475. case 0x2c:
  476. /*
  477. * Permanent equipment check. CU has tried recovery, but
  478. * did not succeed.
  479. */
  480. return tape_34xx_erp_failed(request, -EIO);
  481. case 0x2d:
  482. /* Data security erase failure. */
  483. if (request->op == TO_DSE)
  484. return tape_34xx_erp_failed(request, -EIO);
  485. /* Data security erase failure, but no such command issued. */
  486. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  487. case 0x2e:
  488. /*
  489. * Not capable. This indicates either that the drive fails
  490. * reading the format id mark or that that format specified
  491. * is not supported by the drive.
  492. */
  493. dev_warn (&device->cdev->dev, "The tape unit cannot process "
  494. "the tape format\n");
  495. return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
  496. case 0x30:
  497. /* The medium is write protected. */
  498. dev_warn (&device->cdev->dev, "The tape medium is write-"
  499. "protected\n");
  500. return tape_34xx_erp_failed(request, -EACCES);
  501. case 0x32:
  502. // Tension loss. We cannot recover this, it's an I/O error.
  503. dev_warn (&device->cdev->dev, "The tape does not have the "
  504. "required tape tension\n");
  505. return tape_34xx_erp_failed(request, -EIO);
  506. case 0x33:
  507. /*
  508. * Load Failure. The cartridge was not inserted correctly or
  509. * the tape is not threaded correctly.
  510. */
  511. dev_warn (&device->cdev->dev, "The tape unit failed to load"
  512. " the cartridge\n");
  513. tape_34xx_delete_sbid_from(device, 0);
  514. return tape_34xx_erp_failed(request, -EIO);
  515. case 0x34:
  516. /*
  517. * Unload failure. The drive cannot maintain tape tension
  518. * and control tape movement during an unload operation.
  519. */
  520. dev_warn (&device->cdev->dev, "Automatic unloading of the tape"
  521. " cartridge failed\n");
  522. if (request->op == TO_RUN)
  523. return tape_34xx_erp_failed(request, -EIO);
  524. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  525. case 0x35:
  526. /*
  527. * Drive equipment check. One of the following:
  528. * - cu cannot recover from a drive detected error
  529. * - a check code message is shown on drive display
  530. * - the cartridge loader does not respond correctly
  531. * - a failure occurs during an index, load, or unload cycle
  532. */
  533. dev_warn (&device->cdev->dev, "An equipment check has occurred"
  534. " on the tape unit\n");
  535. return tape_34xx_erp_failed(request, -EIO);
  536. case 0x36:
  537. if (device->cdev->id.driver_info == tape_3490)
  538. /* End of data. */
  539. return tape_34xx_erp_failed(request, -EIO);
  540. /* This erpa is reserved for 3480 */
  541. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  542. case 0x37:
  543. /*
  544. * Tape length error. The tape is shorter than reported in
  545. * the beginning-of-tape data.
  546. */
  547. dev_warn (&device->cdev->dev, "The tape information states an"
  548. " incorrect length\n");
  549. return tape_34xx_erp_failed(request, -EIO);
  550. case 0x38:
  551. /*
  552. * Physical end of tape. A read/write operation reached
  553. * the physical end of tape.
  554. */
  555. if (request->op==TO_WRI ||
  556. request->op==TO_DSE ||
  557. request->op==TO_WTM)
  558. return tape_34xx_erp_failed(request, -ENOSPC);
  559. return tape_34xx_erp_failed(request, -EIO);
  560. case 0x39:
  561. /* Backward at Beginning of tape. */
  562. return tape_34xx_erp_failed(request, -EIO);
  563. case 0x3a:
  564. /* Drive switched to not ready. */
  565. dev_warn (&device->cdev->dev, "The tape unit is not ready\n");
  566. return tape_34xx_erp_failed(request, -EIO);
  567. case 0x3b:
  568. /* Manual rewind or unload. This causes an I/O error. */
  569. dev_warn (&device->cdev->dev, "The tape medium has been "
  570. "rewound or unloaded manually\n");
  571. tape_34xx_delete_sbid_from(device, 0);
  572. return tape_34xx_erp_failed(request, -EIO);
  573. case 0x42:
  574. /*
  575. * Degraded mode. A condition that can cause degraded
  576. * performance is detected.
  577. */
  578. dev_warn (&device->cdev->dev, "The tape subsystem is running "
  579. "in degraded mode\n");
  580. return tape_34xx_erp_retry(request);
  581. case 0x43:
  582. /* Drive not ready. */
  583. tape_34xx_delete_sbid_from(device, 0);
  584. tape_med_state_set(device, MS_UNLOADED);
  585. /* Some commands commands are successful even in this case */
  586. if (sense[1] & SENSE_DRIVE_ONLINE) {
  587. switch(request->op) {
  588. case TO_ASSIGN:
  589. case TO_UNASSIGN:
  590. case TO_DIS:
  591. case TO_NOP:
  592. return tape_34xx_done(request);
  593. break;
  594. default:
  595. break;
  596. }
  597. }
  598. return tape_34xx_erp_failed(request, -ENOMEDIUM);
  599. case 0x44:
  600. /* Locate Block unsuccessful. */
  601. if (request->op != TO_BLOCK && request->op != TO_LBL)
  602. /* No locate block was issued. */
  603. return tape_34xx_erp_bug(device, request,
  604. irb, sense[3]);
  605. return tape_34xx_erp_failed(request, -EIO);
  606. case 0x45:
  607. /* The drive is assigned to a different channel path. */
  608. dev_warn (&device->cdev->dev, "The tape unit is already "
  609. "assigned\n");
  610. return tape_34xx_erp_failed(request, -EIO);
  611. case 0x46:
  612. /*
  613. * Drive not on-line. Drive may be switched offline,
  614. * the power supply may be switched off or
  615. * the drive address may not be set correctly.
  616. */
  617. dev_warn (&device->cdev->dev, "The tape unit is not online\n");
  618. return tape_34xx_erp_failed(request, -EIO);
  619. case 0x47:
  620. /* Volume fenced. CU reports volume integrity is lost. */
  621. dev_warn (&device->cdev->dev, "The control unit has fenced "
  622. "access to the tape volume\n");
  623. tape_34xx_delete_sbid_from(device, 0);
  624. return tape_34xx_erp_failed(request, -EIO);
  625. case 0x48:
  626. /* Log sense data and retry request. */
  627. return tape_34xx_erp_retry(request);
  628. case 0x49:
  629. /* Bus out check. A parity check error on the bus was found. */
  630. dev_warn (&device->cdev->dev, "A parity error occurred on the "
  631. "tape bus\n");
  632. return tape_34xx_erp_failed(request, -EIO);
  633. case 0x4a:
  634. /* Control unit erp failed. */
  635. dev_warn (&device->cdev->dev, "I/O error recovery failed on "
  636. "the tape control unit\n");
  637. return tape_34xx_erp_failed(request, -EIO);
  638. case 0x4b:
  639. /*
  640. * CU and drive incompatible. The drive requests micro-program
  641. * patches, which are not available on the CU.
  642. */
  643. dev_warn (&device->cdev->dev, "The tape unit requires a "
  644. "firmware update\n");
  645. return tape_34xx_erp_failed(request, -EIO);
  646. case 0x4c:
  647. /*
  648. * Recovered Check-One failure. Cu develops a hardware error,
  649. * but is able to recover.
  650. */
  651. return tape_34xx_erp_retry(request);
  652. case 0x4d:
  653. if (device->cdev->id.driver_info == tape_3490)
  654. /*
  655. * Resetting event received. Since the driver does
  656. * not support resetting event recovery (which has to
  657. * be handled by the I/O Layer), retry our command.
  658. */
  659. return tape_34xx_erp_retry(request);
  660. /* This erpa is reserved for 3480. */
  661. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  662. case 0x4e:
  663. if (device->cdev->id.driver_info == tape_3490) {
  664. /*
  665. * Maximum block size exceeded. This indicates, that
  666. * the block to be written is larger than allowed for
  667. * buffered mode.
  668. */
  669. dev_warn (&device->cdev->dev, "The maximum block size"
  670. " for buffered mode is exceeded\n");
  671. return tape_34xx_erp_failed(request, -ENOBUFS);
  672. }
  673. /* This erpa is reserved for 3480. */
  674. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  675. case 0x50:
  676. /*
  677. * Read buffered log (Overflow). CU is running in extended
  678. * buffered log mode, and a counter overflows. This should
  679. * never happen, since we're never running in extended
  680. * buffered log mode.
  681. */
  682. return tape_34xx_erp_retry(request);
  683. case 0x51:
  684. /*
  685. * Read buffered log (EOV). EOF processing occurs while the
  686. * CU is in extended buffered log mode. This should never
  687. * happen, since we're never running in extended buffered
  688. * log mode.
  689. */
  690. return tape_34xx_erp_retry(request);
  691. case 0x52:
  692. /* End of Volume complete. Rewind unload completed ok. */
  693. if (request->op == TO_RUN) {
  694. tape_med_state_set(device, MS_UNLOADED);
  695. tape_34xx_delete_sbid_from(device, 0);
  696. return tape_34xx_erp_succeeded(request);
  697. }
  698. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  699. case 0x53:
  700. /* Global command intercept. */
  701. return tape_34xx_erp_retry(request);
  702. case 0x54:
  703. /* Channel interface recovery (temporary). */
  704. return tape_34xx_erp_retry(request);
  705. case 0x55:
  706. /* Channel interface recovery (permanent). */
  707. dev_warn (&device->cdev->dev, "A channel interface error cannot be"
  708. " recovered\n");
  709. return tape_34xx_erp_failed(request, -EIO);
  710. case 0x56:
  711. /* Channel protocol error. */
  712. dev_warn (&device->cdev->dev, "A channel protocol error "
  713. "occurred\n");
  714. return tape_34xx_erp_failed(request, -EIO);
  715. case 0x57:
  716. if (device->cdev->id.driver_info == tape_3480) {
  717. /* Attention intercept. */
  718. return tape_34xx_erp_retry(request);
  719. } else {
  720. /* Global status intercept. */
  721. return tape_34xx_erp_retry(request);
  722. }
  723. case 0x5a:
  724. /*
  725. * Tape length incompatible. The tape inserted is too long,
  726. * which could cause damage to the tape or the drive.
  727. */
  728. dev_warn (&device->cdev->dev, "The tape unit does not support "
  729. "the tape length\n");
  730. return tape_34xx_erp_failed(request, -EIO);
  731. case 0x5b:
  732. /* Format 3480 XF incompatible */
  733. if (sense[1] & SENSE_BEGINNING_OF_TAPE)
  734. /* The tape will get overwritten. */
  735. return tape_34xx_erp_retry(request);
  736. dev_warn (&device->cdev->dev, "The tape unit does not support"
  737. " format 3480 XF\n");
  738. return tape_34xx_erp_failed(request, -EIO);
  739. case 0x5c:
  740. /* Format 3480-2 XF incompatible */
  741. dev_warn (&device->cdev->dev, "The tape unit does not support tape "
  742. "format 3480-2 XF\n");
  743. return tape_34xx_erp_failed(request, -EIO);
  744. case 0x5d:
  745. /* Tape length violation. */
  746. dev_warn (&device->cdev->dev, "The tape unit does not support"
  747. " the current tape length\n");
  748. return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
  749. case 0x5e:
  750. /* Compaction algorithm incompatible. */
  751. dev_warn (&device->cdev->dev, "The tape unit does not support"
  752. " the compaction algorithm\n");
  753. return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
  754. /* The following erpas should have been covered earlier. */
  755. case 0x23: /* Read data check. */
  756. case 0x25: /* Write data check. */
  757. case 0x26: /* Data check (read opposite). */
  758. case 0x28: /* Write id mark check. */
  759. case 0x31: /* Tape void. */
  760. case 0x40: /* Overrun error. */
  761. case 0x41: /* Record sequence error. */
  762. /* All other erpas are reserved for future use. */
  763. default:
  764. return tape_34xx_erp_bug(device, request, irb, sense[3]);
  765. }
  766. }
  767. /*
  768. * 3480/3490 interrupt handler
  769. */
  770. static int
  771. tape_34xx_irq(struct tape_device *device, struct tape_request *request,
  772. struct irb *irb)
  773. {
  774. if (request == NULL)
  775. return tape_34xx_unsolicited_irq(device, irb);
  776. if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) &&
  777. (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) &&
  778. (request->op == TO_WRI)) {
  779. /* Write at end of volume */
  780. return tape_34xx_erp_failed(request, -ENOSPC);
  781. }
  782. if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
  783. return tape_34xx_unit_check(device, request, irb);
  784. if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
  785. /*
  786. * A unit exception occurs on skipping over a tapemark block.
  787. */
  788. if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) {
  789. if (request->op == TO_BSB || request->op == TO_FSB)
  790. request->rescnt++;
  791. else
  792. DBF_EVENT(5, "Unit Exception!\n");
  793. }
  794. return tape_34xx_done(request);
  795. }
  796. DBF_EVENT(6, "xunknownirq\n");
  797. tape_dump_sense_dbf(device, request, irb);
  798. return TAPE_IO_STOP;
  799. }
  800. /*
  801. * ioctl_overload
  802. */
  803. static int
  804. tape_34xx_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
  805. {
  806. if (cmd == TAPE390_DISPLAY) {
  807. struct display_struct disp;
  808. if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)) != 0)
  809. return -EFAULT;
  810. return tape_std_display(device, &disp);
  811. } else
  812. return -EINVAL;
  813. }
  814. static inline void
  815. tape_34xx_append_new_sbid(struct tape_34xx_block_id bid, struct list_head *l)
  816. {
  817. struct tape_34xx_sbid * new_sbid;
  818. new_sbid = kmalloc(sizeof(*new_sbid), GFP_ATOMIC);
  819. if (!new_sbid)
  820. return;
  821. new_sbid->bid = bid;
  822. list_add(&new_sbid->list, l);
  823. }
  824. /*
  825. * Build up the search block ID list. The block ID consists of a logical
  826. * block number and a hardware specific part. The hardware specific part
  827. * helps the tape drive to speed up searching for a specific block.
  828. */
  829. static void
  830. tape_34xx_add_sbid(struct tape_device *device, struct tape_34xx_block_id bid)
  831. {
  832. struct list_head * sbid_list;
  833. struct tape_34xx_sbid * sbid;
  834. struct list_head * l;
  835. /*
  836. * immediately return if there is no list at all or the block to add
  837. * is located in segment 1 of wrap 0 because this position is used
  838. * if no hardware position data is supplied.
  839. */
  840. sbid_list = (struct list_head *) device->discdata;
  841. if (!sbid_list || (bid.segment < 2 && bid.wrap == 0))
  842. return;
  843. /*
  844. * Search the position where to insert the new entry. Hardware
  845. * acceleration uses only the segment and wrap number. So we
  846. * need only one entry for a specific wrap/segment combination.
  847. * If there is a block with a lower number but the same hard-
  848. * ware position data we just update the block number in the
  849. * existing entry.
  850. */
  851. list_for_each(l, sbid_list) {
  852. sbid = list_entry(l, struct tape_34xx_sbid, list);
  853. if (
  854. (sbid->bid.segment == bid.segment) &&
  855. (sbid->bid.wrap == bid.wrap)
  856. ) {
  857. if (bid.block < sbid->bid.block)
  858. sbid->bid = bid;
  859. else return;
  860. break;
  861. }
  862. /* Sort in according to logical block number. */
  863. if (bid.block < sbid->bid.block) {
  864. tape_34xx_append_new_sbid(bid, l->prev);
  865. break;
  866. }
  867. }
  868. /* List empty or new block bigger than last entry. */
  869. if (l == sbid_list)
  870. tape_34xx_append_new_sbid(bid, l->prev);
  871. DBF_LH(4, "Current list is:\n");
  872. list_for_each(l, sbid_list) {
  873. sbid = list_entry(l, struct tape_34xx_sbid, list);
  874. DBF_LH(4, "%d:%03d@%05d\n",
  875. sbid->bid.wrap,
  876. sbid->bid.segment,
  877. sbid->bid.block
  878. );
  879. }
  880. }
  881. /*
  882. * Delete all entries from the search block ID list that belong to tape blocks
  883. * equal or higher than the given number.
  884. */
  885. static void
  886. tape_34xx_delete_sbid_from(struct tape_device *device, int from)
  887. {
  888. struct list_head * sbid_list;
  889. struct tape_34xx_sbid * sbid;
  890. struct list_head * l;
  891. struct list_head * n;
  892. sbid_list = (struct list_head *) device->discdata;
  893. if (!sbid_list)
  894. return;
  895. list_for_each_safe(l, n, sbid_list) {
  896. sbid = list_entry(l, struct tape_34xx_sbid, list);
  897. if (sbid->bid.block >= from) {
  898. DBF_LH(4, "Delete sbid %d:%03d@%05d\n",
  899. sbid->bid.wrap,
  900. sbid->bid.segment,
  901. sbid->bid.block
  902. );
  903. list_del(l);
  904. kfree(sbid);
  905. }
  906. }
  907. }
  908. /*
  909. * Merge hardware position data into a block id.
  910. */
  911. static void
  912. tape_34xx_merge_sbid(
  913. struct tape_device * device,
  914. struct tape_34xx_block_id * bid
  915. ) {
  916. struct tape_34xx_sbid * sbid;
  917. struct tape_34xx_sbid * sbid_to_use;
  918. struct list_head * sbid_list;
  919. struct list_head * l;
  920. sbid_list = (struct list_head *) device->discdata;
  921. bid->wrap = 0;
  922. bid->segment = 1;
  923. if (!sbid_list || list_empty(sbid_list))
  924. return;
  925. sbid_to_use = NULL;
  926. list_for_each(l, sbid_list) {
  927. sbid = list_entry(l, struct tape_34xx_sbid, list);
  928. if (sbid->bid.block >= bid->block)
  929. break;
  930. sbid_to_use = sbid;
  931. }
  932. if (sbid_to_use) {
  933. bid->wrap = sbid_to_use->bid.wrap;
  934. bid->segment = sbid_to_use->bid.segment;
  935. DBF_LH(4, "Use %d:%03d@%05d for %05d\n",
  936. sbid_to_use->bid.wrap,
  937. sbid_to_use->bid.segment,
  938. sbid_to_use->bid.block,
  939. bid->block
  940. );
  941. }
  942. }
  943. static int
  944. tape_34xx_setup_device(struct tape_device * device)
  945. {
  946. int rc;
  947. struct list_head * discdata;
  948. DBF_EVENT(6, "34xx device setup\n");
  949. if ((rc = tape_std_assign(device)) == 0) {
  950. if ((rc = tape_34xx_medium_sense(device)) != 0) {
  951. DBF_LH(3, "34xx medium sense returned %d\n", rc);
  952. }
  953. }
  954. discdata = kmalloc(sizeof(struct list_head), GFP_KERNEL);
  955. if (discdata) {
  956. INIT_LIST_HEAD(discdata);
  957. device->discdata = discdata;
  958. }
  959. return rc;
  960. }
  961. static void
  962. tape_34xx_cleanup_device(struct tape_device *device)
  963. {
  964. tape_std_unassign(device);
  965. if (device->discdata) {
  966. tape_34xx_delete_sbid_from(device, 0);
  967. kfree(device->discdata);
  968. device->discdata = NULL;
  969. }
  970. }
  971. /*
  972. * MTTELL: Tell block. Return the number of block relative to current file.
  973. */
  974. static int
  975. tape_34xx_mttell(struct tape_device *device, int mt_count)
  976. {
  977. struct {
  978. struct tape_34xx_block_id cbid;
  979. struct tape_34xx_block_id dbid;
  980. } __attribute__ ((packed)) block_id;
  981. int rc;
  982. rc = tape_std_read_block_id(device, (__u64 *) &block_id);
  983. if (rc)
  984. return rc;
  985. tape_34xx_add_sbid(device, block_id.cbid);
  986. return block_id.cbid.block;
  987. }
  988. /*
  989. * MTSEEK: seek to the specified block.
  990. */
  991. static int
  992. tape_34xx_mtseek(struct tape_device *device, int mt_count)
  993. {
  994. struct tape_request *request;
  995. struct tape_34xx_block_id * bid;
  996. if (mt_count > 0x3fffff) {
  997. DBF_EXCEPTION(6, "xsee parm\n");
  998. return -EINVAL;
  999. }
  1000. request = tape_alloc_request(3, 4);
  1001. if (IS_ERR(request))
  1002. return PTR_ERR(request);
  1003. /* setup ccws */
  1004. request->op = TO_LBL;
  1005. bid = (struct tape_34xx_block_id *) request->cpdata;
  1006. bid->format = (*device->modeset_byte & 0x08) ?
  1007. TAPE34XX_FMT_3480_XF : TAPE34XX_FMT_3480;
  1008. bid->block = mt_count;
  1009. tape_34xx_merge_sbid(device, bid);
  1010. tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
  1011. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  1012. tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
  1013. /* execute it */
  1014. return tape_do_io_free(device, request);
  1015. }
  1016. #ifdef CONFIG_S390_TAPE_BLOCK
  1017. /*
  1018. * Tape block read for 34xx.
  1019. */
  1020. static struct tape_request *
  1021. tape_34xx_bread(struct tape_device *device, struct request *req)
  1022. {
  1023. struct tape_request *request;
  1024. struct ccw1 *ccw;
  1025. int count = 0;
  1026. unsigned off;
  1027. char *dst;
  1028. struct bio_vec *bv;
  1029. struct req_iterator iter;
  1030. struct tape_34xx_block_id * start_block;
  1031. DBF_EVENT(6, "xBREDid:");
  1032. /* Count the number of blocks for the request. */
  1033. rq_for_each_segment(bv, req, iter)
  1034. count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
  1035. /* Allocate the ccw request. */
  1036. request = tape_alloc_request(3+count+1, 8);
  1037. if (IS_ERR(request))
  1038. return request;
  1039. /* Setup ccws. */
  1040. request->op = TO_BLOCK;
  1041. start_block = (struct tape_34xx_block_id *) request->cpdata;
  1042. start_block->block = blk_rq_pos(req) >> TAPEBLOCK_HSEC_S2B;
  1043. DBF_EVENT(6, "start_block = %i\n", start_block->block);
  1044. ccw = request->cpaddr;
  1045. ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
  1046. /*
  1047. * We always setup a nop after the mode set ccw. This slot is
  1048. * used in tape_std_check_locate to insert a locate ccw if the
  1049. * current tape position doesn't match the start block to be read.
  1050. * The second nop will be filled with a read block id which is in
  1051. * turn used by tape_34xx_free_bread to populate the segment bid
  1052. * table.
  1053. */
  1054. ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
  1055. ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
  1056. rq_for_each_segment(bv, req, iter) {
  1057. dst = kmap(bv->bv_page) + bv->bv_offset;
  1058. for (off = 0; off < bv->bv_len; off += TAPEBLOCK_HSEC_SIZE) {
  1059. ccw->flags = CCW_FLAG_CC;
  1060. ccw->cmd_code = READ_FORWARD;
  1061. ccw->count = TAPEBLOCK_HSEC_SIZE;
  1062. set_normalized_cda(ccw, (void*) __pa(dst));
  1063. ccw++;
  1064. dst += TAPEBLOCK_HSEC_SIZE;
  1065. }
  1066. }
  1067. ccw = tape_ccw_end(ccw, NOP, 0, NULL);
  1068. DBF_EVENT(6, "xBREDccwg\n");
  1069. return request;
  1070. }
  1071. static void
  1072. tape_34xx_free_bread (struct tape_request *request)
  1073. {
  1074. struct ccw1* ccw;
  1075. ccw = request->cpaddr;
  1076. if ((ccw + 2)->cmd_code == READ_BLOCK_ID) {
  1077. struct {
  1078. struct tape_34xx_block_id cbid;
  1079. struct tape_34xx_block_id dbid;
  1080. } __attribute__ ((packed)) *rbi_data;
  1081. rbi_data = request->cpdata;
  1082. if (request->device)
  1083. tape_34xx_add_sbid(request->device, rbi_data->cbid);
  1084. }
  1085. /* Last ccw is a nop and doesn't need clear_normalized_cda */
  1086. for (; ccw->flags & CCW_FLAG_CC; ccw++)
  1087. if (ccw->cmd_code == READ_FORWARD)
  1088. clear_normalized_cda(ccw);
  1089. tape_free_request(request);
  1090. }
  1091. /*
  1092. * check_locate is called just before the tape request is passed to
  1093. * the common io layer for execution. It has to check the current
  1094. * tape position and insert a locate ccw if it doesn't match the
  1095. * start block for the request.
  1096. */
  1097. static void
  1098. tape_34xx_check_locate(struct tape_device *device, struct tape_request *request)
  1099. {
  1100. struct tape_34xx_block_id * start_block;
  1101. start_block = (struct tape_34xx_block_id *) request->cpdata;
  1102. if (start_block->block == device->blk_data.block_position)
  1103. return;
  1104. DBF_LH(4, "Block seek(%06d+%06d)\n", start_block->block, device->bof);
  1105. start_block->wrap = 0;
  1106. start_block->segment = 1;
  1107. start_block->format = (*device->modeset_byte & 0x08) ?
  1108. TAPE34XX_FMT_3480_XF :
  1109. TAPE34XX_FMT_3480;
  1110. start_block->block = start_block->block + device->bof;
  1111. tape_34xx_merge_sbid(device, start_block);
  1112. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  1113. tape_ccw_cc(request->cpaddr + 2, READ_BLOCK_ID, 8, request->cpdata);
  1114. }
  1115. #endif
  1116. /*
  1117. * List of 3480/3490 magnetic tape commands.
  1118. */
  1119. static tape_mtop_fn tape_34xx_mtop[TAPE_NR_MTOPS] = {
  1120. [MTRESET] = tape_std_mtreset,
  1121. [MTFSF] = tape_std_mtfsf,
  1122. [MTBSF] = tape_std_mtbsf,
  1123. [MTFSR] = tape_std_mtfsr,
  1124. [MTBSR] = tape_std_mtbsr,
  1125. [MTWEOF] = tape_std_mtweof,
  1126. [MTREW] = tape_std_mtrew,
  1127. [MTOFFL] = tape_std_mtoffl,
  1128. [MTNOP] = tape_std_mtnop,
  1129. [MTRETEN] = tape_std_mtreten,
  1130. [MTBSFM] = tape_std_mtbsfm,
  1131. [MTFSFM] = tape_std_mtfsfm,
  1132. [MTEOM] = tape_std_mteom,
  1133. [MTERASE] = tape_std_mterase,
  1134. [MTRAS1] = NULL,
  1135. [MTRAS2] = NULL,
  1136. [MTRAS3] = NULL,
  1137. [MTSETBLK] = tape_std_mtsetblk,
  1138. [MTSETDENSITY] = NULL,
  1139. [MTSEEK] = tape_34xx_mtseek,
  1140. [MTTELL] = tape_34xx_mttell,
  1141. [MTSETDRVBUFFER] = NULL,
  1142. [MTFSS] = NULL,
  1143. [MTBSS] = NULL,
  1144. [MTWSM] = NULL,
  1145. [MTLOCK] = NULL,
  1146. [MTUNLOCK] = NULL,
  1147. [MTLOAD] = tape_std_mtload,
  1148. [MTUNLOAD] = tape_std_mtunload,
  1149. [MTCOMPRESSION] = tape_std_mtcompression,
  1150. [MTSETPART] = NULL,
  1151. [MTMKPART] = NULL
  1152. };
  1153. /*
  1154. * Tape discipline structure for 3480 and 3490.
  1155. */
  1156. static struct tape_discipline tape_discipline_34xx = {
  1157. .owner = THIS_MODULE,
  1158. .setup_device = tape_34xx_setup_device,
  1159. .cleanup_device = tape_34xx_cleanup_device,
  1160. .process_eov = tape_std_process_eov,
  1161. .irq = tape_34xx_irq,
  1162. .read_block = tape_std_read_block,
  1163. .write_block = tape_std_write_block,
  1164. #ifdef CONFIG_S390_TAPE_BLOCK
  1165. .bread = tape_34xx_bread,
  1166. .free_bread = tape_34xx_free_bread,
  1167. .check_locate = tape_34xx_check_locate,
  1168. #endif
  1169. .ioctl_fn = tape_34xx_ioctl,
  1170. .mtop_array = tape_34xx_mtop
  1171. };
  1172. static struct ccw_device_id tape_34xx_ids[] = {
  1173. { CCW_DEVICE_DEVTYPE(0x3480, 0, 0x3480, 0), .driver_info = tape_3480},
  1174. { CCW_DEVICE_DEVTYPE(0x3490, 0, 0x3490, 0), .driver_info = tape_3490},
  1175. { /* end of list */ },
  1176. };
  1177. static int
  1178. tape_34xx_online(struct ccw_device *cdev)
  1179. {
  1180. return tape_generic_online(
  1181. dev_get_drvdata(&cdev->dev),
  1182. &tape_discipline_34xx
  1183. );
  1184. }
  1185. static struct ccw_driver tape_34xx_driver = {
  1186. .name = "tape_34xx",
  1187. .owner = THIS_MODULE,
  1188. .ids = tape_34xx_ids,
  1189. .probe = tape_generic_probe,
  1190. .remove = tape_generic_remove,
  1191. .set_online = tape_34xx_online,
  1192. .set_offline = tape_generic_offline,
  1193. .freeze = tape_generic_pm_suspend,
  1194. };
  1195. static int
  1196. tape_34xx_init (void)
  1197. {
  1198. int rc;
  1199. TAPE_DBF_AREA = debug_register ( "tape_34xx", 2, 2, 4*sizeof(long));
  1200. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1201. #ifdef DBF_LIKE_HELL
  1202. debug_set_level(TAPE_DBF_AREA, 6);
  1203. #endif
  1204. DBF_EVENT(3, "34xx init\n");
  1205. /* Register driver for 3480/3490 tapes. */
  1206. rc = ccw_driver_register(&tape_34xx_driver);
  1207. if (rc)
  1208. DBF_EVENT(3, "34xx init failed\n");
  1209. else
  1210. DBF_EVENT(3, "34xx registered\n");
  1211. return rc;
  1212. }
  1213. static void
  1214. tape_34xx_exit(void)
  1215. {
  1216. ccw_driver_unregister(&tape_34xx_driver);
  1217. debug_unregister(TAPE_DBF_AREA);
  1218. }
  1219. MODULE_DEVICE_TABLE(ccw, tape_34xx_ids);
  1220. MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH");
  1221. MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape device driver");
  1222. MODULE_LICENSE("GPL");
  1223. module_init(tape_34xx_init);
  1224. module_exit(tape_34xx_exit);