Skip to content

Commit

Permalink
ata_timing: ensure t->cycle is always correct
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alan Cox authored and Jeff Garzik committed Apr 28, 2007
1 parent c1c4e8d commit 4f701d1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4f701d1

Please sign in to comment.