aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:37 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:37 -0400
commite6830a86c260d73c6f370aa7ed17ee6c71e5ee05 (patch)
treec2c7d472184da1549852b86eef551609cddcbcbf /drivers/ide
parentb109f526cabcd098131e770fd6232282bce147b4 (diff)
ide: call ide_build_sglist() prior to ->dma_setup (v2)
* Re-map sg table if needed in ide_build_sglist(). * Move ide_build_sglist() call from ->dma_setup to its users. * Un-export ide_build_sglist(). v2: * Build fix for CONFIG_BLK_DEV_IDEDMA=n (noticed by Randy Dunlap). There should be no functional changes caused by this patch. Cc: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/au1xxx-ide.c7
-rw-r--r--drivers/ide/icside.c6
-rw-r--r--drivers/ide/ide-atapi.c19
-rw-r--r--drivers/ide/ide-dma-sff.c4
-rw-r--r--drivers/ide/ide-dma.c5
-rw-r--r--drivers/ide/ide-taskfile.c1
-rw-r--r--drivers/ide/pmac.c7
-rw-r--r--drivers/ide/sgiioc4.c10
-rw-r--r--drivers/ide/tx4939ide.c4
9 files changed, 22 insertions, 41 deletions
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 82f153810eb9..3fc3ced8192c 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -211,21 +211,16 @@ static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed)
211#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 211#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
212static int auide_build_dmatable(ide_drive_t *drive) 212static int auide_build_dmatable(ide_drive_t *drive)
213{ 213{
214 int i, iswrite, count = 0;
215 ide_hwif_t *hwif = drive->hwif; 214 ide_hwif_t *hwif = drive->hwif;
216 struct request *rq = hwif->rq; 215 struct request *rq = hwif->rq;
217 _auide_hwif *ahwif = &auide_hwif; 216 _auide_hwif *ahwif = &auide_hwif;
218 struct scatterlist *sg; 217 struct scatterlist *sg;
218 int i = hwif->sg_nents, iswrite, count = 0;
219 219
220 iswrite = (rq_data_dir(rq) == WRITE); 220 iswrite = (rq_data_dir(rq) == WRITE);
221 /* Save for interrupt context */ 221 /* Save for interrupt context */
222 ahwif->drive = drive; 222 ahwif->drive = drive;
223 223
224 hwif->sg_nents = i = ide_build_sglist(drive, rq);
225
226 if (!i)
227 return 0;
228
229 /* fill the descriptors */ 224 /* fill the descriptors */
230 sg = hwif->sg_table; 225 sg = hwif->sg_table;
231 while (i && sg_dma_len(sg)) { 226 while (i && sg_dma_len(sg)) {
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index cf0522f937c1..78fc36f98d29 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -325,12 +325,6 @@ static int icside_dma_setup(ide_drive_t *drive)
325 */ 325 */
326 BUG_ON(dma_channel_active(ec->dma)); 326 BUG_ON(dma_channel_active(ec->dma));
327 327
328 hwif->sg_nents = ide_build_sglist(drive, rq);
329 if (hwif->sg_nents == 0) {
330 ide_map_sg(drive, rq);
331 return 1;
332 }
333
334 /* 328 /*
335 * Ensure that we have the right interrupt routed. 329 * Ensure that we have the right interrupt routed.
336 */ 330 */
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index f72b5a675435..2b9ac2106674 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -631,18 +631,23 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
631 struct ide_atapi_pc *pc; 631 struct ide_atapi_pc *pc;
632 ide_hwif_t *hwif = drive->hwif; 632 ide_hwif_t *hwif = drive->hwif;
633 ide_expiry_t *expiry = NULL; 633 ide_expiry_t *expiry = NULL;
634 struct request *rq = hwif->rq;
634 unsigned int timeout; 635 unsigned int timeout;
635 u32 tf_flags; 636 u32 tf_flags;
636 u16 bcount; 637 u16 bcount;
637 638
638 if (dev_is_idecd(drive)) { 639 if (dev_is_idecd(drive)) {
639 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; 640 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
640 bcount = ide_cd_get_xferlen(hwif->rq); 641 bcount = ide_cd_get_xferlen(rq);
641 expiry = ide_cd_expiry; 642 expiry = ide_cd_expiry;
642 timeout = ATAPI_WAIT_PC; 643 timeout = ATAPI_WAIT_PC;
643 644
644 if (drive->dma) 645 if (drive->dma) {
645 drive->dma = !hwif->dma_ops->dma_setup(drive); 646 if (ide_build_sglist(drive, rq))
647 drive->dma = !hwif->dma_ops->dma_setup(drive);
648 else
649 drive->dma = 0;
650 }
646 } else { 651 } else {
647 pc = drive->pc; 652 pc = drive->pc;
648 653
@@ -661,8 +666,12 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
661 } 666 }
662 667
663 if ((pc->flags & PC_FLAG_DMA_OK) && 668 if ((pc->flags & PC_FLAG_DMA_OK) &&
664 (drive->dev_flags & IDE_DFLAG_USING_DMA)) 669 (drive->dev_flags & IDE_DFLAG_USING_DMA)) {
665 drive->dma = !hwif->dma_ops->dma_setup(drive); 670 if (ide_build_sglist(drive, rq))
671 drive->dma = !hwif->dma_ops->dma_setup(drive);
672 else
673 drive->dma = 0;
674 }
666 675
667 if (!drive->dma) 676 if (!drive->dma)
668 pc->flags &= ~PC_FLAG_DMA_OK; 677 pc->flags &= ~PC_FLAG_DMA_OK;
diff --git a/drivers/ide/ide-dma-sff.c b/drivers/ide/ide-dma-sff.c
index 123d393658af..22b3e751d19b 100644
--- a/drivers/ide/ide-dma-sff.c
+++ b/drivers/ide/ide-dma-sff.c
@@ -120,10 +120,6 @@ int ide_build_dmatable(ide_drive_t *drive, struct request *rq)
120 struct scatterlist *sg; 120 struct scatterlist *sg;
121 u8 is_trm290 = !!(hwif->host_flags & IDE_HFLAG_TRM290); 121 u8 is_trm290 = !!(hwif->host_flags & IDE_HFLAG_TRM290);
122 122
123 hwif->sg_nents = ide_build_sglist(drive, rq);
124 if (hwif->sg_nents == 0)
125 return 0;
126
127 for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) { 123 for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) {
128 u32 cur_addr, cur_len, xcount, bcount; 124 u32 cur_addr, cur_len, xcount, bcount;
129 125
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index a878f4734f81..12c11b71402e 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -138,14 +138,15 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
138 hwif->sg_dma_direction = DMA_TO_DEVICE; 138 hwif->sg_dma_direction = DMA_TO_DEVICE;
139 139
140 i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction); 140 i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
141 if (i) { 141 if (i == 0)
142 ide_map_sg(drive, rq);
143 else {
142 hwif->orig_sg_nents = hwif->sg_nents; 144 hwif->orig_sg_nents = hwif->sg_nents;
143 hwif->sg_nents = i; 145 hwif->sg_nents = i;
144 } 146 }
145 147
146 return i; 148 return i;
147} 149}
148EXPORT_SYMBOL_GPL(ide_build_sglist);
149 150
150/** 151/**
151 * ide_destroy_dmatable - clean up DMA mapping 152 * ide_destroy_dmatable - clean up DMA mapping
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 15bbfc1dcd28..925fb9241893 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -103,6 +103,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
103 return ide_started; 103 return ide_started;
104 default: 104 default:
105 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || 105 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
106 ide_build_sglist(drive, hwif->rq) == 0 ||
106 dma_ops->dma_setup(drive)) 107 dma_ops->dma_setup(drive))
107 return ide_stopped; 108 return ide_stopped;
108 dma_ops->dma_exec_cmd(drive, tf->command); 109 dma_ops->dma_exec_cmd(drive, tf->command);
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 74625e821a43..904fb54668e8 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1429,10 +1429,10 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
1429 pmac_ide_hwif_t *pmif = 1429 pmac_ide_hwif_t *pmif =
1430 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1430 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1431 struct dbdma_cmd *table; 1431 struct dbdma_cmd *table;
1432 int i, count = 0;
1433 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; 1432 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
1434 struct scatterlist *sg; 1433 struct scatterlist *sg;
1435 int wr = (rq_data_dir(rq) == WRITE); 1434 int wr = (rq_data_dir(rq) == WRITE);
1435 int i = hwif->sg_nents, count = 0;
1436 1436
1437 /* DMA table is already aligned */ 1437 /* DMA table is already aligned */
1438 table = (struct dbdma_cmd *) pmif->dma_table_cpu; 1438 table = (struct dbdma_cmd *) pmif->dma_table_cpu;
@@ -1442,11 +1442,6 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
1442 while (readl(&dma->status) & RUN) 1442 while (readl(&dma->status) & RUN)
1443 udelay(1); 1443 udelay(1);
1444 1444
1445 hwif->sg_nents = i = ide_build_sglist(drive, rq);
1446
1447 if (!i)
1448 return 0;
1449
1450 /* Build DBDMA commands list */ 1445 /* Build DBDMA commands list */
1451 sg = hwif->sg_table; 1446 sg = hwif->sg_table;
1452 while (i && sg_dma_len(sg)) { 1447 while (i && sg_dma_len(sg)) {
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c
index 1cffe70f385d..ab9433a7ad1f 100644
--- a/drivers/ide/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -429,15 +429,9 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
429{ 429{
430 ide_hwif_t *hwif = drive->hwif; 430 ide_hwif_t *hwif = drive->hwif;
431 unsigned int *table = hwif->dmatable_cpu; 431 unsigned int *table = hwif->dmatable_cpu;
432 unsigned int count = 0, i = 1; 432 unsigned int count = 0, i = hwif->sg_nents;
433 struct scatterlist *sg; 433 struct scatterlist *sg = hwif->sg_table;
434 434
435 hwif->sg_nents = i = ide_build_sglist(drive, rq);
436
437 if (!i)
438 return 0; /* sglist of length Zero */
439
440 sg = hwif->sg_table;
441 while (i && sg_dma_len(sg)) { 435 while (i && sg_dma_len(sg)) {
442 dma_addr_t cur_addr; 436 dma_addr_t cur_addr;
443 int cur_len; 437 int cur_len;
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index f0033eb2e885..ee86688d8461 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -240,10 +240,6 @@ static int tx4939ide_build_dmatable(ide_drive_t *drive, struct request *rq)
240 int i; 240 int i;
241 struct scatterlist *sg; 241 struct scatterlist *sg;
242 242
243 hwif->sg_nents = ide_build_sglist(drive, rq);
244 if (hwif->sg_nents == 0)
245 return 0;
246
247 for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) { 243 for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) {
248 u32 cur_addr, cur_len, bcount; 244 u32 cur_addr, cur_len, bcount;
249 245