tape_3590.c 34 KB

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