aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-02-02 02:50:52 -0500
committerJeff Garzik <jeff@garzik.org>2007-05-01 07:49:54 -0400
commit31daabda16063b64a99a526242add727601e43c3 (patch)
tree771e48219041e0a60f33f439c35324d0a3849224 /include/linux/libata.h
parentb8cffc6ad8c000410186815b7bcc6b76ef1bbb13 (diff)
libata: reimplement reset sequencing
libata previously depended upon waits in prereset to get resets after hotplug right for both spin up and device ready wait. This was necessary both for reliablity and speed as reset was likely to fail if initiated too early and each try usually took more than 30secs to fail. Previous patches fixed the reliability part by fixing status and SCR handling in resets. This patch remedies the speed part by improving reset sequencing. Prereset waiting timeout is adjusted to 10s because spinup wait is replaced by reset sequencing and !BSY wait is not as important as before. During boot or module loading where the drive is already fully spun up, !BSY wait succeeds immediately, so 10s should be enough in most cases. It matters after hotplugging or other error conditions, but in those cases, !BSY wait in prereset simply can't be relied upon due to the varied and weird behaviors ATA controllers and devices show. Reset is now driven by ata_eh_reset_timeouts[] table which contains timeouts for each reset try. The first reset can be softreset but the following ones are always hardreset if available. Each timeout defines deadline for the reset try. If a reset try fails, reset is retried with the next timeout till the end of the timeout table is reached. If a reset try fails before the timeout with error, libata waits till the deadline of the failed try before retrying. IOW, the timeout table defines timetable of reset tries such that the n'th try always begins at least after the sum of all previous timeouts has passed. The current timetable defines 4 tries and takes around 1 minute. @0 : First try. This should succeed most of the time during boot. @10 : 10s is enough to spin up most consumer harddrives. Give it another shot. @20 : 20s should spin up > 99% of working drives. This has 30s timeout for retarded devices needing long idleness post reset. @55 : Final try with 5s timeout just in case. The above timetable is trade off between not annoying the device too much with frequent resets and taking reasonable amount of time in most cases. Some controllers may do better with shorter timeouts while others may fare better with longer but we just can't rely upon LLD writers to test each controller with wide variety of devices using various scenarios. We need default behavior which reasonably fits most cases. I've tested the above timetable on a dozen SATA controllers and a few PATA controllers with about a dozen different drives from all major vendors and 4 different ODDs from three different vendors for both boot and hotplug (if available) cases. Boot probing is not affected unless the device is broken in which cases new code gives up on the port after a minute rather than five or nine minutes. When hotplugging, most devices get detected on the first or second try. Multi-platter drives with long spin up time which sometimes took > 40 secs with the original code, now usually comes up during the second try and at least right after the third try @20. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h16
1 files changed, 0 insertions, 16 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 69fc1b8a9215..7906d750aa77 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -296,18 +296,8 @@ enum {
296 296
297 /* how hard are we gonna try to probe/recover devices */ 297 /* how hard are we gonna try to probe/recover devices */
298 ATA_PROBE_MAX_TRIES = 3, 298 ATA_PROBE_MAX_TRIES = 3,
299 ATA_EH_RESET_TRIES = 3,
300 ATA_EH_DEV_TRIES = 3, 299 ATA_EH_DEV_TRIES = 3,
301 300
302 /* Drive spinup time (time from power-on to the first D2H FIS)
303 * in msecs - 8s currently. Failing to get ready in this time
304 * isn't critical. It will result in reset failure for
305 * controllers which can't wait for the first D2H FIS. libata
306 * will retry, so it just has to be long enough to spin up
307 * most devices.
308 */
309 ATA_SPINUP_WAIT = 8000,
310
311 /* Horkage types. May be set by libata or controller on drives 301 /* Horkage types. May be set by libata or controller on drives
312 (some horkage may be drive/controller pair dependant */ 302 (some horkage may be drive/controller pair dependant */
313 303
@@ -495,7 +485,6 @@ struct ata_eh_info {
495 unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */ 485 unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */
496 unsigned int flags; /* ATA_EHI_* flags */ 486 unsigned int flags; /* ATA_EHI_* flags */
497 487
498 unsigned long hotplug_timestamp;
499 unsigned int probe_mask; 488 unsigned int probe_mask;
500 489
501 char desc[ATA_EH_DESC_LEN]; 490 char desc[ATA_EH_DESC_LEN];
@@ -925,12 +914,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
925 914
926static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi) 915static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi)
927{ 916{
928 if (ehi->flags & ATA_EHI_HOTPLUGGED)
929 return;
930
931 ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK; 917 ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK;
932 ehi->hotplug_timestamp = jiffies;
933
934 ehi->action |= ATA_EH_SOFTRESET; 918 ehi->action |= ATA_EH_SOFTRESET;
935 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; 919 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
936} 920}