• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/ide/

Lines Matching refs:tape

2  * IDE ATAPI streaming tape driver.
15 * Documentation/ide/ChangeLog.ide-tape.1995-2002
18 #define DRV_NAME "ide-tape"
71 * The following parameter is used to select the point in the internal tape fifo
82 * function in ide-tape. There are two cases in which we poll for DSC:
85 * from/to the tape's data buffers, without causing an actual media access.
86 * In case the tape is not ready yet, we take out our request from the device
100 * timeout should be longer then the maximum execution time of a tape operation.
114 /* tape directions */
186 /* tape block size, usually 512 or 1024 bytes */
190 /* Copy of the tape's Capabilities and Mechanical Page */
196 * At most, there is only one ide-tape originated data transfer request
201 /* Data buffer size chosen based on the tape's recommendation */
210 /* Measures average tape speed */
217 /* the tape hardware is write protected */
219 /* the tape is write protected (hardware or opened as read-only) */
236 struct ide_tape_obj *tape = NULL;
241 tape = idetape_devs[i];
243 tape = ide_drv_g(disk, ide_tape_obj);
245 if (tape) {
246 if (ide_device_get(tape->drive))
247 tape = NULL;
249 get_device(&tape->dev);
253 return tape;
256 static void ide_tape_put(struct ide_tape_obj *tape)
258 ide_drive_t *drive = tape->drive;
261 put_device(&tape->dev);
272 idetape_tape_t *tape = drive->driver_data;
277 tape->sense_key = sense[2] & 0xF;
278 tape->asc = sense[12];
279 tape->ascq = sense[13];
283 rq->cmd[0], tape->sense_key, tape->asc, tape->ascq);
287 rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]);
297 if (tape->sense_key == 5) {
309 if ((sense[2] & 0x40) || (tape->sense_key == 0xd
310 && tape->asc == 0x0 && tape->ascq == 0x2)) {
316 if (tape->sense_key == 8) {
330 idetape_tape_t *tape = drive->driver_data;
349 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
353 (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size;
355 tape->avg_size += blocks * tape->blk_size;
357 if (time_after_eq(jiffies, tape->avg_time + HZ)) {
358 tape->avg_speed = tape->avg_size * HZ /
359 (jiffies - tape->avg_time) / 1024;
360 tape->avg_size = 0;
361 tape->avg_time = jiffies;
364 tape->first_frame += blocks;
382 idetape_tape_t *tape = drive->driver_data;
385 drive->hwif->rq->cmd[0], tape->dsc_poll_freq);
387 tape->postponed_rq = true;
389 ide_stall_queue(drive, tape->dsc_poll_freq);
394 idetape_tape_t *tape = drive->driver_data;
397 tape->dsc_polling_start = jiffies;
398 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST;
399 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT;
422 * Since the tape drive will not issue an interrupt, we have to poll for this
445 idetape_tape_t *tape = drive->driver_data;
464 tape->sense_key == 2 && tape->asc == 4 &&
465 (tape->ascq == 1 || tape->ascq == 8))) {
466 printk(KERN_ERR "ide-tape: %s: I/O error, "
469 tape->name, pc->c[0],
470 tape->sense_key, tape->asc,
471 tape->ascq);
490 /* A mode sense command is used to "sense" tape parameters. */
520 idetape_tape_t *tape = drive->driver_data;
530 printk(KERN_ERR "ide-tape: %s: I/O error, ",
531 tape->name);
545 static void ide_tape_create_rw_cmd(idetape_tape_t *tape,
549 unsigned int length = blk_rq_sectors(rq) / (tape->blk_size >> 9);
555 if (blk_rq_bytes(rq) == tape->buffer_size)
572 idetape_tape_t *tape = drive->driver_data;
591 * If the tape is still busy, postpone our request and service
607 if (!tape->postponed_rq) {
608 tape->dsc_polling_start = jiffies;
609 tape->dsc_poll_freq = tape->best_dsc_rw_freq;
610 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT;
611 } else if (time_after(jiffies, tape->dsc_timeout)) {
612 printk(KERN_ERR "ide-tape: %s: DSC timeout\n",
613 tape->name);
621 tape->dsc_polling_start +
623 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW;
628 tape->postponed_rq = false;
632 pc = &tape->queued_pc;
633 ide_tape_create_rw_cmd(tape, pc, rq, READ_6);
637 pc = &tape->queued_pc;
638 ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6);
685 idetape_tape_t *tape = drive->driver_data;
686 struct gendisk *disk = tape->disk;
689 /* Wait for the tape to become ready */
695 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2)
696 || (tape->asc == 0x3A)) {
703 } else if (!(tape->sense_key == 2 && tape->asc == 4 &&
704 (tape->ascq == 1 || tape->ascq == 8)))
713 struct ide_tape_obj *tape = drive->driver_data;
718 rc = ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0);
727 idetape_tape_t *tape = drive->driver_data;
738 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer))
748 printk(KERN_INFO "ide-tape: Block location is unknown"
749 "to the tape\n");
757 tape->partition = buf[1];
758 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]);
764 return tape->first_frame;
781 idetape_tape_t *tape = drive->driver_data;
783 if (tape->chrdev_dir != IDETAPE_DIR_READ)
787 tape->valid = 0;
788 if (tape->buf != NULL) {
789 kfree(tape->buf);
790 tape->buf = NULL;
793 tape->chrdev_dir = IDETAPE_DIR_NONE;
797 * Position the tape to the requested block using the LOCATE packet command.
805 idetape_tape_t *tape = drive->driver_data;
806 struct gendisk *disk = tape->disk;
810 if (tape->chrdev_dir == IDETAPE_DIR_READ)
827 idetape_tape_t *tape = drive->driver_data;
835 printk(KERN_INFO "ide-tape: %s: position_tape failed in"
836 " %s\n", tape->name, __func__);
848 idetape_tape_t *tape = drive->driver_data;
855 BUG_ON(size < 0 || size % tape->blk_size);
860 rq->rq_disk = tape->disk;
861 rq->__sector = tape->first_frame;
864 ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size,
870 blk_execute_rq(drive->queue, tape->disk, rq, 0);
874 tape->cur = tape->buf;
876 tape->valid = size;
878 tape->valid = 0;
923 idetape_tape_t *tape = drive->driver_data;
925 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
926 printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer"
930 if (tape->buf) {
931 size_t aligned = roundup(tape->valid, tape->blk_size);
933 memset(tape->cur, 0, aligned - tape->valid);
935 kfree(tape->buf);
936 tape->buf = NULL;
938 tape->chrdev_dir = IDETAPE_DIR_NONE;
943 idetape_tape_t *tape = drive->driver_data;
948 if (tape->chrdev_dir == dir)
951 if (tape->chrdev_dir == IDETAPE_DIR_READ)
953 else if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
958 if (tape->buf || tape->valid) {
959 printk(KERN_ERR "ide-tape: valid should be 0 now\n");
960 tape->valid = 0;
963 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL);
964 if (!tape->buf)
966 tape->chrdev_dir = dir;
967 tape->cur = tape->buf;
981 kfree(tape->buf);
982 tape->buf = NULL;
983 tape->chrdev_dir = IDETAPE_DIR_NONE;
993 idetape_tape_t *tape = drive->driver_data;
995 memset(tape->buf, 0, tape->buffer_size);
998 unsigned int count = min(tape->buffer_size, bcount);
1006 * Rewinds the tape to the Beginning Of the current Partition (BOP). We
1011 struct ide_tape_obj *tape = drive->driver_data;
1012 struct gendisk *disk = tape->disk;
1033 idetape_tape_t *tape = drive->driver_data;
1048 tape->best_dsc_rw_freq = config.dsc_rw_frequency;
1052 config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq;
1066 idetape_tape_t *tape = drive->driver_data;
1067 struct gendisk *disk = tape->disk;
1070 int sprev = !!(tape->caps[4] & 0x20);
1083 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
1084 tape->valid = 0;
1108 printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n",
1117 * The tape is optimized to maximize throughput when it is transferring an
1119 * the specific tape (26kB on my particular tape, 32kB for Onstream).
1132 struct ide_tape_obj *tape = file->private_data;
1133 ide_drive_t *drive = tape->drive;
1140 if (tape->chrdev_dir != IDETAPE_DIR_READ) {
1142 if (count > tape->blk_size &&
1143 (count % tape->blk_size) == 0)
1144 tape->user_bs_factor = count / tape->blk_size;
1155 if (!tape->valid) {
1162 tape->buffer_size) <= 0)
1167 todo = min_t(size_t, count - done, tape->valid);
1168 if (copy_to_user(buf + done, tape->cur, todo))
1171 tape->cur += todo;
1172 tape->valid -= todo;
1187 struct ide_tape_obj *tape = file->private_data;
1188 ide_drive_t *drive = tape->drive;
1194 if (tape->write_prot)
1208 if (tape->valid == tape->buffer_size &&
1210 tape->buffer_size) <= 0)
1215 tape->buffer_size - tape->valid);
1216 if (copy_from_user(tape->cur, buf + done, todo))
1219 tape->cur += todo;
1220 tape->valid += todo;
1229 struct ide_tape_obj *tape = drive->driver_data;
1234 if (ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0)) {
1235 printk(KERN_ERR "ide-tape: Couldn't write a filemark\n");
1245 * Note: MTBSF and MTBSFM are not supported when the tape doesn't support
1256 idetape_tape_t *tape = drive->driver_data;
1257 struct gendisk *disk = tape->disk;
1278 if (tape->write_prot)
1301 if (tape->door_locked) {
1303 tape->door_locked = DOOR_UNLOCKED;
1327 if (mt_count < tape->blk_size ||
1328 mt_count % tape->blk_size)
1330 tape->user_bs_factor = mt_count / tape->blk_size;
1340 mt_count * tape->user_bs_factor, tape->partition, 0);
1350 tape->door_locked = DOOR_EXPLICITLY_LOCKED;
1356 tape->door_locked = DOOR_UNLOCKED;
1359 printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n",
1368 * ide-tape ioctls are supported on both interfaces.
1373 struct ide_tape_obj *tape = file->private_data;
1374 ide_drive_t *drive = tape->drive;
1378 int block_offset = 0, position = tape->first_frame;
1383 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
1388 block_offset = tape->valid /
1389 (tape->blk_size * tape->user_bs_factor);
1402 mtget.mt_blkno = position / tape->user_bs_factor - block_offset;
1404 ((tape->blk_size * tape->user_bs_factor)
1407 if (tape->drv_write_prot)
1414 mtpos.mt_blkno = position / tape->user_bs_factor - block_offset;
1419 if (tape->chrdev_dir == IDETAPE_DIR_READ)
1436 * Do a mode sense page 0 with block descriptor and if it succeeds set the tape
1441 idetape_tape_t *tape = drive->driver_data;
1446 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) {
1447 printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
1448 if (tape->blk_size == 0) {
1449 printk(KERN_WARNING "ide-tape: Cannot deal with zero "
1451 tape->blk_size = 32768;
1455 tape->blk_size = (buf[4 + 5] << 16) +
1458 tape->drv_write_prot = (buf[2] & 0x80) >> 7;
1461 tape->blk_size, tape->drv_write_prot);
1468 idetape_tape_t *tape;
1476 tape = ide_tape_get(NULL, true, i);
1477 if (!tape) {
1482 drive = tape->drive;
1483 filp->private_data = tape;
1503 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name);
1516 tape->write_prot = 1;
1518 tape->write_prot = tape->drv_write_prot;
1521 if (tape->write_prot) {
1530 /* Lock the tape drive door so user can't eject. */
1531 if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
1532 if (!ide_set_media_lock(drive, tape->disk, 1)) {
1533 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
1534 tape->door_locked = DOOR_LOCKED;
1542 ide_tape_put(tape);
1551 idetape_tape_t *tape = drive->driver_data;
1554 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL);
1555 if (tape->buf != NULL) {
1556 idetape_pad_zeros(drive, tape->blk_size *
1557 (tape->user_bs_factor - 1));
1558 kfree(tape->buf);
1559 tape->buf = NULL;
1568 struct ide_tape_obj *tape = filp->private_data;
1569 ide_drive_t *drive = tape->drive;
1574 tape = drive->driver_data;
1578 if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
1580 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
1589 if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
1590 if (tape->door_locked == DOOR_LOCKED) {
1591 if (!ide_set_media_lock(drive, tape->disk, 0))
1592 tape->door_locked = DOOR_UNLOCKED;
1596 ide_tape_put(tape);
1605 idetape_tape_t *tape = drive->driver_data;
1611 if (ide_queue_pc_tail(drive, tape->disk, &pc, pc_buf, pc.req_xfer)) {
1612 printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n",
1613 tape->name);
1624 printk(KERN_INFO "ide-tape: %s <-> %s: %.8s %.16s rev %.4s\n",
1625 drive->name, tape->name, vendor_id, product_id, fw_rev);
1629 * Ask the tape about its various parameters. In particular, we will adjust our
1630 * data transfer buffer size to the recommended value as returned by the tape.
1634 idetape_tape_t *tape = drive->driver_data;
1640 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) {
1641 printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming"
1643 tape->blk_size = 512;
1644 put_unaligned(52, (u16 *)&tape->caps[12]);
1645 put_unaligned(540, (u16 *)&tape->caps[14]);
1646 put_unaligned(6*52, (u16 *)&tape->caps[16]);
1661 printk(KERN_INFO "ide-tape: %s: invalid tape speed "
1666 printk(KERN_INFO "ide-tape: %s: invalid max_speed "
1671 memcpy(&tape->caps, caps, 20);
1678 tape->blk_size = 512;
1680 tape->blk_size = 1024;
1687 idetape_tape_t *tape = drive->driver_data; \
1688 return tape->field; \
1694 idetape_tape_t *tape = drive->driver_data; \
1695 tape->field = arg; \
1738 * 2. Ask the tape for its capabilities.
1745 static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
1750 u16 *ctl = (u16 *)&tape->caps[12];
1759 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n",
1760 tape->name);
1768 tape->minor = minor;
1769 tape->name[0] = 'h';
1770 tape->name[1] = 't';
1771 tape->name[2] = '0' + minor;
1772 tape->chrdev_dir = IDETAPE_DIR_NONE;
1777 tape->user_bs_factor = 1;
1778 tape->buffer_size = *ctl * tape->blk_size;
1779 while (tape->buffer_size > 0xffff) {
1780 printk(KERN_NOTICE "ide-tape: decreasing stage size\n");
1782 tape->buffer_size = *ctl * tape->blk_size;
1784 buffer_size = tape->buffer_size;
1787 speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]);
1789 t = (IDETAPE_FIFO_THRESHOLD * tape->buffer_size * HZ) / (speed * 1000);
1795 tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN,
1797 printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, "
1799 drive->name, tape->name, *(u16 *)&tape->caps[14],
1800 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size,
1801 tape->buffer_size / 1024,
1802 tape->best_dsc_rw_freq * 1000 / HZ,
1805 ide_proc_register_driver(drive, tape->driver);
1810 idetape_tape_t *tape = drive->driver_data;
1812 ide_proc_unregister_driver(drive, tape->driver);
1813 device_del(&tape->dev);
1814 ide_unregister_region(tape->disk);
1817 put_device(&tape->dev);
1823 struct ide_tape_obj *tape = to_ide_drv(dev, ide_tape_obj);
1824 ide_drive_t *drive = tape->drive;
1825 struct gendisk *g = tape->disk;
1827 BUG_ON(tape->valid);
1831 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor));
1833 MKDEV(IDETAPE_MAJOR, tape->minor + 128));
1834 idetape_devs[tape->minor] = NULL;
1837 kfree(tape);
1844 idetape_tape_t *tape = drive->driver_data;
1846 seq_printf(m, "%s\n", tape->name);
1885 .name = "ide-tape",
1910 struct ide_tape_obj *tape;
1913 tape = ide_tape_get(bdev->bd_disk, false, 0);
1916 if (!tape)
1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj);
1927 ide_tape_put(tape);
1936 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj);
1937 ide_drive_t *drive = tape->drive;
1958 idetape_tape_t *tape;
1972 printk(KERN_ERR "ide-tape: %s: not supported by this version of"
1976 tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL);
1977 if (tape == NULL) {
1978 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n",
1989 tape->dev.parent = &drive->gendev;
1990 tape->dev.release = ide_tape_release;
1991 dev_set_name(&tape->dev, dev_name(&drive->gendev));
1993 if (device_register(&tape->dev))
1996 tape->drive = drive;
1997 tape->driver = &idetape_driver;
1998 tape->disk = g;
2000 g->private_data = &tape->driver;
2002 drive->driver_data = tape;
2007 idetape_devs[minor] = tape;
2010 idetape_setup(drive, tape, minor);
2013 MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name);
2016 "n%s", tape->name);
2026 kfree(tape);
2050 printk(KERN_ERR "ide-tape: Failed to register chrdev"
2070 MODULE_ALIAS("ide:*m-tape*");