1 /***************************************************************************
3 * drivers/s390/char/tape34xx.c
4 * common tape device discipline for 34xx tapes.
6 * S390 and zSeries version
7 * Copyright (C) 2001 IBM Corporation
8 * Author(s): Carsten Otte <cotte@de.ibm.com>
9 * Tuan Ngo-Anh <ngoanh@de.ibm.com>
11 ****************************************************************************
15 #include <linux/config.h>
16 #include <linux/version.h>
17 #include <linux/stddef.h>
18 #include <linux/kernel.h>
19 #include <asm/types.h>
20 #include <asm/uaccess.h>
21 #include <linux/stat.h>
22 #include <linux/proc_fs.h>
23 #include <asm/ccwcache.h>
24 #include <asm/idals.h>
25 #ifdef CONFIG_S390_TAPE_DYNAMIC
26 #include <asm/s390dyn.h>
28 #include <asm/debug.h>
29 #include <linux/compatmac.h>
33 #define PRINTK_HEADER "T34xx:"
35 tape_event_handler_t tape34xx_event_handler_table[TS_SIZE][TE_SIZE] =
37 /* {START , DONE, FAILED, ERROR, OTHER } */
38 {NULL, tape34xx_unused_done, NULL, NULL, NULL}, /* TS_UNUSED */
39 {NULL, tape34xx_idle_done, NULL, NULL, NULL}, /* TS_IDLE */
40 {NULL, NULL, NULL, NULL, NULL}, /* TS_DONE */
41 {NULL, NULL, NULL, NULL, NULL}, /* TS_FAILED */
42 {NULL, tape34xx_block_done, NULL, NULL, NULL}, /* TS_BLOCK_INIT */
43 {NULL, tape34xx_bsb_init_done, NULL, NULL, NULL}, /* TS_BSB_INIT */
44 {NULL, tape34xx_bsf_init_done, NULL, NULL, NULL}, /* TS_BSF_INIT */
45 {NULL, tape34xx_dse_init_done, NULL, NULL, NULL}, /* TS_DSE_INIT */
46 {NULL, NULL, NULL, NULL, NULL}, /* TS_EGA_INIT */
47 {NULL, tape34xx_fsb_init_done, NULL, NULL, NULL}, /* TS_FSB_INIT */
48 {NULL, tape34xx_fsf_init_done, NULL, NULL, NULL}, /* TS_FSF_INIT */
49 {NULL, NULL, NULL, NULL, NULL}, /* TS_LDI_INIT */
50 {NULL, tape34xx_lbl_init_done, NULL, NULL, NULL}, /* TS_LBL_INIT */
51 {NULL, NULL, NULL, NULL, NULL}, /* TS_MSE_INIT */
52 {NULL, tape34xx_nop_init_done, NULL, NULL, NULL}, /* TS_NOP_INIT */
53 {NULL, NULL, NULL, NULL, NULL}, /* TS_RBA_INIT */
54 {NULL, tape34xx_rbi_init_done, NULL, NULL, NULL}, /* TS_RBI_INIT */
55 {NULL, NULL, NULL, NULL, NULL}, /* TS_RBU_INIT */
56 {NULL, NULL, NULL, NULL, NULL}, /* TS_RBL_INIT */
57 {NULL, NULL, NULL, NULL, NULL}, /* TS_RDC_INIT */
58 {NULL, tape34xx_rfo_init_done, NULL, NULL, NULL}, /* TS_RFO_INIT */
59 {NULL, NULL, NULL, NULL, NULL}, /* TS_RSD_INIT */
60 {NULL, tape34xx_rew_init_done, NULL, NULL, NULL}, /* TS_REW_INIT */
61 {NULL, tape34xx_rew_release_init_done, NULL, NULL, NULL}, /* TS_REW_RELEASE_IMIT */
62 {NULL, tape34xx_run_init_done, NULL, NULL, NULL}, /* TS_RUN_INIT */
63 {NULL, NULL, NULL, NULL, NULL}, /* TS_SEN_INIT */
64 {NULL, NULL, NULL, NULL, NULL}, /* TS_SID_INIT */
65 {NULL, NULL, NULL, NULL, NULL}, /* TS_SNP_INIT */
66 {NULL, NULL, NULL, NULL, NULL}, /* TS_SPG_INIT */
67 {NULL, NULL, NULL, NULL, NULL}, /* TS_SWI_INIT */
68 {NULL, NULL, NULL, NULL, NULL}, /* TS_SMR_INIT */
69 {NULL, NULL, NULL, NULL, NULL}, /* TS_SYN_INIT */
70 {NULL, NULL, NULL, NULL, NULL}, /* TS_TIO_INIT */
71 {NULL, NULL, NULL, NULL, NULL}, /* TS_UNA_INIT */
72 {NULL, tape34xx_wri_init_done, NULL, NULL, NULL}, /* TS_WRI_INIT */
73 {NULL, tape34xx_wtm_init_done, NULL, NULL, NULL}, /* TS_WTM_INIT */
74 {NULL, NULL, NULL, NULL, NULL}}; /* TS_NOT_OPER */
78 tape34xx_ioctl_overload (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
80 return -EINVAL; // no additional ioctls
85 tape34xx_write_block (const char *data, size_t count, tape_info_t * ti)
91 cqr = tape_alloc_ccw_req (ti, 2, 0);
94 debug_text_exception (tape_debug_area,6,"xwbl nomem");
95 #endif /* TAPE_DEBUG */
98 mem = kmalloc (count, GFP_KERNEL);
100 tape_free_request (cqr);
102 debug_text_exception (tape_debug_area,6,"xwbl nomem");
103 #endif /* TAPE_DEBUG */
106 if (copy_from_user (mem, data, count)) {
108 tape_free_request (cqr);
110 debug_text_exception (tape_debug_area,6,"xwbl segf.");
111 #endif /* TAPE_DEBUG */
115 ccw->cmd_code = MODE_SET_DB;
116 ccw->flags = CCW_FLAG_CC;
118 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
121 ccw->cmd_code = WRITE_CMD;
124 set_normalized_cda (ccw, (unsigned long) mem);
125 if ((ccw->cda) == 0) {
127 tape_free_request (cqr);
130 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
132 ti->userbuf = (void *) data;
133 tapestate_set (ti, TS_WRI_INIT);
134 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
136 debug_text_event (tape_debug_area,6,"xwbl ccwg");
137 #endif /* TAPE_DEBUG */
142 tape34xx_free_write_block (ccw_req_t * cqr, tape_info_t * ti)
144 unsigned long lockflags;
146 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
149 clear_normalized_cda (ccw);
151 tape_free_request (cqr);
152 ti->kernbuf = ti->userbuf = NULL;
153 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
155 debug_text_event (tape_debug_area,6,"xfwb free");
156 #endif /* TAPE_DEBUG */
160 tape34xx_read_block (const char *data, size_t count, tape_info_t * ti)
166 cqr = tape_alloc_ccw_req (ti, 2, 0);
169 debug_text_exception (tape_debug_area,6,"xrbl nomem");
170 #endif /* TAPE_DEBUG */
173 mem = kmalloc (count, GFP_KERNEL);
175 tape_free_request (cqr);
177 debug_text_exception (tape_debug_area,6,"xrbl nomem");
178 #endif /* TAPE_DEBUG */
182 ccw->cmd_code = MODE_SET_DB;
183 ccw->flags = CCW_FLAG_CC;
185 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
188 ccw->cmd_code = READ_FORWARD;
191 set_normalized_cda (ccw, (unsigned long) mem);
192 if ((ccw->cda) == 0) {
194 tape_free_request (cqr);
197 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
199 ti->userbuf = (void *) data;
200 tapestate_set (ti, TS_RFO_INIT);
201 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
203 debug_text_event (tape_debug_area,6,"xrbl ccwg");
204 #endif /* TAPE_DEBUG */
209 tape34xx_read_opposite (tape_info_t * ti,int novalue)
214 // first, retrieve the count from the old cqr.
220 clear_normalized_cda (ccw);
221 tape_free_request (cqr);
223 cqr = tape_alloc_ccw_req (ti, 3, 0);
226 debug_text_exception (tape_debug_area,6,"xrop nomem");
227 #endif /* TAPE_DEBUG */
231 ccw->cmd_code = MODE_SET_DB;
232 ccw->flags = CCW_FLAG_CC;
234 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
237 ccw->cmd_code = READ_BACKWARD;
238 ccw->flags = CCW_FLAG_CC;
240 set_normalized_cda (ccw, (unsigned long) ti->kernbuf);
241 if ((ccw->cda) == 0) {
242 tape_free_request (cqr);
246 ccw->cmd_code = FORSPACEBLOCK;
247 ccw->flags = CCW_FLAG_CC;
249 ccw->cda = (unsigned long)ccw;
254 ccw->cda = (unsigned long)ccw;
255 tapestate_set (ti, TS_RBA_INIT);
257 debug_text_event (tape_debug_area,6,"xrop ccwg");
258 #endif /* TAPE_DEBUG */
263 tape34xx_free_read_block (ccw_req_t * cqr, tape_info_t * ti)
265 unsigned long lockflags;
268 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
271 cpysize = ccw->count - ti->devstat.rescnt;
272 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
273 if (copy_to_user (ti->userbuf, ti->kernbuf, cpysize)) {
275 debug_text_exception (tape_debug_area,6,"xfrb segf.");
276 #endif /* TAPE_DEBUG */
278 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
279 clear_normalized_cda (ccw);
281 tape_free_request (cqr);
282 ti->kernbuf = ti->userbuf = NULL;
283 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
285 debug_text_event (tape_debug_area,6,"xfrb free");
286 #endif /* TAPE_DEBUG */
290 * The IOCTL interface is implemented in the following section,
291 * excepted the MTRESET, MTSETBLK which are handled by tapechar.c
294 * MTFSF: Forward space over 'count' file marks. The tape is positioned
295 * at the EOT (End of Tape) side of the file mark.
298 tape34xx_mtfsf (tape_info_t * ti, int count)
304 if ((count == 0) || (count > 510)) {
306 debug_text_exception (tape_debug_area,6,"xfsf parm");
307 #endif /* TAPE_DEBUG */
310 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
313 debug_text_exception (tape_debug_area,6,"xfsf nomem");
314 #endif /* TAPE_DEBUG */
318 ccw->cmd_code = MODE_SET_DB;
319 ccw->flags = CCW_FLAG_CC;
321 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
323 for (i = 0; i < count; i++) {
324 ccw->cmd_code = FORSPACEFILE;
325 ccw->flags = CCW_FLAG_CC;
327 ccw->cda = (unsigned long) (&(ccw->cmd_code));
333 ccw->cda = (unsigned long) (&(ccw->cmd_code));
334 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
337 tapestate_set (ti, TS_FSF_INIT);
338 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
340 debug_text_event (tape_debug_area,6,"xfsf ccwg");
341 #endif /* TAPE_DEBUG */
346 * MTBSF: Backward space over 'count' file marks. The tape is positioned at
347 * the EOT (End of Tape) side of the last skipped file mark.
350 tape34xx_mtbsf (tape_info_t * ti, int count)
356 if ((count == 0) || (count > 510)) {
358 debug_text_exception (tape_debug_area,6,"xbsf parm");
359 #endif /* TAPE_DEBUG */
362 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
365 debug_text_exception (tape_debug_area,6,"xbsf nomem");
366 #endif /* TAPE_DEBUG */
370 ccw->cmd_code = MODE_SET_DB;
371 ccw->flags = CCW_FLAG_CC;
373 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
375 for (i = 0; i < count; i++) {
376 ccw->cmd_code = BACKSPACEFILE;
377 ccw->flags = CCW_FLAG_CC;
379 ccw->cda = (unsigned long) (&(ccw->cmd_code));
385 ccw->cda = (unsigned long) (&(ccw->cmd_code));
386 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
389 tapestate_set (ti, TS_BSF_INIT);
390 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
392 debug_text_event (tape_debug_area,6,"xbsf ccwg");
393 #endif /* TAPE_DEBUG */
398 * MTFSR: Forward space over 'count' tape blocks (blocksize is set
402 tape34xx_mtfsr (tape_info_t * ti, int count)
408 if ((count == 0) || (count > 510)) {
410 debug_text_exception (tape_debug_area,6,"xfsr parm");
411 #endif /* TAPE_DEBUG */
414 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
417 debug_text_exception (tape_debug_area,6,"xfsr nomem");
418 #endif /* TAPE_DEBUG */
422 ccw->cmd_code = MODE_SET_DB;
423 ccw->flags = CCW_FLAG_CC;
425 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
427 for (i = 0; i < count; i++) {
428 ccw->cmd_code = FORSPACEBLOCK;
429 ccw->flags = CCW_FLAG_CC;
431 ccw->cda = (unsigned long) (&(ccw->cmd_code));
437 ccw->cda = (unsigned long) (&(ccw->cmd_code));
438 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
441 tapestate_set (ti, TS_FSB_INIT);
442 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
444 debug_text_event (tape_debug_area,6,"xfsr ccwgen");
445 #endif /* TAPE_DEBUG */
450 * MTBSR: Backward space over 'count' tape blocks.
451 * (blocksize is set via MTSETBLK.
454 tape34xx_mtbsr (tape_info_t * ti, int count)
460 if ((count == 0) || (count > 510)) {
462 debug_text_exception (tape_debug_area,6,"xbsr parm");
463 #endif /* TAPE_DEBUG */
466 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
469 debug_text_exception (tape_debug_area,6,"xbsr nomem");
470 #endif /* TAPE_DEBUG */
474 ccw->cmd_code = MODE_SET_DB;
475 ccw->flags = CCW_FLAG_CC;
477 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
479 for (i = 0; i < count; i++) {
480 ccw->cmd_code = BACKSPACEBLOCK;
481 ccw->flags = CCW_FLAG_CC;
483 ccw->cda = (unsigned long) (&(ccw->cmd_code));
489 ccw->cda = (unsigned long) (&(ccw->cmd_code));
490 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
493 tapestate_set (ti, TS_BSB_INIT);
494 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
496 debug_text_event (tape_debug_area,6,"xbsr ccwg");
497 #endif /* TAPE_DEBUG */
502 * MTWEOF: Write 'count' file marks at the current position.
505 tape34xx_mtweof (tape_info_t * ti, int count)
511 if ((count == 0) || (count > 510)) {
513 debug_text_exception (tape_debug_area,6,"xweo parm");
514 #endif /* TAPE_DEBUG */
517 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
520 debug_text_exception (tape_debug_area,6,"xweo nomem");
521 #endif /* TAPE_DEBUG */
525 ccw->cmd_code = MODE_SET_DB;
526 ccw->flags = CCW_FLAG_CC;
528 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
530 for (i = 0; i < count; i++) {
531 ccw->cmd_code = WRITETAPEMARK;
532 ccw->flags = CCW_FLAG_CC;
534 ccw->cda = (unsigned long) (&(ccw->cmd_code));
540 ccw->cda = (unsigned long) (&(ccw->cmd_code));
542 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
545 tapestate_set (ti, TS_WTM_INIT);
546 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
548 debug_text_event (tape_debug_area,6,"xweo ccwg");
549 #endif /* TAPE_DEBUG */
554 * MTREW: Rewind the tape.
557 tape34xx_mtrew (tape_info_t * ti, int count)
562 cqr = tape_alloc_ccw_req (ti, 3, 0);
565 debug_text_exception (tape_debug_area,6,"xrew nomem");
566 #endif /* TAPE_DEBUG */
570 ccw->cmd_code = MODE_SET_DB;
571 ccw->flags = CCW_FLAG_CC;
573 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
575 ccw->cmd_code = REWIND;
576 ccw->flags = CCW_FLAG_CC;
578 ccw->cda = (unsigned long) (&(ccw->cmd_code));
583 ccw->cda = (unsigned long) (&(ccw->cmd_code));
584 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
587 tapestate_set (ti, TS_REW_INIT);
588 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
590 debug_text_event (tape_debug_area,6,"xrew ccwg");
591 #endif /* TAPE_DEBUG */
596 * MTOFFL: Rewind the tape and put the drive off-line.
597 * Implement 'rewind unload'
600 tape34xx_mtoffl (tape_info_t * ti, int count)
605 cqr = tape_alloc_ccw_req (ti, 3, 32);
608 debug_text_exception (tape_debug_area,6,"xoff nomem");
609 #endif /* TAPE_DEBUG */
613 ccw->cmd_code = MODE_SET_DB;
614 ccw->flags = CCW_FLAG_CC;
616 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
618 ccw->cmd_code = REWIND_UNLOAD;
619 ccw->flags = CCW_FLAG_CC;
621 ccw->cda = (unsigned long) (&(ccw->cmd_code));
623 ccw->cmd_code = SENSE;
626 ccw->cda = (unsigned long) cqr->cpaddr;
627 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
630 tapestate_set (ti, TS_RUN_INIT);
631 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
633 debug_text_event (tape_debug_area,6,"xoff ccwg");
634 #endif /* TAPE_DEBUG */
639 * MTNOP: 'No operation'.
642 tape34xx_mtnop (tape_info_t * ti, int count)
647 cqr = tape_alloc_ccw_req (ti, 1, 0);
650 debug_text_exception (tape_debug_area,6,"xnop nomem");
651 #endif /* TAPE_DEBUG */
658 ccw->cda = (unsigned long) ccw->cmd_code;
659 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
662 tapestate_set (ti, TS_NOP_INIT);
663 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
665 debug_text_event (tape_debug_area,6,"xnop ccwg");
666 #endif /* TAPE_DEBUG */
671 * MTBSFM: Backward space over 'count' file marks.
672 * The tape is positioned at the BOT (Begin Of Tape) side of the
673 * last skipped file mark.
676 tape34xx_mtbsfm (tape_info_t * ti, int count)
682 if ((count == 0) || (count > 510)) {
684 debug_text_exception (tape_debug_area,6,"xbsm parm");
685 #endif /* TAPE_DEBUG */
688 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
691 debug_text_exception (tape_debug_area,6,"xbsm nomem");
692 #endif /* TAPE_DEBUG */
696 ccw->cmd_code = MODE_SET_DB;
697 ccw->flags = CCW_FLAG_CC;
699 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
701 for (i = 0; i < count; i++) {
702 ccw->cmd_code = BACKSPACEFILE;
703 ccw->flags = CCW_FLAG_CC;
705 ccw->cda = (unsigned long) (&(ccw->cmd_code));
711 ccw->cda = (unsigned long) (&(ccw->cmd_code));
712 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
715 tapestate_set (ti, TS_BSF_INIT);
716 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
718 debug_text_event (tape_debug_area,6,"xbsm ccwg");
719 #endif /* TAPE_DEBUG */
724 * MTFSFM: Forward space over 'count' file marks.
725 * The tape is positioned at the BOT (Begin Of Tape) side
726 * of the last skipped file mark.
729 tape34xx_mtfsfm (tape_info_t * ti, int count)
735 if ((count == 0) || (count > 510)) {
737 debug_text_exception (tape_debug_area,6,"xfsm parm");
738 #endif /* TAPE_DEBUG */
741 cqr = tape_alloc_ccw_req (ti, 2 + count, 0);
744 debug_text_exception (tape_debug_area,6,"xfsm nomem");
745 #endif /* TAPE_DEBUG */
749 ccw->cmd_code = MODE_SET_DB;
750 ccw->flags = CCW_FLAG_CC;
752 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
754 for (i = 0; i < count; i++) {
755 ccw->cmd_code = FORSPACEFILE;
756 ccw->flags = CCW_FLAG_CC;
758 ccw->cda = (unsigned long) (&(ccw->cmd_code));
764 ccw->cda = (unsigned long) (&(ccw->cmd_code));
765 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
768 tapestate_set (ti, TS_FSF_INIT);
769 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
771 debug_text_event (tape_debug_area,6,"xfsm ccwg");
772 #endif /* TAPE_DEBUG */
777 * MTEOM: positions at the end of the portion of the tape already used
778 * for recordind data. MTEOM positions after the last file mark, ready for
779 * appending another file.
780 * MTRETEN: Retension the tape, i.e. forward space to end of tape and rewind.
783 tape34xx_mteom (tape_info_t * ti, int count)
788 cqr = tape_alloc_ccw_req (ti, 4, 0);
791 debug_text_exception (tape_debug_area,6,"xeom nomem");
792 #endif /* TAPE_DEBUG */
796 ccw->cmd_code = MODE_SET_DB;
797 ccw->flags = CCW_FLAG_CC;
799 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
801 ccw->cmd_code = FORSPACEFILE;
802 ccw->flags = CCW_FLAG_CC;
804 ccw->cda = (unsigned long) (&(ccw->cmd_code));
807 ccw->flags = CCW_FLAG_CC;
809 ccw->cda = (unsigned long) (&(ccw->cmd_code));
811 ccw->cmd_code = CCW_CMD_TIC;
814 ccw->cda = (unsigned long) (cqr->cpaddr);
815 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
818 tapestate_set (ti, TS_FSF_INIT);
819 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
821 debug_text_event (tape_debug_area,6,"xeom ccwg");
822 #endif /* TAPE_DEBUG */
827 * MTERASE: erases the tape.
830 tape34xx_mterase (tape_info_t * ti, int count)
835 cqr = tape_alloc_ccw_req (ti, 5, 0);
838 debug_text_exception (tape_debug_area,6,"xera nomem");
839 #endif /* TAPE_DEBUG */
843 ccw->cmd_code = MODE_SET_DB;
844 ccw->flags = CCW_FLAG_CC;
846 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
848 ccw->cmd_code = REWIND;
849 ccw->flags = CCW_FLAG_CC;
851 ccw->cda = (unsigned long) (&(ccw->cmd_code));
853 ccw->cmd_code = ERASE_GAP;
854 ccw->flags = CCW_FLAG_CC;
856 ccw->cda = (unsigned long) (&(ccw->cmd_code));
858 ccw->cmd_code = DATA_SEC_ERASE;
859 ccw->flags = CCW_FLAG_CC;
861 ccw->cda = (unsigned long) (&(ccw->cmd_code));
866 ccw->cda = (unsigned long) (&(ccw->cmd_code));
867 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
870 tapestate_set (ti, TS_DSE_INIT);
871 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
873 debug_text_event (tape_debug_area,6,"xera ccwg");
874 #endif /* TAPE_DEBUG */
879 * MTSETDENSITY: set tape density.
882 tape34xx_mtsetdensity (tape_info_t * ti, int count)
887 cqr = tape_alloc_ccw_req (ti, 2, 0);
890 debug_text_exception (tape_debug_area,6,"xden nomem");
891 #endif /* TAPE_DEBUG */
895 ccw->cmd_code = MODE_SET_DB;
896 ccw->flags = CCW_FLAG_CC;
898 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
903 ccw->cda = (unsigned long) (&(ccw->cmd_code));
904 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
907 tapestate_set (ti, TS_NOP_INIT);
908 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
910 debug_text_event (tape_debug_area,6,"xden ccwg");
911 #endif /* TAPE_DEBUG */
916 * MTSEEK: seek to the specified block.
919 tape34xx_mtseek (tape_info_t * ti, int count)
925 if ((data = kmalloc (4 * sizeof (__u8), GFP_KERNEL)) == NULL) {
927 debug_text_exception (tape_debug_area,6,"xsee nomem");
928 #endif /* TAPE_DEBUG */
932 data[1] = data[2] = data[3] = 0x00;
933 if (count >= 4194304) {
935 debug_text_exception (tape_debug_area,6,"xsee parm");
936 #endif /* TAPE_DEBUG */
940 if (((tape34xx_disc_data_t *) ti->discdata)->modeset_byte & 0x08) // IDRC on
942 data[1] = data[1] | 0x80;
943 data[3] += count % 256;
944 data[2] += (count / 256) % 256;
945 data[1] += (count / 65536);
947 debug_text_event (tape_debug_area,6,"xsee id:");
948 debug_int_event (tape_debug_area,6,count);
949 #endif /* TAPE_DEBUG */
950 cqr = tape_alloc_ccw_req (ti, 3, 0);
953 debug_text_exception (tape_debug_area,6,"xsee nomem");
954 #endif /* TAPE_DEBUG */
959 ccw->cmd_code = MODE_SET_DB;
960 ccw->flags = CCW_FLAG_CC;
962 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
964 ccw->cmd_code = LOCATE;
965 ccw->flags = CCW_FLAG_CC;
967 set_normalized_cda (ccw, (unsigned long) data);
972 ccw->cda = (unsigned long) (&(ccw->cmd_code));
973 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
976 tapestate_set (ti, TS_LBL_INIT);
977 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
979 debug_text_event (tape_debug_area,6,"xsee ccwg");
980 #endif /* TAPE_DEBUG */
985 * MTTELL: Tell block. Return the number of block relative to current file.
988 tape34xx_mttell (tape_info_t * ti, int count)
994 cqr = tape_alloc_ccw_req (ti, 2, 0);
997 debug_text_exception (tape_debug_area,6,"xtel nomem");
998 #endif /* TAPE_DEBUG */
1001 mem = kmalloc (8, GFP_KERNEL);
1003 tape_free_request (cqr);
1005 debug_text_exception (tape_debug_area,6,"xtel nomem");
1006 #endif /* TAPE_DEBUG */
1010 ccw->cmd_code = MODE_SET_DB;
1011 ccw->flags = CCW_FLAG_CC;
1013 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1016 ccw->cmd_code = READ_BLOCK_ID;
1019 set_normalized_cda (ccw, (unsigned long) mem);
1020 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1023 tapestate_set (ti, TS_RBI_INIT);
1024 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1026 debug_text_event (tape_debug_area,6,"xtel ccwg");
1027 #endif /* TAPE_DEBUG */
1032 * MTSETDRVBUFFER: Set the tape drive buffer code to number.
1036 tape34xx_mtsetdrvbuffer (tape_info_t * ti, int count)
1041 cqr = tape_alloc_ccw_req (ti, 2, 0);
1044 debug_text_exception (tape_debug_area,6,"xbuf nomem");
1045 #endif /* TAPE_DEBUG */
1049 ccw->cmd_code = MODE_SET_DB;
1050 ccw->flags = CCW_FLAG_CC;
1052 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1054 ccw->cmd_code = NOP;
1057 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1058 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1061 tapestate_set (ti, TS_NOP_INIT);
1062 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1064 debug_text_event (tape_debug_area,6,"xbuf ccwg");
1065 #endif /* TAPE_DEBUG */
1070 * MTLOCK: Locks the tape drive door.
1071 * Implement NOP CCW command.
1074 tape34xx_mtlock (tape_info_t * ti, int count)
1079 cqr = tape_alloc_ccw_req (ti, 2, 0);
1082 debug_text_exception (tape_debug_area,6,"xloc nomem");
1083 #endif /* TAPE_DEBUG */
1087 ccw->cmd_code = MODE_SET_DB;
1088 ccw->flags = CCW_FLAG_CC;
1090 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1092 ccw->cmd_code = NOP;
1095 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1096 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1099 tapestate_set (ti, TS_NOP_INIT);
1100 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1102 debug_text_event (tape_debug_area,6,"xloc ccwg");
1103 #endif /* TAPE_DEBUG */
1108 * MTUNLOCK: Unlocks the tape drive door.
1109 * Implement the NOP CCW command.
1112 tape34xx_mtunlock (tape_info_t * ti, int count)
1117 cqr = tape_alloc_ccw_req (ti, 2, 0);
1120 debug_text_exception (tape_debug_area,6,"xulk nomem");
1121 #endif /* TAPE_DEBUG */
1125 ccw->cmd_code = MODE_SET_DB;
1126 ccw->flags = CCW_FLAG_CC;
1128 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1130 ccw->cmd_code = NOP;
1133 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1134 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1137 tapestate_set (ti, TS_NOP_INIT);
1138 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1140 debug_text_event (tape_debug_area,6,"xulk ccwg");
1141 #endif /* TAPE_DEBUG */
1146 * MTLOAD: Loads the tape.
1147 * This function is not implemented and returns NULL, which causes the Frontend to wait for a medium being loaded.
1148 * The 3480/3490 type Tapes do not support a load command
1151 tape34xx_mtload (tape_info_t * ti, int count)
1157 * MTUNLOAD: Rewind the tape and unload it.
1160 tape34xx_mtunload (tape_info_t * ti, int count)
1165 cqr = tape_alloc_ccw_req (ti, 3, 32);
1168 debug_text_exception (tape_debug_area,6,"xunl nomem");
1169 #endif /* TAPE_DEBUG */
1173 ccw->cmd_code = MODE_SET_DB;
1174 ccw->flags = CCW_FLAG_CC;
1176 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1178 ccw->cmd_code = REWIND_UNLOAD;
1179 ccw->flags = CCW_FLAG_CC;
1181 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1183 ccw->cmd_code = SENSE;
1186 ccw->cda = (unsigned long) cqr->cpaddr;
1187 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1190 tapestate_set (ti, TS_RUN_INIT);
1191 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1193 debug_text_event (tape_debug_area,6,"xunl ccwg");
1194 #endif /* TAPE_DEBUG */
1199 * MTCOMPRESSION: used to enable compression.
1200 * Sets the IDRC on/off.
1203 tape34xx_mtcompression (tape_info_t * ti, int count)
1208 if ((count < 0) || (count > 1)) {
1210 debug_text_exception (tape_debug_area,6,"xcom parm");
1211 #endif /* TAPE_DEBUG */
1215 ((tape34xx_disc_data_t *) ti->discdata)->modeset_byte = 0x00; // IDRC off
1218 ((tape34xx_disc_data_t *) ti->discdata)->modeset_byte = 0x08; // IDRC on
1220 cqr = tape_alloc_ccw_req (ti, 2, 0);
1223 debug_text_exception (tape_debug_area,6,"xcom nomem");
1224 #endif /* TAPE_DEBUG */
1228 ccw->cmd_code = MODE_SET_DB;
1229 ccw->flags = CCW_FLAG_CC;
1231 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1233 ccw->cmd_code = NOP;
1236 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1237 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1240 tapestate_set (ti, TS_NOP_INIT);
1241 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1243 debug_text_event (tape_debug_area,6,"xcom ccwg");
1244 #endif /* TAPE_DEBUG */
1249 * MTSTPART: Move the tape head at the partition with the number 'count'.
1250 * Implement the NOP CCW command.
1253 tape34xx_mtsetpart (tape_info_t * ti, int count)
1258 cqr = tape_alloc_ccw_req (ti, 2, 0);
1261 debug_text_exception (tape_debug_area,6,"xspa nomem");
1262 #endif /* TAPE_DEBUG */
1266 ccw->cmd_code = MODE_SET_DB;
1267 ccw->flags = CCW_FLAG_CC;
1269 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1271 ccw->cmd_code = NOP;
1274 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1275 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1278 tapestate_set (ti, TS_NOP_INIT);
1279 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1281 debug_text_event (tape_debug_area,6,"xspa ccwg");
1282 #endif /* TAPE_DEBUG */
1287 * MTMKPART: .... dummy .
1288 * Implement the NOP CCW command.
1291 tape34xx_mtmkpart (tape_info_t * ti, int count)
1296 cqr = tape_alloc_ccw_req (ti, 2, 0);
1299 debug_text_exception (tape_debug_area,6,"xnpa nomem");
1300 #endif /* TAPE_DEBUG */
1304 ccw->cmd_code = MODE_SET_DB;
1305 ccw->flags = CCW_FLAG_CC;
1307 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1309 ccw->cmd_code = NOP;
1312 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1313 s390irq_spin_lock_irqsave (ti->devinfo.irq, lockflags);
1316 tapestate_set (ti, TS_NOP_INIT);
1317 s390irq_spin_unlock_irqrestore (ti->devinfo.irq, lockflags);
1319 debug_text_event (tape_debug_area,6,"xnpa ccwg");
1320 #endif /* TAPE_DEBUG */
1325 * MTIOCGET: query the tape drive status.
1328 tape34xx_mtiocget (tape_info_t * ti, int count)
1334 * MTIOCPOS: query the tape position.
1337 tape34xx_mtiocpos (tape_info_t * ti, int count)
1342 ccw_req_t * tape34xx_bread (struct request *req,tape_info_t* ti,int tapeblock_major) {
1346 int s2b = blksize_size[tapeblock_major][ti->blk_minor]/hardsect_size[tapeblock_major][ti->blk_minor];
1349 struct buffer_head* bh;
1350 for (bh = req->bh; bh; bh = bh->b_reqnext) {
1351 if (bh->b_size > blksize_size[tapeblock_major][ti->blk_minor])
1352 for (size = 0; size < bh->b_size; size += blksize_size[tapeblock_major][ti->blk_minor])
1357 if ((data = kmalloc (4 * sizeof (__u8), GFP_ATOMIC)) == NULL) {
1359 debug_text_exception (tape_debug_area,3,"xBREDnomem");
1360 #endif /* TAPE_DEBUG */
1364 data[1] = data[2] = data[3] = 0x00;
1365 realcount=req->sector/s2b;
1366 if (((tape34xx_disc_data_t *) ti->discdata)->modeset_byte & 0x08) // IDRC on
1368 data[1] = data[1] | 0x80;
1369 data[3] += realcount % 256;
1370 data[2] += (realcount / 256) % 256;
1371 data[1] += (realcount / 65536);
1373 debug_text_event (tape_debug_area,6,"xBREDid:");
1374 debug_int_event (tape_debug_area,6,realcount);
1375 #endif /* TAPE_DEBUG */
1376 cqr = tape_alloc_ccw_req (ti, 2+bhct+1, 0);
1379 debug_text_exception (tape_debug_area,6,"xBREDnomem");
1380 #endif /* TAPE_DEBUG */
1385 ccw->cmd_code = MODE_SET_DB;
1386 ccw->flags = CCW_FLAG_CC;
1388 set_normalized_cda (ccw, (unsigned long) (&(((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)));
1389 if (realcount!=ti->position) {
1391 ccw->cmd_code = LOCATE;
1392 ccw->flags = CCW_FLAG_CC;
1394 set_normalized_cda (ccw, (unsigned long) data);
1396 ti->position=realcount+req->nr_sectors/s2b;
1397 for (bh=req->bh;bh!=NULL;) {
1398 ccw->flags = CCW_FLAG_CC;
1399 if (bh->b_size >= blksize_size[tapeblock_major][ti->blk_minor]) {
1400 for (size = 0; size < bh->b_size; size += blksize_size[tapeblock_major][ti->blk_minor]) {
1402 ccw->flags = CCW_FLAG_CC;
1403 ccw->cmd_code = READ_FORWARD;
1404 ccw->count = blksize_size[tapeblock_major][ti->blk_minor];
1405 set_normalized_cda (ccw, __pa (bh->b_data + size));
1408 } else { /* group N bhs to fit into byt_per_blk */
1409 for (size = 0; bh != NULL && size < blksize_size[tapeblock_major][ti->blk_minor];) {
1411 ccw->flags = CCW_FLAG_DC;
1412 ccw->cmd_code = READ_FORWARD;
1413 ccw->count = bh->b_size;
1414 set_normalized_cda (ccw, __pa (bh->b_data));
1418 if (size != blksize_size[tapeblock_major][ti->blk_minor]) {
1419 PRINT_WARN ("Cannot fulfill small request %d vs. %d (%ld sects)\n",
1421 blksize_size[tapeblock_major][ti->blk_minor],
1424 tape_free_request (cqr);
1429 ccw -> flags &= ~(CCW_FLAG_DC);
1430 ccw -> flags |= (CCW_FLAG_CC);
1432 ccw->cmd_code = NOP;
1435 ccw->cda = (unsigned long) (&(ccw->cmd_code));
1438 tapestate_set (ti, TS_BLOCK_INIT);
1440 debug_text_event (tape_debug_area,6,"xBREDccwg");
1441 #endif /* TAPE_DEBUG */
1444 void tape34xx_free_bread (ccw_req_t* cqr,struct _tape_info_t* ti) {
1446 for (ccw=(ccw1_t*)cqr->cpaddr;(ccw->flags & CCW_FLAG_CC)||(ccw->flags & CCW_FLAG_DC);ccw++)
1447 if ((ccw->cmd_code == MODE_SET_DB) ||
1448 (ccw->cmd_code == LOCATE) ||
1449 (ccw->cmd_code == READ_FORWARD))
1450 clear_normalized_cda(ccw);
1451 tape_free_request(cqr);
1456 /* event handlers */
1458 tape34xx_default_handler (tape_info_t * ti)
1461 debug_text_event (tape_debug_area,6,"xdefhandle");
1462 #endif /* TAPE_DEBUG */
1463 PRINT_ERR ("TAPE34XX: An unexpected Unit Check occurred.\n");
1464 PRINT_ERR ("TAPE34XX: Please read Documentation/s390/TAPE and report it!\n");
1465 PRINT_ERR ("TAPE34XX: Current state is: %s",
1466 (((tapestate_get (ti) < TS_SIZE) && (tapestate_get (ti) >= 0)) ?
1467 state_verbose[tapestate_get (ti)] : "->UNKNOWN STATE<-"));
1468 tape_dump_sense (&ti->devstat);
1471 switch (tapestate_get(ti)) {
1472 case TS_REW_RELEASE_INIT:
1473 tapestate_set(ti,TS_FAILED);
1477 tapestate_set(ti,TS_FAILED);
1478 schedule_tapeblock_exec_IO(ti);
1481 tapestate_set(ti,TS_FAILED);
1482 wake_up_interruptible (&ti->wq);
1487 tape34xx_unexpect_uchk_handler (tape_info_t * ti)
1489 if ((ti->devstat.ii.sense.data[0] == 0x40) &&
1490 (ti->devstat.ii.sense.data[1] == 0x40) &&
1491 (ti->devstat.ii.sense.data[3] == 0x43)) {
1492 // no tape in the drive
1493 PRINT_INFO ("Drive %d not ready. No volume loaded.\n", ti->rew_minor / 2);
1495 debug_text_event (tape_debug_area,3,"xuuh nomed");
1496 #endif /* TAPE_DEBUG */
1497 tapestate_set (ti, TS_FAILED);
1498 ti->rc = -ENOMEDIUM;
1500 wake_up_interruptible (&ti->wq);
1501 } else if ((ti->devstat.ii.sense.data[0] == 0x42) &&
1502 (ti->devstat.ii.sense.data[1] == 0x44) &&
1503 (ti->devstat.ii.sense.data[3] == 0x3b)) {
1504 PRINT_INFO ("Media in drive %d was changed!\n",
1507 debug_text_event (tape_debug_area,3,"xuuh medchg");
1509 /* nothing to do. chan end & dev end will be reported when io is finished */
1512 debug_text_event (tape_debug_area,3,"xuuh unexp");
1513 debug_text_event (tape_debug_area,3,"state:");
1514 debug_text_event (tape_debug_area,3,((tapestate_get (ti) < TS_SIZE) &&
1515 (tapestate_get (ti) >= 0)) ?
1516 state_verbose[tapestate_get (ti)] :
1518 #endif /* TAPE_DEBUG */
1519 tape34xx_default_handler (ti);
1524 tape34xx_unused_done (tape_info_t * ti)
1526 if (ti->medium_is_unloaded) {
1527 // A medium was inserted in the drive!
1529 debug_text_event (tape_debug_area,6,"xuui med");
1530 #endif /* TAPE_DEBUG */
1531 PRINT_WARN ("A medium was inserted into the tape.\n");
1532 ti->medium_is_unloaded=0;
1535 debug_text_event (tape_debug_area,3,"unsol.irq!");
1536 debug_text_event (tape_debug_area,3,"dev end");
1537 debug_int_exception (tape_debug_area,3,ti->devinfo.irq);
1538 #endif /* TAPE_DEBUG */
1539 PRINT_WARN ("Unsolicited IRQ (Device End) caught in unused state.\n");
1540 tape_dump_sense (&ti->devstat);
1546 tape34xx_idle_done (tape_info_t * ti)
1548 if (ti->medium_is_unloaded) {
1549 // A medium was inserted in the drive!
1551 debug_text_event (tape_debug_area,6,"xuud med");
1552 #endif /* TAPE_DEBUG */
1553 PRINT_WARN ("A medium was inserted into the tape.\n");
1554 ti->medium_is_unloaded=0;
1555 wake_up_interruptible (&ti->wq);
1558 debug_text_event (tape_debug_area,3,"unsol.irq!");
1559 debug_text_event (tape_debug_area,3,"dev end");
1560 debug_int_exception (tape_debug_area,3,ti->devinfo.irq);
1561 #endif /* TAPE_DEBUG */
1562 PRINT_WARN ("Unsolicited IRQ (Device End) caught in idle state.\n");
1563 tape_dump_sense (&ti->devstat);
1568 tape34xx_block_done (tape_info_t * ti)
1571 debug_text_event (tape_debug_area,6,"x:bREQdone");
1572 #endif /* TAPE_DEBUG */
1573 tapestate_set(ti,TS_DONE);
1574 schedule_tapeblock_exec_IO(ti);
1578 tape34xx_bsf_init_done (tape_info_t * ti)
1581 debug_text_event (tape_debug_area,6,"bsf done");
1583 tapestate_set (ti, TS_DONE);
1586 wake_up_interruptible (&ti->wq);
1590 tape34xx_dse_init_done (tape_info_t * ti)
1593 debug_text_event (tape_debug_area,6,"dse done");
1595 tapestate_set (ti, TS_DONE);
1598 wake_up_interruptible (&ti->wq);
1602 tape34xx_fsf_init_done (tape_info_t * ti)
1605 debug_text_event (tape_debug_area,6,"fsf done");
1607 tapestate_set (ti, TS_DONE);
1610 wake_up_interruptible (&ti->wq);
1614 tape34xx_fsb_init_done (tape_info_t * ti)
1617 debug_text_event (tape_debug_area,6,"fsb done");
1619 tapestate_set (ti, TS_DONE);
1622 wake_up_interruptible (&ti->wq);
1626 tape34xx_bsb_init_done (tape_info_t * ti)
1629 debug_text_event (tape_debug_area,6,"bsb done");
1631 tapestate_set (ti, TS_DONE);
1638 tape34xx_lbl_init_done (tape_info_t * ti)
1641 debug_text_event (tape_debug_area,6,"lbl done");
1643 tapestate_set (ti, TS_DONE);
1645 //s390irq_spin_unlock(tape->devinfo.irq);
1651 tape34xx_nop_init_done (tape_info_t * ti)
1654 debug_text_event (tape_debug_area,6,"nop done..");
1655 debug_text_exception (tape_debug_area,6,"or rew/rel");
1657 tapestate_set (ti, TS_DONE);
1659 //s390irq_spin_unlock(tape->devinfo.irq);
1665 tape34xx_rfo_init_done (tape_info_t * ti)
1668 debug_text_event (tape_debug_area,6,"rfo done");
1670 tapestate_set (ti, TS_DONE);
1677 tape34xx_rbi_init_done (tape_info_t * ti)
1683 tapestate_set (ti, TS_FAILED);
1686 ti->rc += 256 * data[2];
1687 ti->rc += 65536 * (data[1] & 0x3F);
1689 debug_text_event (tape_debug_area,6,"rbi done");
1690 debug_text_event (tape_debug_area,6,"data:");
1692 debug_int_event (tape_debug_area,6,data[i]);
1695 wake_up_interruptible (&ti->wq);
1699 tape34xx_rew_init_done (tape_info_t * ti)
1702 debug_text_event (tape_debug_area,6,"rew done");
1705 //s390irq_spin_lock(tape->devinfo.irq);
1706 tapestate_set (ti, TS_DONE);
1708 //s390irq_spin_unlock(tape->devinfo.irq);
1710 wake_up_interruptible (&ti->wq);
1714 tape34xx_rew_release_init_done (tape_info_t * ti)
1717 debug_text_event (tape_debug_area,6,"rewR done");
1719 tapestate_set (ti, TS_DONE);
1721 //s390irq_spin_unlock(tape->devinfo.irq);
1727 tape34xx_run_init_done (tape_info_t * ti)
1730 debug_text_event (tape_debug_area,6,"rew done");
1732 tapestate_set (ti, TS_DONE);
1735 wake_up_interruptible (&ti->wq);
1739 tape34xx_wri_init_done (tape_info_t * ti)
1742 debug_text_event (tape_debug_area,6,"wri done");
1745 //s390irq_spin_lock(ti->devinfo.irq);
1746 tapestate_set (ti, TS_DONE);
1748 //s390irq_spin_unlock(ti->devinfo.irq);
1750 wake_up_interruptible (&ti->wq);
1754 tape34xx_wtm_init_done (tape_info_t * ti)
1757 debug_text_event (tape_debug_area,3,"wtm done");
1759 tapestate_set (ti, TS_DONE);
1762 wake_up_interruptible (&ti->wq);
1765 /* This function analyses the tape's sense-data in case of a unit-check. If possible,
1766 it tries to recover from the error. Else the user is informed about the problem. */
1768 tape34xx_error_recovery (tape_info_t* ti)
1770 __u8* sense=ti->devstat.ii.sense.data;
1771 int inhibit_cu_recovery=0;
1772 int cu_type=ti->discipline->cu_type;
1773 if ((((tape34xx_disc_data_t *) ti->discdata)->modeset_byte)&0x80) inhibit_cu_recovery=1;
1774 if (tapestate_get(ti)==TS_BLOCK_INIT) {
1775 // no recovery for block device, bottom half will retry...
1776 tape34xx_error_recovery_has_failed(ti,EIO);
1779 if (sense[0]&SENSE_COMMAND_REJECT)
1780 switch (tapestate_get(ti)) {
1786 if (sense[1]&SENSE_WRITE_PROTECT) {
1787 // trying to write, but medium is write protected
1788 tape34xx_error_recovery_has_failed(ti,EACCES);
1792 tape34xx_error_recovery_HWBUG(ti,1);
1795 // special cases for various tape-states when reaching end of recorded area
1796 if (((sense[0]==0x08) || (sense[0]==0x10) || (sense[0]==0x12)) &&
1797 ((sense[1]==0x40) || (sense[1]==0x0c)))
1798 switch (tapestate_get(ti)) {
1800 // Trying to seek beyond end of recorded area
1801 tape34xx_error_recovery_has_failed(ti,EIO);
1804 // Block could not be located.
1805 tape34xx_error_recovery_has_failed(ti,EIO);
1808 // Try to read beyond end of recorded area -> 0 bytes read
1809 tape34xx_error_recovery_has_failed(ti,0);
1812 // Sensing special bits
1813 if (sense[0]&SENSE_BUS_OUT_CHECK) {
1814 tape34xx_error_recovery_do_retry(ti);
1817 if (sense[0]&SENSE_DATA_CHECK) {
1818 // hardware failure, damaged tape or improper operating conditions
1821 // a read data check occurred
1822 if ((sense[2]&SENSE_TAPE_SYNC_MODE) ||
1823 (inhibit_cu_recovery)) {
1824 // data check is not permanent, may be recovered.
1825 // We always use async-mode with cu-recovery, so this should *never* happen.
1826 tape34xx_error_recovery_HWBUG(ti,2);
1829 // data check is permanent, CU recovery has failed
1830 PRINT_WARN("Permanent read error, recovery failed!\n");
1831 tape34xx_error_recovery_has_failed(ti,EIO);
1835 // a write data check occurred
1836 if ((sense[2]&SENSE_TAPE_SYNC_MODE) ||
1837 (inhibit_cu_recovery)) {
1838 // data check is not permanent, may be recovered.
1839 // We always use async-mode with cu-recovery, so this should *never* happen.
1840 tape34xx_error_recovery_HWBUG(ti,3);
1843 // data check is permanent, cu-recovery has failed
1844 PRINT_WARN("Permanent write error, recovery failed!\n");
1845 tape34xx_error_recovery_has_failed(ti,EIO);
1849 // Data Check (read opposite) occurred. We'll recover this.
1850 tape34xx_error_recovery_read_opposite(ti);
1853 // The ID-Mark at the beginning of the tape could not be written. This is fatal, we'll report and exit.
1854 PRINT_WARN("ID-Mark could not be written. Check your hardware!\n");
1855 tape34xx_error_recovery_has_failed(ti,EIO);
1858 // Tape void. Tried to read beyond end of device. We'll report and exit.
1859 PRINT_WARN("Try to read beyond end of recorded area!\n");
1860 tape34xx_error_recovery_has_failed(ti,ENOSPC);
1863 // Record sequence error. cu detected incorrect block-id sequence on tape. We'll report and exit.
1864 PRINT_WARN("Illegal block-id sequence found!\n");
1865 tape34xx_error_recovery_has_failed(ti,EIO);
1868 // well, all data checks for 3480 should result in one of the above erpa-codes. if not -> bug
1869 // On 3490, other data-check conditions do exist.
1870 if (cu_type==0x3480) {
1871 tape34xx_error_recovery_HWBUG(ti,4);
1876 if (sense[0]&SENSE_OVERRUN) {
1877 // A data overrun between cu and drive occurred. The channel speed is to slow! We'll report this and exit!
1879 case 0x40: // overrun error
1880 PRINT_WARN ("Data overrun error between control-unit and drive. Use a faster channel connection, if possible! \n");
1881 tape34xx_error_recovery_has_failed(ti,EIO);
1884 // Overrun bit is set, but erpa does not show overrun error. This is a bug.
1885 tape34xx_error_recovery_HWBUG(ti,5);
1889 if (sense[1]&SENSE_RECORD_SEQUENCE_ERR) {
1892 // Record sequence error. cu detected incorrect block-id sequence on tape. We'll report and exit.
1893 PRINT_WARN("Illegal block-id sequence found!\n");
1894 tape34xx_error_recovery_has_failed(ti,EIO);
1897 // Record sequence error bit is set, but erpa does not show record sequence error. This is a bug.
1898 tape34xx_error_recovery_HWBUG(ti,6);
1902 // Sensing erpa codes
1905 // Everything is fine, but we got a unit check. Report and ignore!
1906 PRINT_WARN ("Non-error sense was found. Unit-check will be ignored, expect errors...\n");
1909 // Data streaming not operational. Cu switches to interlock mode, we reissue the command.
1910 PRINT_WARN ("Data streaming not operational. Switching to interlock-mode! \n");
1911 tape34xx_error_recovery_do_retry(ti);
1914 // Path equipment check. Might be drive adapter error, buffer error on the lower interface, internal path not useable, or error during cartridge load.
1915 // All of the above are not recoverable
1916 PRINT_WARN ("A path equipment check occurred. One of the following conditions occurred:\n");
1917 PRINT_WARN ("drive adapter error,buffer error on the lower interface, internal path not useable, error during cartridge load.\n");
1918 tape34xx_error_recovery_has_failed(ti,EIO);
1921 // Read data check. Should have been be covered earlier -> Bug!
1922 tape34xx_error_recovery_HWBUG(ti,7);
1925 // Load display check. Load display was command was issued, but the drive is displaying a drive check message. Can be threated as "device end".
1926 tape34xx_error_recovery_succeded(ti);
1929 // Write data check. Should have been covered earlier -> Bug!
1930 tape34xx_error_recovery_HWBUG(ti,8);
1933 // Data check (read opposite). Should have been covered earlier -> Bug!
1934 tape34xx_error_recovery_HWBUG(ti,9);
1937 // Command reject. May indicate illegal channel program or buffer over/underrun.
1938 // Since all channel programms are issued by this driver and ought be correct,
1939 // we assume a over/underrun situaltion and retry the channel program.
1940 tape34xx_error_recovery_do_retry(ti);
1943 // Write id mark check. Should have beed covered earlier -> bug!
1944 tape34xx_error_recovery_HWBUG(ti,10);
1947 // Function incompatible. Either idrc is on but hardware not capable doing idrc
1948 // or a perform subsystem func is issued and the cu is not online. Anyway, this
1949 // cannot be recovered and is an I/O error.
1950 PRINT_WARN ("Function incompatible. Try to switch off idrc! \n");
1951 tape34xx_error_recovery_has_failed(ti,EIO);
1954 // Unsolicited environmental data. An internal counter overflows, we can ignore
1955 // this and reissue the cmd.
1956 tape34xx_error_recovery_do_retry(ti);
1959 // Environmental data present. Indicates either unload completed ok or read buffered
1960 // log command completed ok.
1961 if (tapestate_get(ti)==TS_RUN_INIT) {
1962 // Rewind unload completed ok.
1963 tape34xx_error_recovery_succeded(ti);
1966 // Since we do not issue read buffered log commands, this should never occur -> bug.
1967 tape34xx_error_recovery_HWBUG(ti,11);
1970 // Permanent equipment check. cu has tried recovery, but did not succeed. This is an
1972 tape34xx_error_recovery_has_failed(ti,EIO);
1975 // Data security erase failure.
1976 if (tapestate_get(ti)==TS_DSE_INIT) {
1977 // report an I/O error
1978 tape34xx_error_recovery_has_failed(ti,EIO);
1981 // Data security erase failure, but no such command issued. This is a bug.
1982 tape34xx_error_recovery_HWBUG(ti,12);
1985 // Not capable. This indicates either that the drive fails reading the format id mark
1986 // or that that format specified is not supported by the drive. We write a message and
1987 // return an I/O error.
1988 PRINT_WARN("Drive not capable processing the tape format!");
1989 tape34xx_error_recovery_has_failed(ti,EMEDIUMTYPE);
1992 // This erpa is reserved. This is a bug.
1993 tape34xx_error_recovery_HWBUG(ti,13);
1996 // The medium is write protected, while trying to write on it. We'll report this.
1997 PRINT_WARN("Medium is write protected!\n");
1998 tape34xx_error_recovery_has_failed(ti,EACCES);
2001 // Tape void. Should have beed covered ealier -> bug
2002 tape34xx_error_recovery_HWBUG(ti,14);
2005 // Tension loss. We cannot recover this, it's an I/O error.
2006 PRINT_WARN("The drive lost tape tension.\n");
2007 tape34xx_error_recovery_has_failed(ti,EIO);
2010 // Load Failure. The catridge was not inserted correctly or the tape is not threaded
2011 // correctly. We cannot recover this, the user has to reload the catridge.
2012 PRINT_WARN("Cartridge load failure. Reload the cartridge and try again.\n");
2013 tape34xx_error_recovery_has_failed(ti,EIO);
2016 // Unload failure. The drive cannot maintain tape tension and control tape movement
2017 // during an unload operation.
2018 PRINT_WARN("Failure during cartridge unload. Please try manually.\n");
2019 if (tapestate_get(ti)!=TS_RUN_INIT) {
2020 tape34xx_error_recovery_HWBUG(ti,15);
2023 tape34xx_error_recovery_has_failed(ti,EIO);
2026 // Drive equipment check. One of the following:
2027 // - cu cannot recover from a drive detected error
2028 // - a check code message is displayed on drive message/load displays
2029 // - the cartridge loader does not respond correctly
2030 // - a failure occurs during an index, load, or unload cycle
2031 PRINT_WARN("Equipment check! Please check the drive and the cartridge loader.\n");
2032 tape34xx_error_recovery_has_failed(ti,EIO);
2037 // This erpa is reserved for 3480 -> BUG
2038 tape34xx_error_recovery_HWBUG(ti,16);
2041 // End of data. This is a permanent I/O error, which cannot be recovered.
2042 // A read-type command has reached the end-of-data mark.
2043 tape34xx_error_recovery_has_failed(ti,EIO);
2047 // Tape length error. The tape is shorter than reported in the beginning-of-tape data.
2048 PRINT_WARN("Tape length error.\n");
2049 tape34xx_error_recovery_has_failed(ti,EIO);
2052 // Physical end of tape. A read/write operation reached the physical end of tape.
2053 if (tapestate_get(ti)==TS_WRI_INIT ||
2054 tapestate_get(ti)==TS_DSE_INIT ||
2055 tapestate_get(ti)==TS_EGA_INIT ||
2056 tapestate_get(ti)==TS_WTM_INIT){
2057 tape34xx_error_recovery_has_failed(ti,ENOSPC);
2059 tape34xx_error_recovery_has_failed(ti,EIO);
2063 // Backward at BOT. The drive is at BOT and is requestet to move backward.
2064 tape34xx_error_recovery_has_failed(ti,EIO);
2067 // Drive switched not ready, but the command needs the drive to be ready.
2068 PRINT_WARN("Drive not ready. Turn the ready/not ready switch to ready position and try again.\n");
2069 tape34xx_error_recovery_has_failed(ti,EIO);
2072 // Manual rewind or unload. This causes an I/O error.
2073 PRINT_WARN("Medium was rewound or unloaded manually. Expect errors! Please do only use the mtoffl and mtrew ioctl to unload tapes or rewind tapes.\n");
2074 tape34xx_error_recovery_has_failed(ti,EIO);
2080 // These erpas are reserved -> BUG
2081 tape34xx_error_recovery_HWBUG(ti,17);
2084 // Overrun error. This should have been covered earlier -> bug.
2085 tape34xx_error_recovery_HWBUG(ti,18);
2088 // Record sequence error. This should have been covered earlier -> bug.
2089 tape34xx_error_recovery_HWBUG(ti,19);
2092 // Degraded mode. A condition that can cause degraded performace is detected.
2093 PRINT_WARN("Subsystem is running in degraded mode. This may compromise your performace.\n");
2094 tape34xx_error_recovery_do_retry(ti);
2097 // Drive not ready. Probably swith the ready/not ready switch to ready?
2098 PRINT_WARN("The drive is not ready. Maybe no medium in?\n");
2099 tape34xx_error_recovery_has_failed(ti,ENOMEDIUM);
2102 // Locate Block unsuccessfull. We'll report this.
2103 if ((tapestate_get(ti)!=TS_BLOCK_INIT) &&
2104 (tapestate_get(ti)!=TS_LBL_INIT)) {
2105 tape34xx_error_recovery_HWBUG(ti,20); // No locate block was issued...
2108 tape34xx_error_recovery_has_failed(ti,EIO);
2111 // The drive is assigned elsewhere [to a different channel path/computer].
2112 PRINT_WARN("The drive is assigned elsewhere.\n");
2113 tape34xx_error_recovery_has_failed(ti,EIO);
2116 // Drive not online. Drive may be switched offline, the power supply may be switched off
2117 // or the drive address may not be set correctly.
2118 PRINT_WARN("The drive is not online.");
2119 tape34xx_error_recovery_has_failed(ti,EIO);
2122 // Volume fenced. cu reports volume integrity is lost!
2123 PRINT_WARN("Volume fenced. The volume integrity is lost! \n");
2124 tape34xx_error_recovery_has_failed(ti,EIO);
2127 // Log sense data and retry request. We'll do so...
2128 tape34xx_error_recovery_do_retry(ti);
2131 // Bus out check. A parity check error on the bus was found. PRINT_WARN("Bus out check. A data transfer over the bus was corrupted.\n");
2132 tape34xx_error_recovery_has_failed(ti,EIO);
2135 // Control unit erp failed. We'll report this.
2136 PRINT_WARN("The control unit failed recovering an I/O error.\n");
2137 tape34xx_error_recovery_has_failed(ti,EIO);
2140 // Cu and drive incompatible. The drive requests micro-program patches, which are not available on the cu.
2141 PRINT_WARN("The drive needs microprogram patches from the control unit, which are not available.\n");
2142 tape34xx_error_recovery_has_failed(ti,EIO);
2145 // Recovered Check-One failure. Cu develops a hardware error, but is able to recover. We'll reissue the command.
2146 tape34xx_error_recovery_do_retry(ti);
2151 // This erpa is reserved for 3480 -> bug
2152 tape34xx_error_recovery_HWBUG(ti,21);
2155 // Resetting event received. Since the driver does not support resetting event recovery
2156 // (which has to be handled by the I/O Layer), we'll report and retry our command.
2157 tape34xx_error_recovery_do_retry(ti);
2163 // This erpa is reserved for 3480 -> bug.
2164 tape34xx_error_recovery_HWBUG(ti,22);
2167 // Maximum block size exeeded. This indicates, that the block to be written is larger
2168 // than allowed for buffered mode. We'll report this...
2169 PRINT_WARN("Maximum block size for buffered mode exceeded.\n");
2170 tape34xx_error_recovery_has_failed(ti,ENOBUFS);
2174 // These erpas are reserved -> bug
2175 tape34xx_error_recovery_HWBUG(ti,23);
2178 // Read buffered log (Overflow). Cu is running in extended beffered log mode, and a counter overflows.
2179 // This should never happen, since we're never running in extended buffered log mode -> bug.
2180 tape34xx_error_recovery_do_retry(ti);
2183 // Read buffered log (EOV). EOF processing occurs while the cu is in extended buffered log mode.
2184 // This should never happen, since we're never running in extended buffered log mode -> bug.
2185 tape34xx_error_recovery_do_retry(ti);
2188 // End of Volume complete. Rewind unload completed ok. We'll report to the user...
2189 if (tapestate_get(ti)!=TS_RUN_INIT) {
2190 tape34xx_error_recovery_HWBUG(ti,24);
2193 tape34xx_error_recovery_succeded(ti);
2196 // Global command intercept. We'll have to reissue our command.
2197 tape34xx_error_recovery_do_retry(ti);
2200 // Channel interface recovery (temporary). This can be recovered by reissuing the command.
2201 tape34xx_error_recovery_do_retry(ti);
2204 // Channel interface recovery (permanent). This cannot be recovered, we'll inform the user.
2205 PRINT_WARN("A permanent channel interface error occurred.\n");
2206 tape34xx_error_recovery_has_failed(ti,EIO);
2209 // Channel protocol error. This cannot be recovered.
2210 PRINT_WARN("A channel protocol error occurred.\n");
2211 tape34xx_error_recovery_has_failed(ti,EIO);
2216 // Attention intercept. We have to reissue the command.
2217 PRINT_WARN("An attention intercept occurred, which will be recovered.\n");
2218 tape34xx_error_recovery_do_retry(ti);
2221 // Global status intercept. We have to reissue the command.
2222 PRINT_WARN("An global status intercept was received, which will be recovered.\n");
2223 tape34xx_error_recovery_do_retry(ti);
2228 // These erpas are reserved -> bug.
2229 tape34xx_error_recovery_HWBUG(ti,25);
2232 // Tape length incompatible. The tape inserted is too long,
2233 // which could cause damage to the tape or the drive.
2234 PRINT_WARN("Tape length incompatible [should be IBM Cartridge System Tape]. May cause damage to drive or tape.n");
2235 tape34xx_error_recovery_has_failed(ti,EIO);
2238 // Format 3480 XF incompatible
2239 if (sense[1]&SENSE_BEGINNING_OF_TAPE) {
2240 // Everything is fine. The tape will be overwritten in a different format.
2241 tape34xx_error_recovery_do_retry(ti);
2244 PRINT_WARN("Tape format is incompatible to the drive, which writes 3480-2 XF.\n");
2245 tape34xx_error_recovery_has_failed(ti,EIO);
2248 // Format 3480-2 XF incompatible
2249 PRINT_WARN("Tape format is incompatible to the drive. The drive cannot access 3480-2 XF volumes.\n");
2250 tape34xx_error_recovery_has_failed(ti,EIO);
2253 // Tape length violation.
2254 PRINT_WARN("Tape length violation [should be IBM Enhanced Capacity Cartridge System Tape]. May cause damage to drive or tape.\n");
2255 tape34xx_error_recovery_has_failed(ti,EMEDIUMTYPE);
2258 // Compaction algorithm incompatible.
2259 PRINT_WARN("The volume is recorded using an incompatible compaction algorith, which is not supported by the control unit.\n");
2260 tape34xx_error_recovery_has_failed(ti,EMEDIUMTYPE);
2263 // Reserved erpas -> bug
2264 tape34xx_error_recovery_HWBUG(ti,26);
2269 void tape34xx_error_recovery_has_failed (tape_info_t* ti,int error_id) {
2271 debug_text_event (tape_debug_area,3,"xerp fail");
2272 debug_text_event (tape_debug_area,3,(((tapestate_get (ti) < TS_SIZE) &&
2273 (tapestate_get (ti) >= 0)) ?
2274 state_verbose[tapestate_get (ti)] : "UNKNOWN"));
2276 if ((tapestate_get(ti)!=TS_UNUSED) && (tapestate_get(ti)!=TS_IDLE)) {
2277 tape_dump_sense(&ti->devstat);
2280 switch (tapestate_get(ti)) {
2281 case TS_REW_RELEASE_INIT:
2284 tapestate_set(ti,TS_FAILED);
2288 tapestate_set(ti,TS_FAILED);
2289 schedule_tapeblock_exec_IO(ti);
2292 tapestate_set(ti,TS_FAILED);
2293 wake_up_interruptible (&ti->wq);
2296 PRINT_WARN("Recieved an unsolicited IRQ.\n");
2297 tape_dump_sense(&ti->devstat);
2301 void tape34xx_error_recovery_succeded(tape_info_t* ti) {
2303 debug_text_event (tape_debug_area,3,"xerp done");
2304 debug_text_event (tape_debug_area,3,(((tapestate_get (ti) < TS_SIZE) &&
2305 (tapestate_get (ti) >= 0)) ?
2306 state_verbose[tapestate_get (ti)] : "UNKNOWN"));
2308 if ((tapestate_get(ti)!=TS_UNUSED) && (tapestate_get(ti)!=TS_DONE)) {
2309 tapestate_event (ti, TE_DONE);
2311 PRINT_WARN("Recieved an unsolicited IRQ.\n");
2312 tape_dump_sense(&ti->devstat);
2316 void tape34xx_error_recovery_do_retry(tape_info_t* ti) {
2318 debug_text_event (tape_debug_area,3,"xerp retr");
2319 debug_text_event (tape_debug_area,3,(((tapestate_get (ti) < TS_SIZE) &&
2320 (tapestate_get (ti) >= 0)) ?
2321 state_verbose[tapestate_get (ti)] : "UNKNOWN"));
2323 if ((tapestate_get(ti)!=TS_UNUSED) && (tapestate_get(ti)!=TS_IDLE)) {
2324 tape_dump_sense(&ti->devstat);
2325 while (do_IO (ti->devinfo.irq, ti->cqr->cpaddr, (unsigned long) ti->cqr, 0x00, ti->cqr->options));
2327 PRINT_WARN("Recieved an unsolicited IRQ.\n");
2328 tape_dump_sense(&ti->devstat);
2333 tape34xx_error_recovery_read_opposite (tape_info_t* ti) {
2334 switch (tapestate_get(ti)) {
2336 // We did read forward, but the data could not be read *correctly*.
2337 // We will read backward and then skip forward again.
2338 ti->cqr=tape34xx_read_opposite(ti,0);
2340 tape34xx_error_recovery_has_failed(ti,EIO);
2342 tape34xx_error_recovery_do_retry(ti);
2345 // We tried to read forward and backward, but hat no success -> failed.
2346 tape34xx_error_recovery_has_failed(ti,EIO);
2349 tape34xx_error_recovery_do_retry(ti);
2352 PRINT_WARN("read_opposite_recovery_called_with_state:%s\n",
2353 (((tapestate_get (ti) < TS_SIZE) &&
2354 (tapestate_get (ti) >= 0)) ?
2355 state_verbose[tapestate_get (ti)] : "UNKNOWN"));
2360 tape34xx_error_recovery_HWBUG (tape_info_t* ti,int condno) {
2361 devstat_t* stat=&ti->devstat;
2362 PRINT_WARN("An unexpected condition #%d was caught in tape error recovery.\n",condno);
2363 PRINT_WARN("Please report this incident.\n");
2364 PRINT_WARN("State of the tape:%s\n",
2365 (((tapestate_get (ti) < TS_SIZE) &&
2366 (tapestate_get (ti) >= 0)) ?
2367 state_verbose[tapestate_get (ti)] : "UNKNOWN"));
2368 PRINT_INFO ("Sense data: %02X%02X%02X%02X %02X%02X%02X%02X "
2369 " %02X%02X%02X%02X %02X%02X%02X%02X \n",
2370 stat->ii.sense.data[0], stat->ii.sense.data[1],
2371 stat->ii.sense.data[2], stat->ii.sense.data[3],
2372 stat->ii.sense.data[4], stat->ii.sense.data[5],
2373 stat->ii.sense.data[6], stat->ii.sense.data[7],
2374 stat->ii.sense.data[8], stat->ii.sense.data[9],
2375 stat->ii.sense.data[10], stat->ii.sense.data[11],
2376 stat->ii.sense.data[12], stat->ii.sense.data[13],
2377 stat->ii.sense.data[14], stat->ii.sense.data[15]);
2378 PRINT_INFO ("Sense data: %02X%02X%02X%02X %02X%02X%02X%02X "
2379 " %02X%02X%02X%02X %02X%02X%02X%02X \n",
2380 stat->ii.sense.data[16], stat->ii.sense.data[17],
2381 stat->ii.sense.data[18], stat->ii.sense.data[19],
2382 stat->ii.sense.data[20], stat->ii.sense.data[21],
2383 stat->ii.sense.data[22], stat->ii.sense.data[23],
2384 stat->ii.sense.data[24], stat->ii.sense.data[25],
2385 stat->ii.sense.data[26], stat->ii.sense.data[27],
2386 stat->ii.sense.data[28], stat->ii.sense.data[29],
2387 stat->ii.sense.data[30], stat->ii.sense.data[31]);
2388 tape34xx_error_recovery_has_failed(ti,EIO);