diff options
-rw-r--r-- | drivers/ide/ide-dma.c | 57 | ||||
-rw-r--r-- | drivers/ide/ide-io.c | 57 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
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 | } |
471 | EXPORT_SYMBOL_GPL(ide_dma_timeout); | 471 | EXPORT_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 | */ | ||
478 | ide_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); | ||
526 | out: | ||
527 | return ret; | ||
528 | } | ||
529 | |||
473 | void ide_release_dma_engine(ide_hwif_t *hwif) | 530 | void 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 | */ | ||
827 | static 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); | ||
875 | out: | ||
876 | return ret; | ||
877 | } | ||
878 | |||
879 | static void ide_plug_device(ide_drive_t *drive) | 822 | static 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 | ||
1468 | void ide_dma_lost_irq(ide_drive_t *); | 1468 | void ide_dma_lost_irq(ide_drive_t *); |
1469 | void ide_dma_timeout(ide_drive_t *); | 1469 | void ide_dma_timeout(ide_drive_t *); |
1470 | ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int); | ||
1470 | 1471 | ||
1471 | #else | 1472 | #else |
1472 | static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } | 1473 | static 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) { ; } | |||
1478 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } | 1479 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } |
1479 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } | 1480 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } |
1480 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | 1481 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } |
1482 | static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; } | ||
1481 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } | 1483 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } |
1482 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | 1484 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
1483 | 1485 | ||