summaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorAlan Cox2007-04-23 12:55:36 +0200
committerJeff Garzik2007-04-28 20:51:33 +0200
commit4f701d1e9a796a3d6657e1129bee0566d7cda916 (patch)
treeac2b13b4fc37bcc29ada2f46fde1e2cd2d734052 /drivers/ata/libata-core.c
parentlibata: add missing call to ->cable_detect() in new EH path (diff)
downloadkernel-qcow2-linux-4f701d1e9a796a3d6657e1129bee0566d7cda916.tar.gz
kernel-qcow2-linux-4f701d1e9a796a3d6657e1129bee0566d7cda916.tar.xz
kernel-qcow2-linux-4f701d1e9a796a3d6657e1129bee0566d7cda916.zip
ata_timing: ensure t->cycle is always correct
Russell King hit a case where quantisation errors accumulated such that the cycle time was shorter than rather than equal to the active/recovery time. The code already knows how to stretch times to fit the cycle time but does not know about the reverse. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 227399e48470..4e1df5382b9a 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2639,6 +2639,12 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
t->active += (t->cycle - (t->active + t->recover)) / 2;
t->recover = t->cycle - t->active;
}
+
+ /* In a few cases quantisation may produce enough errors to
+ leave t->cycle too low for the sum of active and recovery
+ if so we must correct this */
+ if (t->active + t->recover > t->cycle)
+ t->cycle = t->active + t->recover;
return 0;
}