ide: move ide_map_sg() call out of ->dma_setup method (take 2)

Move ide_map_sg() call from ->dma_setup implementations and
ide_destroy_dmatable() one from *_build_dmatable() to ide_dma_prepare().

There should be no functional changes caused by this patch.

Sergei:
Removed 'use_pio_instead' labels and replaced 'goto' with 'return 0' --
that required no changes to the follow-up patches...
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 8a4a5738
...@@ -236,7 +236,7 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -236,7 +236,7 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
if (++count >= PRD_ENTRIES) { if (++count >= PRD_ENTRIES) {
printk(KERN_WARNING "%s: DMA table too small\n", printk(KERN_WARNING "%s: DMA table too small\n",
drive->name); drive->name);
goto use_pio_instead; return 0;
} }
/* Lets enable intr for the last descriptor only */ /* Lets enable intr for the last descriptor only */
...@@ -272,9 +272,6 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -272,9 +272,6 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
if (count) if (count)
return 1; return 1;
use_pio_instead:
ide_destroy_dmatable(drive);
return 0; /* revert to PIO for this request */ return 0; /* revert to PIO for this request */
} }
...@@ -290,10 +287,8 @@ static void auide_dma_start(ide_drive_t *drive ) ...@@ -290,10 +287,8 @@ static void auide_dma_start(ide_drive_t *drive )
static int auide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) static int auide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
{ {
if (auide_build_dmatable(drive, cmd) == 0) { if (auide_build_dmatable(drive, cmd) == 0)
ide_map_sg(drive, cmd);
return 1; return 1;
}
drive->waiting_for_dma = 1; drive->waiting_for_dma = 1;
return 0; return 0;
......
...@@ -166,8 +166,6 @@ use_pio_instead: ...@@ -166,8 +166,6 @@ use_pio_instead:
printk(KERN_ERR "%s: %s\n", drive->name, printk(KERN_ERR "%s: %s\n", drive->name,
count ? "DMA table too small" : "empty DMA table?"); count ? "DMA table too small" : "empty DMA table?");
ide_destroy_dmatable(drive);
return 0; /* revert to PIO for this request */ return 0; /* revert to PIO for this request */
} }
EXPORT_SYMBOL_GPL(ide_build_dmatable); EXPORT_SYMBOL_GPL(ide_build_dmatable);
......
...@@ -570,8 +570,12 @@ int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -570,8 +570,12 @@ int ide_dma_prepare(ide_drive_t *drive, struct ide_cmd *cmd)
if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
(dma_ops->dma_check && dma_ops->dma_check(drive, cmd)) || (dma_ops->dma_check && dma_ops->dma_check(drive, cmd)) ||
ide_build_sglist(drive, cmd) == 0 || ide_build_sglist(drive, cmd) == 0)
dma_ops->dma_setup(drive, cmd))
return 1; return 1;
if (dma_ops->dma_setup(drive, cmd)) {
ide_destroy_dmatable(drive);
ide_map_sg(drive, cmd);
return 1;
}
return 0; return 0;
} }
...@@ -1455,7 +1455,7 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -1455,7 +1455,7 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
"switching to PIO on Ohare chipset\n", drive->name); "switching to PIO on Ohare chipset\n", drive->name);
pmif->broken_dma_warn = 1; pmif->broken_dma_warn = 1;
} }
goto use_pio_instead; return 0;
} }
while (cur_len) { while (cur_len) {
unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00; unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
...@@ -1463,7 +1463,7 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -1463,7 +1463,7 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
if (count++ >= MAX_DCMDS) { if (count++ >= MAX_DCMDS) {
printk(KERN_WARNING "%s: DMA table too small\n", printk(KERN_WARNING "%s: DMA table too small\n",
drive->name); drive->name);
goto use_pio_instead; return 0;
} }
st_le16(&table->command, wr? OUTPUT_MORE: INPUT_MORE); st_le16(&table->command, wr? OUTPUT_MORE: INPUT_MORE);
st_le16(&table->req_count, tc); st_le16(&table->req_count, tc);
...@@ -1492,9 +1492,6 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -1492,9 +1492,6 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name);
use_pio_instead:
ide_destroy_dmatable(drive);
return 0; /* revert to PIO for this request */ return 0; /* revert to PIO for this request */
} }
...@@ -1510,10 +1507,8 @@ static int pmac_ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -1510,10 +1507,8 @@ static int pmac_ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4); u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4);
u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE); u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
if (pmac_ide_build_dmatable(drive, cmd) == 0) { if (pmac_ide_build_dmatable(drive, cmd) == 0)
ide_map_sg(drive, cmd);
return 1; return 1;
}
/* Apple adds 60ns to wrDataSetup on reads */ /* Apple adds 60ns to wrDataSetup on reads */
if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) { if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
......
...@@ -321,10 +321,8 @@ static int scc_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -321,10 +321,8 @@ static int scc_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
u8 dma_stat; u8 dma_stat;
/* fall back to pio! */ /* fall back to pio! */
if (ide_build_dmatable(drive, cmd) == 0) { if (ide_build_dmatable(drive, cmd) == 0)
ide_map_sg(drive, cmd);
return 1; return 1;
}
/* PRD table */ /* PRD table */
out_be32((void __iomem *)(hwif->dma_base + 8), hwif->dmatable_dma); out_be32((void __iomem *)(hwif->dma_base + 8), hwif->dmatable_dma);
......
...@@ -442,7 +442,7 @@ static int sgiioc4_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -442,7 +442,7 @@ static int sgiioc4_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
printk(KERN_WARNING printk(KERN_WARNING
"%s: DMA table too small\n", "%s: DMA table too small\n",
drive->name); drive->name);
goto use_pio_instead; return 0;
} else { } else {
u32 bcount = u32 bcount =
0x10000 - (cur_addr & 0xffff); 0x10000 - (cur_addr & 0xffff);
...@@ -477,9 +477,6 @@ static int sgiioc4_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -477,9 +477,6 @@ static int sgiioc4_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
return count; return count;
} }
use_pio_instead:
ide_destroy_dmatable(drive);
return 0; /* revert to PIO for this request */ return 0; /* revert to PIO for this request */
} }
...@@ -488,11 +485,9 @@ static int sgiioc4_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -488,11 +485,9 @@ static int sgiioc4_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
int ddir; int ddir;
u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE); u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
if (sgiioc4_build_dmatable(drive, cmd) == 0) { if (sgiioc4_build_dmatable(drive, cmd) == 0)
/* try PIO instead of DMA */ /* try PIO instead of DMA */
ide_map_sg(drive, cmd);
return 1; return 1;
}
if (write) if (write)
/* Writes TO the IOC4 FROM Main Memory */ /* Writes TO the IOC4 FROM Main Memory */
......
...@@ -193,11 +193,10 @@ static int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -193,11 +193,10 @@ static int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
unsigned int count, rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 2; unsigned int count, rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 2;
count = ide_build_dmatable(drive, cmd); count = ide_build_dmatable(drive, cmd);
if (count == 0) { if (count == 0)
ide_map_sg(drive, cmd);
/* try PIO instead of DMA */ /* try PIO instead of DMA */
return 1; return 1;
}
outl(hwif->dmatable_dma | rw, hwif->dma_base); outl(hwif->dmatable_dma | rw, hwif->dma_base);
drive->waiting_for_dma = 1; drive->waiting_for_dma = 1;
/* start DMA */ /* start DMA */
......
...@@ -279,8 +279,6 @@ use_pio_instead: ...@@ -279,8 +279,6 @@ use_pio_instead:
printk(KERN_ERR "%s: %s\n", drive->name, printk(KERN_ERR "%s: %s\n", drive->name,
count ? "DMA table too small" : "empty DMA table?"); count ? "DMA table too small" : "empty DMA table?");
ide_destroy_dmatable(drive);
return 0; /* revert to PIO for this request */ return 0; /* revert to PIO for this request */
} }
#else #else
...@@ -294,10 +292,8 @@ static int tx4939ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -294,10 +292,8 @@ static int tx4939ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
u8 rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 0 : ATA_DMA_WR; u8 rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 0 : ATA_DMA_WR;
/* fall back to PIO! */ /* fall back to PIO! */
if (tx4939ide_build_dmatable(drive, cmd) == 0) { if (tx4939ide_build_dmatable(drive, cmd) == 0)
ide_map_sg(drive, cmd);
return 1; return 1;
}
/* PRD table */ /* PRD table */
tx4939ide_writel(hwif->dmatable_dma, base, TX4939IDE_PRD_Ptr); tx4939ide_writel(hwif->dmatable_dma, base, TX4939IDE_PRD_Ptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment