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. static void
  213. tape_3590_work_handler(void *data)
  214. {
  215. struct {
  216. struct tape_device *device;
  217. enum tape_op op;
  218. struct work_struct work;
  219. } *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 {
  238. struct tape_device *device;
  239. enum tape_op op;
  240. struct work_struct work;
  241. } *p;
  242. if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
  243. return -ENOMEM;
  244. INIT_WORK(&p->work, tape_3590_work_handler, p);
  245. p->device = tape_get_device_reference(device);
  246. p->op = op;
  247. schedule_work(&p->work);
  248. return 0;
  249. }
  250. #ifdef CONFIG_S390_TAPE_BLOCK
  251. /*
  252. * Tape Block READ
  253. */
  254. static struct tape_request *
  255. tape_3590_bread(struct tape_device *device, struct request *req)
  256. {
  257. struct tape_request *request;
  258. struct ccw1 *ccw;
  259. int count = 0, start_block, i;
  260. unsigned off;
  261. char *dst;
  262. struct bio_vec *bv;
  263. struct bio *bio;
  264. DBF_EVENT(6, "xBREDid:");
  265. start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
  266. DBF_EVENT(6, "start_block = %i\n", start_block);
  267. rq_for_each_bio(bio, req) {
  268. bio_for_each_segment(bv, bio, i) {
  269. count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
  270. }
  271. }
  272. request = tape_alloc_request(2 + count + 1, 4);
  273. if (IS_ERR(request))
  274. return request;
  275. request->op = TO_BLOCK;
  276. *(__u32 *) request->cpdata = start_block;
  277. ccw = request->cpaddr;
  278. ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
  279. /*
  280. * We always setup a nop after the mode set ccw. This slot is
  281. * used in tape_std_check_locate to insert a locate ccw if the
  282. * current tape position doesn't match the start block to be read.
  283. */
  284. ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
  285. rq_for_each_bio(bio, req) {
  286. bio_for_each_segment(bv, bio, i) {
  287. dst = kmap(bv->bv_page) + bv->bv_offset;
  288. for (off = 0; off < bv->bv_len;
  289. off += TAPEBLOCK_HSEC_SIZE) {
  290. ccw->flags = CCW_FLAG_CC;
  291. ccw->cmd_code = READ_FORWARD;
  292. ccw->count = TAPEBLOCK_HSEC_SIZE;
  293. set_normalized_cda(ccw, (void *) __pa(dst));
  294. ccw++;
  295. dst += TAPEBLOCK_HSEC_SIZE;
  296. }
  297. if (off > bv->bv_len)
  298. BUG();
  299. }
  300. }
  301. ccw = tape_ccw_end(ccw, NOP, 0, NULL);
  302. DBF_EVENT(6, "xBREDccwg\n");
  303. return request;
  304. }
  305. static void
  306. tape_3590_free_bread(struct tape_request *request)
  307. {
  308. struct ccw1 *ccw;
  309. /* Last ccw is a nop and doesn't need clear_normalized_cda */
  310. for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
  311. if (ccw->cmd_code == READ_FORWARD)
  312. clear_normalized_cda(ccw);
  313. tape_free_request(request);
  314. }
  315. /*
  316. * check_locate is called just before the tape request is passed to
  317. * the common io layer for execution. It has to check the current
  318. * tape position and insert a locate ccw if it doesn't match the
  319. * start block for the request.
  320. */
  321. static void
  322. tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
  323. {
  324. __u32 *start_block;
  325. start_block = (__u32 *) request->cpdata;
  326. if (*start_block != device->blk_data.block_position) {
  327. /* Add the start offset of the file to get the real block. */
  328. *start_block += device->bof;
  329. tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
  330. }
  331. }
  332. #endif
  333. /*
  334. * The done handler is called at device/channel end and wakes up the sleeping
  335. * process
  336. */
  337. static int
  338. tape_3590_done(struct tape_device *device, struct tape_request *request)
  339. {
  340. struct tape_3590_med_sense *sense;
  341. DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
  342. switch (request->op) {
  343. case TO_BSB:
  344. case TO_BSF:
  345. case TO_DSE:
  346. case TO_FSB:
  347. case TO_FSF:
  348. case TO_LBL:
  349. case TO_RFO:
  350. case TO_RBA:
  351. case TO_REW:
  352. case TO_WRI:
  353. case TO_WTM:
  354. case TO_BLOCK:
  355. case TO_LOAD:
  356. tape_med_state_set(device, MS_LOADED);
  357. break;
  358. case TO_RUN:
  359. tape_med_state_set(device, MS_UNLOADED);
  360. break;
  361. case TO_MSEN:
  362. sense = (struct tape_3590_med_sense *) request->cpdata;
  363. if (sense->masst == MSENSE_UNASSOCIATED)
  364. tape_med_state_set(device, MS_UNLOADED);
  365. if (sense->masst == MSENSE_ASSOCIATED_MOUNT)
  366. tape_med_state_set(device, MS_LOADED);
  367. break;
  368. case TO_RBI: /* RBI seems to succeed even without medium loaded. */
  369. case TO_NOP: /* Same to NOP. */
  370. case TO_READ_CONFIG:
  371. case TO_READ_ATTMSG:
  372. case TO_DIS:
  373. case TO_ASSIGN:
  374. case TO_UNASSIGN:
  375. break;
  376. case TO_SIZE:
  377. break;
  378. }
  379. return TAPE_IO_SUCCESS;
  380. }
  381. /*
  382. * This fuction is called, when error recovery was successfull
  383. */
  384. static inline int
  385. tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
  386. {
  387. DBF_EVENT(3, "Error Recovery successfull for %s\n",
  388. tape_op_verbose[request->op]);
  389. return tape_3590_done(device, request);
  390. }
  391. /*
  392. * This fuction is called, when error recovery was not successfull
  393. */
  394. static inline int
  395. tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
  396. struct irb *irb, int rc)
  397. {
  398. DBF_EVENT(3, "Error Recovery failed for %s\n",
  399. tape_op_verbose[request->op]);
  400. tape_dump_sense_dbf(device, request, irb);
  401. return rc;
  402. }
  403. /*
  404. * Error Recovery do retry
  405. */
  406. static inline int
  407. tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
  408. struct irb *irb)
  409. {
  410. DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
  411. tape_dump_sense_dbf(device, request, irb);
  412. return TAPE_IO_RETRY;
  413. }
  414. /*
  415. * Handle unsolicited interrupts
  416. */
  417. static int
  418. tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
  419. {
  420. if (irb->scsw.dstat == DEV_STAT_CHN_END)
  421. /* Probably result of halt ssch */
  422. return TAPE_IO_PENDING;
  423. else if (irb->scsw.dstat == 0x85)
  424. /* Device Ready -> check medium state */
  425. tape_3590_schedule_work(device, TO_MSEN);
  426. else if (irb->scsw.dstat & DEV_STAT_ATTENTION)
  427. tape_3590_schedule_work(device, TO_READ_ATTMSG);
  428. else {
  429. DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
  430. PRINT_WARN("Unsolicited IRQ (Device End) caught.\n");
  431. tape_dump_sense(device, NULL, irb);
  432. }
  433. return TAPE_IO_SUCCESS;
  434. }
  435. /*
  436. * Basic Recovery routine
  437. */
  438. static int
  439. tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
  440. struct irb *irb, int rc)
  441. {
  442. struct tape_3590_sense *sense;
  443. sense = (struct tape_3590_sense *) irb->ecw;
  444. switch (sense->bra) {
  445. case SENSE_BRA_PER:
  446. return tape_3590_erp_failed(device, request, irb, rc);
  447. case SENSE_BRA_CONT:
  448. return tape_3590_erp_succeded(device, request);
  449. case SENSE_BRA_RE:
  450. return tape_3590_erp_retry(device, request, irb);
  451. case SENSE_BRA_DRE:
  452. return tape_3590_erp_failed(device, request, irb, rc);
  453. default:
  454. PRINT_ERR("Unknown BRA %x - This should not happen!\n",
  455. sense->bra);
  456. BUG();
  457. return TAPE_IO_STOP;
  458. }
  459. }
  460. /*
  461. * RDL: Read Device (buffered) log
  462. */
  463. static int
  464. tape_3590_erp_read_buf_log(struct tape_device *device,
  465. struct tape_request *request, struct irb *irb)
  466. {
  467. /*
  468. * We just do the basic error recovery at the moment (retry).
  469. * Perhaps in the future, we read the log and dump it somewhere...
  470. */
  471. return tape_3590_erp_basic(device, request, irb, -EIO);
  472. }
  473. /*
  474. * SWAP: Swap Devices
  475. */
  476. static int
  477. tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
  478. struct irb *irb)
  479. {
  480. /*
  481. * This error recovery should swap the tapes
  482. * if the original has a problem. The operation
  483. * should proceed with the new tape... this
  484. * should probably be done in user space!
  485. */
  486. PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id);
  487. return tape_3590_erp_basic(device, request, irb, -EIO);
  488. }
  489. /*
  490. * LBY: Long Busy
  491. */
  492. static int
  493. tape_3590_erp_long_busy(struct tape_device *device,
  494. struct tape_request *request, struct irb *irb)
  495. {
  496. /* FIXME: how about WAITING for a minute ? */
  497. PRINT_WARN("(%s): Device is busy! Please wait a minute!\n",
  498. device->cdev->dev.bus_id);
  499. return tape_3590_erp_basic(device, request, irb, -EBUSY);
  500. }
  501. /*
  502. * SPI: Special Intercept
  503. */
  504. static int
  505. tape_3590_erp_special_interrupt(struct tape_device *device,
  506. struct tape_request *request, struct irb *irb)
  507. {
  508. return tape_3590_erp_basic(device, request, irb, -EIO);
  509. }
  510. /*
  511. * RDA: Read Alternate
  512. */
  513. static int
  514. tape_3590_erp_read_alternate(struct tape_device *device,
  515. struct tape_request *request, struct irb *irb)
  516. {
  517. struct tape_3590_disc_data *data;
  518. /*
  519. * The issued Read Backward or Read Previous command is not
  520. * supported by the device
  521. * The recovery action should be to issue another command:
  522. * Read Revious: if Read Backward is not supported
  523. * Read Backward: if Read Previous is not supported
  524. */
  525. data = device->discdata;
  526. if (data->read_back_op == READ_PREVIOUS) {
  527. DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
  528. device->cdev_id);
  529. data->read_back_op = READ_BACKWARD;
  530. } else {
  531. DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
  532. device->cdev_id);
  533. data->read_back_op = READ_PREVIOUS;
  534. }
  535. tape_3590_read_opposite(device, request);
  536. return tape_3590_erp_retry(device, request, irb);
  537. }
  538. /*
  539. * Error Recovery read opposite
  540. */
  541. static int
  542. tape_3590_erp_read_opposite(struct tape_device *device,
  543. struct tape_request *request, struct irb *irb)
  544. {
  545. switch (request->op) {
  546. case TO_RFO:
  547. /*
  548. * We did read forward, but the data could not be read.
  549. * We will read backward and then skip forward again.
  550. */
  551. tape_3590_read_opposite(device, request);
  552. return tape_3590_erp_retry(device, request, irb);
  553. case TO_RBA:
  554. /* We tried to read forward and backward, but hat no success */
  555. return tape_3590_erp_failed(device, request, irb, -EIO);
  556. break;
  557. default:
  558. PRINT_WARN("read_opposite_recovery_called_with_op: %s\n",
  559. tape_op_verbose[request->op]);
  560. return tape_3590_erp_failed(device, request, irb, -EIO);
  561. }
  562. }
  563. /*
  564. * Print an MIM (Media Information Message) (message code f0)
  565. */
  566. static void
  567. tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
  568. {
  569. struct tape_3590_sense *sense;
  570. sense = (struct tape_3590_sense *) irb->ecw;
  571. /* Exception Message */
  572. switch (sense->fmt.f70.emc) {
  573. case 0x02:
  574. PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id);
  575. break;
  576. case 0x03:
  577. PRINT_WARN("(%s): Data degraded in partion %i\n",
  578. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  579. break;
  580. case 0x04:
  581. PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id);
  582. break;
  583. case 0x05:
  584. PRINT_WARN("(%s): Medium degraded in partition %i\n",
  585. device->cdev->dev.bus_id, sense->fmt.f70.mp);
  586. break;
  587. case 0x06:
  588. PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id);
  589. break;
  590. case 0x07:
  591. PRINT_WARN("(%s): Medium Exception 0x%02x\n",
  592. device->cdev->dev.bus_id, sense->fmt.f70.md);
  593. break;
  594. default:
  595. PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n",
  596. device->cdev->dev.bus_id, sense->fmt.f70.emc);
  597. break;
  598. }
  599. /* Service Message */
  600. switch (sense->fmt.f70.smc) {
  601. case 0x02:
  602. PRINT_WARN("(%s): Reference Media maintenance procedure %i\n",
  603. device->cdev->dev.bus_id, sense->fmt.f70.md);
  604. break;
  605. default:
  606. PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n",
  607. device->cdev->dev.bus_id, sense->fmt.f70.smc);
  608. break;
  609. }
  610. }
  611. /*
  612. * Print an I/O Subsystem Service Information Message (message code f1)
  613. */
  614. static void
  615. tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
  616. {
  617. struct tape_3590_sense *sense;
  618. sense = (struct tape_3590_sense *) irb->ecw;
  619. /* Exception Message */
  620. switch (sense->fmt.f71.emc) {
  621. case 0x01:
  622. PRINT_WARN("(%s): Effect of failure is unknown\n",
  623. device->cdev->dev.bus_id);
  624. break;
  625. case 0x02:
  626. PRINT_WARN("(%s): CU Exception - no performance impact\n",
  627. device->cdev->dev.bus_id);
  628. break;
  629. case 0x03:
  630. PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n",
  631. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  632. break;
  633. case 0x04:
  634. PRINT_WARN("(%s): CU Exception on device path 0x%02x\n",
  635. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  636. break;
  637. case 0x05:
  638. PRINT_WARN("(%s): CU Exception on library path 0x%02x\n",
  639. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  640. break;
  641. case 0x06:
  642. PRINT_WARN("(%s): CU Exception on node 0x%02x\n",
  643. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  644. break;
  645. case 0x07:
  646. PRINT_WARN("(%s): CU Exception on partition 0x%02x\n",
  647. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  648. break;
  649. default:
  650. PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n",
  651. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  652. }
  653. /* Service Message */
  654. switch (sense->fmt.f71.smc) {
  655. case 0x01:
  656. PRINT_WARN("(%s): Repair impact is unknown\n",
  657. device->cdev->dev.bus_id);
  658. break;
  659. case 0x02:
  660. PRINT_WARN("(%s): Repair will not impact cu performance\n",
  661. device->cdev->dev.bus_id);
  662. break;
  663. case 0x03:
  664. if (sense->fmt.f71.mdf == 0)
  665. PRINT_WARN("(%s): Repair will disable node "
  666. "0x%x on CU\n",
  667. device->cdev->dev.bus_id,
  668. sense->fmt.f71.md[1]);
  669. else
  670. PRINT_WARN("(%s): Repair will disable nodes "
  671. "(0x%x-0x%x) on CU\n",
  672. device->cdev->dev.bus_id,
  673. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  674. break;
  675. case 0x04:
  676. if (sense->fmt.f71.mdf == 0)
  677. PRINT_WARN("(%s): Repair will disable cannel path "
  678. "0x%x on CU\n",
  679. device->cdev->dev.bus_id,
  680. sense->fmt.f71.md[1]);
  681. else
  682. PRINT_WARN("(%s): Repair will disable cannel paths "
  683. "(0x%x-0x%x) on CU\n",
  684. device->cdev->dev.bus_id,
  685. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  686. break;
  687. case 0x05:
  688. if (sense->fmt.f71.mdf == 0)
  689. PRINT_WARN("(%s): Repair will disable device path "
  690. "0x%x on CU\n",
  691. device->cdev->dev.bus_id,
  692. sense->fmt.f71.md[1]);
  693. else
  694. PRINT_WARN("(%s): Repair will disable device paths "
  695. "(0x%x-0x%x) on CU\n",
  696. device->cdev->dev.bus_id,
  697. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  698. break;
  699. case 0x06:
  700. if (sense->fmt.f71.mdf == 0)
  701. PRINT_WARN("(%s): Repair will disable library path "
  702. "0x%x on CU\n",
  703. device->cdev->dev.bus_id,
  704. sense->fmt.f71.md[1]);
  705. else
  706. PRINT_WARN("(%s): Repair will disable library paths "
  707. "(0x%x-0x%x) on CU\n",
  708. device->cdev->dev.bus_id,
  709. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  710. break;
  711. case 0x07:
  712. PRINT_WARN("(%s): Repair will disable access to CU\n",
  713. device->cdev->dev.bus_id);
  714. break;
  715. default:
  716. PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n",
  717. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  718. }
  719. }
  720. /*
  721. * Print an Device Subsystem Service Information Message (message code f2)
  722. */
  723. static void
  724. tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
  725. {
  726. struct tape_3590_sense *sense;
  727. sense = (struct tape_3590_sense *) irb->ecw;
  728. /* Exception Message */
  729. switch (sense->fmt.f71.emc) {
  730. case 0x01:
  731. PRINT_WARN("(%s): Effect of failure is unknown\n",
  732. device->cdev->dev.bus_id);
  733. break;
  734. case 0x02:
  735. PRINT_WARN("(%s): DV Exception - no performance impact\n",
  736. device->cdev->dev.bus_id);
  737. break;
  738. case 0x03:
  739. PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n",
  740. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  741. break;
  742. case 0x04:
  743. PRINT_WARN("(%s): DV Exception on loader 0x%02x\n",
  744. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  745. break;
  746. case 0x05:
  747. PRINT_WARN("(%s): DV Exception on message display 0x%02x\n",
  748. device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
  749. break;
  750. case 0x06:
  751. PRINT_WARN("(%s): DV Exception in tape path\n",
  752. device->cdev->dev.bus_id);
  753. break;
  754. case 0x07:
  755. PRINT_WARN("(%s): DV Exception in drive\n",
  756. device->cdev->dev.bus_id);
  757. break;
  758. default:
  759. PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n",
  760. device->cdev->dev.bus_id, sense->fmt.f71.emc);
  761. }
  762. /* Service Message */
  763. switch (sense->fmt.f71.smc) {
  764. case 0x01:
  765. PRINT_WARN("(%s): Repair impact is unknown\n",
  766. device->cdev->dev.bus_id);
  767. break;
  768. case 0x02:
  769. PRINT_WARN("(%s): Repair will not impact device performance\n",
  770. device->cdev->dev.bus_id);
  771. break;
  772. case 0x03:
  773. if (sense->fmt.f71.mdf == 0)
  774. PRINT_WARN("(%s): Repair will disable channel path "
  775. "0x%x on DV\n",
  776. device->cdev->dev.bus_id,
  777. sense->fmt.f71.md[1]);
  778. else
  779. PRINT_WARN("(%s): Repair will disable channel path "
  780. "(0x%x-0x%x) on DV\n",
  781. device->cdev->dev.bus_id,
  782. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  783. break;
  784. case 0x04:
  785. if (sense->fmt.f71.mdf == 0)
  786. PRINT_WARN("(%s): Repair will disable interface 0x%x "
  787. "on DV\n",
  788. device->cdev->dev.bus_id,
  789. sense->fmt.f71.md[1]);
  790. else
  791. PRINT_WARN("(%s): Repair will disable interfaces "
  792. "(0x%x-0x%x) on DV\n",
  793. device->cdev->dev.bus_id,
  794. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  795. break;
  796. case 0x05:
  797. if (sense->fmt.f71.mdf == 0)
  798. PRINT_WARN("(%s): Repair will disable loader 0x%x "
  799. "on DV\n",
  800. device->cdev->dev.bus_id,
  801. sense->fmt.f71.md[1]);
  802. else
  803. PRINT_WARN("(%s): Repair will disable loader "
  804. "(0x%x-0x%x) on DV\n",
  805. device->cdev->dev.bus_id,
  806. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  807. break;
  808. case 0x07:
  809. PRINT_WARN("(%s): Repair will disable access to DV\n",
  810. device->cdev->dev.bus_id);
  811. break;
  812. case 0x08:
  813. if (sense->fmt.f71.mdf == 0)
  814. PRINT_WARN("(%s): Repair will disable message "
  815. "display 0x%x on DV\n",
  816. device->cdev->dev.bus_id,
  817. sense->fmt.f71.md[1]);
  818. else
  819. PRINT_WARN("(%s): Repair will disable message "
  820. "displays (0x%x-0x%x) on DV\n",
  821. device->cdev->dev.bus_id,
  822. sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
  823. break;
  824. case 0x09:
  825. PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id);
  826. break;
  827. default:
  828. PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n",
  829. device->cdev->dev.bus_id, sense->fmt.f71.smc);
  830. }
  831. }
  832. /*
  833. * Print standard ERA Message
  834. */
  835. static void
  836. tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
  837. {
  838. struct tape_3590_sense *sense;
  839. sense = (struct tape_3590_sense *) irb->ecw;
  840. if (sense->mc == 0)
  841. return;
  842. if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
  843. if (tape_3590_msg[sense->mc] != NULL)
  844. PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id,
  845. tape_3590_msg[sense->mc]);
  846. else {
  847. PRINT_WARN("(%s): Message Code 0x%x\n",
  848. device->cdev->dev.bus_id, sense->mc);
  849. }
  850. return;
  851. }
  852. if (sense->mc == 0xf0) {
  853. /* Standard Media Information Message */
  854. PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, "
  855. "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id,
  856. sense->fmt.f70.sev, sense->mc,
  857. sense->fmt.f70.emc, sense->fmt.f70.smc,
  858. sense->fmt.f70.refcode, sense->fmt.f70.mid,
  859. sense->fmt.f70.fid);
  860. tape_3590_print_mim_msg_f0(device, irb);
  861. return;
  862. }
  863. if (sense->mc == 0xf1) {
  864. /* Standard I/O Subsystem Service Information Message */
  865. PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, "
  866. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  867. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  868. device->cdev->id.dev_model,
  869. sense->mc, sense->fmt.f71.emc,
  870. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  871. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  872. tape_3590_print_io_sim_msg_f1(device, irb);
  873. return;
  874. }
  875. if (sense->mc == 0xf2) {
  876. /* Standard Device Service Information Message */
  877. PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, "
  878. "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
  879. device->cdev->dev.bus_id, sense->fmt.f71.sev,
  880. device->cdev->id.dev_model,
  881. sense->mc, sense->fmt.f71.emc,
  882. sense->fmt.f71.smc, sense->fmt.f71.refcode1,
  883. sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
  884. tape_3590_print_dev_sim_msg_f2(device, irb);
  885. return;
  886. }
  887. if (sense->mc == 0xf3) {
  888. /* Standard Library Service Information Message */
  889. return;
  890. }
  891. PRINT_WARN("(%s): Device Message(%x)\n",
  892. device->cdev->dev.bus_id, sense->mc);
  893. }
  894. /*
  895. * 3590 error Recovery routine:
  896. * If possible, it tries to recover from the error. If this is not possible,
  897. * inform the user about the problem.
  898. */
  899. static int
  900. tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
  901. struct irb *irb)
  902. {
  903. struct tape_3590_sense *sense;
  904. int rc;
  905. #ifdef CONFIG_S390_TAPE_BLOCK
  906. if (request->op == TO_BLOCK) {
  907. /*
  908. * Recovery for block device requests. Set the block_position
  909. * to something invalid and retry.
  910. */
  911. device->blk_data.block_position = -1;
  912. if (request->retries-- <= 0)
  913. return tape_3590_erp_failed(device, request, irb, -EIO);
  914. else
  915. return tape_3590_erp_retry(device, request, irb);
  916. }
  917. #endif
  918. sense = (struct tape_3590_sense *) irb->ecw;
  919. /*
  920. * First check all RC-QRCs where we want to do something special
  921. * - "break": basic error recovery is done
  922. * - "goto out:": just print error message if available
  923. */
  924. rc = -EIO;
  925. switch (sense->rc_rqc) {
  926. case 0x1110:
  927. tape_3590_print_era_msg(device, irb);
  928. return tape_3590_erp_read_buf_log(device, request, irb);
  929. case 0x2011:
  930. tape_3590_print_era_msg(device, irb);
  931. return tape_3590_erp_read_alternate(device, request, irb);
  932. case 0x2230:
  933. case 0x2231:
  934. tape_3590_print_era_msg(device, irb);
  935. return tape_3590_erp_special_interrupt(device, request, irb);
  936. case 0x3010:
  937. DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
  938. device->cdev_id);
  939. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  940. case 0x3012:
  941. DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
  942. device->cdev_id);
  943. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  944. case 0x3020:
  945. DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
  946. return tape_3590_erp_basic(device, request, irb, -ENOSPC);
  947. case 0x3122:
  948. DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
  949. device->cdev_id);
  950. return tape_3590_erp_basic(device, request, irb, -EIO);
  951. case 0x3123:
  952. DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
  953. device->cdev_id);
  954. tape_med_state_set(device, MS_UNLOADED);
  955. return tape_3590_erp_basic(device, request, irb, 0);
  956. case 0x4010:
  957. /*
  958. * print additional msg since default msg
  959. * "device intervention" is not very meaningfull
  960. */
  961. PRINT_WARN("(%s): Tape operation when medium not loaded\n",
  962. device->cdev->dev.bus_id);
  963. tape_med_state_set(device, MS_UNLOADED);
  964. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  965. case 0x4012: /* Device Long Busy */
  966. tape_3590_print_era_msg(device, irb);
  967. return tape_3590_erp_long_busy(device, request, irb);
  968. case 0x5010:
  969. if (sense->rac == 0xd0) {
  970. /* Swap */
  971. tape_3590_print_era_msg(device, irb);
  972. return tape_3590_erp_swap(device, request, irb);
  973. }
  974. if (sense->rac == 0x26) {
  975. /* Read Opposite */
  976. tape_3590_print_era_msg(device, irb);
  977. return tape_3590_erp_read_opposite(device, request,
  978. irb);
  979. }
  980. return tape_3590_erp_basic(device, request, irb, -EIO);
  981. case 0x5020:
  982. case 0x5021:
  983. case 0x5022:
  984. case 0x5040:
  985. case 0x5041:
  986. case 0x5042:
  987. tape_3590_print_era_msg(device, irb);
  988. return tape_3590_erp_swap(device, request, irb);
  989. case 0x5110:
  990. case 0x5111:
  991. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  992. case 0x5120:
  993. case 0x1120:
  994. tape_med_state_set(device, MS_UNLOADED);
  995. return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
  996. case 0x6020:
  997. PRINT_WARN("(%s): Cartridge of wrong type ?\n",
  998. device->cdev->dev.bus_id);
  999. return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
  1000. case 0x8011:
  1001. PRINT_WARN("(%s): Another host has reserved the tape device\n",
  1002. device->cdev->dev.bus_id);
  1003. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1004. case 0x8013:
  1005. PRINT_WARN("(%s): Another host has priviliged access to the "
  1006. "tape device\n", device->cdev->dev.bus_id);
  1007. PRINT_WARN("(%s): To solve the problem unload the current "
  1008. "cartridge!\n", device->cdev->dev.bus_id);
  1009. return tape_3590_erp_basic(device, request, irb, -EPERM);
  1010. default:
  1011. return tape_3590_erp_basic(device, request, irb, -EIO);
  1012. }
  1013. }
  1014. /*
  1015. * 3590 interrupt handler:
  1016. */
  1017. static int
  1018. tape_3590_irq(struct tape_device *device, struct tape_request *request,
  1019. struct irb *irb)
  1020. {
  1021. if (request == NULL)
  1022. return tape_3590_unsolicited_irq(device, irb);
  1023. if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) &&
  1024. (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) {
  1025. /* Write at end of volume */
  1026. DBF_EVENT(2, "End of volume\n");
  1027. return tape_3590_erp_failed(device, request, irb, -ENOSPC);
  1028. }
  1029. if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
  1030. return tape_3590_unit_check(device, request, irb);
  1031. if (irb->scsw.dstat & DEV_STAT_DEV_END) {
  1032. if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) {
  1033. if (request->op == TO_FSB || request->op == TO_BSB)
  1034. request->rescnt++;
  1035. else
  1036. DBF_EVENT(5, "Unit Exception!\n");
  1037. }
  1038. return tape_3590_done(device, request);
  1039. }
  1040. if (irb->scsw.dstat & DEV_STAT_CHN_END) {
  1041. DBF_EVENT(2, "cannel end\n");
  1042. return TAPE_IO_PENDING;
  1043. }
  1044. if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
  1045. DBF_EVENT(2, "Unit Attention when busy..\n");
  1046. return TAPE_IO_PENDING;
  1047. }
  1048. DBF_EVENT(6, "xunknownirq\n");
  1049. PRINT_ERR("Unexpected interrupt.\n");
  1050. PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]);
  1051. tape_dump_sense(device, request, irb);
  1052. return TAPE_IO_STOP;
  1053. }
  1054. /*
  1055. * Setup device function
  1056. */
  1057. static int
  1058. tape_3590_setup_device(struct tape_device *device)
  1059. {
  1060. int rc;
  1061. struct tape_3590_disc_data *data;
  1062. DBF_EVENT(6, "3590 device setup\n");
  1063. data = kmalloc(sizeof(struct tape_3590_disc_data),
  1064. GFP_KERNEL | GFP_DMA);
  1065. if (data == NULL)
  1066. return -ENOMEM;
  1067. data->read_back_op = READ_PREVIOUS;
  1068. device->discdata = data;
  1069. if ((rc = tape_std_assign(device)) == 0) {
  1070. /* Try to find out if medium is loaded */
  1071. if ((rc = tape_3590_sense_medium(device)) != 0)
  1072. DBF_LH(3, "3590 medium sense returned %d\n", rc);
  1073. }
  1074. return rc;
  1075. }
  1076. /*
  1077. * Cleanup device function
  1078. */
  1079. static void
  1080. tape_3590_cleanup_device(struct tape_device *device)
  1081. {
  1082. tape_std_unassign(device);
  1083. kfree(device->discdata);
  1084. device->discdata = NULL;
  1085. }
  1086. /*
  1087. * List of 3590 magnetic tape commands.
  1088. */
  1089. static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
  1090. [MTRESET] = tape_std_mtreset,
  1091. [MTFSF] = tape_std_mtfsf,
  1092. [MTBSF] = tape_std_mtbsf,
  1093. [MTFSR] = tape_std_mtfsr,
  1094. [MTBSR] = tape_std_mtbsr,
  1095. [MTWEOF] = tape_std_mtweof,
  1096. [MTREW] = tape_std_mtrew,
  1097. [MTOFFL] = tape_std_mtoffl,
  1098. [MTNOP] = tape_std_mtnop,
  1099. [MTRETEN] = tape_std_mtreten,
  1100. [MTBSFM] = tape_std_mtbsfm,
  1101. [MTFSFM] = tape_std_mtfsfm,
  1102. [MTEOM] = tape_std_mteom,
  1103. [MTERASE] = tape_std_mterase,
  1104. [MTRAS1] = NULL,
  1105. [MTRAS2] = NULL,
  1106. [MTRAS3] = NULL,
  1107. [MTSETBLK] = tape_std_mtsetblk,
  1108. [MTSETDENSITY] = NULL,
  1109. [MTSEEK] = tape_3590_mtseek,
  1110. [MTTELL] = tape_3590_mttell,
  1111. [MTSETDRVBUFFER] = NULL,
  1112. [MTFSS] = NULL,
  1113. [MTBSS] = NULL,
  1114. [MTWSM] = NULL,
  1115. [MTLOCK] = NULL,
  1116. [MTUNLOCK] = NULL,
  1117. [MTLOAD] = tape_std_mtload,
  1118. [MTUNLOAD] = tape_std_mtunload,
  1119. [MTCOMPRESSION] = tape_std_mtcompression,
  1120. [MTSETPART] = NULL,
  1121. [MTMKPART] = NULL
  1122. };
  1123. /*
  1124. * Tape discipline structure for 3590.
  1125. */
  1126. static struct tape_discipline tape_discipline_3590 = {
  1127. .owner = THIS_MODULE,
  1128. .setup_device = tape_3590_setup_device,
  1129. .cleanup_device = tape_3590_cleanup_device,
  1130. .process_eov = tape_std_process_eov,
  1131. .irq = tape_3590_irq,
  1132. .read_block = tape_std_read_block,
  1133. .write_block = tape_std_write_block,
  1134. #ifdef CONFIG_S390_TAPE_BLOCK
  1135. .bread = tape_3590_bread,
  1136. .free_bread = tape_3590_free_bread,
  1137. .check_locate = tape_3590_check_locate,
  1138. #endif
  1139. .ioctl_fn = tape_3590_ioctl,
  1140. .mtop_array = tape_3590_mtop
  1141. };
  1142. static struct ccw_device_id tape_3590_ids[] = {
  1143. {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
  1144. { /* end of list */ }
  1145. };
  1146. static int
  1147. tape_3590_online(struct ccw_device *cdev)
  1148. {
  1149. return tape_generic_online(cdev->dev.driver_data,
  1150. &tape_discipline_3590);
  1151. }
  1152. static int
  1153. tape_3590_offline(struct ccw_device *cdev)
  1154. {
  1155. return tape_generic_offline(cdev->dev.driver_data);
  1156. }
  1157. static struct ccw_driver tape_3590_driver = {
  1158. .name = "tape_3590",
  1159. .owner = THIS_MODULE,
  1160. .ids = tape_3590_ids,
  1161. .probe = tape_generic_probe,
  1162. .remove = tape_generic_remove,
  1163. .set_offline = tape_3590_offline,
  1164. .set_online = tape_3590_online,
  1165. };
  1166. /*
  1167. * Setup discipline structure.
  1168. */
  1169. static int
  1170. tape_3590_init(void)
  1171. {
  1172. int rc;
  1173. TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
  1174. debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
  1175. #ifdef DBF_LIKE_HELL
  1176. debug_set_level(TAPE_DBF_AREA, 6);
  1177. #endif
  1178. DBF_EVENT(3, "3590 init\n");
  1179. /* Register driver for 3590 tapes. */
  1180. rc = ccw_driver_register(&tape_3590_driver);
  1181. if (rc)
  1182. DBF_EVENT(3, "3590 init failed\n");
  1183. else
  1184. DBF_EVENT(3, "3590 registered\n");
  1185. return rc;
  1186. }
  1187. static void
  1188. tape_3590_exit(void)
  1189. {
  1190. ccw_driver_unregister(&tape_3590_driver);
  1191. debug_unregister(TAPE_DBF_AREA);
  1192. }
  1193. MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
  1194. MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
  1195. MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
  1196. MODULE_LICENSE("GPL");
  1197. module_init(tape_3590_init);
  1198. module_exit(tape_3590_exit);