]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
AHCI: speed up resume
authorZhang Rui <rui.zhang@intel.com>
Fri, 4 Jul 2008 05:32:17 +0000 (13:32 +0800)
committerJeff Garzik <jgarzik@redhat.com>
Mon, 14 Jul 2008 19:59:33 +0000 (15:59 -0400)
During resume, sleep 1 second to wait for the HBA reset
to finish is a waste of time.

According to the AHCI 1.2 spec,
We should poll the HOST_CTL register,
and return error if the host reset is not
finished within 1 second.

Test results show that the HBA reset can be done quickly(in usecs).
And this patch may save nearly 1 second during resume.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/ahci.c

index 65d4e968feb497928e14c30d07b544de033844d9..4ff3f03cf97bfc1d0b8878743deb22b42a708c11 100644 (file)
@@ -1142,12 +1142,15 @@ static int ahci_reset_controller(struct ata_host *host)
                        readl(mmio + HOST_CTL); /* flush */
                }
 
-               /* reset must complete within 1 second, or
+               /*
+                * to perform host reset, OS should set HOST_RESET
+                * and poll until this bit is read to be "0".
+                * reset must complete within 1 second, or
                 * the hardware should be considered fried.
                 */
-               ssleep(1);
+               tmp = ata_wait_register(mmio + HOST_CTL, HOST_RESET,
+                                       HOST_RESET, 10, 1000);
 
-               tmp = readl(mmio + HOST_CTL);
                if (tmp & HOST_RESET) {
                        dev_printk(KERN_ERR, host->dev,
                                   "controller reset failed (0x%x)\n", tmp);