]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sata_nv: wait for response on entering/leaving ADMA mode
authorRobert Hancock <hancockr@shaw.ca>
Tue, 6 Feb 2007 00:26:03 +0000 (16:26 -0800)
committerJeff Garzik <jeff@garzik.org>
Fri, 9 Feb 2007 22:39:39 +0000 (17:39 -0500)
Update sata_nv to wait for the controller to indicate via the status
register that it has entered the requested state when switching between
ADMA mode and register mode.  This issue came up recently when debugging
some problems with cache flush command timeouts and while it didn't appear
to fix that problem, this is something we should likely be doing in any
case.

Signed-off-by: Robert Hancock <hancockr@shaw.ca>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/ata/sata_nv.c

index 19817b37616143cd9e9132c89a29a9db8a49a7d9..aea005d5663cb24ebbfaceeec9193013be3a67e9 100644 (file)
@@ -512,14 +512,38 @@ static void nv_adma_register_mode(struct ata_port *ap)
 {
        struct nv_adma_port_priv *pp = ap->private_data;
        void __iomem *mmio = pp->ctl_block;
-       u16 tmp;
+       u16 tmp, status;
+       int count = 0;
 
        if (pp->flags & NV_ADMA_PORT_REGISTER_MODE)
                return;
 
+       status = readw(mmio + NV_ADMA_STAT);
+       while(!(status & NV_ADMA_STAT_IDLE) && count < 20) {
+               ndelay(50);
+               status = readw(mmio + NV_ADMA_STAT);
+               count++;
+       }
+       if(count == 20)
+               ata_port_printk(ap, KERN_WARNING,
+                       "timeout waiting for ADMA IDLE, stat=0x%hx\n",
+                       status);
+
        tmp = readw(mmio + NV_ADMA_CTL);
        writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
 
+       count = 0;
+       status = readw(mmio + NV_ADMA_STAT);
+       while(!(status & NV_ADMA_STAT_LEGACY) && count < 20) {
+               ndelay(50);
+               status = readw(mmio + NV_ADMA_STAT);
+               count++;
+       }
+       if(count == 20)
+               ata_port_printk(ap, KERN_WARNING,
+                        "timeout waiting for ADMA LEGACY, stat=0x%hx\n",
+                        status);
+
        pp->flags |= NV_ADMA_PORT_REGISTER_MODE;
 }
 
@@ -527,7 +551,8 @@ static void nv_adma_mode(struct ata_port *ap)
 {
        struct nv_adma_port_priv *pp = ap->private_data;
        void __iomem *mmio = pp->ctl_block;
-       u16 tmp;
+       u16 tmp, status;
+       int count = 0;
 
        if (!(pp->flags & NV_ADMA_PORT_REGISTER_MODE))
                return;
@@ -537,6 +562,18 @@ static void nv_adma_mode(struct ata_port *ap)
        tmp = readw(mmio + NV_ADMA_CTL);
        writew(tmp | NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
 
+       status = readw(mmio + NV_ADMA_STAT);
+       while(((status & NV_ADMA_STAT_LEGACY) ||
+             !(status & NV_ADMA_STAT_IDLE)) && count < 20) {
+               ndelay(50);
+               status = readw(mmio + NV_ADMA_STAT);
+               count++;
+       }
+       if(count == 20)
+               ata_port_printk(ap, KERN_WARNING,
+                       "timeout waiting for ADMA LEGACY clear and IDLE, stat=0x%hx\n",
+                       status);
+
        pp->flags &= ~NV_ADMA_PORT_REGISTER_MODE;
 }