ide: destroy DMA mappings after ending DMA (v2)
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tue, 31 Mar 2009 18:15:20 +0000 (20:15 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tue, 31 Mar 2009 18:15:20 +0000 (20:15 +0200)
Move ide_destroy_dmatable() call out from ->dma_end method to
{ide_pc,cdrom_newpc,ide_dma}_intr(), ide_dma_timeout_retry()
and sgiioc4_resetproc().

This causes minor/safe behavior changes w.r.t.:
* cmd64x.c::cmd64{8,x}_dma_end()
* cs5536.c::cs5536_dma_end()
* icside.c::icside_dma_end()
* it821x.c::it821x_dma_end()
* scc_pata.c::__scc_dma_end()
* sl82c105.c::sl82c105_dma_end()
* tx4939ide.c::tx4939ide_dma_end()

v2:
* Fix build for CONFIG_BLK_DEV_IDEDMA=n (reported by Randy Dunlap).

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
15 files changed:
drivers/ide/au1xxx-ide.c
drivers/ide/cmd64x.c
drivers/ide/icside.c
drivers/ide/ide-atapi.c
drivers/ide/ide-cd.c
drivers/ide/ide-dma-sff.c
drivers/ide/ide-dma.c
drivers/ide/ns87415.c
drivers/ide/pmac.c
drivers/ide/sc1200.c
drivers/ide/scc_pata.c
drivers/ide/sgiioc4.c
drivers/ide/trm290.c
drivers/ide/tx4939ide.c
include/linux/ide.h

index 0c08c5e01f2aadd8030cb86f4fa5f55a0aafa9f5..ba2a211758a942f05e4a8a6324a5a9525924ed14 100644 (file)
@@ -280,8 +280,6 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
 
 static int auide_dma_end(ide_drive_t *drive)
 {
-       ide_destroy_dmatable(drive);
-
        return 0;
 }
 
index f0a49d2ff711fb4545864382007850ec6eb4bee1..f2edf280ef8bb88dbfa854c98bbc32926c01222b 100644 (file)
@@ -327,8 +327,6 @@ static int cmd646_1_dma_end(ide_drive_t *drive)
        outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD);
        /* clear the INTR & ERROR bits */
        outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS);
-       /* and free any DMA resources */
-       ide_destroy_dmatable(drive);
        /* verify good DMA status */
        return (dma_stat & 7) != 4;
 }
index f069f122ee6e8cdec57c03b2f185a82b51b27e9e..9bf57d7c8e57076eb7594b4be3027025320b344e 100644 (file)
@@ -291,9 +291,6 @@ static int icside_dma_end(ide_drive_t *drive)
 
        disable_dma(ec->dma);
 
-       /* Teardown mappings after DMA has completed. */
-       ide_destroy_dmatable(drive);
-
        return get_dma_residue(ec->dma) != 0;
 }
 
index f591166d2c9335739de34748d688e82880d476e1..1481f71f8173c12b776e7007df6f2229c268c1db 100644 (file)
@@ -342,8 +342,11 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
        stat = tp_ops->read_status(hwif);
 
        if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
-               if (hwif->dma_ops->dma_end(drive) ||
-                   (drive->media == ide_tape && (stat & ATA_ERR))) {
+               int rc = hwif->dma_ops->dma_end(drive);
+
+               ide_destroy_dmatable(drive);
+
+               if (rc || (drive->media == ide_tape && (stat & ATA_ERR))) {
                        if (drive->media == ide_floppy)
                                printk(KERN_ERR "%s: DMA %s error\n",
                                        drive->name, rq_data_dir(pc->rq)
index 5319e7a73708c19af9e312f380a84b3b05c200e9..4a0d66ee9547345501a80694d3412795bf0fa4d5 100644 (file)
@@ -639,6 +639,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        if (dma) {
                drive->dma = 0;
                dma_error = hwif->dma_ops->dma_end(drive);
+               ide_destroy_dmatable(drive);
                if (dma_error) {
                        printk(KERN_ERR PFX "%s: DMA %s error\n", drive->name,
                                        write ? "write" : "read");
index 7836d7e03ffff98f1fbf5a2492fc10d184110c95..f8adbb5eb339ab7bd80360a22d80513ee5d702fc 100644 (file)
@@ -310,8 +310,6 @@ int ide_dma_end(ide_drive_t *drive)
        /* clear INTR & ERROR bits */
        ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR);
 
-       /* purge DMA mappings */
-       ide_destroy_dmatable(drive);
        wmb();
 
        /* verify good DMA status */
index 4e2005071113e4a41171c8b4395791a28f92e11f..b430898bbcd6edfdf9ec3eba8a07e440fc5d188e 100644 (file)
@@ -92,6 +92,7 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive)
        u8 stat = 0, dma_stat = 0;
 
        dma_stat = hwif->dma_ops->dma_end(drive);
+       ide_destroy_dmatable(drive);
        stat = hwif->tp_ops->read_status(hwif);
 
        if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) {
@@ -479,6 +480,7 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
        if (error < 0) {
                printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
                (void)dma_ops->dma_end(drive);
+               ide_destroy_dmatable(drive);
                ret = ide_error(drive, "dma timeout error",
                                hwif->tp_ops->read_status(hwif));
        } else {
@@ -490,6 +492,7 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
                        ide_dump_status(drive, "DMA timeout",
                                        hwif->tp_ops->read_status(hwif));
                        (void)dma_ops->dma_end(drive);
+                       ide_destroy_dmatable(drive);
                }
        }
 
index 9039a373020ff90c064d86a3ab5c11d6add2f47e..9ad71a74f93f4210760d8306185ca284bfbdf403 100644 (file)
@@ -210,8 +210,6 @@ static int ns87415_dma_end(ide_drive_t *drive)
        /* from ERRATA: clear the INTR & ERROR bits */
        dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
        outb(dma_cmd | 6, hwif->dma_base + ATA_DMA_CMD);
-       /* and free any DMA resources */
-       ide_destroy_dmatable(drive);
        /* verify good DMA status */
        return (dma_stat & 7) != 4;
 }
index d15cc46a66e33304b4e6dbdf08adb6586f0b18ab..5643a8b957bff98077e15e6f05687f9a9f6f2c02 100644 (file)
@@ -1562,8 +1562,6 @@ pmac_ide_dma_end (ide_drive_t *drive)
        dstat = readl(&dma->status);
        writel(((RUN|WAKE|DEAD) << 16), &dma->control);
 
-       ide_destroy_dmatable(drive);
-
        /* verify good dma status. we don't check for ACTIVE beeing 0. We should...
         * in theory, but with ATAPI decices doing buffer underruns, that would
         * cause us to disable DMA, which isn't what we want
index 371549d18a01be3cd48a41a89e37605f80c3586b..d9c47034beddd40a5b6cf5d15447c35d808f8a69 100644 (file)
@@ -184,7 +184,6 @@ static int sc1200_dma_end(ide_drive_t *drive)
        outb(inb(dma_base)&~1, dma_base);       /* !! DO THIS HERE !! stop DMA */
 
        drive->waiting_for_dma = 0;
-       ide_destroy_dmatable(drive);            /* purge DMA mappings */
 
        return (dma_stat & 7) != 4;             /* verify good DMA status */
 }
