aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2008-04-27 09:38:27 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-27 09:38:27 -0400
commit0aa4b01e0345bb43450dee4377fc53fb4fd44eb1 (patch)
tree03ebf2ab6513c9c1290a45f3c4726b43cccf8678
parentea1ab3d3319b399e2b707c270d2d6077b61183f6 (diff)
ide-tape: remove remaining pipeline functionality
The driver is using now solely its own request queue. - tape->next_stage is always NULL so it is safe to remove all code depending on tape->next_stage != NULL - this patch removes the last place which sets IDETAPE_FLAG_PIPELINE_ACTIVE in tape->flags [bart: add above explanations] Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-tape.c102
1 files changed, 2 insertions, 100 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ad7e532cbe60..8eb117519ba4 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -642,28 +642,6 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
642 } 642 }
643} 643}
644 644
645static void idetape_activate_next_stage(ide_drive_t *drive)
646{
647 idetape_tape_t *tape = drive->driver_data;
648 idetape_stage_t *stage = tape->next_stage;
649 struct request *rq = &stage->rq;
650
651 debug_log(DBG_PROCS, "Enter %s\n", __func__);
652
653 if (stage == NULL) {
654 printk(KERN_ERR "ide-tape: bug: Trying to activate a non"
655 " existing stage\n");
656 return;
657 }
658
659 rq->rq_disk = tape->disk;
660 rq->buffer = NULL;
661 rq->special = (void *)stage->bh;
662 tape->active_data_rq = rq;
663 tape->active_stage = stage;
664 tape->next_stage = stage->next;
665}
666
667/* Free a stage along with its related buffers completely. */ 645/* Free a stage along with its related buffers completely. */
668static void __idetape_kfree_stage(idetape_stage_t *stage) 646static void __idetape_kfree_stage(idetape_stage_t *stage)
669{ 647{
@@ -1546,28 +1524,6 @@ static void idetape_init_merge_stage(idetape_tape_t *tape)
1546 } 1524 }
1547} 1525}
1548 1526
1549/* Install a completion in a pending request and sleep until it is serviced. The
1550 * caller should ensure that the request will not be serviced before we install
1551 * the completion (usually by disabling interrupts).
1552 */
1553static void idetape_wait_for_request(ide_drive_t *drive, struct request *rq)
1554{
1555 DECLARE_COMPLETION_ONSTACK(wait);
1556 idetape_tape_t *tape = drive->driver_data;
1557
1558 if (rq == NULL || !blk_special_request(rq)) {
1559 printk(KERN_ERR "ide-tape: bug: Trying to sleep on non-valid"
1560 " request\n");
1561 return;
1562 }
1563 rq->end_io_data = &wait;
1564 rq->end_io = blk_end_sync_rq;
1565 spin_unlock_irq(&tape->lock);
1566 wait_for_completion(&wait);
1567 /* The stage and its struct request have been deallocated */
1568 spin_lock_irq(&tape->lock);
1569}
1570
1571static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) 1527static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive)
1572{ 1528{
1573 idetape_tape_t *tape = drive->driver_data; 1529 idetape_tape_t *tape = drive->driver_data;
@@ -1782,8 +1738,6 @@ static int __idetape_discard_read_pipeline(ide_drive_t *drive)
1782 1738
1783 spin_lock_irqsave(&tape->lock, flags); 1739 spin_lock_irqsave(&tape->lock, flags);
1784 tape->next_stage = NULL; 1740 tape->next_stage = NULL;
1785 if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags))
1786 idetape_wait_for_request(drive, tape->active_data_rq);
1787 spin_unlock_irqrestore(&tape->lock, flags); 1741 spin_unlock_irqrestore(&tape->lock, flags);
1788 1742
1789 while (tape->first_stage != NULL) { 1743 while (tape->first_stage != NULL) {
@@ -1878,19 +1832,6 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks,
1878 return (tape->blk_size * (blocks-rq.current_nr_sectors)); 1832 return (tape->blk_size * (blocks-rq.current_nr_sectors));
1879} 1833}
1880 1834
1881/* start servicing the pipeline stages, starting from tape->next_stage. */
1882static void idetape_plug_pipeline(ide_drive_t *drive)
1883{
1884 idetape_tape_t *tape = drive->driver_data;
1885
1886 if (tape->next_stage == NULL)
1887 return;
1888 if (!test_and_set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) {
1889 idetape_activate_next_stage(drive);
1890 (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end);
1891 }
1892}
1893
1894static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) 1835static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc)
1895{ 1836{
1896 idetape_init_pc(pc); 1837 idetape_init_pc(pc);
@@ -1932,45 +1873,11 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd)
1932static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) 1873static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks)
1933{ 1874{
1934 idetape_tape_t *tape = drive->driver_data; 1875 idetape_tape_t *tape = drive->driver_data;
1935 unsigned long flags;
1936 1876
1937 debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 1877 debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
1938 1878
1939 /* Attempt to allocate a new stage. Beware possible race conditions. */ 1879 return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE,
1940 while (1) { 1880 blocks, tape->merge_stage->bh);
1941 spin_lock_irqsave(&tape->lock, flags);
1942 if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) {
1943 idetape_wait_for_request(drive, tape->active_data_rq);
1944 spin_unlock_irqrestore(&tape->lock, flags);
1945 } else {
1946 spin_unlock_irqrestore(&tape->lock, flags);
1947 idetape_plug_pipeline(drive);
1948 if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE,
1949 &tape->flags))
1950 continue;
1951 return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE,
1952 blocks, tape->merge_stage->bh);
1953 }
1954 }
1955}
1956
1957/*
1958 * Wait until all pending pipeline requests are serviced. Typically called on
1959 * device close.
1960 */
1961static void idetape_wait_for_pipeline(ide_drive_t *drive)
1962{
1963 idetape_tape_t *tape = drive->driver_data;
1964 unsigned long flags;
1965
1966 while (tape->next_stage || test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE,
1967 &tape->flags)) {
1968 idetape_plug_pipeline(drive);
1969 spin_lock_irqsave(&tape->lock, flags);
1970 if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags))
1971 idetape_wait_for_request(drive, tape->active_data_rq);
1972 spin_unlock_irqrestore(&tape->lock, flags);
1973 }
1974} 1881}
1975 1882
1976static void idetape_empty_write_pipeline(ide_drive_t *drive) 1883static void idetape_empty_write_pipeline(ide_drive_t *drive)
@@ -2020,7 +1927,6 @@ static void idetape_empty_write_pipeline(ide_drive_t *drive)
2020 (void) idetape_add_chrdev_write_request(drive, blocks); 1927 (void) idetape_add_chrdev_write_request(drive, blocks);
2021 tape->merge_stage_size = 0; 1928 tape->merge_stage_size = 0;
2022 } 1929 }
2023 idetape_wait_for_pipeline(drive);
2024 if (tape->merge_stage != NULL) { 1930 if (tape->merge_stage != NULL) {
2025 __idetape_kfree_stage(tape->merge_stage); 1931 __idetape_kfree_stage(tape->merge_stage);
2026 tape->merge_stage = NULL; 1932 tape->merge_stage = NULL;
@@ -2093,7 +1999,6 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages)
2093 tape->insert_time = jiffies; 1999 tape->insert_time = jiffies;
2094 tape->insert_size = 0; 2000 tape->insert_size = 0;
2095 tape->insert_speed = 0; 2001 tape->insert_speed = 0;
2096 idetape_plug_pipeline(drive);
2097 } 2002 }
2098 } 2003 }
2099 return 0; 2004 return 0;
@@ -2593,7 +2498,6 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
2593 idetape_flush_tape_buffers(drive); 2498 idetape_flush_tape_buffers(drive);
2594 } 2499 }
2595 if (cmd == MTIOCGET || cmd == MTIOCPOS) { 2500 if (cmd == MTIOCGET || cmd == MTIOCPOS) {
2596 idetape_wait_for_pipeline(drive);
2597 block_offset = tape->merge_stage_size / 2501 block_offset = tape->merge_stage_size /
2598 (tape->blk_size * tape->user_bs_factor); 2502 (tape->blk_size * tape->user_bs_factor);
2599 position = idetape_read_position(drive); 2503 position = idetape_read_position(drive);
@@ -2772,8 +2676,6 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp)
2772 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 2676 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
2773 if (minor < 128) 2677 if (minor < 128)
2774 idetape_discard_read_pipeline(drive, 1); 2678 idetape_discard_read_pipeline(drive, 1);
2775 else
2776 idetape_wait_for_pipeline(drive);
2777 } 2679 }
2778 2680
2779 if (minor < 128 && test_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags)) 2681 if (minor < 128 && test_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags))