aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-08-27 05:09:15 -0400
committerJeff Garzik <jgarzik@redhat.com>2010-09-09 14:19:18 -0400
commitf1f5a807b051eddd3f302e503d39214e5bde0ef2 (patch)
treee953579992d5127dda716c84d64d8d2a733d9b33 /drivers/ata
parent673424c0890a00e22398017c9adf999577526220 (diff)
ahci: fix hang on failed softreset
ahci_do_softreset() compared the current time and deadline in reverse when calculating timeout for SRST issue. The result is that if @deadline is in future, SRST is issued with 0 timeout, which hasn't caused any problem because it later waits for DRDY with the correct timeout. If deadline is already exceeded by the time SRST is about to be issued, the timeout calculation underflows and if the device doesn't respond, timeout doesn't trigger for a _very_ long time. Reverse the incorrect comparison order. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Anssi Hannula <anssi.hannula@iki.fi> Tested-by: Gwendal Grignou <gwendal@google.com> Cc: stable@kernel.org Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libahci.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 666850d31df2..68dc6785472f 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1326,7 +1326,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1326 /* issue the first D2H Register FIS */ 1326 /* issue the first D2H Register FIS */
1327 msecs = 0; 1327 msecs = 0;
1328 now = jiffies; 1328 now = jiffies;
1329 if (time_after(now, deadline)) 1329 if (time_after(deadline, now))
1330 msecs = jiffies_to_msecs(deadline - now); 1330 msecs = jiffies_to_msecs(deadline - now);
1331 1331
1332 tf.ctl |= ATA_SRST; 1332 tf.ctl |= ATA_SRST;