From: Tejun Heo Date: Fri, 27 Aug 2010 09:09:15 +0000 (+0200) Subject: ahci: fix hang on failed softreset X-Git-Tag: v2.6.35.5~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b88bc4f87ca83631af8ab3286964a547835a0df;p=thirdparty%2Fkernel%2Fstable.git ahci: fix hang on failed softreset commit f1f5a807b051eddd3f302e503d39214e5bde0ef2 upstream. 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 Reported-by: Anssi Hannula Tested-by: Gwendal Grignou Signed-off-by: Jeff Garzik Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 81e772a94d598..98c80e1ab6e99 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -1320,7 +1320,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class, /* issue the first D2H Register FIS */ msecs = 0; now = jiffies; - if (time_after(now, deadline)) + if (time_after(deadline, now)) msecs = jiffies_to_msecs(deadline - now); tf.ctl |= ATA_SRST;