lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1215074882.3214.15.camel@rzhang-dt.sh.intel.com>
Date:	Thu, 03 Jul 2008 16:48:02 +0800
From:	Zhang Rui <rui.zhang@...el.com>
To:	linux-pm <linux-pm@...ts.linux-foundation.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Cc:	tj@...nel.org, "Rafael J. Wysocki" <rjw@...k.pl>
Subject: [RFC PATCH] AHCI: speed up resume

During S3 resume, AHCI driver sleeps 1 second to wait for the HBA reset
to finish. This is luxurious, :)

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@...el.com>
--
 drivers/ata/ahci.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/ata/ahci.c
===================================================================
--- linux-2.6.orig/drivers/ata/ahci.c	2007-05-03 11:06:33.000000000 +0800
+++ linux-2.6/drivers/ata/ahci.c	2008-07-02 16:25:54.000000000 +0800
@@ -1073,18 +1073,29 @@
 
 	/* global controller reset */
 	if (!ahci_skip_host_reset) {
+		int delay = msecs_to_jiffies(1000);
+		int timeout;
+
 		tmp = readl(mmio + HOST_CTL);
 		if ((tmp & HOST_RESET) == 0) {
 			writel(tmp | HOST_RESET, mmio + HOST_CTL);
 			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);
+		timeout = jiffies + delay;
+		while (jiffies < timeout) {
+			tmp = readl(mmio + HOST_CTL);
+			if (!(tmp & HOST_RESET))
+				break;
+			cpu_relax();
+		}
 
-		tmp = readl(mmio + HOST_CTL);
 		if (tmp & HOST_RESET) {
 			dev_printk(KERN_ERR, host->dev,
 				   "controller reset failed (0x%x)\n", tmp);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