Lines Matching +full:sense +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
7 * Tuan Ngo-Anh <ngoanh@de.ibm.com>
53 * Medium sense for 34xx tapes. There is no 'real' medium sense call.
54 * So we just do a normal sense.
58 struct tape_device *device = request->device; in __tape_34xx_medium_sense()
59 unsigned char *sense; in __tape_34xx_medium_sense() local
61 if (request->rc == 0) { in __tape_34xx_medium_sense()
62 sense = request->cpdata; in __tape_34xx_medium_sense()
66 * means that the drive is 'neither ready nor on-line' it is in __tape_34xx_medium_sense()
70 if (sense[0] & SENSE_INTERVENTION_REQUIRED) in __tape_34xx_medium_sense()
75 if (sense[1] & SENSE_WRITE_PROTECT) in __tape_34xx_medium_sense()
76 device->tape_generic_status |= GMT_WR_PROT(~0); in __tape_34xx_medium_sense()
78 device->tape_generic_status &= ~GMT_WR_PROT(~0); in __tape_34xx_medium_sense()
80 DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n", in __tape_34xx_medium_sense()
81 request->rc); in __tape_34xx_medium_sense()
96 request->op = TO_MSEN; in tape_34xx_medium_sense()
97 tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); in tape_34xx_medium_sense()
113 request->op = TO_MSEN; in tape_34xx_medium_sense_async()
114 tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); in tape_34xx_medium_sense_async()
115 request->callback = (void *) __tape_34xx_medium_sense; in tape_34xx_medium_sense_async()
116 request->callback_data = NULL; in tape_34xx_medium_sense_async()
141 struct tape_device *device = p->device; in tape_34xx_work_handler()
143 switch(p->op) { in tape_34xx_work_handler()
160 return -ENOMEM; in tape_34xx_schedule_work()
162 INIT_WORK(&p->work, tape_34xx_work_handler); in tape_34xx_schedule_work()
164 p->device = tape_get_device(device); in tape_34xx_schedule_work()
165 p->op = op; in tape_34xx_schedule_work()
167 schedule_work(&p->work); in tape_34xx_schedule_work()
172 * Done Handler is called when dev stat = DEVICE-END (successful operation)
177 DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]); in tape_34xx_done()
179 switch (request->op) { in tape_34xx_done()
186 tape_34xx_delete_sbid_from(request->device, 0); in tape_34xx_done()
198 tape_op_verbose[request->op], rc); in tape_34xx_erp_failed()
206 tape_op_verbose[request->op]); in tape_34xx_erp_succeeded()
213 DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]); in tape_34xx_erp_retry()
224 if (irb->scsw.cmd.dstat == 0x85) { /* READY */ in tape_34xx_unsolicited_irq()
230 DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id); in tape_34xx_unsolicited_irq()
244 if (request->op == TO_RFO) { in tape_34xx_erp_read_opposite()
256 * success -> failed. in tape_34xx_erp_read_opposite()
258 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_erp_read_opposite()
265 if (request->op != TO_ASSIGN) { in tape_34xx_erp_bug()
266 dev_err(&device->cdev->dev, "An unexpected condition %d " in tape_34xx_erp_bug()
270 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_erp_bug()
281 if (irb->ecw[3] == 0x40) { in tape_34xx_erp_overrun()
282 dev_warn (&device->cdev->dev, "A data overrun occurred between" in tape_34xx_erp_overrun()
284 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_erp_overrun()
286 return tape_34xx_erp_bug(device, request, irb, -1); in tape_34xx_erp_overrun()
296 if (irb->ecw[3] == 0x41) { in tape_34xx_erp_sequence()
298 * cu detected incorrect block-id sequence on tape. in tape_34xx_erp_sequence()
300 dev_warn (&device->cdev->dev, "The block ID sequence on the " in tape_34xx_erp_sequence()
302 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_erp_sequence()
308 return tape_34xx_erp_bug(device, request, irb, -2); in tape_34xx_erp_sequence()
312 * This function analyses the tape's sense-data in case of a unit-check.
321 __u8* sense; in tape_34xx_unit_check() local
323 inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0; in tape_34xx_unit_check()
324 sense = irb->ecw; in tape_34xx_unit_check()
327 sense[0] & SENSE_COMMAND_REJECT && in tape_34xx_unit_check()
328 sense[1] & SENSE_WRITE_PROTECT in tape_34xx_unit_check()
331 request->op == TO_DSE || in tape_34xx_unit_check()
332 request->op == TO_WRI || in tape_34xx_unit_check()
333 request->op == TO_WTM in tape_34xx_unit_check()
336 return tape_34xx_erp_failed(request, -EACCES); in tape_34xx_unit_check()
338 return tape_34xx_erp_bug(device, request, irb, -3); in tape_34xx_unit_check()
343 * Special cases for various tape-states when reaching in tape_34xx_unit_check()
347 * sense[0] == SENSE_EQUIPMENT_CHECK && in tape_34xx_unit_check()
348 * sense[1] == SENSE_DRIVE_ONLINE && in tape_34xx_unit_check()
349 * sense[3] == 0x47 (Volume Fenced) in tape_34xx_unit_check()
355 sense[0] == SENSE_DATA_CHECK || in tape_34xx_unit_check()
356 sense[0] == SENSE_EQUIPMENT_CHECK || in tape_34xx_unit_check()
357 sense[0] == SENSE_EQUIPMENT_CHECK + SENSE_DEFERRED_UNIT_CHECK in tape_34xx_unit_check()
359 sense[1] == SENSE_DRIVE_ONLINE || in tape_34xx_unit_check()
360 sense[1] == SENSE_BEGINNING_OF_TAPE + SENSE_WRITE_MODE in tape_34xx_unit_check()
362 switch (request->op) { in tape_34xx_unit_check()
364 * sense[0] == SENSE_DATA_CHECK && in tape_34xx_unit_check()
365 * sense[1] == SENSE_DRIVE_ONLINE in tape_34xx_unit_check()
366 * sense[3] == 0x36 (End Of Data) in tape_34xx_unit_check()
373 return tape_34xx_erp_failed(request, -ENOSPC); in tape_34xx_unit_check()
378 * sense[0] == SENSE_DATA_CHECK && in tape_34xx_unit_check()
379 * sense[1] == SENSE_DRIVE_ONLINE && in tape_34xx_unit_check()
380 * sense[3] == 0x36 (End Of Data) in tape_34xx_unit_check()
385 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
388 /* Read beyond end of recorded area -> 0 bytes read */ in tape_34xx_unit_check()
392 * sense[0] == SENSE_EQUIPMENT_CHECK && in tape_34xx_unit_check()
393 * sense[1] == SENSE_DRIVE_ONLINE && in tape_34xx_unit_check()
394 * sense[3] == 0x38 (Physical End Of Volume) in tape_34xx_unit_check()
398 return tape_34xx_erp_failed(request, -ENOSPC); in tape_34xx_unit_check()
405 if (sense[0] & SENSE_BUS_OUT_CHECK) in tape_34xx_unit_check()
408 if (sense[0] & SENSE_DATA_CHECK) { in tape_34xx_unit_check()
413 switch (sense[3]) { in tape_34xx_unit_check()
416 if ((sense[2] & SENSE_TAPE_SYNC_MODE) || in tape_34xx_unit_check()
419 // recovered. We always use async-mode with in tape_34xx_unit_check()
420 // cu-recovery, so this should *never* happen. in tape_34xx_unit_check()
422 irb, -4); in tape_34xx_unit_check()
425 dev_warn (&device->cdev->dev, "A read error occurred " in tape_34xx_unit_check()
427 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
430 if ((sense[2] & SENSE_TAPE_SYNC_MODE) || in tape_34xx_unit_check()
433 // recovered. We always use async-mode with in tape_34xx_unit_check()
434 // cu-recovery, so this should *never* happen. in tape_34xx_unit_check()
436 irb, -5); in tape_34xx_unit_check()
438 // data check is permanent, cu-recovery has failed in tape_34xx_unit_check()
439 dev_warn (&device->cdev->dev, "A write error on the " in tape_34xx_unit_check()
441 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
446 /* ID-Mark at tape start couldn't be written */ in tape_34xx_unit_check()
447 dev_warn (&device->cdev->dev, "Writing the ID-mark " in tape_34xx_unit_check()
449 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
452 dev_warn (&device->cdev->dev, "Reading the tape beyond" in tape_34xx_unit_check()
454 return tape_34xx_erp_failed(request, -ENOSPC); in tape_34xx_unit_check()
457 dev_warn (&device->cdev->dev, "The tape contains an " in tape_34xx_unit_check()
459 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
462 * the above erpa-codes. For 3490, other data-check in tape_34xx_unit_check()
464 if (device->cdev->id.driver_info == tape_3480) in tape_34xx_unit_check()
466 irb, -6); in tape_34xx_unit_check()
470 if (sense[0] & SENSE_OVERRUN) in tape_34xx_unit_check()
473 if (sense[1] & SENSE_RECORD_SEQUENCE_ERR) in tape_34xx_unit_check()
477 switch (sense[3]) { in tape_34xx_unit_check()
484 * interlock mode. Reissue the command. in tape_34xx_unit_check()
493 dev_warn (&device->cdev->dev, "A path equipment check occurred" in tape_34xx_unit_check()
495 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
515 * subsystem func is issued and the CU is not on-line. in tape_34xx_unit_check()
517 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
529 if (request->op == TO_RUN) { in tape_34xx_unit_check()
535 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
541 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
544 if (request->op == TO_DSE) in tape_34xx_unit_check()
545 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
547 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
554 dev_warn (&device->cdev->dev, "The tape unit cannot process " in tape_34xx_unit_check()
556 return tape_34xx_erp_failed(request, -EMEDIUMTYPE); in tape_34xx_unit_check()
559 dev_warn (&device->cdev->dev, "The tape medium is write-" in tape_34xx_unit_check()
561 return tape_34xx_erp_failed(request, -EACCES); in tape_34xx_unit_check()
564 dev_warn (&device->cdev->dev, "The tape does not have the " in tape_34xx_unit_check()
566 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
572 dev_warn (&device->cdev->dev, "The tape unit failed to load" in tape_34xx_unit_check()
575 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
581 dev_warn (&device->cdev->dev, "Automatic unloading of the tape" in tape_34xx_unit_check()
583 if (request->op == TO_RUN) in tape_34xx_unit_check()
584 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
585 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
589 * - cu cannot recover from a drive detected error in tape_34xx_unit_check()
590 * - a check code message is shown on drive display in tape_34xx_unit_check()
591 * - the cartridge loader does not respond correctly in tape_34xx_unit_check()
592 * - a failure occurs during an index, load, or unload cycle in tape_34xx_unit_check()
594 dev_warn (&device->cdev->dev, "An equipment check has occurred" in tape_34xx_unit_check()
596 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
598 if (device->cdev->id.driver_info == tape_3490) in tape_34xx_unit_check()
600 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
602 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
606 * the beginning-of-tape data. in tape_34xx_unit_check()
608 dev_warn (&device->cdev->dev, "The tape information states an" in tape_34xx_unit_check()
610 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
616 if (request->op==TO_WRI || in tape_34xx_unit_check()
617 request->op==TO_DSE || in tape_34xx_unit_check()
618 request->op==TO_WTM) in tape_34xx_unit_check()
619 return tape_34xx_erp_failed(request, -ENOSPC); in tape_34xx_unit_check()
620 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
623 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
626 dev_warn (&device->cdev->dev, "The tape unit is not ready\n"); in tape_34xx_unit_check()
627 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
630 dev_warn (&device->cdev->dev, "The tape medium has been " in tape_34xx_unit_check()
633 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
636 * Degraded mode. A condition that can cause degraded in tape_34xx_unit_check()
639 dev_warn (&device->cdev->dev, "The tape subsystem is running " in tape_34xx_unit_check()
640 "in degraded mode\n"); in tape_34xx_unit_check()
647 if (sense[1] & SENSE_DRIVE_ONLINE) { in tape_34xx_unit_check()
648 switch(request->op) { in tape_34xx_unit_check()
659 return tape_34xx_erp_failed(request, -ENOMEDIUM); in tape_34xx_unit_check()
662 if (request->op != TO_BLOCK && request->op != TO_LBL) in tape_34xx_unit_check()
665 irb, sense[3]); in tape_34xx_unit_check()
666 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
669 dev_warn (&device->cdev->dev, "The tape unit is already " in tape_34xx_unit_check()
671 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
674 * Drive not on-line. Drive may be switched offline, in tape_34xx_unit_check()
678 dev_warn (&device->cdev->dev, "The tape unit is not online\n"); in tape_34xx_unit_check()
679 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
682 dev_warn (&device->cdev->dev, "The control unit has fenced " in tape_34xx_unit_check()
685 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
687 /* Log sense data and retry request. */ in tape_34xx_unit_check()
691 dev_warn (&device->cdev->dev, "A parity error occurred on the " in tape_34xx_unit_check()
693 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
696 dev_warn (&device->cdev->dev, "I/O error recovery failed on " in tape_34xx_unit_check()
698 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
701 * CU and drive incompatible. The drive requests micro-program in tape_34xx_unit_check()
704 dev_warn (&device->cdev->dev, "The tape unit requires a " in tape_34xx_unit_check()
706 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
709 * Recovered Check-One failure. Cu develops a hardware error, in tape_34xx_unit_check()
714 if (device->cdev->id.driver_info == tape_3490) in tape_34xx_unit_check()
722 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
724 if (device->cdev->id.driver_info == tape_3490) { in tape_34xx_unit_check()
728 * buffered mode. in tape_34xx_unit_check()
730 dev_warn (&device->cdev->dev, "The maximum block size" in tape_34xx_unit_check()
731 " for buffered mode is exceeded\n"); in tape_34xx_unit_check()
732 return tape_34xx_erp_failed(request, -ENOBUFS); in tape_34xx_unit_check()
735 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
739 * buffered log mode, and a counter overflows. This should in tape_34xx_unit_check()
741 * buffered log mode. in tape_34xx_unit_check()
747 * CU is in extended buffered log mode. This should never in tape_34xx_unit_check()
749 * log mode. in tape_34xx_unit_check()
754 if (request->op == TO_RUN) { in tape_34xx_unit_check()
759 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
768 dev_warn (&device->cdev->dev, "A channel interface error cannot be" in tape_34xx_unit_check()
770 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
773 dev_warn (&device->cdev->dev, "A channel protocol error " in tape_34xx_unit_check()
775 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
787 dev_warn (&device->cdev->dev, "The tape unit does not support " in tape_34xx_unit_check()
789 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
792 if (sense[1] & SENSE_BEGINNING_OF_TAPE) in tape_34xx_unit_check()
795 dev_warn (&device->cdev->dev, "The tape unit does not support" in tape_34xx_unit_check()
797 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
799 /* Format 3480-2 XF incompatible */ in tape_34xx_unit_check()
800 dev_warn (&device->cdev->dev, "The tape unit does not support tape " in tape_34xx_unit_check()
801 "format 3480-2 XF\n"); in tape_34xx_unit_check()
802 return tape_34xx_erp_failed(request, -EIO); in tape_34xx_unit_check()
805 dev_warn (&device->cdev->dev, "The tape unit does not support" in tape_34xx_unit_check()
807 return tape_34xx_erp_failed(request, -EMEDIUMTYPE); in tape_34xx_unit_check()
810 dev_warn (&device->cdev->dev, "The tape unit does not support" in tape_34xx_unit_check()
812 return tape_34xx_erp_failed(request, -EMEDIUMTYPE); in tape_34xx_unit_check()
824 return tape_34xx_erp_bug(device, request, irb, sense[3]); in tape_34xx_unit_check()
838 if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) && in tape_34xx_irq()
839 (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) && in tape_34xx_irq()
840 (request->op == TO_WRI)) { in tape_34xx_irq()
842 return tape_34xx_erp_failed(request, -ENOSPC); in tape_34xx_irq()
845 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) in tape_34xx_irq()
848 if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) { in tape_34xx_irq()
852 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) { in tape_34xx_irq()
853 if (request->op == TO_BSB || request->op == TO_FSB) in tape_34xx_irq()
854 request->rescnt++; in tape_34xx_irq()
876 return -EFAULT; in tape_34xx_ioctl()
880 return -EINVAL; in tape_34xx_ioctl()
892 new_sbid->bid = bid; in tape_34xx_append_new_sbid()
893 list_add(&new_sbid->list, l); in tape_34xx_append_new_sbid()
913 sbid_list = (struct list_head *) device->discdata; in tape_34xx_add_sbid()
921 * If there is a block with a lower number but the same hard- in tape_34xx_add_sbid()
929 (sbid->bid.segment == bid.segment) && in tape_34xx_add_sbid()
930 (sbid->bid.wrap == bid.wrap) in tape_34xx_add_sbid()
932 if (bid.block < sbid->bid.block) in tape_34xx_add_sbid()
933 sbid->bid = bid; in tape_34xx_add_sbid()
939 if (bid.block < sbid->bid.block) { in tape_34xx_add_sbid()
940 tape_34xx_append_new_sbid(bid, l->prev); in tape_34xx_add_sbid()
946 tape_34xx_append_new_sbid(bid, l->prev); in tape_34xx_add_sbid()
952 sbid->bid.wrap, in tape_34xx_add_sbid()
953 sbid->bid.segment, in tape_34xx_add_sbid()
954 sbid->bid.block in tape_34xx_add_sbid()
971 sbid_list = (struct list_head *) device->discdata; in tape_34xx_delete_sbid_from()
977 if (sbid->bid.block >= from) { in tape_34xx_delete_sbid_from()
979 sbid->bid.wrap, in tape_34xx_delete_sbid_from()
980 sbid->bid.segment, in tape_34xx_delete_sbid_from()
981 sbid->bid.block in tape_34xx_delete_sbid_from()
1002 sbid_list = (struct list_head *) device->discdata; in tape_34xx_merge_sbid()
1003 bid->wrap = 0; in tape_34xx_merge_sbid()
1004 bid->segment = 1; in tape_34xx_merge_sbid()
1013 if (sbid->bid.block >= bid->block) in tape_34xx_merge_sbid()
1018 bid->wrap = sbid_to_use->bid.wrap; in tape_34xx_merge_sbid()
1019 bid->segment = sbid_to_use->bid.segment; in tape_34xx_merge_sbid()
1021 sbid_to_use->bid.wrap, in tape_34xx_merge_sbid()
1022 sbid_to_use->bid.segment, in tape_34xx_merge_sbid()
1023 sbid_to_use->bid.block, in tape_34xx_merge_sbid()
1024 bid->block in tape_34xx_merge_sbid()
1038 DBF_LH(3, "34xx medium sense returned %d\n", rc); in tape_34xx_setup_device()
1044 device->discdata = discdata; in tape_34xx_setup_device()
1055 if (device->discdata) { in tape_34xx_cleanup_device()
1057 kfree(device->discdata); in tape_34xx_cleanup_device()
1058 device->discdata = NULL; in tape_34xx_cleanup_device()
1094 return -EINVAL; in tape_34xx_mtseek()
1101 request->op = TO_LBL; in tape_34xx_mtseek()
1102 bid = (struct tape_34xx_block_id *) request->cpdata; in tape_34xx_mtseek()
1103 bid->format = (*device->modeset_byte & 0x08) ? in tape_34xx_mtseek()
1105 bid->block = mt_count; in tape_34xx_mtseek()
1108 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); in tape_34xx_mtseek()
1109 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); in tape_34xx_mtseek()
1110 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); in tape_34xx_mtseek()
1179 dev_get_drvdata(&cdev->dev), in tape_34xx_online()
1228 MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH");