diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 210 |
1 files changed, 113 insertions, 97 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index ad13527ff440..2fe4e8fdf3da 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -299,10 +299,8 @@ typedef struct ide_tape_obj { | |||
299 | /* Timer used to poll for dsc */ | 299 | /* Timer used to poll for dsc */ |
300 | struct timer_list dsc_timer; | 300 | struct timer_list dsc_timer; |
301 | /* Read/Write dsc polling frequency */ | 301 | /* Read/Write dsc polling frequency */ |
302 | unsigned long best_dsc_rw_frequency; | 302 | unsigned long best_dsc_rw_freq; |
303 | /* The current polling frequency */ | 303 | unsigned long dsc_poll_freq; |
304 | unsigned long dsc_polling_frequency; | ||
305 | /* Maximum waiting time */ | ||
306 | unsigned long dsc_timeout; | 304 | unsigned long dsc_timeout; |
307 | 305 | ||
308 | /* | 306 | /* |
@@ -310,7 +308,7 @@ typedef struct ide_tape_obj { | |||
310 | */ | 308 | */ |
311 | u8 partition; | 309 | u8 partition; |
312 | /* Current block */ | 310 | /* Current block */ |
313 | unsigned int first_frame_position; | 311 | unsigned int first_frame; |
314 | 312 | ||
315 | /* | 313 | /* |
316 | * Last error information | 314 | * Last error information |
@@ -326,11 +324,8 @@ typedef struct ide_tape_obj { | |||
326 | /* Current character device data transfer direction */ | 324 | /* Current character device data transfer direction */ |
327 | u8 chrdev_dir; | 325 | u8 chrdev_dir; |
328 | 326 | ||
329 | /* | 327 | /* tape block size, usually 512 or 1024 bytes */ |
330 | * Device information | 328 | unsigned short blk_size; |
331 | */ | ||
332 | /* Usually 512 or 1024 bytes */ | ||
333 | unsigned short tape_block_size; | ||
334 | int user_bs_factor; | 329 | int user_bs_factor; |
335 | 330 | ||
336 | /* Copy of the tape's Capabilities and Mechanical Page */ | 331 | /* Copy of the tape's Capabilities and Mechanical Page */ |
@@ -349,8 +344,8 @@ typedef struct ide_tape_obj { | |||
349 | * The data buffer size is chosen based on the tape's | 344 | * The data buffer size is chosen based on the tape's |
350 | * recommendation. | 345 | * recommendation. |
351 | */ | 346 | */ |
352 | /* Pointer to the request which is waiting in the device request queue */ | 347 | /* Ptr to the request which is waiting in the device request queue */ |
353 | struct request *active_data_request; | 348 | struct request *active_data_rq; |
354 | /* Data buffer size (chosen based on the tape's recommendation */ | 349 | /* Data buffer size (chosen based on the tape's recommendation */ |
355 | int stage_size; | 350 | int stage_size; |
356 | idetape_stage_t *merge_stage; | 351 | idetape_stage_t *merge_stage; |
@@ -388,7 +383,7 @@ typedef struct ide_tape_obj { | |||
388 | /* Status/Action flags: long for set_bit */ | 383 | /* Status/Action flags: long for set_bit */ |
389 | unsigned long flags; | 384 | unsigned long flags; |
390 | /* protects the ide-tape queue */ | 385 | /* protects the ide-tape queue */ |
391 | spinlock_t spinlock; | 386 | spinlock_t lock; |
392 | 387 | ||
393 | /* | 388 | /* |
394 | * Measures average tape speed | 389 | * Measures average tape speed |
@@ -750,7 +745,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
750 | /* Correct pc->actually_transferred by asking the tape. */ | 745 | /* Correct pc->actually_transferred by asking the tape. */ |
751 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { | 746 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { |
752 | pc->actually_transferred = pc->request_transfer - | 747 | pc->actually_transferred = pc->request_transfer - |
753 | tape->tape_block_size * | 748 | tape->blk_size * |
754 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); | 749 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); |
755 | idetape_update_buffers(pc); | 750 | idetape_update_buffers(pc); |
756 | } | 751 | } |
@@ -809,7 +804,7 @@ static void idetape_activate_next_stage(ide_drive_t *drive) | |||
809 | rq->rq_disk = tape->disk; | 804 | rq->rq_disk = tape->disk; |
810 | rq->buffer = NULL; | 805 | rq->buffer = NULL; |
811 | rq->special = (void *)stage->bh; | 806 | rq->special = (void *)stage->bh; |
812 | tape->active_data_request = rq; | 807 | tape->active_data_rq = rq; |
813 | tape->active_stage = stage; | 808 | tape->active_stage = stage; |
814 | tape->next_stage = stage->next; | 809 | tape->next_stage = stage->next; |
815 | } | 810 | } |
@@ -951,13 +946,13 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
951 | return 0; | 946 | return 0; |
952 | } | 947 | } |
953 | 948 | ||
954 | spin_lock_irqsave(&tape->spinlock, flags); | 949 | spin_lock_irqsave(&tape->lock, flags); |
955 | 950 | ||
956 | /* The request was a pipelined data transfer request */ | 951 | /* The request was a pipelined data transfer request */ |
957 | if (tape->active_data_request == rq) { | 952 | if (tape->active_data_rq == rq) { |
958 | active_stage = tape->active_stage; | 953 | active_stage = tape->active_stage; |
959 | tape->active_stage = NULL; | 954 | tape->active_stage = NULL; |
960 | tape->active_data_request = NULL; | 955 | tape->active_data_rq = NULL; |
961 | tape->nr_pending_stages--; | 956 | tape->nr_pending_stages--; |
962 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 957 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
963 | remove_stage = 1; | 958 | remove_stage = 1; |
@@ -978,7 +973,8 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
978 | /* | 973 | /* |
979 | * Insert the next request into the request queue. | 974 | * Insert the next request into the request queue. |
980 | */ | 975 | */ |
981 | (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); | 976 | (void)ide_do_drive_cmd(drive, tape->active_data_rq, |
977 | ide_end); | ||
982 | } else if (!error) { | 978 | } else if (!error) { |
983 | idetape_increase_max_pipeline_stages(drive); | 979 | idetape_increase_max_pipeline_stages(drive); |
984 | } | 980 | } |
@@ -990,9 +986,9 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
990 | 986 | ||
991 | if (remove_stage) | 987 | if (remove_stage) |
992 | idetape_remove_stage_head(drive); | 988 | idetape_remove_stage_head(drive); |
993 | if (tape->active_data_request == NULL) | 989 | if (tape->active_data_rq == NULL) |
994 | clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 990 | clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); |
995 | spin_unlock_irqrestore(&tape->spinlock, flags); | 991 | spin_unlock_irqrestore(&tape->lock, flags); |
996 | return 0; | 992 | return 0; |
997 | } | 993 | } |
998 | 994 | ||
@@ -1089,7 +1085,7 @@ static void idetape_postpone_request (ide_drive_t *drive) | |||
1089 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1085 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
1090 | 1086 | ||
1091 | tape->postponed_rq = HWGROUP(drive)->rq; | 1087 | tape->postponed_rq = HWGROUP(drive)->rq; |
1092 | ide_stall_queue(drive, tape->dsc_polling_frequency); | 1088 | ide_stall_queue(drive, tape->dsc_poll_freq); |
1093 | } | 1089 | } |
1094 | 1090 | ||
1095 | typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, unsigned int); | 1091 | typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, unsigned int); |
@@ -1190,7 +1186,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
1190 | (stat & SEEK_STAT) == 0) { | 1186 | (stat & SEEK_STAT) == 0) { |
1191 | /* Media access command */ | 1187 | /* Media access command */ |
1192 | tape->dsc_polling_start = jiffies; | 1188 | tape->dsc_polling_start = jiffies; |
1193 | tape->dsc_polling_frequency = IDETAPE_DSC_MA_FAST; | 1189 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; |
1194 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; | 1190 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; |
1195 | /* Allow ide.c to handle other requests */ | 1191 | /* Allow ide.c to handle other requests */ |
1196 | idetape_postpone_request(drive); | 1192 | idetape_postpone_request(drive); |
@@ -1543,10 +1539,10 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | |||
1543 | { | 1539 | { |
1544 | idetape_tape_t *tape = drive->driver_data; | 1540 | idetape_tape_t *tape = drive->driver_data; |
1545 | struct request *rq = HWGROUP(drive)->rq; | 1541 | struct request *rq = HWGROUP(drive)->rq; |
1546 | int blocks = tape->pc->actually_transferred / tape->tape_block_size; | 1542 | int blocks = tape->pc->actually_transferred / tape->blk_size; |
1547 | 1543 | ||
1548 | tape->avg_size += blocks * tape->tape_block_size; | 1544 | tape->avg_size += blocks * tape->blk_size; |
1549 | tape->insert_size += blocks * tape->tape_block_size; | 1545 | tape->insert_size += blocks * tape->blk_size; |
1550 | if (tape->insert_size > 1024 * 1024) | 1546 | if (tape->insert_size > 1024 * 1024) |
1551 | tape->measure_insert_time = 1; | 1547 | tape->measure_insert_time = 1; |
1552 | if (tape->measure_insert_time) { | 1548 | if (tape->measure_insert_time) { |
@@ -1563,7 +1559,7 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | |||
1563 | } | 1559 | } |
1564 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1560 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
1565 | 1561 | ||
1566 | tape->first_frame_position += blocks; | 1562 | tape->first_frame += blocks; |
1567 | rq->current_nr_sectors -= blocks; | 1563 | rq->current_nr_sectors -= blocks; |
1568 | 1564 | ||
1569 | if (!tape->pc->error) | 1565 | if (!tape->pc->error) |
@@ -1583,7 +1579,8 @@ static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsi | |||
1583 | pc->bh = bh; | 1579 | pc->bh = bh; |
1584 | atomic_set(&bh->b_count, 0); | 1580 | atomic_set(&bh->b_count, 0); |
1585 | pc->buffer = NULL; | 1581 | pc->buffer = NULL; |
1586 | pc->request_transfer = pc->buffer_size = length * tape->tape_block_size; | 1582 | pc->buffer_size = length * tape->blk_size; |
1583 | pc->request_transfer = pc->buffer_size; | ||
1587 | if (pc->request_transfer == tape->stage_size) | 1584 | if (pc->request_transfer == tape->stage_size) |
1588 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 1585 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); |
1589 | } | 1586 | } |
@@ -1621,7 +1618,8 @@ static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, uns | |||
1621 | pc->b_data = bh->b_data; | 1618 | pc->b_data = bh->b_data; |
1622 | pc->b_count = atomic_read(&bh->b_count); | 1619 | pc->b_count = atomic_read(&bh->b_count); |
1623 | pc->buffer = NULL; | 1620 | pc->buffer = NULL; |
1624 | pc->request_transfer = pc->buffer_size = length * tape->tape_block_size; | 1621 | pc->buffer_size = length * tape->blk_size; |
1622 | pc->request_transfer = pc->buffer_size; | ||
1625 | if (pc->request_transfer == tape->stage_size) | 1623 | if (pc->request_transfer == tape->stage_size) |
1626 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 1624 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); |
1627 | } | 1625 | } |
@@ -1689,7 +1687,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1689 | (stat & SEEK_STAT) == 0) { | 1687 | (stat & SEEK_STAT) == 0) { |
1690 | if (postponed_rq == NULL) { | 1688 | if (postponed_rq == NULL) { |
1691 | tape->dsc_polling_start = jiffies; | 1689 | tape->dsc_polling_start = jiffies; |
1692 | tape->dsc_polling_frequency = tape->best_dsc_rw_frequency; | 1690 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; |
1693 | tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; | 1691 | tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; |
1694 | } else if (time_after(jiffies, tape->dsc_timeout)) { | 1692 | } else if (time_after(jiffies, tape->dsc_timeout)) { |
1695 | printk(KERN_ERR "ide-tape: %s: DSC timeout\n", | 1693 | printk(KERN_ERR "ide-tape: %s: DSC timeout\n", |
@@ -1701,7 +1699,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1701 | return ide_do_reset(drive); | 1699 | return ide_do_reset(drive); |
1702 | } | 1700 | } |
1703 | } else if (time_after(jiffies, tape->dsc_polling_start + IDETAPE_DSC_MA_THRESHOLD)) | 1701 | } else if (time_after(jiffies, tape->dsc_polling_start + IDETAPE_DSC_MA_THRESHOLD)) |
1704 | tape->dsc_polling_frequency = IDETAPE_DSC_MA_SLOW; | 1702 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; |
1705 | idetape_postpone_request(drive); | 1703 | idetape_postpone_request(drive); |
1706 | return ide_stopped; | 1704 | return ide_stopped; |
1707 | } | 1705 | } |
@@ -1748,7 +1746,7 @@ static inline int idetape_pipeline_active (idetape_tape_t *tape) | |||
1748 | int rc1, rc2; | 1746 | int rc1, rc2; |
1749 | 1747 | ||
1750 | rc1 = test_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 1748 | rc1 = test_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); |
1751 | rc2 = (tape->active_data_request != NULL); | 1749 | rc2 = (tape->active_data_rq != NULL); |
1752 | return rc1; | 1750 | return rc1; |
1753 | } | 1751 | } |
1754 | 1752 | ||
@@ -1930,7 +1928,7 @@ static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage) | |||
1930 | 1928 | ||
1931 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1929 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
1932 | 1930 | ||
1933 | spin_lock_irqsave(&tape->spinlock, flags); | 1931 | spin_lock_irqsave(&tape->lock, flags); |
1934 | stage->next = NULL; | 1932 | stage->next = NULL; |
1935 | if (tape->last_stage != NULL) | 1933 | if (tape->last_stage != NULL) |
1936 | tape->last_stage->next=stage; | 1934 | tape->last_stage->next=stage; |
@@ -1941,7 +1939,7 @@ static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage) | |||
1941 | tape->next_stage = tape->last_stage; | 1939 | tape->next_stage = tape->last_stage; |
1942 | tape->nr_stages++; | 1940 | tape->nr_stages++; |
1943 | tape->nr_pending_stages++; | 1941 | tape->nr_pending_stages++; |
1944 | spin_unlock_irqrestore(&tape->spinlock, flags); | 1942 | spin_unlock_irqrestore(&tape->lock, flags); |
1945 | } | 1943 | } |
1946 | 1944 | ||
1947 | /* | 1945 | /* |
@@ -1962,10 +1960,10 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) | |||
1962 | } | 1960 | } |
1963 | rq->end_io_data = &wait; | 1961 | rq->end_io_data = &wait; |
1964 | rq->end_io = blk_end_sync_rq; | 1962 | rq->end_io = blk_end_sync_rq; |
1965 | spin_unlock_irq(&tape->spinlock); | 1963 | spin_unlock_irq(&tape->lock); |
1966 | wait_for_completion(&wait); | 1964 | wait_for_completion(&wait); |
1967 | /* The stage and its struct request have been deallocated */ | 1965 | /* The stage and its struct request have been deallocated */ |
1968 | spin_lock_irq(&tape->spinlock); | 1966 | spin_lock_irq(&tape->lock); |
1969 | } | 1967 | } |
1970 | 1968 | ||
1971 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | 1969 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) |
@@ -1991,7 +1989,7 @@ static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | |||
1991 | be32_to_cpu(*(u32 *)&readpos[4])); | 1989 | be32_to_cpu(*(u32 *)&readpos[4])); |
1992 | 1990 | ||
1993 | tape->partition = readpos[1]; | 1991 | tape->partition = readpos[1]; |
1994 | tape->first_frame_position = | 1992 | tape->first_frame = |
1995 | be32_to_cpu(*(u32 *)&readpos[4]); | 1993 | be32_to_cpu(*(u32 *)&readpos[4]); |
1996 | set_bit(IDETAPE_ADDRESS_VALID, &tape->flags); | 1994 | set_bit(IDETAPE_ADDRESS_VALID, &tape->flags); |
1997 | idetape_end_request(drive, 1, 0); | 1995 | idetape_end_request(drive, 1, 0); |
@@ -2133,7 +2131,7 @@ static int idetape_read_position (ide_drive_t *drive) | |||
2133 | idetape_create_read_position_cmd(&pc); | 2131 | idetape_create_read_position_cmd(&pc); |
2134 | if (idetape_queue_pc_tail(drive, &pc)) | 2132 | if (idetape_queue_pc_tail(drive, &pc)) |
2135 | return -1; | 2133 | return -1; |
2136 | position = tape->first_frame_position; | 2134 | position = tape->first_frame; |
2137 | return position; | 2135 | return position; |
2138 | } | 2136 | } |
2139 | 2137 | ||
@@ -2173,7 +2171,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive) | |||
2173 | return 0; | 2171 | return 0; |
2174 | 2172 | ||
2175 | /* Remove merge stage. */ | 2173 | /* Remove merge stage. */ |
2176 | cnt = tape->merge_stage_size / tape->tape_block_size; | 2174 | cnt = tape->merge_stage_size / tape->blk_size; |
2177 | if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) | 2175 | if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) |
2178 | ++cnt; /* Filemarks count as 1 sector */ | 2176 | ++cnt; /* Filemarks count as 1 sector */ |
2179 | tape->merge_stage_size = 0; | 2177 | tape->merge_stage_size = 0; |
@@ -2190,11 +2188,11 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive) | |||
2190 | if (tape->first_stage == NULL) | 2188 | if (tape->first_stage == NULL) |
2191 | return 0; | 2189 | return 0; |
2192 | 2190 | ||
2193 | spin_lock_irqsave(&tape->spinlock, flags); | 2191 | spin_lock_irqsave(&tape->lock, flags); |
2194 | tape->next_stage = NULL; | 2192 | tape->next_stage = NULL; |
2195 | if (idetape_pipeline_active(tape)) | 2193 | if (idetape_pipeline_active(tape)) |
2196 | idetape_wait_for_request(drive, tape->active_data_request); | 2194 | idetape_wait_for_request(drive, tape->active_data_rq); |
2197 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2195 | spin_unlock_irqrestore(&tape->lock, flags); |
2198 | 2196 | ||
2199 | while (tape->first_stage != NULL) { | 2197 | while (tape->first_stage != NULL) { |
2200 | struct request *rq_ptr = &tape->first_stage->rq; | 2198 | struct request *rq_ptr = &tape->first_stage->rq; |
@@ -2273,7 +2271,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct | |||
2273 | idetape_init_rq(&rq, cmd); | 2271 | idetape_init_rq(&rq, cmd); |
2274 | rq.rq_disk = tape->disk; | 2272 | rq.rq_disk = tape->disk; |
2275 | rq.special = (void *)bh; | 2273 | rq.special = (void *)bh; |
2276 | rq.sector = tape->first_frame_position; | 2274 | rq.sector = tape->first_frame; |
2277 | rq.nr_sectors = rq.current_nr_sectors = blocks; | 2275 | rq.nr_sectors = rq.current_nr_sectors = blocks; |
2278 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); | 2276 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); |
2279 | 2277 | ||
@@ -2284,7 +2282,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct | |||
2284 | idetape_init_merge_stage(tape); | 2282 | idetape_init_merge_stage(tape); |
2285 | if (rq.errors == IDETAPE_ERROR_GENERAL) | 2283 | if (rq.errors == IDETAPE_ERROR_GENERAL) |
2286 | return -EIO; | 2284 | return -EIO; |
2287 | return (tape->tape_block_size * (blocks-rq.current_nr_sectors)); | 2285 | return (tape->blk_size * (blocks-rq.current_nr_sectors)); |
2288 | } | 2286 | } |
2289 | 2287 | ||
2290 | /* | 2288 | /* |
@@ -2300,7 +2298,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) | |||
2300 | if (!idetape_pipeline_active(tape)) { | 2298 | if (!idetape_pipeline_active(tape)) { |
2301 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 2299 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); |
2302 | idetape_activate_next_stage(drive); | 2300 | idetape_activate_next_stage(drive); |
2303 | (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); | 2301 | (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); |
2304 | } | 2302 | } |
2305 | } | 2303 | } |
2306 | 2304 | ||
@@ -2346,10 +2344,10 @@ static void idetape_wait_first_stage (ide_drive_t *drive) | |||
2346 | 2344 | ||
2347 | if (tape->first_stage == NULL) | 2345 | if (tape->first_stage == NULL) |
2348 | return; | 2346 | return; |
2349 | spin_lock_irqsave(&tape->spinlock, flags); | 2347 | spin_lock_irqsave(&tape->lock, flags); |
2350 | if (tape->active_stage == tape->first_stage) | 2348 | if (tape->active_stage == tape->first_stage) |
2351 | idetape_wait_for_request(drive, tape->active_data_request); | 2349 | idetape_wait_for_request(drive, tape->active_data_rq); |
2352 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2350 | spin_unlock_irqrestore(&tape->lock, flags); |
2353 | } | 2351 | } |
2354 | 2352 | ||
2355 | /* | 2353 | /* |
@@ -2377,12 +2375,12 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) | |||
2377 | * Pay special attention to possible race conditions. | 2375 | * Pay special attention to possible race conditions. |
2378 | */ | 2376 | */ |
2379 | while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { | 2377 | while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { |
2380 | spin_lock_irqsave(&tape->spinlock, flags); | 2378 | spin_lock_irqsave(&tape->lock, flags); |
2381 | if (idetape_pipeline_active(tape)) { | 2379 | if (idetape_pipeline_active(tape)) { |
2382 | idetape_wait_for_request(drive, tape->active_data_request); | 2380 | idetape_wait_for_request(drive, tape->active_data_rq); |
2383 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2381 | spin_unlock_irqrestore(&tape->lock, flags); |
2384 | } else { | 2382 | } else { |
2385 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2383 | spin_unlock_irqrestore(&tape->lock, flags); |
2386 | idetape_insert_pipeline_into_queue(drive); | 2384 | idetape_insert_pipeline_into_queue(drive); |
2387 | if (idetape_pipeline_active(tape)) | 2385 | if (idetape_pipeline_active(tape)) |
2388 | continue; | 2386 | continue; |
@@ -2396,7 +2394,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) | |||
2396 | rq = &new_stage->rq; | 2394 | rq = &new_stage->rq; |
2397 | idetape_init_rq(rq, REQ_IDETAPE_WRITE); | 2395 | idetape_init_rq(rq, REQ_IDETAPE_WRITE); |
2398 | /* Doesn't actually matter - We always assume sequential access */ | 2396 | /* Doesn't actually matter - We always assume sequential access */ |
2399 | rq->sector = tape->first_frame_position; | 2397 | rq->sector = tape->first_frame; |
2400 | rq->nr_sectors = rq->current_nr_sectors = blocks; | 2398 | rq->nr_sectors = rq->current_nr_sectors = blocks; |
2401 | 2399 | ||
2402 | idetape_switch_buffers(tape, new_stage); | 2400 | idetape_switch_buffers(tape, new_stage); |
@@ -2413,7 +2411,9 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) | |||
2413 | */ | 2411 | */ |
2414 | if (!idetape_pipeline_active(tape)) { | 2412 | if (!idetape_pipeline_active(tape)) { |
2415 | if (tape->nr_stages >= tape->max_stages * 9 / 10 || | 2413 | if (tape->nr_stages >= tape->max_stages * 9 / 10 || |
2416 | tape->nr_stages >= tape->max_stages - tape->uncontrolled_pipeline_head_speed * 3 * 1024 / tape->tape_block_size) { | 2414 | tape->nr_stages >= tape->max_stages - |
2415 | tape->uncontrolled_pipeline_head_speed * 3 * 1024 / | ||
2416 | tape->blk_size) { | ||
2417 | tape->measure_insert_time = 1; | 2417 | tape->measure_insert_time = 1; |
2418 | tape->insert_time = jiffies; | 2418 | tape->insert_time = jiffies; |
2419 | tape->insert_size = 0; | 2419 | tape->insert_size = 0; |
@@ -2438,10 +2438,10 @@ static void idetape_wait_for_pipeline (ide_drive_t *drive) | |||
2438 | 2438 | ||
2439 | while (tape->next_stage || idetape_pipeline_active(tape)) { | 2439 | while (tape->next_stage || idetape_pipeline_active(tape)) { |
2440 | idetape_insert_pipeline_into_queue(drive); | 2440 | idetape_insert_pipeline_into_queue(drive); |
2441 | spin_lock_irqsave(&tape->spinlock, flags); | 2441 | spin_lock_irqsave(&tape->lock, flags); |
2442 | if (idetape_pipeline_active(tape)) | 2442 | if (idetape_pipeline_active(tape)) |
2443 | idetape_wait_for_request(drive, tape->active_data_request); | 2443 | idetape_wait_for_request(drive, tape->active_data_rq); |
2444 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2444 | spin_unlock_irqrestore(&tape->lock, flags); |
2445 | } | 2445 | } |
2446 | } | 2446 | } |
2447 | 2447 | ||
@@ -2460,12 +2460,13 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
2460 | tape->merge_stage_size = tape->stage_size; | 2460 | tape->merge_stage_size = tape->stage_size; |
2461 | } | 2461 | } |
2462 | if (tape->merge_stage_size) { | 2462 | if (tape->merge_stage_size) { |
2463 | blocks = tape->merge_stage_size / tape->tape_block_size; | 2463 | blocks = tape->merge_stage_size / tape->blk_size; |
2464 | if (tape->merge_stage_size % tape->tape_block_size) { | 2464 | if (tape->merge_stage_size % tape->blk_size) { |
2465 | unsigned int i; | 2465 | unsigned int i; |
2466 | 2466 | ||
2467 | blocks++; | 2467 | blocks++; |
2468 | i = tape->tape_block_size - tape->merge_stage_size % tape->tape_block_size; | 2468 | i = tape->blk_size - tape->merge_stage_size % |
2469 | tape->blk_size; | ||
2469 | bh = tape->bh->b_reqnext; | 2470 | bh = tape->bh->b_reqnext; |
2470 | while (bh) { | 2471 | while (bh) { |
2471 | atomic_set(&bh->b_count, 0); | 2472 | atomic_set(&bh->b_count, 0); |
@@ -2571,7 +2572,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) | |||
2571 | if (tape->restart_speed_control_req) | 2572 | if (tape->restart_speed_control_req) |
2572 | idetape_restart_speed_control(drive); | 2573 | idetape_restart_speed_control(drive); |
2573 | idetape_init_rq(&rq, REQ_IDETAPE_READ); | 2574 | idetape_init_rq(&rq, REQ_IDETAPE_READ); |
2574 | rq.sector = tape->first_frame_position; | 2575 | rq.sector = tape->first_frame; |
2575 | rq.nr_sectors = rq.current_nr_sectors = blocks; | 2576 | rq.nr_sectors = rq.current_nr_sectors = blocks; |
2576 | if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && | 2577 | if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && |
2577 | tape->nr_stages < max_stages) { | 2578 | tape->nr_stages < max_stages) { |
@@ -2624,11 +2625,13 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | |||
2624 | if (tape->first_stage == NULL) { | 2625 | if (tape->first_stage == NULL) { |
2625 | if (test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags)) | 2626 | if (test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags)) |
2626 | return 0; | 2627 | return 0; |
2627 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, tape->merge_stage->bh); | 2628 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, |
2629 | tape->merge_stage->bh); | ||
2628 | } | 2630 | } |
2629 | idetape_wait_first_stage(drive); | 2631 | idetape_wait_first_stage(drive); |
2630 | rq_ptr = &tape->first_stage->rq; | 2632 | rq_ptr = &tape->first_stage->rq; |
2631 | bytes_read = tape->tape_block_size * (rq_ptr->nr_sectors - rq_ptr->current_nr_sectors); | 2633 | bytes_read = tape->blk_size * (rq_ptr->nr_sectors - |
2634 | rq_ptr->current_nr_sectors); | ||
2632 | rq_ptr->nr_sectors = rq_ptr->current_nr_sectors = 0; | 2635 | rq_ptr->nr_sectors = rq_ptr->current_nr_sectors = 0; |
2633 | 2636 | ||
2634 | 2637 | ||
@@ -2638,15 +2641,15 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | |||
2638 | idetape_switch_buffers(tape, tape->first_stage); | 2641 | idetape_switch_buffers(tape, tape->first_stage); |
2639 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) | 2642 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) |
2640 | set_bit(IDETAPE_FILEMARK, &tape->flags); | 2643 | set_bit(IDETAPE_FILEMARK, &tape->flags); |
2641 | spin_lock_irqsave(&tape->spinlock, flags); | 2644 | spin_lock_irqsave(&tape->lock, flags); |
2642 | idetape_remove_stage_head(drive); | 2645 | idetape_remove_stage_head(drive); |
2643 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2646 | spin_unlock_irqrestore(&tape->lock, flags); |
2644 | tape->pipeline_head++; | 2647 | tape->pipeline_head++; |
2645 | idetape_calculate_speeds(drive); | 2648 | idetape_calculate_speeds(drive); |
2646 | } | 2649 | } |
2647 | if (bytes_read > blocks * tape->tape_block_size) { | 2650 | if (bytes_read > blocks * tape->blk_size) { |
2648 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); | 2651 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); |
2649 | bytes_read = blocks * tape->tape_block_size; | 2652 | bytes_read = blocks * tape->blk_size; |
2650 | } | 2653 | } |
2651 | return (bytes_read); | 2654 | return (bytes_read); |
2652 | } | 2655 | } |
@@ -2663,7 +2666,7 @@ static void idetape_pad_zeros (ide_drive_t *drive, int bcount) | |||
2663 | bh = tape->merge_stage->bh; | 2666 | bh = tape->merge_stage->bh; |
2664 | count = min(tape->stage_size, bcount); | 2667 | count = min(tape->stage_size, bcount); |
2665 | bcount -= count; | 2668 | bcount -= count; |
2666 | blocks = count / tape->tape_block_size; | 2669 | blocks = count / tape->blk_size; |
2667 | while (count) { | 2670 | while (count) { |
2668 | atomic_set(&bh->b_count, min(count, (unsigned int)bh->b_size)); | 2671 | atomic_set(&bh->b_count, min(count, (unsigned int)bh->b_size)); |
2669 | memset(bh->b_data, 0, atomic_read(&bh->b_count)); | 2672 | memset(bh->b_data, 0, atomic_read(&bh->b_count)); |
@@ -2685,9 +2688,10 @@ static int idetape_pipeline_size (ide_drive_t *drive) | |||
2685 | stage = tape->first_stage; | 2688 | stage = tape->first_stage; |
2686 | while (stage != NULL) { | 2689 | while (stage != NULL) { |
2687 | rq = &stage->rq; | 2690 | rq = &stage->rq; |
2688 | size += tape->tape_block_size * (rq->nr_sectors-rq->current_nr_sectors); | 2691 | size += tape->blk_size * (rq->nr_sectors - |
2692 | rq->current_nr_sectors); | ||
2689 | if (rq->errors == IDETAPE_ERROR_FILEMARK) | 2693 | if (rq->errors == IDETAPE_ERROR_FILEMARK) |
2690 | size += tape->tape_block_size; | 2694 | size += tape->blk_size; |
2691 | stage = stage->next; | 2695 | stage = stage->next; |
2692 | } | 2696 | } |
2693 | size += tape->merge_stage_size; | 2697 | size += tape->merge_stage_size; |
@@ -2744,11 +2748,11 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned l | |||
2744 | case 0x0340: | 2748 | case 0x0340: |
2745 | if (copy_from_user(&config, argp, sizeof(config))) | 2749 | if (copy_from_user(&config, argp, sizeof(config))) |
2746 | return -EFAULT; | 2750 | return -EFAULT; |
2747 | tape->best_dsc_rw_frequency = config.dsc_rw_frequency; | 2751 | tape->best_dsc_rw_freq = config.dsc_rw_frequency; |
2748 | tape->max_stages = config.nr_stages; | 2752 | tape->max_stages = config.nr_stages; |
2749 | break; | 2753 | break; |
2750 | case 0x0350: | 2754 | case 0x0350: |
2751 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency; | 2755 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; |
2752 | config.nr_stages = tape->max_stages; | 2756 | config.nr_stages = tape->max_stages; |
2753 | if (copy_to_user(argp, &config, sizeof(config))) | 2757 | if (copy_to_user(argp, &config, sizeof(config))) |
2754 | return -EFAULT; | 2758 | return -EFAULT; |
@@ -2798,7 +2802,7 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
2798 | set_bit(IDETAPE_FILEMARK, &tape->flags); | 2802 | set_bit(IDETAPE_FILEMARK, &tape->flags); |
2799 | return 0; | 2803 | return 0; |
2800 | } | 2804 | } |
2801 | spin_lock_irqsave(&tape->spinlock, flags); | 2805 | spin_lock_irqsave(&tape->lock, flags); |
2802 | if (tape->first_stage == tape->active_stage) { | 2806 | if (tape->first_stage == tape->active_stage) { |
2803 | /* | 2807 | /* |
2804 | * We have reached the active stage in the read pipeline. | 2808 | * We have reached the active stage in the read pipeline. |
@@ -2810,11 +2814,11 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
2810 | * __idetape_discard_read_pipeline(), for example. | 2814 | * __idetape_discard_read_pipeline(), for example. |
2811 | */ | 2815 | */ |
2812 | tape->next_stage = NULL; | 2816 | tape->next_stage = NULL; |
2813 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2817 | spin_unlock_irqrestore(&tape->lock, flags); |
2814 | idetape_wait_first_stage(drive); | 2818 | idetape_wait_first_stage(drive); |
2815 | tape->next_stage = tape->first_stage->next; | 2819 | tape->next_stage = tape->first_stage->next; |
2816 | } else | 2820 | } else |
2817 | spin_unlock_irqrestore(&tape->spinlock, flags); | 2821 | spin_unlock_irqrestore(&tape->lock, flags); |
2818 | if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK) | 2822 | if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK) |
2819 | ++count; | 2823 | ++count; |
2820 | idetape_remove_stage_head(drive); | 2824 | idetape_remove_stage_head(drive); |
@@ -2876,9 +2880,9 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
2876 | 2880 | ||
2877 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 2881 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
2878 | if (test_bit(IDETAPE_DETECT_BS, &tape->flags)) | 2882 | if (test_bit(IDETAPE_DETECT_BS, &tape->flags)) |
2879 | if (count > tape->tape_block_size && | 2883 | if (count > tape->blk_size && |
2880 | (count % tape->tape_block_size) == 0) | 2884 | (count % tape->blk_size) == 0) |
2881 | tape->user_bs_factor = count / tape->tape_block_size; | 2885 | tape->user_bs_factor = count / tape->blk_size; |
2882 | } | 2886 | } |
2883 | if ((rc = idetape_initiate_read(drive, tape->max_stages)) < 0) | 2887 | if ((rc = idetape_initiate_read(drive, tape->max_stages)) < 0) |
2884 | return rc; | 2888 | return rc; |
@@ -3115,9 +3119,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
3115 | return (idetape_queue_pc_tail(drive, &pc)); | 3119 | return (idetape_queue_pc_tail(drive, &pc)); |
3116 | case MTSETBLK: | 3120 | case MTSETBLK: |
3117 | if (mt_count) { | 3121 | if (mt_count) { |
3118 | if (mt_count < tape->tape_block_size || mt_count % tape->tape_block_size) | 3122 | if (mt_count < tape->blk_size || |
3123 | mt_count % tape->blk_size) | ||
3119 | return -EIO; | 3124 | return -EIO; |
3120 | tape->user_bs_factor = mt_count / tape->tape_block_size; | 3125 | tape->user_bs_factor = mt_count / |
3126 | tape->blk_size; | ||
3121 | clear_bit(IDETAPE_DETECT_BS, &tape->flags); | 3127 | clear_bit(IDETAPE_DETECT_BS, &tape->flags); |
3122 | } else | 3128 | } else |
3123 | set_bit(IDETAPE_DETECT_BS, &tape->flags); | 3129 | set_bit(IDETAPE_DETECT_BS, &tape->flags); |
@@ -3164,7 +3170,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
3164 | struct mtop mtop; | 3170 | struct mtop mtop; |
3165 | struct mtget mtget; | 3171 | struct mtget mtget; |
3166 | struct mtpos mtpos; | 3172 | struct mtpos mtpos; |
3167 | int block_offset = 0, position = tape->first_frame_position; | 3173 | int block_offset = 0, position = tape->first_frame; |
3168 | void __user *argp = (void __user *)arg; | 3174 | void __user *argp = (void __user *)arg; |
3169 | 3175 | ||
3170 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); | 3176 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); |
@@ -3175,7 +3181,8 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
3175 | idetape_flush_tape_buffers(drive); | 3181 | idetape_flush_tape_buffers(drive); |
3176 | } | 3182 | } |
3177 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { | 3183 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { |
3178 | block_offset = idetape_pipeline_size(drive) / (tape->tape_block_size * tape->user_bs_factor); | 3184 | block_offset = idetape_pipeline_size(drive) / |
3185 | (tape->blk_size * tape->user_bs_factor); | ||
3179 | if ((position = idetape_read_position(drive)) < 0) | 3186 | if ((position = idetape_read_position(drive)) < 0) |
3180 | return -EIO; | 3187 | return -EIO; |
3181 | } | 3188 | } |
@@ -3188,7 +3195,10 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
3188 | memset(&mtget, 0, sizeof (struct mtget)); | 3195 | memset(&mtget, 0, sizeof (struct mtget)); |
3189 | mtget.mt_type = MT_ISSCSI2; | 3196 | mtget.mt_type = MT_ISSCSI2; |
3190 | mtget.mt_blkno = position / tape->user_bs_factor - block_offset; | 3197 | mtget.mt_blkno = position / tape->user_bs_factor - block_offset; |
3191 | mtget.mt_dsreg = ((tape->tape_block_size * tape->user_bs_factor) << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; | 3198 | mtget.mt_dsreg = |
3199 | ((tape->blk_size * tape->user_bs_factor) | ||
3200 | << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; | ||
3201 | |||
3192 | if (tape->drv_write_prot) { | 3202 | if (tape->drv_write_prot) { |
3193 | mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); | 3203 | mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); |
3194 | } | 3204 | } |
@@ -3219,14 +3229,14 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
3219 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | 3229 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); |
3220 | if (idetape_queue_pc_tail(drive, &pc)) { | 3230 | if (idetape_queue_pc_tail(drive, &pc)) { |
3221 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | 3231 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); |
3222 | if (tape->tape_block_size == 0) { | 3232 | if (tape->blk_size == 0) { |
3223 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | 3233 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " |
3224 | "block size, assuming 32k\n"); | 3234 | "block size, assuming 32k\n"); |
3225 | tape->tape_block_size = 32768; | 3235 | tape->blk_size = 32768; |
3226 | } | 3236 | } |
3227 | return; | 3237 | return; |
3228 | } | 3238 | } |
3229 | tape->tape_block_size = (pc.buffer[4 + 5] << 16) + | 3239 | tape->blk_size = (pc.buffer[4 + 5] << 16) + |
3230 | (pc.buffer[4 + 6] << 8) + | 3240 | (pc.buffer[4 + 6] << 8) + |
3231 | pc.buffer[4 + 7]; | 3241 | pc.buffer[4 + 7]; |
3232 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | 3242 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; |
@@ -3328,7 +3338,8 @@ static void idetape_write_release (ide_drive_t *drive, unsigned int minor) | |||
3328 | idetape_empty_write_pipeline(drive); | 3338 | idetape_empty_write_pipeline(drive); |
3329 | tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0); | 3339 | tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0); |
3330 | if (tape->merge_stage != NULL) { | 3340 | if (tape->merge_stage != NULL) { |
3331 | idetape_pad_zeros(drive, tape->tape_block_size * (tape->user_bs_factor - 1)); | 3341 | idetape_pad_zeros(drive, tape->blk_size * |
3342 | (tape->user_bs_factor - 1)); | ||
3332 | __idetape_kfree_stage(tape->merge_stage); | 3343 | __idetape_kfree_stage(tape->merge_stage); |
3333 | tape->merge_stage = NULL; | 3344 | tape->merge_stage = NULL; |
3334 | } | 3345 | } |
@@ -3456,7 +3467,7 @@ static void idetape_get_mode_sense_results (ide_drive_t *drive) | |||
3456 | if (idetape_queue_pc_tail(drive, &pc)) { | 3467 | if (idetape_queue_pc_tail(drive, &pc)) { |
3457 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" | 3468 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" |
3458 | " some default values\n"); | 3469 | " some default values\n"); |
3459 | tape->tape_block_size = 512; | 3470 | tape->blk_size = 512; |
3460 | put_unaligned(52, (u16 *)&tape->caps[12]); | 3471 | put_unaligned(52, (u16 *)&tape->caps[12]); |
3461 | put_unaligned(540, (u16 *)&tape->caps[14]); | 3472 | put_unaligned(540, (u16 *)&tape->caps[14]); |
3462 | put_unaligned(6*52, (u16 *)&tape->caps[16]); | 3473 | put_unaligned(6*52, (u16 *)&tape->caps[16]); |
@@ -3486,9 +3497,9 @@ static void idetape_get_mode_sense_results (ide_drive_t *drive) | |||
3486 | 3497 | ||
3487 | memcpy(&tape->caps, caps, 20); | 3498 | memcpy(&tape->caps, caps, 20); |
3488 | if (caps[7] & 0x02) | 3499 | if (caps[7] & 0x02) |
3489 | tape->tape_block_size = 512; | 3500 | tape->blk_size = 512; |
3490 | else if (caps[7] & 0x04) | 3501 | else if (caps[7] & 0x04) |
3491 | tape->tape_block_size = 1024; | 3502 | tape->blk_size = 1024; |
3492 | } | 3503 | } |
3493 | 3504 | ||
3494 | #ifdef CONFIG_IDE_PROC_FS | 3505 | #ifdef CONFIG_IDE_PROC_FS |
@@ -3508,8 +3519,11 @@ static void idetape_add_settings (ide_drive_t *drive) | |||
3508 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); | 3519 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); |
3509 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 3520 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3510 | 1, 1, (u16 *)&tape->caps[14], NULL); | 3521 | 1, 1, (u16 *)&tape->caps[14], NULL); |
3511 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); | 3522 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, |
3512 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); | 3523 | 1024, &tape->stage_size, NULL); |
3524 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, | ||
3525 | IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, | ||
3526 | NULL); | ||
3513 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); | 3527 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); |
3514 | ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL); | 3528 | ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL); |
3515 | ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL); | 3529 | ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL); |
@@ -3542,7 +3556,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3542 | struct sysinfo si; | 3556 | struct sysinfo si; |
3543 | u16 *ctl = (u16 *)&tape->caps[12]; | 3557 | u16 *ctl = (u16 *)&tape->caps[12]; |
3544 | 3558 | ||
3545 | spin_lock_init(&tape->spinlock); | 3559 | spin_lock_init(&tape->lock); |
3546 | drive->dsc_overlap = 1; | 3560 | drive->dsc_overlap = 1; |
3547 | if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { | 3561 | if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { |
3548 | printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", | 3562 | printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", |
@@ -3570,11 +3584,11 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3570 | idetape_get_mode_sense_results(drive); | 3584 | idetape_get_mode_sense_results(drive); |
3571 | ide_tape_get_bsize_from_bdesc(drive); | 3585 | ide_tape_get_bsize_from_bdesc(drive); |
3572 | tape->user_bs_factor = 1; | 3586 | tape->user_bs_factor = 1; |
3573 | tape->stage_size = *ctl * tape->tape_block_size; | 3587 | tape->stage_size = *ctl * tape->blk_size; |
3574 | while (tape->stage_size > 0xffff) { | 3588 | while (tape->stage_size > 0xffff) { |
3575 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); | 3589 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); |
3576 | *ctl /= 2; | 3590 | *ctl /= 2; |
3577 | tape->stage_size = *ctl * tape->tape_block_size; | 3591 | tape->stage_size = *ctl * tape->blk_size; |
3578 | } | 3592 | } |
3579 | stage_size = tape->stage_size; | 3593 | stage_size = tape->stage_size; |
3580 | tape->pages_per_stage = stage_size / PAGE_SIZE; | 3594 | tape->pages_per_stage = stage_size / PAGE_SIZE; |
@@ -3613,14 +3627,16 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3613 | * Ensure that the number we got makes sense; limit | 3627 | * Ensure that the number we got makes sense; limit |
3614 | * it within IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. | 3628 | * it within IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. |
3615 | */ | 3629 | */ |
3616 | tape->best_dsc_rw_frequency = max_t(unsigned long, min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN); | 3630 | tape->best_dsc_rw_freq = max_t(unsigned long, |
3631 | min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), | ||
3632 | IDETAPE_DSC_RW_MIN); | ||
3617 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " | 3633 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " |
3618 | "%dkB pipeline, %lums tDSC%s\n", | 3634 | "%dkB pipeline, %lums tDSC%s\n", |
3619 | drive->name, tape->name, *(u16 *)&tape->caps[14], | 3635 | drive->name, tape->name, *(u16 *)&tape->caps[14], |
3620 | (*(u16 *)&tape->caps[16] * 512) / tape->stage_size, | 3636 | (*(u16 *)&tape->caps[16] * 512) / tape->stage_size, |
3621 | tape->stage_size / 1024, | 3637 | tape->stage_size / 1024, |
3622 | tape->max_stages * tape->stage_size / 1024, | 3638 | tape->max_stages * tape->stage_size / 1024, |
3623 | tape->best_dsc_rw_frequency * 1000 / HZ, | 3639 | tape->best_dsc_rw_freq * 1000 / HZ, |
3624 | drive->using_dma ? ", DMA":""); | 3640 | drive->using_dma ? ", DMA":""); |
3625 | 3641 | ||
3626 | idetape_add_settings(drive); | 3642 | idetape_add_settings(drive); |