diff options
author | Tejun Heo <htejun@gmail.com> | 2008-04-07 09:47:19 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-17 15:44:22 -0400 |
commit | 705e76beb90b97421e1f61e857c4246799781bb5 (patch) | |
tree | e571ad9229d469cd73d1388c76823922400823d5 /include/linux/libata.h | |
parent | 203c75b8245c5386044721d9c5eda5c6b71b3d14 (diff) |
libata: restructure SFF post-reset readiness waits
Previously, post-softreset readiness is waited as follows.
1. ata_sff_wait_after_reset() waits for 150ms and then for
ATA_TMOUT_FF_WAIT if status is 0xff and other conditions meet.
2. ata_bus_softreset() finishes with -ENODEV if status is still 0xff.
If not, continue to #3.
3. ata_bus_post_reset() waits readiness of dev0 and/or dev1 depending
on devmask using ata_sff_wait_ready().
And for post-hardreset readiness,
1. ata_sff_wait_after_reset() waits for 150ms and then for
ATA_TMOUT_FF_WAIT if status is 0xff and other conditions meet.
2. sata_sff_hardreset waits for device readiness using
ata_sff_wait_ready().
This patch merges and unifies post-reset readiness waits into
ata_sff_wait_ready() and ata_sff_wait_after_reset().
ATA_TMOUT_FF_WAIT handling is merged into ata_sff_wait_ready(). If TF
status is 0xff, link status is unknown and the port is SATA, it will
continue polling till ATA_TMOUT_FF_WAIT.
ata_sff_wait_after_reset() is updated to perform the following steps.
1. waits for 150ms.
2. waits for dev0 readiness using ata_sff_wait_ready(). Note that
this is done regardless of devmask, as ata_sff_wait_ready() handles
0xff status correctly, this preserves the original behavior except
that it may wait longer after softreset if link is online but
status is 0xff. This behavior change is very unlikely to cause any
actual difference and is intended. It brings softreset behavior to
that of hardreset.
3. waits for dev1 readiness just the same way ata_bus_post_reset() did.
Now both soft and hard resets call ata_sff_wait_after_reset() after
reset to wait for readiness after resets. As
ata_sff_wait_after_reset() contains calls to ->sff_dev_select(),
explicit call near the end of sata_sff_hardreset() is removed.
This change makes reset implementation simpler and more consistent.
While at it, make the magical 150ms wait post-reset wait duration a
constant and ata_sff_wait_ready() and ata_sff_wait_after_reset() take
@link instead of @ap. This is to make them consistent with other
reset helpers and ease core changes.
pata_scc is updated accordingly.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 6e14c27319d5..da5560244787 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -249,6 +249,18 @@ enum { | |||
249 | */ | 249 | */ |
250 | ATA_TMOUT_FF_WAIT = 4 * HZ / 5, | 250 | ATA_TMOUT_FF_WAIT = 4 * HZ / 5, |
251 | 251 | ||
252 | /* Spec mandates to wait for ">= 2ms" before checking status | ||
253 | * after reset. We wait 150ms, because that was the magic | ||
254 | * delay used for ATAPI devices in Hale Landis's ATADRVR, for | ||
255 | * the period of time between when the ATA command register is | ||
256 | * written, and then status is checked. Because waiting for | ||
257 | * "a while" before checking status is fine, post SRST, we | ||
258 | * perform this magic delay here as well. | ||
259 | * | ||
260 | * Old drivers/ide uses the 2mS rule and then waits for ready. | ||
261 | */ | ||
262 | ATA_WAIT_AFTER_RESET_MSECS = 150, | ||
263 | |||
252 | /* ATA bus states */ | 264 | /* ATA bus states */ |
253 | BUS_UNKNOWN = 0, | 265 | BUS_UNKNOWN = 0, |
254 | BUS_DMA = 1, | 266 | BUS_DMA = 1, |
@@ -1351,7 +1363,7 @@ extern u8 ata_sff_check_status(struct ata_port *ap); | |||
1351 | extern u8 ata_sff_altstatus(struct ata_port *ap); | 1363 | extern u8 ata_sff_altstatus(struct ata_port *ap); |
1352 | extern int ata_sff_busy_sleep(struct ata_port *ap, | 1364 | extern int ata_sff_busy_sleep(struct ata_port *ap, |
1353 | unsigned long timeout_pat, unsigned long timeout); | 1365 | unsigned long timeout_pat, unsigned long timeout); |
1354 | extern int ata_sff_wait_ready(struct ata_port *ap, unsigned long deadline); | 1366 | extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline); |
1355 | extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); | 1367 | extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); |
1356 | extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 1368 | extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
1357 | extern void ata_sff_exec_command(struct ata_port *ap, | 1369 | extern void ata_sff_exec_command(struct ata_port *ap, |
@@ -1373,8 +1385,8 @@ extern void ata_sff_thaw(struct ata_port *ap); | |||
1373 | extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline); | 1385 | extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline); |
1374 | extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present, | 1386 | extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present, |
1375 | u8 *r_err); | 1387 | u8 *r_err); |
1376 | extern void ata_sff_wait_after_reset(struct ata_port *ap, | 1388 | extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask, |
1377 | unsigned long deadline); | 1389 | unsigned long deadline); |
1378 | extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes, | 1390 | extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes, |
1379 | unsigned long deadline); | 1391 | unsigned long deadline); |
1380 | extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class, | 1392 | extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class, |