aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-atapi.c18
-rw-r--r--drivers/ide/ide-dma.c11
-rw-r--r--drivers/ide/ide-taskfile.c4
-rw-r--r--include/linux/ide.h7
4 files changed, 19 insertions, 21 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 1481f71f8173..89d2339bdef3 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -638,7 +638,6 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
638{ 638{
639 struct ide_atapi_pc *pc; 639 struct ide_atapi_pc *pc;
640 ide_hwif_t *hwif = drive->hwif; 640 ide_hwif_t *hwif = drive->hwif;
641 const struct ide_dma_ops *dma_ops = hwif->dma_ops;
642 ide_expiry_t *expiry = NULL; 641 ide_expiry_t *expiry = NULL;
643 struct request *rq = hwif->rq; 642 struct request *rq = hwif->rq;
644 unsigned int timeout; 643 unsigned int timeout;
@@ -652,12 +651,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
652 expiry = ide_cd_expiry; 651 expiry = ide_cd_expiry;
653 timeout = ATAPI_WAIT_PC; 652 timeout = ATAPI_WAIT_PC;
654 653
655 if (drive->dma) { 654 if (drive->dma)
656 if (ide_build_sglist(drive, cmd)) 655 drive->dma = !ide_dma_prepare(drive, cmd);
657 drive->dma = !dma_ops->dma_setup(drive, cmd);
658 else
659 drive->dma = 0;
660 }
661 } else { 656 } else {
662 pc = drive->pc; 657 pc = drive->pc;
663 658
@@ -675,13 +670,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
675 ide_dma_off(drive); 670 ide_dma_off(drive);
676 } 671 }
677 672
678 if ((pc->flags & PC_FLAG_DMA_OK) && 673 if (pc->flags & PC_FLAG_DMA_OK)
679 (drive->dev_flags & IDE_DFLAG_USING_DMA)) { 674 drive->dma = !ide_dma_prepare(drive, cmd);
680 if (ide_build_sglist(drive, cmd))
681 drive->dma = !dma_ops->dma_setup(drive, cmd);
682 else
683 drive->dma = 0;
684 }
685 675
686 if (!drive->dma) 676 if (!drive->dma)
687 pc->flags &= ~PC_FLAG_DMA_OK; 677 pc->flags &= ~PC_FLAG_DMA_OK;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index b430898bbcd6..cf5897f5533f 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -128,7 +128,7 @@ int ide_dma_good_drive(ide_drive_t *drive)
128 * operate in a portable fashion. 128 * operate in a portable fashion.
129 */ 129 */
130 130
131int ide_build_sglist(ide_drive_t *drive, struct ide_cmd *cmd) 131static int ide_build_sglist(ide_drive_t *drive, struct ide_cmd *cmd)
132{ 132{
133 ide_hwif_t *hwif = drive->hwif; 133 ide_hwif_t *hwif = drive->hwif;
134 struct scatterlist *sg = hwif->sg_table; 134 struct scatterlist *sg = hwif->sg_table;
@@ -563,3 +563,12 @@ int ide_allocate_dma_engine(ide_hwif_t *hwif)
563 return 0; 563 return 0;
564} 564}
565EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); 565EXPORT_SYMBOL_GPL(ide_allocate_dma_engine);
566
567int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd)
568{
569 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
570 ide_build_sglist(drive, cmd) == 0 ||
571 drive->hwif->dma_ops->dma_setup(drive, cmd))
572 return 1;
573 return 0;
574}
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index a3b7a50562b2..dba68db629bf 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -100,9 +100,7 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
100 ide_execute_command(drive, cmd, handler, WAIT_WORSTCASE); 100 ide_execute_command(drive, cmd, handler, WAIT_WORSTCASE);
101 return ide_started; 101 return ide_started;
102 case ATA_PROT_DMA: 102 case ATA_PROT_DMA:
103 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || 103 if (ide_dma_prepare(drive, cmd))
104 ide_build_sglist(drive, cmd) == 0 ||
105 dma_ops->dma_setup(drive, cmd))
106 return ide_stopped; 104 return ide_stopped;
107 hwif->expiry = dma_ops->dma_timer_expiry; 105 hwif->expiry = dma_ops->dma_timer_expiry;
108 ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD); 106 ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index b6c4942fde11..78892e2a432c 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1443,7 +1443,8 @@ ide_startstop_t ide_dma_intr(ide_drive_t *);
1443int ide_allocate_dma_engine(ide_hwif_t *); 1443int ide_allocate_dma_engine(ide_hwif_t *);
1444void ide_release_dma_engine(ide_hwif_t *); 1444void ide_release_dma_engine(ide_hwif_t *);
1445 1445
1446int ide_build_sglist(ide_drive_t *, struct ide_cmd *); 1446int ide_dma_prepare(ide_drive_t *, struct ide_cmd *);
1447
1447void ide_destroy_dmatable(ide_drive_t *); 1448void ide_destroy_dmatable(ide_drive_t *);
1448 1449
1449#ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1450#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
@@ -1477,8 +1478,8 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1477static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; } 1478static inline ide_startstop_t ide_dma_intr(ide_drive_t *drive) { return ide_stopped; }
1478static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; } 1479static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) { return ide_stopped; }
1479static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1480static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
1480static inline int ide_build_sglist(ide_drive_t *drive, 1481static inline int ide_dma_prepare(ide_drive_t *drive,
1481 struct ide_cmd *cmd) { return 0; } 1482 struct ide_cmd *cmd) { return 1; }
1482static inline void ide_destroy_dmatable(ide_drive_t *drive) { ; } 1483static inline void ide_destroy_dmatable(ide_drive_t *drive) { ; }
1483#endif /* CONFIG_BLK_DEV_IDEDMA */ 1484#endif /* CONFIG_BLK_DEV_IDEDMA */
1484 1485