tape_3590.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  1. /*
  2. * drivers/s390/char/tape_3590.c
  3. * tape device discipline for 3590 tapes.
  4. *
  5. * Copyright (C) IBM Corp. 2001,2006
  6. * Author(s): Stefan Bader <shbader@de.ibm.com>
  7. * Michael Holzheu <holzheu@de.ibm.com>
  8. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/init.h>
  12. #include <linux/bio.h>
  13. #define TAPE_DBF_AREA tape_3590_dbf
  14. #include "tape.h"
  15. #include "tape_std.h"
  16. #include "tape_3590.h"
  17. /*
  18. * Pointer to debug area.
  19. */
  20. debug_info_t *TAPE_DBF_AREA = NULL;
  21. EXPORT_SYMBOL(TAPE_DBF_AREA);
  22. /*******************************************************************
  23. * Error Recovery fuctions:
  24. * - Read Opposite: implemented
  25. * - Read Device (buffered) log: BRA
  26. * - Read Library log: BRA
  27. * - Swap Devices: BRA
  28. * - Long Busy: BRA
  29. * - Special Intercept: BRA
  30. * - Read Alternate: implemented
  31. *******************************************************************/
  32. #define PRINTK_HEADER "TAPE_3590: "
  33. static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = {
  34. [0x00] = "",
  35. [0x10] = "Lost Sense",
  36. [0x11] = "Assigned Elsewhere",
  37. [0x12] = "Allegiance Reset",
  38. [0x13] = "Shared Access Violation",
  39. [0x20] = "Command Reject",
  40. [0x21] = "Configuration Error",
  41. [0x22] = "Protection Exception",
  42. [0x23] = "Write Protect",
  43. [0x24] = "Write Length",
  44. [0x25] = "Read-Only Format",
  45. [0x31] = "Beginning of Partition",
  46. [0x33] = "End of Partition",
  47. [0x34] = "End of Data",
  48. [0x35] = "Block not found",
  49. [0x40] = "Device Intervention",
  50. [0x41] = "Loader Intervention",
  51. [0x42] = "Library Intervention",
  52. [0x50] = "Write Error",
  53. [0x51] = "Erase Error",
  54. [0x52] = "Formatting Error",
  55. [0x53] = "Read Error",
  56. [0x54] = "Unsupported Format",
  57. [0x55] = "No Formatting",
  58. [0x56] = "Positioning lost",
  59. [0x57] = "Read Length",
  60. [0x60] = "Unsupported Medium",
  61. [0x61] = "Medium Length Error",
  62. [0x62] = "Medium removed",
  63. [0x64] = "Load Check",
  64. [0x65] = "Unload Check",
  65. [0x70] = "Equipment Check",
  66. [0x71] = "Bus out Check",
  67. [0x72] = "Protocol Error",
  68. [0x73] = "Interface Error",
  69. [0x74] = "Overrun",
  70. [0x75] = "Halt Signal",
  71. [0x90] = "Device fenced",
  72. [0x91] = "Device Path fenced",
  73. [0xa0] = "Volume misplaced",
  74. [0xa1] = "Volume inaccessible",
  75. [0xa2] = "Volume in input",
  76. [0xa3] = "Volume ejected",
  77. [0xa4] = "All categories reserved",
  78. [0xa5] = "Duplicate Volume",
  79. [0xa6] = "Library Manager Offline",
  80. [0xa7] = "Library Output Station full",
  81. [0xa8] = "Vision System non-operational",
  82. [0xa9] = "Library Manager Equipment Check",
  83. [0xaa] = "Library Equipment Check",
  84. [0xab] = "All Library Cells full",
  85. [0xac] = "No Cleaner Volumes in Library",
  86. [0xad] = "I/O Station door open",
  87. [0xae] = "Subsystem environmental alert",
  88. };
  89. /*
  90. * 3590 IOCTL Overload
  91. */
  92. static int
  93. tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
  94. {
  95. switch (cmd) {
  96. case TAPE390_DISPLAY: {
  97. struct display_struct disp;
  98. if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)))
  99. return -EFAULT;
  100. return tape_std_display(device, &disp);
  101. }
  102. default:
  103. return -EINVAL; /* no additional ioctls */
  104. }
  105. }
  106. /*
  107. * SENSE Medium: Get Sense data about medium state
  108. */
  109. static int
  110. tape_3590_sense_medium(struct tape_device *device)
  111. {
  112. struct tape_request *request;
  113. request = tape_alloc_request(1, 128);
  114. if (IS_ERR(request))
  115. return PTR_ERR(request);
  116. request->op = TO_MSEN;
  117. tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata);
  118. return tape_do_io_free(device, request);
  119. }
  120. /*
  121. * MTTELL: Tell block. Return the number of block relative to current file.
  122. */
  123. static int
  124. tape_3590_mttell(struct tape_device *device, int mt_count)
  125. {
  126. __u64 block_id;
  127. int rc;
  128. rc = tape_std_read_block_id(device, &block_id);
  129. if (rc)
  130. return rc;
  131. return block_id >> 32;
  132. }
  133. /*
  134. * MTSEEK: seek to the specified block.
  135. */
  136. static int
  137. tape_3590_mtseek(struct tape_device *device, int count)
  138. {
  139. struct tape_request *request;
  140. DBF_EVENT(6, "xsee id: %x\n", count);
  141. request = tape_alloc_request(3, 4);
  142. if (IS_ERR(request))
  143. return PTR_ERR(request);
  144. request->op = TO_LBL;
  145. tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
  146. *(__u32 *) request->cpdata = count;
  147. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  148. tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
  149. return tape_do_io_free(device, request);
  150. }
  151. /*
  152. * Read Opposite Error Recovery Function:
  153. * Used, when Read Forward does not work
  154. */
  155. static void
  156. tape_3590_read_opposite(struct tape_device *device,
  157. struct tape_request *request)
  158. {
  159. struct tape_3590_disc_data *data;
  160. /*
  161. * We have allocated 4 ccws in tape_std_read, so we can now
  162. * transform the request to a read backward, followed by a
  163. * forward space block.
  164. */
  165. request->op = TO_RBA;
  166. tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
  167. data = device->discdata;
  168. tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op,
  169. device->char_data.idal_buf);
  170. tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
  171. tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
  172. DBF_EVENT(6, "xrop ccwg\n");
  173. }
  174. /*
  175. * Read Attention Msg
  176. * This should be done after an interrupt with attention bit (0x80)
  177. * in device state.
  178. *
  179. * After a "read attention message" request there are two possible
  180. * results:
  181. *
  182. * 1. A unit check is presented, when attention sense is present (e.g. when
  183. * a medium has been unloaded). The attention sense comes then
  184. * together with the unit check. The recovery action is either "retry"
  185. * (in case there is an attention message pending) or "permanent error".
  186. *
  187. * 2. The attention msg is written to the "read subsystem data" buffer.
  188. * In this case we probably should print it to the console.
  189. */
  190. static int
  191. tape_3590_read_attmsg(struct tape_device *device)
  192. {
  193. struct tape_request *request;
  194. char *buf;
  195. request = tape_alloc_request(3, 4096);
  196. if (IS_ERR(request))
  197. return PTR_ERR(request);
  198. request->op = TO_READ_ATTMSG;
  199. buf = request->cpdata;
  200. buf[0] = PREP_RD_SS_DATA;
  201. buf[6] = RD_ATTMSG; /* read att msg */
  202. tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf);
  203. tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12);
  204. tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
  205. return tape_do_io_free(device, request);
  206. }
  207. /*
  208. * These functions are used to schedule follow-up actions from within an
  209. * interrupt context (like unsolicited interrupts).
  210. */
  211. struct work_handler_data {
  212. struct tape_device *device;
  213. enum tape_op op;
  214. struct work_struct work;
  215. };
  216. static void
  217. tape_3590_work_handler(void *data)
  218. {
  219. struct work_handler_data *p = data;
  220. switch (p->op) {
  221. case TO_MSEN:
  222. tape_3590_sense_medium(p->device);
  223. break;
  224. case TO_READ_ATTMSG:
  225. tape_3590_read_attmsg(p->device);
  226. break;
  227. default:
  228. DBF_EVENT(3, "T3590: work handler undefined for "
  229. "operation 0x%02x\n", p->op);
  230. }
  231. tape_put_device(p->device);
  232. kfree(p);
  233. }
  234. static int
  235. tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
  236. {
  237. struct work_handler_data *p;
  238. if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
  239. return -ENOMEM;
  240. INIT_WORK(&p->work, tape_3590_work_handler, p);
  241. p->device = tape_get_device_reference(device);
  242. p->op = op;
  243. schedule_work(&p->work);
  244. return 0;
  245. }
  246. #ifdef CONFIG_S390_TAPE_BLOCK
  247. /*
  248. * Tape Block READ
  249. */
  250. static struct tape_request *
  251. tape_3590_bread(struct tape_device *device, struct request *req)
  252. {
  253. struct tape_request *request;
  254. struct ccw1 *ccw;
  255. int count = 0, start_block, i;
  256. unsigned off;
  257. char *dst;
  258. struct bio_vec *bv;
  259. struct bio *bio;
  260. DBF_EVENT(6, "xBREDid:");
  261. start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
  262. DBF_EVENT(6, "start_block = %i\n", start_block);
  263. rq_for_each_bio(bio, req) {
  264. bio_for_each_segment(bv, bio, i) {
  265. count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
  266. }
  267. }
  268. request = tape_alloc_request(2 + count + 1, 4);
  269. if (IS_ERR(request))
  270. return request;
  271. request->op = TO_BLOCK;
  272. *(__u32 *) request->cpdata = start_block;
  273. ccw = request->cpaddr;
  274. ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
  275. /*
  276. * We always setup a nop after the mode set ccw. This slot is
  277. * used in tape_std_check_locate to insert a locate ccw if the
  278. * current tape position doesn't match the start block to be read.
  279. */
  280. ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
  281. rq_for_each_bio(bio, req) {
  282. bio_for_each_segment(bv, bio, i) {
  283. dst = page_address(bv->bv_page) + bv->bv_offset;
  284. for (off = 0; off < bv->bv_len;
  285. off += TAPEBLOCK_HSEC_SIZE) {
  286. ccw->flags = CCW_FLAG_CC;
  287. ccw->cmd_code = READ_FORWARD;
  288. ccw->count = TAPEBLOCK_HSEC_SIZE;
  289. set_normalized_cda(ccw, (void *) __pa(dst));
  290. ccw++;
  291. dst += TAPEBLOCK_HSEC_SIZE;
  292. }
  293. if (off > bv->bv_len)
  294. BUG();
  295. }
  296. }
  297. ccw = tape_ccw_end(ccw, NOP, 0, NULL);
  298. DBF_EVENT(6, "xBREDccwg\n");
  299. return request;
  300. }
  301. static void
  302. tape_3590_free_bread(struct tape_request *request)
  303. {
  304. struct ccw1 *ccw;
  305. /* Last ccw is a nop and doesn't need clear_normalized_cda */
  306. for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
  307. if (ccw->cmd_code == READ_FORWARD)
  308. clear_normalized_cda(ccw);
  309. tape_free_request(request);
  310. }
  311. /*
  312. * check_locate is called just before the tape request is passed to
  313. * the common io layer for execution. It has to check the current
  314. * tape position and insert a locate ccw if it doesn't match the
  315. * start block for the request.
  316. */
  317. static void
  318. tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
  319. {
  320. __u32 *start_block;
  321. start_block = (__u32 *) request->cpdata;
  322. if (*start_block != device->blk_data.block_position) {
  323. /* Add the start offset of the file to get the real block. */
  324. *start_block += device->bof;
  325. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  326. }
  327. }
  328. #endif
  329. /*
  330. * The done handler is called at device/channel end and wakes up the sleeping
  331. * process
  332. */
  333. static int
  334. tape_3590_done(struct tape_device *device, struct tape_request *request)
  335. {
  336. struct tape_3590_med_sense *sense;
  337. DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
  338. switch (request->op) {
  339. case TO_BSB:
  340. case TO_BSF:
  341. case TO_DSE:
  342. case TO_FSB:
  343. case TO_FSF:
  344. case TO_LBL:
  345. case TO_RFO:
  346. case TO_RBA:
  347. case TO_REW:
  348. case TO_WRI:
  349. case TO_WTM:
  350. case TO_BLOCK:
  351. case TO_LOAD:
  352. tape_med_state_set(device, MS_LOADED);
  353. break;
  354. case TO_RUN:
  355. tape_med_state_set(device, MS_UNLOADED);
  356. break;
  357. case TO_MSEN:
  358. sense = (struct tape_3590_med_sense *) request->cpdata;
  359. if (sense->masst == MSENSE_UNASSOCIATED)
  360. tape_med_state_set(device, MS_UNLOADED);
  361. if (sense->masst == MSENSE_ASSOCIATED_MOUNT)
  362. tape_med_state_set(device, MS_LOADED);
  363. break;
  364. case TO_RBI: /* RBI seems to succeed even without medium loaded. */
  365. case TO_NOP: /* Same to NOP. */
  366. case TO_READ_CONFIG:
  367. case TO_READ_ATTMSG:
  368. case TO_DIS:
  369. case TO_ASSIGN:
  370. case TO_UNASSIGN:
  371. break;
  372. case TO_SIZE:
  373. break;
  374. }
  375. return TAPE_IO_SUCCESS;
  376. }
  377. /*
  378. * This fuction is called, when error recovery was successfull
  379. */
  380. static inline int
  381. tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
  382. {
  383. DBF_EVENT(3, "Error Recovery successfull for %s\n",
  384. tape_op_verbose[request->op]);
  385. return tape_3590_done(device, request);
  386. }
  387. /*
  388. * This fuction is called, when error recovery was not successfull
  389. */
  390. static inline int
  391. tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
  392. struct irb *irb, int rc)
  393. {
  394. DBF_EVENT(3, "Error Recovery failed for %s\n",
  395. tape_op_verbose[request->op]);
  396. tape_dump_sense_dbf(device, request, irb);
  397. return rc;
  398. }
  399. /*
  400. * Error Recovery do retry
  401. */
  402. static inline int
  403. tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
  404. struct irb *irb)
  405. {
  406. DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
  407. tape_dump_sense_dbf(device, request, irb);
  408. return TAPE_IO_RETRY;
  409. }
  410. /*
  411. * Handle unsolicited interrupts
  412. */
  413. static int
  414. tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
  415. {
  416. if (irb->scsw.dstat == DEV_STAT_CHN_END)
  417. /* Probably result of halt ssch */
  418. return TAPE_IO_PENDING;
  419. else if (irb->scsw.dstat == 0x85)
  420. /* Device Ready -> check medium state */
  421. tape_3590_schedule_work(device, TO_MSEN);
  422. else if (irb->scsw.dstat & DEV_STAT_ATTENTION)
  423. tape_3590_schedule_work(device, TO_READ_ATTMSG);
  424. else {
  425. DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
  426. PRINT_WARN("Unsolicited IRQ (Device End) caught.\n");
  427. tape_dump_sense(device, NULL, irb);
  428. }
  429. return TAPE_IO_SUCCESS;
  430. }
  431. /*
  432. * Basic Recovery routine
  433. */
  434. static int
  435. tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
  436. struct irb *irb, int rc)
  437. {
  438. struct tape_3590_sense *sense;
  439. sense = (struct tape_3590_sense *) irb->ecw;
  440. switch (sense->bra) {
  441. case SENSE_BRA_PER:
  442. return tape_3590_erp_failed(device, request, irb, rc);
  443. case SENSE_BRA_CONT:
  444. return tape_3590_erp_succeded(device, request);
  445. case SENSE_BRA_RE:
  446. return tape_3590_erp_retry(device, request, irb);
  447. case SENSE_BRA_DRE:
  448. return tape_3590_erp_failed(device, request, irb, rc);
  449. default:
  450. PRINT_ERR("Unknown BRA %x - This should not happen!\n",
  451. sense->bra);
  452. BUG();
  453. return TAPE_IO_STOP;
  454. }
  455. }
  456. /*
  457. * RDL: Read Device (buffered) log
  458. */
  459. static int
  460. tape_3590_erp_read_buf_log(struct tape_device *device,
  461. struct tape_request *request, struct irb *irb)
  462. {
  463. /*
  464. * We just do the basic error recovery at the moment (retry).
  465. * Perhaps in the future, we read the log and dump it somewhere...
  466. */
  467. return tape_3590_erp_basic(device, request, irb, -EIO);
  468. }
  469. /*
  470. * SWAP: Swap Devices
  471. */
  472. static int
  473. tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
  474. struct irb *irb)
  475. {
  476. /*
  477. * This error recovery should swap the tapes
  478. * if the original has a problem. The operation
  479. * should proceed with the new tape... this
  480. * should probably be done in user space!
  481. */
  482. PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id);
  483. return tape_3590_erp_basic(device, request, irb, -EIO);
  484. }
  485. /*
  486. * LBY: Long Busy
  487. */
  488. static int
  489. tape_3590_erp_long_busy(struct tape_device *device,
  490. struct tape_request *request, struct irb *irb)
  491. {
  492. /* FIXME: how about WAITING for a minute ? */
  493. PRINT_WARN("(%s): Device is busy! Please wait a minute!\n",
  494. device->cdev->dev.bus_id);
  495. return tape_3590_erp_basic(device, request, irb, -EBUSY);
  496. }
  497. /*
  498. * SPI: Special Intercept
  499. */
  500. static int
  501. tape_3590_erp_special_interrupt(struct tape_device *device,
  502. struct tape_request *request, struct irb *irb)
  503. {
  504. return tape_3590_erp_basic(device, request, irb, -EIO);
  505. }
  506. /*
  507. * RDA: Read Alternate
  508. */
  509. static int
  510. tape_3590_erp_read_alternate(struct tape_device *device,
  511. struct tape_request *request, struct irb *irb)
  512. {
  513. struct tape_3590_disc_data *data;
  514. /*
  515. * The issued Read Backward or Read Previous command is not
  516. * supported by the device
  517. * The recovery action should be to issue another command:
  518. * Read Revious: if Read Backward is not supported
  519. * Read Backward: if Read Previous is not supported
  520. */
  521. data = device->discdata;
  522. if (data->read_back_op == READ_PREVIOUS) {
  523. DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
  524. device->cdev_id);
  525. data->read_back_op = READ_BACKWARD;
  526. } else {
  527. DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
  528. device->cdev_id);
  529. data->read_back_op = READ_PREVIOUS;
  530. }
  531. tape_3590_read_opposite(device, request);
  532. return tape_3590_erp_retry(device, request, irb);
  533. }
  534. /*
  535. * Error Recovery read opposite
  536. */
  537. static int
  538. tape_3590_erp_read_opposite(struct tape_device *device,
  539. struct tape_request *request, struct irb *irb)
  540. {
  541. switch (request->op) {
  542. case TO_RFO:
  543. /*
  544. * We did read forward, but the data could not be read.
  545. * We will read backward and then skip forward again.
  546. */
  547. tape_3590_read_opposite(device, request);
  548. return tape_3590_erp_retry(device, request, irb);
  549. case TO_RBA:
  550. /* We tried to read forward and backward, but hat no success */
  551. return tape_3590_erp_failed(device, request, irb, -EIO);
  552. break;
  553. default:
  554. PRINT_WARN("read_opposite_recovery_called_with_op: %s\n",
  555. tape_op_verbose[request->op]);
  556. return tape_3590_erp_failed(device, request, irb, -EIO);
  557. }
  558. }
  559. /*
  560. * Print an MIM (Media Information Message) (message code f0)
  561. */
  562. static void
  563. tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
  564. {
  565. struct tape_3590_sense *sense;
  566. sense = (struct tape_3590_sense *) irb->ecw;
  567. /* Exception Message */
  568. switch (sense->fmt.f70.emc) {
  569. case 0x02:
  570. PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id);
  571. break;
  572. case 0x03:
  573. PRINT_WARN("(%s): Data degraded in partion %i\n",
  574. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  575. break;
  576. case 0x04:
  577. PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id);
  578. break;
  579. case 0x05:
  580. PRINT_WARN("(%s): Medium degraded in partition %i\n",
  581. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  582. break;
  583. case 0x06:
  584. PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id);
  585. break;
  586. case 0x07:
  587. PRINT_WARN("(%s): Medium Exception 0x%02x\n",
  588. device->cdev->dev.bus_id, sense->fmt.f70.md);
  589. break;
  590. default:
  591. PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n",
  592. device->cdev->dev.bus_id, sense->fmt.f70.emc);
  593. break;
  594. }
  595. /* Service Message */
  596. switch (sense->fmt.f70.smc) {
  597. case 0x02:
  598. PRINT_WARN("(%s): Reference Media maintenance procedure %i\n",
  599. device->cdev->dev.bus_id, sense->fmt.f70.md);
  600. break;
  601. default:
  602. PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n",
  603. device->cdev->dev.bus_id, sense->fmt.f70.smc);
  604. break;
  605. }
  606. }
  607. /*
  608. * Print an I/O Subsystem Service Information Message (message code f1)
  609. */
  610. static void
  611. tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
  612. {
  613. struct tape_3590_sense *sense;
  614. sense = (struct tape_3590_sense *) irb->ecw;
  615. /* Exception Message */
  616. switch (sense->fmt.f71.emc) {
  617. case 0x01:
  618. PRINT_WARN("(%s): Effect of failure is unknown\n",
  619. device->cdev->dev.bus_id);
  620. break;
  621. case 0x02:
  622. PRINT_WARN("(%s): CU Exception - no performance impact\n",
  623. device->cdev->dev.bus_id);
  624. break;
  625. case 0x03:
  626. PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n",
  627. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  628. break;
  629. case 0x04:
  630. PRINT_WARN("(%s): CU Exception on device path 0x%02x\n",
  631. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  632. break;
  633. case 0x05:
  634. PRINT_WARN("(%s): CU Exception on library path 0x%02x\n",
  635. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  636. break;
  637. case 0x06:
  638. PRINT_WARN("(%s): CU Exception on node 0x%02x\n",
  639. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  640. break;
  641. case 0x07:
  642. PRINT_WARN("(%s): CU Exception on partition 0x%02x\n",
  643. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  644. break;
  645. default:
  646. PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n",
  647. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  648. }
  649. /* Service Message */
  650. switch (sense->fmt.f71.smc) {
  651. case 0x01:
  652. PRINT_WARN("(%s): Repair impact is unknown\n",
  653. device->cdev->dev.bus_id);
  654. break;
  655. case 0x02:
  656. PRINT_WARN("(%s): Repair will not impact cu performance\n",
  657. device->cdev->dev.bus_id);
  658. break;
  659. case 0x03:
  660. if (sense->fmt.f71.mdf == 0)
  661. PRINT_WARN("(%s): Repair will disable node "
  662. "0x%x on CU\n",
  663. device->cdev->dev.bus_id,
  664. sense->fmt.f71.md[1]);
  665. else
  666. PRINT_WARN("(%s): Repair will disable nodes "
  667. "(0x%x-0x%x) on CU\n",
  668. device->cdev->dev.bus_id,
  669. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  670. break;
  671. case 0x04:
  672. if (sense->fmt.f71.mdf == 0)
  673. PRINT_WARN("(%s): Repair will disable cannel path "
  674. "0x%x on CU\n",
  675. device->cdev->dev.bus_id,
  676. sense->fmt.f71.md[1]);
  677. else
  678. PRINT_WARN("(%s): Repair will disable cannel paths "
  679. "(0x%x-0x%x) on CU\n",
  680. device->cdev->dev.bus_id,
  681. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  682. break;
  683. case 0x05:
  684. if (sense->fmt.f71.mdf == 0)
  685. PRINT_WARN("(%s): Repair will disable device path "
  686. "0x%x on CU\n",
  687. device->cdev->dev.bus_id,
  688. sense->fmt.f71.md[1]);
  689. else
  690. PRINT_WARN("(%s): Repair will disable device paths "
  691. "(0x%x-0x%x) on CU\n",
  692. device->cdev->dev.bus_id,
  693. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  694. break;
  695. case 0x06:
  696. if (sense->fmt.f71.mdf == 0)
  697. PRINT_WARN("(%s): Repair will disable library path "
  698. "0x%x on CU\n",
  699. device->cdev->dev.bus_id,
  700. sense->fmt.f71.md[1]);
  701. else
  702. PRINT_WARN("(%s): Repair will disable library paths "
  703. "(0x%x-0x%x) on CU\n",
  704. device->cdev->dev.bus_id,
  705. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  706. break;
  707. case 0x07:
  708. PRINT_WARN("(%s): Repair will disable access to CU\n",
  709. device->cdev->dev.bus_id);
  710. break;
  711. default:
  712. PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n",
  713. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  714. }
  715. }
  716. /*
  717. * Print an Device Subsystem Service Information Message (message code f2)
  718. */
  719. static void
  720. tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
  721. {
  722. struct tape_3590_sense *sense;
  723. sense = (struct tape_3590_sense *) irb->ecw;
  724. /* Exception Message */
  725. switch (sense->fmt.f71.emc) {
  726. case 0x01:
  727. PRINT_WARN("(%s): Effect of failure is unknown\n",
  728. device->cdev->dev.bus_id);
  729. break;
  730. case 0x02:
  731. PRINT_WARN("(%s): DV Exception - no performance impact\n",
  732. device->cdev->dev.bus_id);
  733. break;
  734. case 0x03:
  735. PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n",
  736. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  737. break;
  738. case 0x04:
  739. PRINT_WARN("(%s): DV Exception on loader 0x%02x\n",
  740. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  741. break;
  742. case 0x05:
  743. PRINT_WARN("(%s): DV Exception on message display 0x%02x\n",
  744. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  745. break;
  746. case 0x06:
  747. PRINT_WARN("(%s): DV Exception in tape path\n",
  748. device->cdev->dev.bus_id);
  749. break;
  750. case 0x07:
  751. PRINT_WARN("(%s): DV Exception in drive\n",
  752. device->cdev->dev.bus_id);
  753. break;
  754. default:
  755. PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n",
  756. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  757. }
  758. /* Service Message */
  759. switch (sense->fmt.f71.smc) {
  760. case 0x01:
  761. PRINT_WARN("(%s): Repair impact is unknown\n",
  762. device->cdev->dev.bus_id);
  763. break;
  764. case 0x02:
  765. PRINT_WARN("(%s): Repair will not impact device performance\n",
  766. device->cdev->dev.bus_id);
  767. break;
  768. case 0x03:
  769. if (sense->fmt.f71.mdf == 0)
  770. PRINT_WARN("(%s): Repair will disable channel path "
  771. "0x%x on DV\n",
  772. device->cdev->dev.bus_id,
  773. sense->fmt.f71.md[1]);
  774. else
  775. PRINT_WARN("(%s): Repair will disable channel path "
  776. "(0x%x-0x%x) on DV\n",
  777. device->cdev->dev.bus_id,
  778. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  779. break;
  780. case 0x04:
  781. if (sense->fmt.f71.mdf == 0)
  782. PRINT_WARN("(%s): Repair will disable interface 0x%x "
  783. "on DV\n",
  784. device->cdev->dev.bus_id,
  785. sense->fmt.f71.md[1]);
  786. else
  787. PRINT_WARN("(%s): Repair will disable interfaces "
  788. "(0x%x-0x%x) on DV\n",
  789. device->cdev->dev.bus_id,
  790. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  791. break;
  792. case 0x05:
  793. if (sense->fmt.f71.mdf == 0)
  794. PRINT_WARN("(%s): Repair will disable loader 0x%x "
  795. "on DV\n",
  796. device->cdev->dev.bus_id,
  797. sense->fmt.f71.md[1]);
  798. else
  799. PRINT_WARN("(%s): Repair will disable loader "
  800. "(0x%x-0x%x) on DV\n",
  801. device->cdev->dev.bus_id,
  802. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  803. break;
  804. case 0x07:
  805. PRINT_WARN("(%s): Repair will disable access to DV\n",
  806. device->cdev->dev.bus_id);
  807. break;
  808. case 0x08:
  809. if (sense->fmt.f71.mdf == 0)
  810. PRINT_WARN("(%s): Repair will disable message "
  811. "display 0x%x on DV\n",
  812. device->cdev->dev.bus_id,
  813. sense->fmt.f71.md[1]);
  814. else
  815. PRINT_WARN("(%s): Repair will disable message "
  816. "displays (0x%x-0x%x) on DV\n",
  817. device->cdev->dev.bus_id,
  818. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  819. break;
  820. case 0x09:
  821. PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id);
  822. break;
  823. default:
  824. PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n",
  825. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  826. }
  827. }
  828. /*
  829. * Print standard ERA Message
  830. */
  831. static void
  832. tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
  833. {
  834. struct tape_3590_sense *sense;
  835. sense = (struct tape_3590_sense *) irb->ecw;
  836. if (sense->mc == 0)
  837. return;
  838. if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
  839. if (tape_3590_msg[sense->mc] != NULL)
  840. PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id,
  841. tape_3590_msg[sense->mc]);
  842. else {
  843. PRINT_WARN("(%s): Message Code 0x%x\n",
  844. device->cdev->dev.bus_id, sense->mc);
  845. }
  846. return;
  847. }
  848. if (sense->mc == 0xf0) {
  849. /* Standard Media Information Message */
  850. PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, "
  851. "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id,
  852. sense->fmt.f70.sev, sense->mc,
  853. sense->fmt.f70.emc, sense->fmt.f70.smc,
  854. sense->fmt.f70.refcode, sense->fmt.f70.mid,
  855. sense->fmt.f70.fid);
  856. tape_3590_print_mim_msg_f0(device, irb);
  857. return;
  858. }
  859. if (sense->mc == 0xf1) {
  860. /* Standard I/O Subsystem Service Information Message */
  861. PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, "
  862. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  863. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  864. device->cdev->id.dev_model,
  865. sense->mc, sense->fmt.f71.emc,
  866. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  867. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  868. tape_3590_print_io_sim_msg_f1(device, irb);
  869. return;
  870. }
  871. if (sense->mc == 0xf2) {
  872. /* Standard Device Service Information Message */
  873. PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, "
  874. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  875. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  876. device->cdev->id.dev_model,
  877. sense->mc, sense->fmt.f71.emc,
  878. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  879. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  880. tape_3590_print_dev_sim_msg_f2(device, irb);
  881. return;
  882. }
  883. if (sense->mc == 0xf3) {
  884. /* Standard Library Service Information Message */
  885. return;
  886. }
  887. PRINT_WARN("(%s): Device Message(%x)\n",
  888. device->cdev->dev.bus_id, sense->mc);
  889. }
  890. /*
  891. * 3590 error Recovery routine:
  892. * If possible, it tries to recover from the error. If this is not possible,
  893. * inform the user about the problem.
  894. */
  895. static int
  896. tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
  897. struct irb *irb)
  898. {
  899. struct tape_3590_sense *sense;
  900. int rc;
  901. #ifdef CONFIG_S390_TAPE_BLOCK
  902. if (request->op == TO_BLOCK) {
  903. /*
  904. * Recovery for block device requests. Set the block_position
  905. * to something invalid and retry.
  906. */
  907. device->blk_data.block_position = -1;
  908. if (request->retries-- <= 0)
  909. return tape_3590_erp_failed(device, request, irb, -EIO);
  910. else
  911. return tape_3590_erp_retry(device, request, irb);
  912. }
  913. #endif
  914. sense = (struct tape_3590_sense *) irb->ecw;
  915. /*
  916. * First check all RC-QRCs where we want to do something special
  917. * - "break": basic error recovery is done
  918. * - "goto out:": just print error message if available
  919. */
  920. rc = -EIO;
  921. switch (sense->rc_rqc) {
  922. case 0x1110:
  923. tape_3590_print_era_msg(device, irb);
  924. return tape_3590_erp_read_buf_log(device, request, irb);
  925. case 0x2011:
  926. tape_3590_print_era_msg(device, irb);
  927. return tape_3590_erp_read_alternate(device, request, irb);
  928. case 0x2230:
  929. case 0x2231:
  930. tape_3590_print_era_msg(device, irb);
  931. return tape_3590_erp_special_interrupt(device, request, irb);
  932. case 0x3010:
  933. DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
  934. device->cdev_id);
  935. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  936. case 0x3012:
  937. DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
  938. device->cdev_id);
  939. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  940. case 0x3020:
  941. DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
  942. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  943. case 0x3122:
  944. DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
  945. device->cdev_id);
  946. return tape_3590_erp_basic(device, request, irb, -EIO);
  947. case 0x3123:
  948. DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
  949. device->cdev_id);
  950. tape_med_state_set(device, MS_UNLOADED);
  951. return tape_3590_erp_basic(device, request, irb, 0);
  952. case 0x4010:
  953. /*
  954. * print additional msg since default msg
  955. * "device intervention" is not very meaningfull
  956. */
  957. PRINT_WARN("(%s): Tape operation when medium not loaded\n",
  958. device->cdev->dev.bus_id);
  959. tape_med_state_set(device, MS_UNLOADED);
  960. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  961. case 0x4012: /* Device Long Busy */
  962. tape_3590_print_era_msg(device, irb);
  963. return tape_3590_erp_long_busy(device, request, irb);
  964. case 0x5010:
  965. if (sense->rac == 0xd0) {
  966. /* Swap */
  967. tape_3590_print_era_msg(device, irb);
  968. return tape_3590_erp_swap(device, request, irb);
  969. }
  970. if (sense->rac == 0x26) {
  971. /* Read Opposite */
  972. tape_3590_print_era_msg(device, irb);
  973. return tape_3590_erp_read_opposite(device, request,
  974. irb);
  975. }
  976. return tape_3590_erp_basic(device, request, irb, -EIO);
  977. case 0x5020:
  978. case 0x5021:
  979. case 0x5022:
  980. case 0x5040:
  981. case 0x5041:
  982. case 0x5042:
  983. tape_3590_print_era_msg(device, irb);
  984. return tape_3590_erp_swap(device, request, irb);
  985. case 0x5110:
  986. case 0x5111:
  987. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  988. case 0x5120:
  989. case 0x1120:
  990. tape_med_state_set(device, MS_UNLOADED);
  991. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  992. case 0x6020:
  993. PRINT_WARN("(%s): Cartridge of wrong type ?\n",
  994. device->cdev->dev.bus_id);
  995. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  996. case 0x8011:
  997. PRINT_WARN("(%s): Another host has reserved the tape device\n",
  998. device->cdev->dev.bus_id);
  999. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1000. case 0x8013:
  1001. PRINT_WARN("(%s): Another host has priviliged access to the "
  1002. "tape device\n", device->cdev->dev.bus_id);
  1003. PRINT_WARN("(%s): To solve the problem unload the current "
  1004. "cartridge!\n", device->cdev->dev.bus_id);
  1005. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1006. default:
  1007. return tape_3590_erp_basic(device, request, irb, -EIO);
  1008. }
  1009. }
  1010. /*
  1011. * 3590 interrupt handler:
  1012. */
  1013. static int
  1014. tape_3590_irq(struct tape_device *device, struct tape_request *request,
  1015. struct irb *irb)
  1016. {
  1017. if (request == NULL)
  1018. return tape_3590_unsolicited_irq(device, irb);
  1019. if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) &&
  1020. (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) {
  1021. /* Write at end of volume */
  1022. DBF_EVENT(2, "End of volume\n");
  1023. return tape_3590_erp_failed(device, request, irb, -ENOSPC);
  1024. }
  1025. if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
  1026. return tape_3590_unit_check(device, request, irb);
  1027. if (irb->scsw.dstat & DEV_STAT_DEV_END) {
  1028. if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) {
  1029. if (request->op == TO_FSB || request->op == TO_BSB)
  1030. request->rescnt++;
  1031. else
  1032. DBF_EVENT(5, "Unit Exception!\n");
  1033. }
  1034. return tape_3590_done(device, request);
  1035. }
  1036. if (irb->scsw.dstat & DEV_STAT_CHN_END) {
  1037. DBF_EVENT(2, "cannel end\n");
  1038. return TAPE_IO_PENDING;
  1039. }
  1040. if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
  1041. DBF_EVENT(2, "Unit Attention when busy..\n");
  1042. return TAPE_IO_PENDING;
  1043. }
  1044. DBF_EVENT(6, "xunknownirq\n");
  1045. PRINT_ERR("Unexpected interrupt.\n");
  1046. PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]);
  1047. tape_dump_sense(device, request, irb);
  1048. return TAPE_IO_STOP;
  1049. }
  1050. /*
  1051. * Setup device function
  1052. */
  1053. static int
  1054. tape_3590_setup_device(struct tape_device *device)
  1055. {
  1056. int rc;
  1057. struct tape_3590_disc_data *data;
  1058. DBF_EVENT(6, "3590 device setup\n");
  1059. data = kmalloc(sizeof(struct tape_3590_disc_data),
  1060. GFP_KERNEL | GFP_DMA);
  1061. if (data == NULL)
  1062. return -ENOMEM;
  1063. data->read_back_op = READ_PREVIOUS;
  1064. device->discdata = data;
  1065. if ((rc = tape_std_assign(device)) == 0) {
  1066. /* Try to find out if medium is loaded */
  1067. if ((rc = tape_3590_sense_medium(device)) != 0)
  1068. DBF_LH(3, "3590 medium sense returned %d\n", rc);
  1069. }
  1070. return rc;
  1071. }
  1072. /*
  1073. * Cleanup device function
  1074. */
  1075. static void
  1076. tape_3590_cleanup_device(struct tape_device *device)
  1077. {
  1078. flush_scheduled_work();
  1079. tape_std_unassign(device);
  1080. kfree(device->discdata);
  1081. device->discdata = NULL;
  1082. }
  1083. /*
  1084. * List of 3590 magnetic tape commands.
  1085. */
  1086. static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
  1087. [MTRESET] = tape_std_mtreset,
  1088. [MTFSF] = tape_std_mtfsf,
  1089. [MTBSF] = tape_std_mtbsf,
  1090. [MTFSR] = tape_std_mtfsr,
  1091. [MTBSR] = tape_std_mtbsr,
  1092. [MTWEOF] = tape_std_mtweof,
  1093. [MTREW] = tape_std_mtrew,
  1094. [MTOFFL] = tape_std_mtoffl,
  1095. [MTNOP] = tape_std_mtnop,
  1096. [MTRETEN] = tape_std_mtreten,
  1097. [MTBSFM] = tape_std_mtbsfm,
  1098. [MTFSFM] = tape_std_mtfsfm,
  1099. [MTEOM] = tape_std_mteom,
  1100. [MTERASE] = tape_std_mterase,
  1101. [MTRAS1] = NULL,
  1102. [MTRAS2] = NULL,
  1103. [MTRAS3] = NULL,
  1104. [MTSETBLK] = tape_std_mtsetblk,
  1105. [MTSETDENSITY] = NULL,
  1106. [MTSEEK] = tape_3590_mtseek,
  1107. [MTTELL] = tape_3590_mttell,
  1108. [MTSETDRVBUFFER] = NULL,
  1109. [MTFSS] = NULL,
  1110. [MTBSS] = NULL,
  1111. [MTWSM] = NULL,
  1112. [MTLOCK] = NULL,
  1113. [MTUNLOCK] = NULL,
  1114. [MTLOAD] = tape_std_mtload,
  1115. [MTUNLOAD] = tape_std_mtunload,
  1116. [MTCOMPRESSION] = tape_std_mtcompression,
  1117. [MTSETPART] = NULL,
  1118. [MTMKPART] = NULL
  1119. };
  1120. /*
  1121. * Tape discipline structure for 3590.
  1122. */
  1123. static struct tape_discipline tape_discipline_3590 = {
  1124. .owner = THIS_MODULE,
  1125. .setup_device = tape_3590_setup_device,
  1126. .cleanup_device = tape_3590_cleanup_device,
  1127. .process_eov = tape_std_process_eov,
  1128. .irq = tape_3590_irq,
  1129. .read_block = tape_std_read_block,
  1130. .write_block = tape_std_write_block,
  1131. #ifdef CONFIG_S390_TAPE_BLOCK
  1132. .bread = tape_3590_bread,
  1133. .free_bread = tape_3590_free_bread,
  1134. .check_locate = tape_3590_check_locate,
  1135. #endif
  1136. .ioctl_fn = tape_3590_ioctl,
  1137. .mtop_array = tape_3590_mtop
  1138. };
  1139. static struct ccw_device_id tape_3590_ids[] = {
  1140. {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
  1141. {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592},
  1142. { /* end of list */ }
  1143. };
  1144. static int
  1145. tape_3590_online(struct ccw_device *cdev)
  1146. {
  1147. return tape_generic_online(cdev->dev.driver_data,
  1148. &tape_discipline_3590);
  1149. }
  1150. static int
  1151. tape_3590_offline(struct ccw_device *cdev)
  1152. {
  1153. return tape_generic_offline(cdev->dev.driver_data);
  1154. }
  1155. static struct ccw_driver tape_3590_driver = {
  1156. .name = "tape_3590",
  1157. .owner = THIS_MODULE,
  1158. .ids = tape_3590_ids,
  1159. .probe = tape_generic_probe,
  1160. .remove = tape_generic_remove,
  1161. .set_offline = tape_3590_offline,
  1162. .set_online = tape_3590_online,
  1163. };
  1164. /*
  1165. * Setup discipline structure.
  1166. */
  1167. static int
  1168. tape_3590_init(void)
  1169. {
  1170. int rc;
  1171. TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
  1172. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1173. #ifdef DBF_LIKE_HELL
  1174. debug_set_level(TAPE_DBF_AREA, 6);
  1175. #endif
  1176. DBF_EVENT(3, "3590 init\n");
  1177. /* Register driver for 3590 tapes. */
  1178. rc = ccw_driver_register(&tape_3590_driver);
  1179. if (rc)
  1180. DBF_EVENT(3, "3590 init failed\n");
  1181. else
  1182. DBF_EVENT(3, "3590 registered\n");
  1183. return rc;
  1184. }
  1185. static void
  1186. tape_3590_exit(void)
  1187. {
  1188. ccw_driver_unregister(&tape_3590_driver);
  1189. debug_unregister(TAPE_DBF_AREA);
  1190. }
  1191. MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
  1192. MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
  1193. MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
  1194. MODULE_LICENSE("GPL");
  1195. module_init(tape_3590_init);
  1196. module_exit(tape_3590_exit);