aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-24 18:22:43 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-24 18:22:43 -0400
commit65ca5377322c7543163066f373ae9e6b0ad8de8a (patch)
tree0d333cb6c781f151d82ed66fd4ece26359525366
parentb6a45a0b1e9a358b81201659cf87b023e3ec73e0 (diff)
ide: move ide_dma_timeout_retry() to ide-dma.c
Move ide_dma_timeout_retry() to ide-dma.c and add static inline version for CONFIG_BLK_DEV_IDEDMA=n. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-dma.c57
-rw-r--r--drivers/ide/ide-io.c57
-rw-r--r--include/linux/ide.h2
3 files changed, 59 insertions, 57 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 059c90bb5ad2..a878f4734f81 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -470,6 +470,63 @@ void ide_dma_timeout(ide_drive_t *drive)
470} 470}
471EXPORT_SYMBOL_GPL(ide_dma_timeout); 471EXPORT_SYMBOL_GPL(ide_dma_timeout);
472 472
473/*
474 * un-busy the port etc, and clear any pending DMA status. we want to
475 * retry the current request in pio mode instead of risking tossing it
476 * all away
477 */
478ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
479{
480 ide_hwif_t *hwif = drive->hwif;
481 struct request *rq;
482 ide_startstop_t ret = ide_stopped;
483
484 /*
485 * end current dma transaction
486 */
487
488 if (error < 0) {
489 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
490 (void)hwif->dma_ops->dma_end(drive);
491 ret = ide_error(drive, "dma timeout error",
492 hwif->tp_ops->read_status(hwif));
493 } else {
494 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
495 hwif->dma_ops->dma_timeout(drive);
496 }
497
498 /*
499 * disable dma for now, but remember that we did so because of
500 * a timeout -- we'll reenable after we finish this next request
501 * (or rather the first chunk of it) in pio.
502 */
503 drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY;
504 drive->retry_pio++;
505 ide_dma_off_quietly(drive);
506
507 /*
508 * un-busy drive etc and make sure request is sane
509 */
510
511 rq = hwif->rq;
512 if (!rq)
513 goto out;
514
515 hwif->rq = NULL;
516
517 rq->errors = 0;
518
519 if (!rq->bio)
520 goto out;
521
522 rq->sector = rq->bio->bi_sector;
523 rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
524 rq->hard_cur_sectors = rq->current_nr_sectors;
525 rq->buffer = bio_data(rq->bio);
526out:
527 return ret;
528}
529
473void ide_release_dma_engine(ide_hwif_t *hwif) 530void ide_release_dma_engine(ide_hwif_t *hwif)
474{ 531{
475 if (hwif->dmatable_cpu) { 532 if (hwif->dmatable_cpu) {
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 835cf646bb07..557b15700ea2 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -819,63 +819,6 @@ plug_device_2:
819 blk_plug_device(q); 819 blk_plug_device(q);
820} 820}
821 821
822/*
823 * un-busy the port etc, and clear any pending DMA status. we want to
824 * retry the current request in pio mode instead of risking tossing it
825 * all away
826 */
827static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
828{
829 ide_hwif_t *hwif = drive->hwif;
830 struct request *rq;
831 ide_startstop_t ret = ide_stopped;
832
833 /*
834 * end current dma transaction
835 */
836
837 if (error < 0) {
838 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
839 (void)hwif->dma_ops->dma_end(drive);
840 ret = ide_error(drive, "dma timeout error",
841 hwif->tp_ops->read_status(hwif));
842 } else {
843 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
844 hwif->dma_ops->dma_timeout(drive);
845 }
846
847 /*
848 * disable dma for now, but remember that we did so because of
849 * a timeout -- we'll reenable after we finish this next request
850 * (or rather the first chunk of it) in pio.
851 */
852 drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY;
853 drive->retry_pio++;
854 ide_dma_off_quietly(drive);
855
856 /*
857 * un-busy drive etc and make sure request is sane
858 */
859
860 rq = hwif->rq;
861 if (!rq)
862 goto out;
863
864 hwif->rq = NULL;
865
866 rq->errors = 0;
867
868 if (!rq->bio)
869 goto out;
870
871 rq->sector = rq->bio->bi_sector;
872 rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9;
873 rq->hard_cur_sectors = rq->current_nr_sectors;
874 rq->buffer = bio_data(rq->bio);
875out:
876 return ret;
877}
878
879static void ide_plug_device(ide_drive_t *drive) 822static void ide_plug_device(ide_drive_t *drive)
880{ 823{
881 struct request_queue *q = drive->queue; 824 struct request_queue *q = drive->queue;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 2e95adeedff4..d0065a90452b 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1467,6 +1467,7 @@ static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
1467 1467
1468void ide_dma_lost_irq(ide_drive_t *); 1468void ide_dma_lost_irq(ide_drive_t *);
1469void ide_dma_timeout(ide_drive_t *); 1469void ide_dma_timeout(ide_drive_t *);
1470ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int);
1470 1471
1471#else 1472#else
1472static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } 1473static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }
@@ -1478,6 +1479,7 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; }
1478static inline void ide_dma_verbose(ide_drive_t *drive) { ; } 1479static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1479static inline int ide_set_dma(ide_drive_t *drive) { return 1; } 1480static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
1480static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } 1481static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1482static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
1481static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1483static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
1482#endif /* CONFIG_BLK_DEV_IDEDMA */ 1484#endif /* CONFIG_BLK_DEV_IDEDMA */
1483 1485