index 64534d150b0c720ee8fc433d6d8497aa9f0d7726..693536ebe331e372c8798bf7b1543f1352141bb5 100644 (file)
@@ -365,8 +365,6 @@ static int __scc_dma_end(ide_drive_t *drive)
        dma_stat = scc_dma_sff_read_status(hwif);
        /* clear the INTR & ERROR bits */
        scc_ide_outb(dma_stat | 6, hwif->dma_base + 4);
-       /* purge DMA mappings */
-       ide_destroy_dmatable(drive);
        /* verify good DMA status */
        wmb();
        return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0;
index 44df0c750bab2cd895823ce2dbe91f5f7191d53a..457a762a1f29d1f2f11480eb999e07421bc45458 100644 (file)
@@ -259,7 +259,6 @@ static int sgiioc4_dma_end(ide_drive_t *drive)
        }
 
        drive->waiting_for_dma = 0;
-       ide_destroy_dmatable(drive);
 
        return dma_stat;
 }
@@ -284,6 +283,7 @@ static void
 sgiioc4_resetproc(ide_drive_t * drive)
 {
        sgiioc4_dma_end(drive);
+       ide_destroy_dmatable(drive);
        sgiioc4_clearirq(drive);
 }
 
index d6a950828e9f1f518704f8dd8c94195e3c91ddd3..8dd3d82268707dcd2d2241d5b6b8f58fb8e641e0 100644 (file)
@@ -216,8 +216,7 @@ static int trm290_dma_end(ide_drive_t *drive)
        u16 status;
 
        drive->waiting_for_dma = 0;
-       /* purge DMA mappings */
-       ide_destroy_dmatable(drive);
+
        status = inw(drive->hwif->dma_base + 2);
 
        return status != 0x00ff;
index 53f99853b065dbfc38b7fd45aafd8fe7d825d7b3..f62ced855cf392b05ec58ba346b771b8095e3e0d 100644 (file)
@@ -335,11 +335,9 @@ static int tx4939ide_dma_end(ide_drive_t *drive)
        /* read and clear the INTR & ERROR bits */
        dma_stat = tx4939ide_clear_dma_status(base);
 
-       /* purge DMA mappings */
-       ide_destroy_dmatable(drive);
-       /* verify good DMA status */
        wmb();
 
+       /* verify good DMA status */
        if ((dma_stat & (ATA_DMA_INTR | ATA_DMA_ERR | ATA_DMA_ACTIVE)) == 0 &&
            (ctl & (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST)) ==
            (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST))
index d3035f2f12503a6d1f68b06ef110ed264215fb9c..b6c4942fde11b81ecbb321106a49873dc05bf985 100644 (file)
@@ -1479,6 +1479,7 @@ static inline ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int erro
 static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
 static inline int ide_build_sglist(ide_drive_t *drive,
                                   struct ide_cmd *cmd) { return 0; }
+static inline void ide_destroy_dmatable(ide_drive_t *drive) { ; }
 #endif /* CONFIG_BLK_DEV_IDEDMA */
 
 #ifdef CONFIG_BLK_DEV_IDEACPI