10 #define KMSG_COMPONENT "tape_34xx"
11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 #include <linux/module.h>
17 #include <linux/slab.h>
19 #define TAPE_DBF_AREA tape_34xx_dbf
30 #define TAPE34XX_FMT_3480 0
31 #define TAPE34XX_FMT_3480_2_XF 1
32 #define TAPE34XX_FMT_3480_XF 2
49 static void tape_34xx_delete_sbid_from(
struct tape_device *,
int);
60 if (request->
rc == 0) {
79 DBF_EVENT(4,
"tape_34xx: medium sense failed with rc=%d\n",
84 static int tape_34xx_medium_sense(
struct tape_device *device)
90 if (IS_ERR(request)) {
92 return PTR_ERR(request);
98 __tape_34xx_medium_sense(request);
102 static void tape_34xx_medium_sense_async(
struct tape_device *device)
107 if (IS_ERR(request)) {
114 request->
callback = (
void *) __tape_34xx_medium_sense;
144 tape_34xx_medium_sense_async(device);
147 DBF_EVENT(3,
"T34XX: internal error: unknown work\n");
178 switch (request->
op) {
185 tape_34xx_delete_sbid_from(request->
device, 0);
194 tape_34xx_erp_failed(
struct tape_request *request,
int rc)
196 DBF_EVENT(3,
"Error recovery failed for %s (RC=%d)\n",
204 DBF_EVENT(3,
"Error Recovery successful for %s\n",
206 return tape_34xx_done(request);
223 if (irb->
scsw.
cmd.dstat == 0x85) {
226 tape_34xx_delete_sbid_from(device, 0);
227 tape_34xx_schedule_work(device,
TO_MSEN);
240 tape_34xx_erp_read_opposite(
struct tape_device *device,
250 return tape_34xx_erp_retry(request);
257 return tape_34xx_erp_failed(request, -
EIO);
262 struct irb *irb,
int no)
265 dev_err(&device->
cdev->dev,
"An unexpected condition %d "
266 "occurred in tape error recovery\n", no);
269 return tape_34xx_erp_failed(request, -
EIO);
280 if (irb->
ecw[3] == 0x40) {
281 dev_warn (&device->
cdev->dev,
"A data overrun occurred between"
282 " the control unit and tape unit\n");
283 return tape_34xx_erp_failed(request, -
EIO);
285 return tape_34xx_erp_bug(device, request, irb, -1);
295 if (irb->
ecw[3] == 0x41) {
299 dev_warn (&device->
cdev->dev,
"The block ID sequence on the "
300 "tape is incorrect\n");
301 return tape_34xx_erp_failed(request, -
EIO);
307 return tape_34xx_erp_bug(device, request, irb, -2);
319 int inhibit_cu_recovery;
322 inhibit_cu_recovery = (*device->
modeset_byte & 0x80) ? 1 : 0;
335 return tape_34xx_erp_failed(request, -
EACCES);
337 return tape_34xx_erp_bug(device, request, irb, -3);
361 switch (request->
op) {
372 return tape_34xx_erp_failed(request, -
ENOSPC);
374 return tape_34xx_erp_retry(request);
383 tape_34xx_delete_sbid_from(device, 0);
384 return tape_34xx_erp_failed(request, -
EIO);
388 return tape_34xx_erp_failed(request, 0);
397 return tape_34xx_erp_failed(request, -
ENOSPC);
399 return tape_34xx_erp_failed(request, 0);
405 return tape_34xx_erp_retry(request);
420 return tape_34xx_erp_bug(device, request,
425 "that cannot be recovered\n");
426 return tape_34xx_erp_failed(request, -
EIO);
429 if ((sense[2] & SENSE_TAPE_SYNC_MODE) ||
434 return tape_34xx_erp_bug(device, request,
439 "tape cannot be recovered\n");
440 return tape_34xx_erp_failed(request, -
EIO);
443 return tape_34xx_erp_read_opposite(device, request);
448 return tape_34xx_erp_failed(request, -
EIO);
452 " the end of the recorded area failed\n");
453 return tape_34xx_erp_failed(request, -
ENOSPC);
457 "incorrect block ID sequence\n");
458 return tape_34xx_erp_failed(request, -
EIO);
464 return tape_34xx_erp_bug(device, request,
470 return tape_34xx_erp_overrun(device, request, irb);
473 return tape_34xx_erp_sequence(device, request, irb);
485 return tape_34xx_erp_retry(request);
492 dev_warn (&device->
cdev->dev,
"A path equipment check occurred"
493 " for the tape device\n");
494 return tape_34xx_erp_failed(request, -
EIO);
501 return tape_34xx_erp_succeeded(request);
509 return tape_34xx_erp_retry(request);
516 return tape_34xx_erp_failed(request, -
EIO);
522 return tape_34xx_erp_retry(request);
531 return tape_34xx_erp_succeeded(request);
534 return tape_34xx_erp_bug(device, request, irb, sense[3]);
540 return tape_34xx_erp_failed(request, -
EIO);
544 return tape_34xx_erp_failed(request, -
EIO);
546 return tape_34xx_erp_bug(device, request, irb, sense[3]);
553 dev_warn (&device->
cdev->dev,
"The tape unit cannot process "
554 "the tape format\n");
555 return tape_34xx_erp_failed(request, -
EMEDIUMTYPE);
558 dev_warn (&device->
cdev->dev,
"The tape medium is write-"
560 return tape_34xx_erp_failed(request, -
EACCES);
563 dev_warn (&device->
cdev->dev,
"The tape does not have the "
564 "required tape tension\n");
565 return tape_34xx_erp_failed(request, -
EIO);
571 dev_warn (&device->
cdev->dev,
"The tape unit failed to load"
573 tape_34xx_delete_sbid_from(device, 0);
574 return tape_34xx_erp_failed(request, -
EIO);
580 dev_warn (&device->
cdev->dev,
"Automatic unloading of the tape"
581 " cartridge failed\n");
583 return tape_34xx_erp_failed(request, -
EIO);
584 return tape_34xx_erp_bug(device, request, irb, sense[3]);
593 dev_warn (&device->
cdev->dev,
"An equipment check has occurred"
594 " on the tape unit\n");
595 return tape_34xx_erp_failed(request, -
EIO);
599 return tape_34xx_erp_failed(request, -
EIO);
601 return tape_34xx_erp_bug(device, request, irb, sense[3]);
607 dev_warn (&device->
cdev->dev,
"The tape information states an"
608 " incorrect length\n");
609 return tape_34xx_erp_failed(request, -
EIO);
618 return tape_34xx_erp_failed(request, -
ENOSPC);
619 return tape_34xx_erp_failed(request, -
EIO);
622 return tape_34xx_erp_failed(request, -
EIO);
625 dev_warn (&device->
cdev->dev,
"The tape unit is not ready\n");
626 return tape_34xx_erp_failed(request, -
EIO);
629 dev_warn (&device->
cdev->dev,
"The tape medium has been "
630 "rewound or unloaded manually\n");
631 tape_34xx_delete_sbid_from(device, 0);
632 return tape_34xx_erp_failed(request, -
EIO);
638 dev_warn (&device->
cdev->dev,
"The tape subsystem is running "
639 "in degraded mode\n");
640 return tape_34xx_erp_retry(request);
643 tape_34xx_delete_sbid_from(device, 0);
647 switch(request->
op) {
652 return tape_34xx_done(request);
658 return tape_34xx_erp_failed(request, -
ENOMEDIUM);
663 return tape_34xx_erp_bug(device, request,
665 return tape_34xx_erp_failed(request, -
EIO);
668 dev_warn (&device->
cdev->dev,
"The tape unit is already "
670 return tape_34xx_erp_failed(request, -
EIO);
677 dev_warn (&device->
cdev->dev,
"The tape unit is not online\n");
678 return tape_34xx_erp_failed(request, -
EIO);
681 dev_warn (&device->
cdev->dev,
"The control unit has fenced "
682 "access to the tape volume\n");
683 tape_34xx_delete_sbid_from(device, 0);
684 return tape_34xx_erp_failed(request, -
EIO);
687 return tape_34xx_erp_retry(request);
690 dev_warn (&device->
cdev->dev,
"A parity error occurred on the "
692 return tape_34xx_erp_failed(request, -
EIO);
695 dev_warn (&device->
cdev->dev,
"I/O error recovery failed on "
696 "the tape control unit\n");
697 return tape_34xx_erp_failed(request, -
EIO);
703 dev_warn (&device->
cdev->dev,
"The tape unit requires a "
704 "firmware update\n");
705 return tape_34xx_erp_failed(request, -
EIO);
711 return tape_34xx_erp_retry(request);
719 return tape_34xx_erp_retry(request);
721 return tape_34xx_erp_bug(device, request, irb, sense[3]);
730 " for buffered mode is exceeded\n");
731 return tape_34xx_erp_failed(request, -
ENOBUFS);
734 return tape_34xx_erp_bug(device, request, irb, sense[3]);
742 return tape_34xx_erp_retry(request);
750 return tape_34xx_erp_retry(request);
755 tape_34xx_delete_sbid_from(device, 0);
756 return tape_34xx_erp_succeeded(request);
758 return tape_34xx_erp_bug(device, request, irb, sense[3]);
761 return tape_34xx_erp_retry(request);
764 return tape_34xx_erp_retry(request);
767 dev_warn (&device->
cdev->dev,
"A channel interface error cannot be"
769 return tape_34xx_erp_failed(request, -
EIO);
772 dev_warn (&device->
cdev->dev,
"A channel protocol error "
774 return tape_34xx_erp_failed(request, -
EIO);
778 return tape_34xx_erp_retry(request);
781 return tape_34xx_erp_retry(request);
788 dev_warn (&device->
cdev->dev,
"The tape unit does not support "
789 "the tape length\n");
790 return tape_34xx_erp_failed(request, -
EIO);
795 return tape_34xx_erp_retry(request);
796 dev_warn (&device->
cdev->dev,
"The tape unit does not support"
797 " format 3480 XF\n");
798 return tape_34xx_erp_failed(request, -
EIO);
801 dev_warn (&device->
cdev->dev,
"The tape unit does not support tape "
802 "format 3480-2 XF\n");
803 return tape_34xx_erp_failed(request, -
EIO);
806 dev_warn (&device->
cdev->dev,
"The tape unit does not support"
807 " the current tape length\n");
808 return tape_34xx_erp_failed(request, -
EMEDIUMTYPE);
811 dev_warn (&device->
cdev->dev,
"The tape unit does not support"
812 " the compaction algorithm\n");
813 return tape_34xx_erp_failed(request, -
EMEDIUMTYPE);
825 return tape_34xx_erp_bug(device, request, irb, sense[3]);
837 return tape_34xx_unsolicited_irq(device, irb);
843 return tape_34xx_erp_failed(request, -
ENOSPC);
847 return tape_34xx_unit_check(device, request, irb);
859 return tape_34xx_done(request);
876 if (
copy_from_user(&disp, (
char __user *) arg,
sizeof(disp)) != 0)
894 list_add(&new_sbid->
list, l);
941 tape_34xx_append_new_sbid(bid, l->
prev);
947 tape_34xx_append_new_sbid(bid, l->
prev);
949 DBF_LH(4,
"Current list is:\n");
952 DBF_LH(4,
"%d:%03d@%05d\n",
978 if (sbid->
bid.block >= from) {
979 DBF_LH(4,
"Delete sbid %d:%03d@%05d\n",
994 tape_34xx_merge_sbid(
1007 if (!sbid_list || list_empty(sbid_list))
1019 bid->
wrap = sbid_to_use->
bid.wrap;
1021 DBF_LH(4,
"Use %d:%03d@%05d for %05d\n",
1022 sbid_to_use->
bid.wrap,
1023 sbid_to_use->
bid.segment,
1024 sbid_to_use->
bid.block,
1031 tape_34xx_setup_device(
struct tape_device * device)
1038 if ((rc = tape_34xx_medium_sense(device)) != 0) {
1039 DBF_LH(3,
"34xx medium sense returned %d\n", rc);
1044 INIT_LIST_HEAD(discdata);
1052 tape_34xx_cleanup_device(
struct tape_device *device)
1057 tape_34xx_delete_sbid_from(device, 0);
1068 tape_34xx_mttell(
struct tape_device *device,
int mt_count)
1080 tape_34xx_add_sbid(device, block_id.cbid);
1093 if (mt_count > 0x3fffff) {
1098 if (IS_ERR(request))
1099 return PTR_ERR(request);
1104 bid->
format = (*device->modeset_byte & 0x08) ?
1106 bid->
block = mt_count;
1107 tape_34xx_merge_sbid(device, bid);
1114 return tape_do_io_free(device, request);
1140 [
MTSEEK] = tape_34xx_mtseek,
1141 [
MTTELL] = tape_34xx_mttell,
1160 .setup_device = tape_34xx_setup_device,
1161 .cleanup_device = tape_34xx_cleanup_device,
1163 .irq = tape_34xx_irq,
1166 .ioctl_fn = tape_34xx_ioctl,
1167 .mtop_array = tape_34xx_mtop
1181 &tape_discipline_34xx
1185 static struct ccw_driver tape_34xx_driver = {
1187 .name =
"tape_34xx",
1190 .ids = tape_34xx_ids,
1193 .set_online = tape_34xx_online,
1200 tape_34xx_init (
void)
1204 TAPE_DBF_AREA =
debug_register (
"tape_34xx", 2, 2, 4*
sizeof(
long));
1206 #ifdef DBF_LIKE_HELL
1221 tape_34xx_exit(
void)
1229 MODULE_AUTHOR(
"(C) 2001-2002 IBM Deutschland Entwicklung GmbH");