2 * drivers/s390/char/tape_3590.c
3 * tape device discipline for 3590 tapes.
5 * Copyright IBM Corp. 2001, 2009
6 * Author(s): Stefan Bader <shbader@de.ibm.com>
7 * Michael Holzheu <holzheu@de.ibm.com>
8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
11 #define KMSG_COMPONENT "tape_3590"
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/bio.h>
16 #include <asm/ebcdic.h>
18 #define TAPE_DBF_AREA tape_3590_dbf
19 #define BUFSIZE 512 /* size of buffers for dynamic generated messages */
23 #include "tape_3590.h"
26 * Pointer to debug area.
28 debug_info_t *TAPE_DBF_AREA = NULL;
29 EXPORT_SYMBOL(TAPE_DBF_AREA);
31 /*******************************************************************
32 * Error Recovery fuctions:
33 * - Read Opposite: implemented
34 * - Read Device (buffered) log: BRA
35 * - Read Library log: BRA
37 * - Long Busy: implemented
38 * - Special Intercept: BRA
39 * - Read Alternate: implemented
40 *******************************************************************/
42 static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = {
44 [0x10] = "Lost Sense",
45 [0x11] = "Assigned Elsewhere",
46 [0x12] = "Allegiance Reset",
47 [0x13] = "Shared Access Violation",
48 [0x20] = "Command Reject",
49 [0x21] = "Configuration Error",
50 [0x22] = "Protection Exception",
51 [0x23] = "Write Protect",
52 [0x24] = "Write Length",
53 [0x25] = "Read-Only Format",
54 [0x31] = "Beginning of Partition",
55 [0x33] = "End of Partition",
56 [0x34] = "End of Data",
57 [0x35] = "Block not found",
58 [0x40] = "Device Intervention",
59 [0x41] = "Loader Intervention",
60 [0x42] = "Library Intervention",
61 [0x50] = "Write Error",
62 [0x51] = "Erase Error",
63 [0x52] = "Formatting Error",
64 [0x53] = "Read Error",
65 [0x54] = "Unsupported Format",
66 [0x55] = "No Formatting",
67 [0x56] = "Positioning lost",
68 [0x57] = "Read Length",
69 [0x60] = "Unsupported Medium",
70 [0x61] = "Medium Length Error",
71 [0x62] = "Medium removed",
72 [0x64] = "Load Check",
73 [0x65] = "Unload Check",
74 [0x70] = "Equipment Check",
75 [0x71] = "Bus out Check",
76 [0x72] = "Protocol Error",
77 [0x73] = "Interface Error",
79 [0x75] = "Halt Signal",
80 [0x90] = "Device fenced",
81 [0x91] = "Device Path fenced",
82 [0xa0] = "Volume misplaced",
83 [0xa1] = "Volume inaccessible",
84 [0xa2] = "Volume in input",
85 [0xa3] = "Volume ejected",
86 [0xa4] = "All categories reserved",
87 [0xa5] = "Duplicate Volume",
88 [0xa6] = "Library Manager Offline",
89 [0xa7] = "Library Output Station full",
90 [0xa8] = "Vision System non-operational",
91 [0xa9] = "Library Manager Equipment Check",
92 [0xaa] = "Library Equipment Check",
93 [0xab] = "All Library Cells full",
94 [0xac] = "No Cleaner Volumes in Library",
95 [0xad] = "I/O Station door open",
96 [0xae] = "Subsystem environmental alert",
99 static int crypt_supported(struct tape_device *device)
101 return TAPE390_CRYPT_SUPPORTED(TAPE_3590_CRYPT_INFO(device));
104 static int crypt_enabled(struct tape_device *device)
106 return TAPE390_CRYPT_ON(TAPE_3590_CRYPT_INFO(device));
109 static void ext_to_int_kekl(struct tape390_kekl *in,
110 struct tape3592_kekl *out)
114 memset(out, 0, sizeof(*out));
115 if (in->type == TAPE390_KEKL_TYPE_HASH)
117 if (in->type_on_tape == TAPE390_KEKL_TYPE_HASH)
119 strncpy(out->label, in->label, 64);
120 for (i = strlen(in->label); i < sizeof(out->label); i++)
122 ASCEBC(out->label, sizeof(out->label));
125 static void int_to_ext_kekl(struct tape3592_kekl *in,
126 struct tape390_kekl *out)
128 memset(out, 0, sizeof(*out));
130 out->type = TAPE390_KEKL_TYPE_HASH;
132 out->type = TAPE390_KEKL_TYPE_LABEL;
134 out->type_on_tape = TAPE390_KEKL_TYPE_HASH;
136 out->type_on_tape = TAPE390_KEKL_TYPE_LABEL;
137 memcpy(out->label, in->label, sizeof(in->label));
138 EBCASC(out->label, sizeof(in->label));
139 strstrip(out->label);
142 static void int_to_ext_kekl_pair(struct tape3592_kekl_pair *in,
143 struct tape390_kekl_pair *out)
145 if (in->count == 0) {
146 out->kekl[0].type = TAPE390_KEKL_TYPE_NONE;
147 out->kekl[0].type_on_tape = TAPE390_KEKL_TYPE_NONE;
148 out->kekl[1].type = TAPE390_KEKL_TYPE_NONE;
149 out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE;
150 } else if (in->count == 1) {
151 int_to_ext_kekl(&in->kekl[0], &out->kekl[0]);
152 out->kekl[1].type = TAPE390_KEKL_TYPE_NONE;
153 out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE;
154 } else if (in->count == 2) {
155 int_to_ext_kekl(&in->kekl[0], &out->kekl[0]);
156 int_to_ext_kekl(&in->kekl[1], &out->kekl[1]);
158 printk("Invalid KEKL number: %d\n", in->count);
163 static int check_ext_kekl(struct tape390_kekl *kekl)
165 if (kekl->type == TAPE390_KEKL_TYPE_NONE)
167 if (kekl->type > TAPE390_KEKL_TYPE_HASH)
169 if (kekl->type_on_tape == TAPE390_KEKL_TYPE_NONE)
171 if (kekl->type_on_tape > TAPE390_KEKL_TYPE_HASH)
173 if ((kekl->type == TAPE390_KEKL_TYPE_HASH) &&
174 (kekl->type_on_tape == TAPE390_KEKL_TYPE_LABEL))
182 static int check_ext_kekl_pair(struct tape390_kekl_pair *kekls)
184 if (check_ext_kekl(&kekls->kekl[0]))
186 if (check_ext_kekl(&kekls->kekl[1]))
197 static int tape_3592_kekl_query(struct tape_device *device,
198 struct tape390_kekl_pair *ext_kekls)
200 struct tape_request *request;
201 struct tape3592_kekl_query_order *order;
202 struct tape3592_kekl_query_data *int_kekls;
205 DBF_EVENT(6, "tape3592_kekl_query\n");
206 int_kekls = kmalloc(sizeof(*int_kekls), GFP_KERNEL|GFP_DMA);
209 request = tape_alloc_request(2, sizeof(*order));
210 if (IS_ERR(request)) {
211 rc = PTR_ERR(request);
214 order = request->cpdata;
215 memset(order,0,sizeof(*order));
217 order->max_count = 2;
218 request->op = TO_KEKL_QUERY;
219 tape_ccw_cc(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
220 tape_ccw_end(request->cpaddr + 1, READ_SS_DATA, sizeof(*int_kekls),
222 rc = tape_do_io(device, request);
225 int_to_ext_kekl_pair(&int_kekls->kekls, ext_kekls);
229 tape_free_request(request);
238 static int tape_3592_ioctl_kekl_query(struct tape_device *device,
242 struct tape390_kekl_pair *ext_kekls;
244 DBF_EVENT(6, "tape_3592_ioctl_kekl_query\n");
245 if (!crypt_supported(device))
247 if (!crypt_enabled(device))
249 ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
252 rc = tape_3592_kekl_query(device, ext_kekls);
255 if (copy_to_user((char __user *) arg, ext_kekls, sizeof(*ext_kekls))) {
265 static int tape_3590_mttell(struct tape_device *device, int mt_count);
270 static int tape_3592_kekl_set(struct tape_device *device,
271 struct tape390_kekl_pair *ext_kekls)
273 struct tape_request *request;
274 struct tape3592_kekl_set_order *order;
276 DBF_EVENT(6, "tape3592_kekl_set\n");
277 if (check_ext_kekl_pair(ext_kekls)) {
278 DBF_EVENT(6, "invalid kekls\n");
281 if (tape_3590_mttell(device, 0) != 0)
283 request = tape_alloc_request(1, sizeof(*order));
285 return PTR_ERR(request);
286 order = request->cpdata;
287 memset(order, 0, sizeof(*order));
289 order->kekls.count = 2;
290 ext_to_int_kekl(&ext_kekls->kekl[0], &order->kekls.kekl[0]);
291 ext_to_int_kekl(&ext_kekls->kekl[1], &order->kekls.kekl[1]);
292 request->op = TO_KEKL_SET;
293 tape_ccw_end(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
295 return tape_do_io_free(device, request);
301 static int tape_3592_ioctl_kekl_set(struct tape_device *device,
305 struct tape390_kekl_pair *ext_kekls;
307 DBF_EVENT(6, "tape_3592_ioctl_kekl_set\n");
308 if (!crypt_supported(device))
310 if (!crypt_enabled(device))
312 ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
315 if (copy_from_user(ext_kekls, (char __user *)arg, sizeof(*ext_kekls))) {
319 rc = tape_3592_kekl_set(device, ext_kekls);
328 static int tape_3592_enable_crypt(struct tape_device *device)
330 struct tape_request *request;
333 DBF_EVENT(6, "tape_3592_enable_crypt\n");
334 if (!crypt_supported(device))
336 request = tape_alloc_request(2, 72);
338 return PTR_ERR(request);
339 data = request->cpdata;
347 data[36 + 14] = 0x2f;
348 data[36 + 18] = 0xc3;
349 data[36 + 35] = 0x72;
350 request->op = TO_CRYPT_ON;
351 tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data);
352 tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36);
353 return tape_do_io_free(device, request);
359 static int tape_3592_disable_crypt(struct tape_device *device)
361 struct tape_request *request;
364 DBF_EVENT(6, "tape_3592_disable_crypt\n");
365 if (!crypt_supported(device))
367 request = tape_alloc_request(2, 72);
369 return PTR_ERR(request);
370 data = request->cpdata;
376 data[36 + 35] = 0x32;
378 request->op = TO_CRYPT_OFF;
379 tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data);
380 tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36);
382 return tape_do_io_free(device, request);
386 * IOCTL: Set encryption status
388 static int tape_3592_ioctl_crypt_set(struct tape_device *device,
391 struct tape390_crypt_info info;
393 DBF_EVENT(6, "tape_3592_ioctl_crypt_set\n");
394 if (!crypt_supported(device))
396 if (copy_from_user(&info, (char __user *)arg, sizeof(info)))
398 if (info.status & ~TAPE390_CRYPT_ON_MASK)
400 if (info.status & TAPE390_CRYPT_ON_MASK)
401 return tape_3592_enable_crypt(device);
403 return tape_3592_disable_crypt(device);
406 static int tape_3590_sense_medium(struct tape_device *device);
409 * IOCTL: Query enryption status
411 static int tape_3592_ioctl_crypt_query(struct tape_device *device,
414 DBF_EVENT(6, "tape_3592_ioctl_crypt_query\n");
415 if (!crypt_supported(device))
417 tape_3590_sense_medium(device);
418 if (copy_to_user((char __user *) arg, &TAPE_3590_CRYPT_INFO(device),
419 sizeof(TAPE_3590_CRYPT_INFO(device))))
426 * 3590 IOCTL Overload
429 tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
432 case TAPE390_DISPLAY: {
433 struct display_struct disp;
435 if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)))
438 return tape_std_display(device, &disp);
440 case TAPE390_KEKL_SET:
441 return tape_3592_ioctl_kekl_set(device, arg);
442 case TAPE390_KEKL_QUERY:
443 return tape_3592_ioctl_kekl_query(device, arg);
444 case TAPE390_CRYPT_SET:
445 return tape_3592_ioctl_crypt_set(device, arg);
446 case TAPE390_CRYPT_QUERY:
447 return tape_3592_ioctl_crypt_query(device, arg);
449 return -EINVAL; /* no additional ioctls */
454 * SENSE Medium: Get Sense data about medium state
457 tape_3590_sense_medium(struct tape_device *device)
459 struct tape_request *request;
461 request = tape_alloc_request(1, 128);
463 return PTR_ERR(request);
464 request->op = TO_MSEN;
465 tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata);
466 return tape_do_io_free(device, request);
470 * MTTELL: Tell block. Return the number of block relative to current file.
473 tape_3590_mttell(struct tape_device *device, int mt_count)
478 rc = tape_std_read_block_id(device, &block_id);
481 return block_id >> 32;
485 * MTSEEK: seek to the specified block.
488 tape_3590_mtseek(struct tape_device *device, int count)
490 struct tape_request *request;
492 DBF_EVENT(6, "xsee id: %x\n", count);
493 request = tape_alloc_request(3, 4);
495 return PTR_ERR(request);
496 request->op = TO_LBL;
497 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
498 *(__u32 *) request->cpdata = count;
499 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
500 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
501 return tape_do_io_free(device, request);
505 * Read Opposite Error Recovery Function:
506 * Used, when Read Forward does not work
509 tape_3590_read_opposite(struct tape_device *device,
510 struct tape_request *request)
512 struct tape_3590_disc_data *data;
515 * We have allocated 4 ccws in tape_std_read, so we can now
516 * transform the request to a read backward, followed by a
517 * forward space block.
519 request->op = TO_RBA;
520 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
521 data = device->discdata;
522 tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op,
523 device->char_data.idal_buf);
524 tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
525 tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
526 DBF_EVENT(6, "xrop ccwg\n");
531 * This should be done after an interrupt with attention bit (0x80)
534 * After a "read attention message" request there are two possible
537 * 1. A unit check is presented, when attention sense is present (e.g. when
538 * a medium has been unloaded). The attention sense comes then
539 * together with the unit check. The recovery action is either "retry"
540 * (in case there is an attention message pending) or "permanent error".
542 * 2. The attention msg is written to the "read subsystem data" buffer.
543 * In this case we probably should print it to the console.
546 tape_3590_read_attmsg(struct tape_device *device)
548 struct tape_request *request;
551 request = tape_alloc_request(3, 4096);
553 return PTR_ERR(request);
554 request->op = TO_READ_ATTMSG;
555 buf = request->cpdata;
556 buf[0] = PREP_RD_SS_DATA;
557 buf[6] = RD_ATTMSG; /* read att msg */
558 tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf);
559 tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12);
560 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
561 return tape_do_io_free(device, request);
565 * These functions are used to schedule follow-up actions from within an
566 * interrupt context (like unsolicited interrupts).
568 struct work_handler_data {
569 struct tape_device *device;
571 struct work_struct work;
575 tape_3590_work_handler(struct work_struct *work)
577 struct work_handler_data *p =
578 container_of(work, struct work_handler_data, work);
582 tape_3590_sense_medium(p->device);
585 tape_3590_read_attmsg(p->device);
588 tape_3592_enable_crypt(p->device);
591 tape_3592_disable_crypt(p->device);
594 DBF_EVENT(3, "T3590: work handler undefined for "
595 "operation 0x%02x\n", p->op);
597 tape_put_device(p->device);
602 tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
604 struct work_handler_data *p;
606 if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
609 INIT_WORK(&p->work, tape_3590_work_handler);
611 p->device = tape_get_device_reference(device);
614 schedule_work(&p->work);
618 #ifdef CONFIG_S390_TAPE_BLOCK
622 static struct tape_request *
623 tape_3590_bread(struct tape_device *device, struct request *req)
625 struct tape_request *request;
627 int count = 0, start_block;
631 struct req_iterator iter;
633 DBF_EVENT(6, "xBREDid:");
634 start_block = blk_rq_pos(req) >> TAPEBLOCK_HSEC_S2B;
635 DBF_EVENT(6, "start_block = %i\n", start_block);
637 rq_for_each_segment(bv, req, iter)
638 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
640 request = tape_alloc_request(2 + count + 1, 4);
643 request->op = TO_BLOCK;
644 *(__u32 *) request->cpdata = start_block;
645 ccw = request->cpaddr;
646 ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
649 * We always setup a nop after the mode set ccw. This slot is
650 * used in tape_std_check_locate to insert a locate ccw if the
651 * current tape position doesn't match the start block to be read.
653 ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
655 rq_for_each_segment(bv, req, iter) {
656 dst = page_address(bv->bv_page) + bv->bv_offset;
657 for (off = 0; off < bv->bv_len; off += TAPEBLOCK_HSEC_SIZE) {
658 ccw->flags = CCW_FLAG_CC;
659 ccw->cmd_code = READ_FORWARD;
660 ccw->count = TAPEBLOCK_HSEC_SIZE;
661 set_normalized_cda(ccw, (void *) __pa(dst));
663 dst += TAPEBLOCK_HSEC_SIZE;
665 BUG_ON(off > bv->bv_len);
667 ccw = tape_ccw_end(ccw, NOP, 0, NULL);
668 DBF_EVENT(6, "xBREDccwg\n");
673 tape_3590_free_bread(struct tape_request *request)
677 /* Last ccw is a nop and doesn't need clear_normalized_cda */
678 for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
679 if (ccw->cmd_code == READ_FORWARD)
680 clear_normalized_cda(ccw);
681 tape_free_request(request);
685 * check_locate is called just before the tape request is passed to
686 * the common io layer for execution. It has to check the current
687 * tape position and insert a locate ccw if it doesn't match the
688 * start block for the request.
691 tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
695 start_block = (__u32 *) request->cpdata;
696 if (*start_block != device->blk_data.block_position) {
697 /* Add the start offset of the file to get the real block. */
698 *start_block += device->bof;
699 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
704 static void tape_3590_med_state_set(struct tape_device *device,
705 struct tape_3590_med_sense *sense)
707 struct tape390_crypt_info *c_info;
709 c_info = &TAPE_3590_CRYPT_INFO(device);
711 DBF_EVENT(6, "medium state: %x:%x\n", sense->macst, sense->masst);
712 switch (sense->macst) {
716 tape_med_state_set(device, MS_UNLOADED);
717 TAPE_3590_CRYPT_INFO(device).medium_status = 0;
721 tape_med_state_set(device, MS_LOADED);
724 tape_med_state_set(device, MS_UNKNOWN);
727 c_info->medium_status |= TAPE390_MEDIUM_LOADED_MASK;
728 if (sense->flags & MSENSE_CRYPT_MASK) {
729 DBF_EVENT(6, "Medium is encrypted (%04x)\n", sense->flags);
730 c_info->medium_status |= TAPE390_MEDIUM_ENCRYPTED_MASK;
732 DBF_EVENT(6, "Medium is not encrypted %04x\n", sense->flags);
733 c_info->medium_status &= ~TAPE390_MEDIUM_ENCRYPTED_MASK;
738 * The done handler is called at device/channel end and wakes up the sleeping
742 tape_3590_done(struct tape_device *device, struct tape_request *request)
744 struct tape_3590_disc_data *disc_data;
746 DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
747 disc_data = device->discdata;
749 switch (request->op) {
763 tape_med_state_set(device, MS_LOADED);
766 tape_med_state_set(device, MS_UNLOADED);
767 tape_3590_schedule_work(device, TO_CRYPT_OFF);
770 tape_3590_med_state_set(device, request->cpdata);
773 TAPE_3590_CRYPT_INFO(device).status
774 |= TAPE390_CRYPT_ON_MASK;
775 *(device->modeset_byte) |= 0x03;
778 TAPE_3590_CRYPT_INFO(device).status
779 &= ~TAPE390_CRYPT_ON_MASK;
780 *(device->modeset_byte) &= ~0x03;
782 case TO_RBI: /* RBI seems to succeed even without medium loaded. */
783 case TO_NOP: /* Same to NOP. */
795 return TAPE_IO_SUCCESS;
799 * This fuction is called, when error recovery was successfull
802 tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
804 DBF_EVENT(3, "Error Recovery successful for %s\n",
805 tape_op_verbose[request->op]);
806 return tape_3590_done(device, request);
810 * This fuction is called, when error recovery was not successfull
813 tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
814 struct irb *irb, int rc)
816 DBF_EVENT(3, "Error Recovery failed for %s\n",
817 tape_op_verbose[request->op]);
818 tape_dump_sense_dbf(device, request, irb);
823 * Error Recovery do retry
826 tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
829 DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
830 tape_dump_sense_dbf(device, request, irb);
831 return TAPE_IO_RETRY;
835 * Handle unsolicited interrupts
838 tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
840 if (irb->scsw.cmd.dstat == DEV_STAT_CHN_END)
841 /* Probably result of halt ssch */
842 return TAPE_IO_PENDING;
843 else if (irb->scsw.cmd.dstat == 0x85)
845 DBF_EVENT(3, "unsol.irq! tape ready: %08x\n", device->cdev_id);
846 else if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
847 tape_3590_schedule_work(device, TO_READ_ATTMSG);
849 DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
850 tape_dump_sense_dbf(device, NULL, irb);
852 /* check medium state */
853 tape_3590_schedule_work(device, TO_MSEN);
854 return TAPE_IO_SUCCESS;
858 * Basic Recovery routine
861 tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
862 struct irb *irb, int rc)
864 struct tape_3590_sense *sense;
866 sense = (struct tape_3590_sense *) irb->ecw;
868 switch (sense->bra) {
870 return tape_3590_erp_failed(device, request, irb, rc);
872 return tape_3590_erp_succeded(device, request);
874 return tape_3590_erp_retry(device, request, irb);
876 return tape_3590_erp_failed(device, request, irb, rc);
884 * RDL: Read Device (buffered) log
887 tape_3590_erp_read_buf_log(struct tape_device *device,
888 struct tape_request *request, struct irb *irb)
891 * We just do the basic error recovery at the moment (retry).
892 * Perhaps in the future, we read the log and dump it somewhere...
894 return tape_3590_erp_basic(device, request, irb, -EIO);
901 tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
905 * This error recovery should swap the tapes
906 * if the original has a problem. The operation
907 * should proceed with the new tape... this
908 * should probably be done in user space!
910 dev_warn (&device->cdev->dev, "The tape medium must be loaded into a "
911 "different tape unit\n");
912 return tape_3590_erp_basic(device, request, irb, -EIO);
919 tape_3590_erp_long_busy(struct tape_device *device,
920 struct tape_request *request, struct irb *irb)
922 DBF_EVENT(6, "Device is busy\n");
923 return TAPE_IO_LONG_BUSY;
927 * SPI: Special Intercept
930 tape_3590_erp_special_interrupt(struct tape_device *device,
931 struct tape_request *request, struct irb *irb)
933 return tape_3590_erp_basic(device, request, irb, -EIO);
937 * RDA: Read Alternate
940 tape_3590_erp_read_alternate(struct tape_device *device,
941 struct tape_request *request, struct irb *irb)
943 struct tape_3590_disc_data *data;
946 * The issued Read Backward or Read Previous command is not
947 * supported by the device
948 * The recovery action should be to issue another command:
949 * Read Revious: if Read Backward is not supported
950 * Read Backward: if Read Previous is not supported
952 data = device->discdata;
953 if (data->read_back_op == READ_PREVIOUS) {
954 DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
956 data->read_back_op = READ_BACKWARD;
958 DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
960 data->read_back_op = READ_PREVIOUS;
962 tape_3590_read_opposite(device, request);
963 return tape_3590_erp_retry(device, request, irb);
967 * Error Recovery read opposite
970 tape_3590_erp_read_opposite(struct tape_device *device,
971 struct tape_request *request, struct irb *irb)
973 switch (request->op) {
976 * We did read forward, but the data could not be read.
977 * We will read backward and then skip forward again.
979 tape_3590_read_opposite(device, request);
980 return tape_3590_erp_retry(device, request, irb);
982 /* We tried to read forward and backward, but hat no success */
983 return tape_3590_erp_failed(device, request, irb, -EIO);
986 return tape_3590_erp_failed(device, request, irb, -EIO);
991 * Print an MIM (Media Information Message) (message code f0)
994 tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
996 struct tape_3590_sense *sense;
997 char *exception, *service;
999 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1000 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1002 if (!exception || !service)
1005 sense = (struct tape_3590_sense *) irb->ecw;
1006 /* Exception Message */
1007 switch (sense->fmt.f70.emc) {
1009 snprintf(exception, BUFSIZE, "Data degraded");
1012 snprintf(exception, BUFSIZE, "Data degraded in partion %i",
1016 snprintf(exception, BUFSIZE, "Medium degraded");
1019 snprintf(exception, BUFSIZE, "Medium degraded in partition %i",
1023 snprintf(exception, BUFSIZE, "Block 0 Error");
1026 snprintf(exception, BUFSIZE, "Medium Exception 0x%02x",
1030 snprintf(exception, BUFSIZE, "0x%02x",
1031 sense->fmt.f70.emc);
1034 /* Service Message */
1035 switch (sense->fmt.f70.smc) {
1037 snprintf(service, BUFSIZE, "Reference Media maintenance "
1038 "procedure %i", sense->fmt.f70.md);
1041 snprintf(service, BUFSIZE, "0x%02x",
1042 sense->fmt.f70.smc);
1046 dev_warn (&device->cdev->dev, "Tape media information: exception %s, "
1047 "service %s\n", exception, service);
1055 * Print an I/O Subsystem Service Information Message (message code f1)
1058 tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
1060 struct tape_3590_sense *sense;
1061 char *exception, *service;
1063 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1064 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1066 if (!exception || !service)
1069 sense = (struct tape_3590_sense *) irb->ecw;
1070 /* Exception Message */
1071 switch (sense->fmt.f71.emc) {
1073 snprintf(exception, BUFSIZE, "Effect of failure is unknown");
1076 snprintf(exception, BUFSIZE, "CU Exception - no performance "
1080 snprintf(exception, BUFSIZE, "CU Exception on channel "
1081 "interface 0x%02x", sense->fmt.f71.md[0]);
1084 snprintf(exception, BUFSIZE, "CU Exception on device path "
1085 "0x%02x", sense->fmt.f71.md[0]);
1088 snprintf(exception, BUFSIZE, "CU Exception on library path "
1089 "0x%02x", sense->fmt.f71.md[0]);
1092 snprintf(exception, BUFSIZE, "CU Exception on node 0x%02x",
1093 sense->fmt.f71.md[0]);
1096 snprintf(exception, BUFSIZE, "CU Exception on partition "
1097 "0x%02x", sense->fmt.f71.md[0]);
1100 snprintf(exception, BUFSIZE, "0x%02x",
1101 sense->fmt.f71.emc);
1103 /* Service Message */
1104 switch (sense->fmt.f71.smc) {
1106 snprintf(service, BUFSIZE, "Repair impact is unknown");
1109 snprintf(service, BUFSIZE, "Repair will not impact cu "
1113 if (sense->fmt.f71.mdf == 0)
1114 snprintf(service, BUFSIZE, "Repair will disable node "
1115 "0x%x on CU", sense->fmt.f71.md[1]);
1117 snprintf(service, BUFSIZE, "Repair will disable "
1118 "nodes (0x%x-0x%x) on CU", sense->fmt.f71.md[1],
1119 sense->fmt.f71.md[2]);
1122 if (sense->fmt.f71.mdf == 0)
1123 snprintf(service, BUFSIZE, "Repair will disable "
1124 "channel path 0x%x on CU",
1125 sense->fmt.f71.md[1]);
1127 snprintf(service, BUFSIZE, "Repair will disable cannel"
1128 " paths (0x%x-0x%x) on CU",
1129 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1132 if (sense->fmt.f71.mdf == 0)
1133 snprintf(service, BUFSIZE, "Repair will disable device"
1134 " path 0x%x on CU", sense->fmt.f71.md[1]);
1136 snprintf(service, BUFSIZE, "Repair will disable device"
1137 " paths (0x%x-0x%x) on CU",
1138 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1141 if (sense->fmt.f71.mdf == 0)
1142 snprintf(service, BUFSIZE, "Repair will disable "
1143 "library path 0x%x on CU",
1144 sense->fmt.f71.md[1]);
1146 snprintf(service, BUFSIZE, "Repair will disable "
1147 "library paths (0x%x-0x%x) on CU",
1148 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1151 snprintf(service, BUFSIZE, "Repair will disable access to CU");
1154 snprintf(service, BUFSIZE, "0x%02x",
1155 sense->fmt.f71.smc);
1158 dev_warn (&device->cdev->dev, "I/O subsystem information: exception"
1159 " %s, service %s\n", exception, service);
1166 * Print an Device Subsystem Service Information Message (message code f2)
1169 tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
1171 struct tape_3590_sense *sense;
1172 char *exception, *service;
1174 exception = kmalloc(BUFSIZE, GFP_ATOMIC);
1175 service = kmalloc(BUFSIZE, GFP_ATOMIC);
1177 if (!exception || !service)
1180 sense = (struct tape_3590_sense *) irb->ecw;
1181 /* Exception Message */
1182 switch (sense->fmt.f71.emc) {
1184 snprintf(exception, BUFSIZE, "Effect of failure is unknown");
1187 snprintf(exception, BUFSIZE, "DV Exception - no performance"
1191 snprintf(exception, BUFSIZE, "DV Exception on channel "
1192 "interface 0x%02x", sense->fmt.f71.md[0]);
1195 snprintf(exception, BUFSIZE, "DV Exception on loader 0x%02x",
1196 sense->fmt.f71.md[0]);
1199 snprintf(exception, BUFSIZE, "DV Exception on message display"
1200 " 0x%02x", sense->fmt.f71.md[0]);
1203 snprintf(exception, BUFSIZE, "DV Exception in tape path");
1206 snprintf(exception, BUFSIZE, "DV Exception in drive");
1209 snprintf(exception, BUFSIZE, "0x%02x",
1210 sense->fmt.f71.emc);
1212 /* Service Message */
1213 switch (sense->fmt.f71.smc) {
1215 snprintf(service, BUFSIZE, "Repair impact is unknown");
1218 snprintf(service, BUFSIZE, "Repair will not impact device "
1222 if (sense->fmt.f71.mdf == 0)
1223 snprintf(service, BUFSIZE, "Repair will disable "
1224 "channel path 0x%x on DV",
1225 sense->fmt.f71.md[1]);
1227 snprintf(service, BUFSIZE, "Repair will disable "
1228 "channel path (0x%x-0x%x) on DV",
1229 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1232 if (sense->fmt.f71.mdf == 0)
1233 snprintf(service, BUFSIZE, "Repair will disable "
1234 "interface 0x%x on DV", sense->fmt.f71.md[1]);
1236 snprintf(service, BUFSIZE, "Repair will disable "
1237 "interfaces (0x%x-0x%x) on DV",
1238 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1241 if (sense->fmt.f71.mdf == 0)
1242 snprintf(service, BUFSIZE, "Repair will disable loader"
1243 " 0x%x on DV", sense->fmt.f71.md[1]);
1245 snprintf(service, BUFSIZE, "Repair will disable loader"
1246 " (0x%x-0x%x) on DV",
1247 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1250 snprintf(service, BUFSIZE, "Repair will disable access to DV");
1253 if (sense->fmt.f71.mdf == 0)
1254 snprintf(service, BUFSIZE, "Repair will disable "
1255 "message display 0x%x on DV",
1256 sense->fmt.f71.md[1]);
1258 snprintf(service, BUFSIZE, "Repair will disable "
1259 "message displays (0x%x-0x%x) on DV",
1260 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
1263 snprintf(service, BUFSIZE, "Clean DV");
1266 snprintf(service, BUFSIZE, "0x%02x",
1267 sense->fmt.f71.smc);
1270 dev_warn (&device->cdev->dev, "Device subsystem information: exception"
1271 " %s, service %s\n", exception, service);
1278 * Print standard ERA Message
1281 tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
1283 struct tape_3590_sense *sense;
1285 sense = (struct tape_3590_sense *) irb->ecw;
1288 if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
1289 if (tape_3590_msg[sense->mc] != NULL)
1290 dev_warn (&device->cdev->dev, "The tape unit has "
1291 "issued sense message %s\n",
1292 tape_3590_msg[sense->mc]);
1294 dev_warn (&device->cdev->dev, "The tape unit has "
1295 "issued an unknown sense message code 0x%x\n",
1299 if (sense->mc == 0xf0) {
1300 /* Standard Media Information Message */
1301 dev_warn (&device->cdev->dev, "MIM SEV=%i, MC=%02x, ES=%x/%x, "
1302 "RC=%02x-%04x-%02x\n", sense->fmt.f70.sev, sense->mc,
1303 sense->fmt.f70.emc, sense->fmt.f70.smc,
1304 sense->fmt.f70.refcode, sense->fmt.f70.mid,
1305 sense->fmt.f70.fid);
1306 tape_3590_print_mim_msg_f0(device, irb);
1309 if (sense->mc == 0xf1) {
1310 /* Standard I/O Subsystem Service Information Message */
1311 dev_warn (&device->cdev->dev, "IOSIM SEV=%i, DEVTYPE=3590/%02x,"
1312 " MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
1313 sense->fmt.f71.sev, device->cdev->id.dev_model,
1314 sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc,
1315 sense->fmt.f71.refcode1, sense->fmt.f71.refcode2,
1316 sense->fmt.f71.refcode3);
1317 tape_3590_print_io_sim_msg_f1(device, irb);
1320 if (sense->mc == 0xf2) {
1321 /* Standard Device Service Information Message */
1322 dev_warn (&device->cdev->dev, "DEVSIM SEV=%i, DEVTYPE=3590/%02x"
1323 ", MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
1324 sense->fmt.f71.sev, device->cdev->id.dev_model,
1325 sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc,
1326 sense->fmt.f71.refcode1, sense->fmt.f71.refcode2,
1327 sense->fmt.f71.refcode3);
1328 tape_3590_print_dev_sim_msg_f2(device, irb);
1331 if (sense->mc == 0xf3) {
1332 /* Standard Library Service Information Message */
1335 dev_warn (&device->cdev->dev, "The tape unit has issued an unknown "
1336 "sense message code %x\n", sense->mc);
1339 static int tape_3590_crypt_error(struct tape_device *device,
1340 struct tape_request *request, struct irb *irb)
1348 sense = ((struct tape_3590_sense *) irb->ecw)->fmt.data;
1349 bus_id = dev_name(&device->cdev->dev);
1351 drv_rc = *((u32*) &sense[5]) & 0xffffff;
1353 ekm_rc2 = *((u16*) &sense[10]);
1354 if ((cu_rc == 0) && (ekm_rc2 == 0xee31))
1355 /* key not defined on EKM */
1356 return tape_3590_erp_basic(device, request, irb, -EKEYREJECTED);
1357 if ((cu_rc == 1) || (cu_rc == 2))
1358 /* No connection to EKM */
1359 return tape_3590_erp_basic(device, request, irb, -ENOTCONN);
1361 dev_err (&device->cdev->dev, "The tape unit failed to obtain the "
1362 "encryption key from EKM\n");
1364 return tape_3590_erp_basic(device, request, irb, -ENOKEY);
1368 * 3590 error Recovery routine:
1369 * If possible, it tries to recover from the error. If this is not possible,
1370 * inform the user about the problem.
1373 tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
1376 struct tape_3590_sense *sense;
1379 #ifdef CONFIG_S390_TAPE_BLOCK
1380 if (request->op == TO_BLOCK) {
1382 * Recovery for block device requests. Set the block_position
1383 * to something invalid and retry.
1385 device->blk_data.block_position = -1;
1386 if (request->retries-- <= 0)
1387 return tape_3590_erp_failed(device, request, irb, -EIO);
1389 return tape_3590_erp_retry(device, request, irb);
1393 sense = (struct tape_3590_sense *) irb->ecw;
1395 DBF_EVENT(6, "Unit Check: RQC = %x\n", sense->rc_rqc);
1398 * First check all RC-QRCs where we want to do something special
1399 * - "break": basic error recovery is done
1400 * - "goto out:": just print error message if available
1403 switch (sense->rc_rqc) {
1406 tape_3590_print_era_msg(device, irb);
1407 return tape_3590_erp_read_buf_log(device, request, irb);
1410 tape_3590_print_era_msg(device, irb);
1411 return tape_3590_erp_read_alternate(device, request, irb);
1415 tape_3590_print_era_msg(device, irb);
1416 return tape_3590_erp_special_interrupt(device, request, irb);
1418 return tape_3590_crypt_error(device, request, irb);
1421 DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
1423 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1425 DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
1427 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1429 DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
1430 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1433 DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
1435 return tape_3590_erp_basic(device, request, irb, -EIO);
1437 DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
1439 tape_med_state_set(device, MS_UNLOADED);
1440 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1441 return tape_3590_erp_basic(device, request, irb, 0);
1445 * print additional msg since default msg
1446 * "device intervention" is not very meaningfull
1448 tape_med_state_set(device, MS_UNLOADED);
1449 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1450 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1451 case 0x4012: /* Device Long Busy */
1452 /* XXX: Also use long busy handling here? */
1453 DBF_EVENT(6, "(%08x): LONG BUSY\n", device->cdev_id);
1454 tape_3590_print_era_msg(device, irb);
1455 return tape_3590_erp_basic(device, request, irb, -EBUSY);
1457 DBF_EVENT(6, "(%08x): Crypto LONG BUSY\n", device->cdev_id);
1458 return tape_3590_erp_long_busy(device, request, irb);
1461 if (sense->rac == 0xd0) {
1463 tape_3590_print_era_msg(device, irb);
1464 return tape_3590_erp_swap(device, request, irb);
1466 if (sense->rac == 0x26) {
1468 tape_3590_print_era_msg(device, irb);
1469 return tape_3590_erp_read_opposite(device, request,
1472 return tape_3590_erp_basic(device, request, irb, -EIO);
1479 tape_3590_print_era_msg(device, irb);
1480 return tape_3590_erp_swap(device, request, irb);
1484 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1488 tape_med_state_set(device, MS_UNLOADED);
1489 tape_3590_schedule_work(device, TO_CRYPT_OFF);
1490 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1493 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1496 return tape_3590_erp_basic(device, request, irb, -EPERM);
1498 dev_warn (&device->cdev->dev, "A different host has privileged"
1499 " access to the tape unit\n");
1500 return tape_3590_erp_basic(device, request, irb, -EPERM);
1502 return tape_3590_erp_basic(device, request, irb, -EIO);
1507 * 3590 interrupt handler:
1510 tape_3590_irq(struct tape_device *device, struct tape_request *request,
1513 if (request == NULL)
1514 return tape_3590_unsolicited_irq(device, irb);
1516 if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) &&
1517 (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) &&
1518 (request->op == TO_WRI)) {
1519 /* Write at end of volume */
1520 DBF_EVENT(2, "End of volume\n");
1521 return tape_3590_erp_failed(device, request, irb, -ENOSPC);
1524 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
1525 return tape_3590_unit_check(device, request, irb);
1527 if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
1528 if (irb->scsw.cmd.dstat == DEV_STAT_UNIT_EXCEP) {
1529 if (request->op == TO_FSB || request->op == TO_BSB)
1532 DBF_EVENT(5, "Unit Exception!\n");
1535 return tape_3590_done(device, request);
1538 if (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) {
1539 DBF_EVENT(2, "cannel end\n");
1540 return TAPE_IO_PENDING;
1543 if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) {
1544 DBF_EVENT(2, "Unit Attention when busy..\n");
1545 return TAPE_IO_PENDING;
1548 DBF_EVENT(6, "xunknownirq\n");
1549 tape_dump_sense_dbf(device, request, irb);
1550 return TAPE_IO_STOP;
1554 static int tape_3590_read_dev_chars(struct tape_device *device,
1555 struct tape_3590_rdc_data *rdc_data)
1558 struct tape_request *request;
1560 request = tape_alloc_request(1, sizeof(*rdc_data));
1561 if (IS_ERR(request))
1562 return PTR_ERR(request);
1563 request->op = TO_RDC;
1564 tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data),
1566 rc = tape_do_io(device, request);
1568 memcpy(rdc_data, request->cpdata, sizeof(*rdc_data));
1569 tape_free_request(request);
1574 * Setup device function
1577 tape_3590_setup_device(struct tape_device *device)
1580 struct tape_3590_disc_data *data;
1581 struct tape_3590_rdc_data *rdc_data;
1583 DBF_EVENT(6, "3590 device setup\n");
1584 data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA);
1587 data->read_back_op = READ_PREVIOUS;
1588 device->discdata = data;
1590 rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA);
1595 rc = tape_3590_read_dev_chars(device, rdc_data);
1597 DBF_LH(3, "Read device characteristics failed!\n");
1600 rc = tape_std_assign(device);
1603 if (rdc_data->data[31] == 0x13) {
1604 data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK;
1605 tape_3592_disable_crypt(device);
1607 DBF_EVENT(6, "Device has NO crypto support\n");
1609 /* Try to find out if medium is loaded */
1610 rc = tape_3590_sense_medium(device);
1612 DBF_LH(3, "3590 medium sense returned %d\n", rc);
1625 * Cleanup device function
1628 tape_3590_cleanup_device(struct tape_device *device)
1630 flush_scheduled_work();
1631 tape_std_unassign(device);
1633 kfree(device->discdata);
1634 device->discdata = NULL;
1638 * List of 3590 magnetic tape commands.
1640 static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
1641 [MTRESET] = tape_std_mtreset,
1642 [MTFSF] = tape_std_mtfsf,
1643 [MTBSF] = tape_std_mtbsf,
1644 [MTFSR] = tape_std_mtfsr,
1645 [MTBSR] = tape_std_mtbsr,
1646 [MTWEOF] = tape_std_mtweof,
1647 [MTREW] = tape_std_mtrew,
1648 [MTOFFL] = tape_std_mtoffl,
1649 [MTNOP] = tape_std_mtnop,
1650 [MTRETEN] = tape_std_mtreten,
1651 [MTBSFM] = tape_std_mtbsfm,
1652 [MTFSFM] = tape_std_mtfsfm,
1653 [MTEOM] = tape_std_mteom,
1654 [MTERASE] = tape_std_mterase,
1658 [MTSETBLK] = tape_std_mtsetblk,
1659 [MTSETDENSITY] = NULL,
1660 [MTSEEK] = tape_3590_mtseek,
1661 [MTTELL] = tape_3590_mttell,
1662 [MTSETDRVBUFFER] = NULL,
1668 [MTLOAD] = tape_std_mtload,
1669 [MTUNLOAD] = tape_std_mtunload,
1670 [MTCOMPRESSION] = tape_std_mtcompression,
1676 * Tape discipline structure for 3590.
1678 static struct tape_discipline tape_discipline_3590 = {
1679 .owner = THIS_MODULE,
1680 .setup_device = tape_3590_setup_device,
1681 .cleanup_device = tape_3590_cleanup_device,
1682 .process_eov = tape_std_process_eov,
1683 .irq = tape_3590_irq,
1684 .read_block = tape_std_read_block,
1685 .write_block = tape_std_write_block,
1686 #ifdef CONFIG_S390_TAPE_BLOCK
1687 .bread = tape_3590_bread,
1688 .free_bread = tape_3590_free_bread,
1689 .check_locate = tape_3590_check_locate,
1691 .ioctl_fn = tape_3590_ioctl,
1692 .mtop_array = tape_3590_mtop
1695 static struct ccw_device_id tape_3590_ids[] = {
1696 {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
1697 {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592},
1698 { /* end of list */ }
1702 tape_3590_online(struct ccw_device *cdev)
1704 return tape_generic_online(dev_get_drvdata(&cdev->dev),
1705 &tape_discipline_3590);
1708 static struct ccw_driver tape_3590_driver = {
1709 .name = "tape_3590",
1710 .owner = THIS_MODULE,
1711 .ids = tape_3590_ids,
1712 .probe = tape_generic_probe,
1713 .remove = tape_generic_remove,
1714 .set_offline = tape_generic_offline,
1715 .set_online = tape_3590_online,
1716 .freeze = tape_generic_pm_suspend,
1720 * Setup discipline structure.
1723 tape_3590_init(void)
1727 TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
1728 debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
1729 #ifdef DBF_LIKE_HELL
1730 debug_set_level(TAPE_DBF_AREA, 6);
1733 DBF_EVENT(3, "3590 init\n");
1734 /* Register driver for 3590 tapes. */
1735 rc = ccw_driver_register(&tape_3590_driver);
1737 DBF_EVENT(3, "3590 init failed\n");
1739 DBF_EVENT(3, "3590 registered\n");
1744 tape_3590_exit(void)
1746 ccw_driver_unregister(&tape_3590_driver);
1748 debug_unregister(TAPE_DBF_AREA);
1751 MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
1752 MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
1753 MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
1754 MODULE_LICENSE("GPL");
1756 module_init(tape_3590_init);
1757 module_exit(tape_3590_exit);