aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-07 09:47:19 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:22 -0400
commit9dadd45b24145d6aee2fabb28d7aef972301892b (patch)
treec97c323e2edd400bc94eaceddf20f84e9a6da005 /drivers/ata/libata-core.c
parenta89611e8489ac24f371c9fd6fef6605b170b16ba (diff)
libata: move generic hardreset code from sata_sff_hardreset() to sata_link_hardreset()
sata_sff_hardreset() contains link readiness wait logic which isn't SFF specific. Move that part into sata_link_hardreset(), which now takes two more parameters - @online and @check_ready. Both are optional. The former is out parameter for link onlineness after reset. The latter is used to wait for link readiness after hardreset. Users of sata_link_hardreset() is updated to use new funtionality and ahci_hardreset() is updated to use sata_link_hardreset() instead of sata_sff_hardreset(). This doesn't really cause any behavior change. Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3bad6f189190..b607292b6480 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3557,8 +3557,18 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3557 * @link: link to reset 3557 * @link: link to reset
3558 * @timing: timing parameters { interval, duratinon, timeout } in msec 3558 * @timing: timing parameters { interval, duratinon, timeout } in msec
3559 * @deadline: deadline jiffies for the operation 3559 * @deadline: deadline jiffies for the operation
3560 * @online: optional out parameter indicating link onlineness
3561 * @check_ready: optional callback to check link readiness
3560 * 3562 *
3561 * SATA phy-reset @link using DET bits of SControl register. 3563 * SATA phy-reset @link using DET bits of SControl register.
3564 * After hardreset, link readiness is waited upon using
3565 * ata_wait_ready() if @check_ready is specified. LLDs are
3566 * allowed to not specify @check_ready and wait itself after this
3567 * function returns. Device classification is LLD's
3568 * responsibility.
3569 *
3570 * *@online is set to one iff reset succeeded and @link is online
3571 * after reset.
3562 * 3572 *
3563 * LOCKING: 3573 * LOCKING:
3564 * Kernel thread context (may sleep) 3574 * Kernel thread context (may sleep)
@@ -3567,13 +3577,17 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3567 * 0 on success, -errno otherwise. 3577 * 0 on success, -errno otherwise.
3568 */ 3578 */
3569int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, 3579int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3570 unsigned long deadline) 3580 unsigned long deadline,
3581 bool *online, int (*check_ready)(struct ata_link *))
3571{ 3582{
3572 u32 scontrol; 3583 u32 scontrol;
3573 int rc; 3584 int rc;
3574 3585
3575 DPRINTK("ENTER\n"); 3586 DPRINTK("ENTER\n");
3576 3587
3588 if (online)
3589 *online = false;
3590
3577 if (sata_set_spd_needed(link)) { 3591 if (sata_set_spd_needed(link)) {
3578 /* SATA spec says nothing about how to reconfigure 3592 /* SATA spec says nothing about how to reconfigure
3579 * spd. To be on the safe side, turn off phy during 3593 * spd. To be on the safe side, turn off phy during
@@ -3607,7 +3621,41 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3607 3621
3608 /* bring link back */ 3622 /* bring link back */
3609 rc = sata_link_resume(link, timing, deadline); 3623 rc = sata_link_resume(link, timing, deadline);
3624 if (rc)
3625 goto out;
3626 /* if link is offline nothing more to do */
3627 if (ata_link_offline(link))
3628 goto out;
3629
3630 /* Link is online. From this point, -ENODEV too is an error. */
3631 if (online)
3632 *online = true;
3633
3634 if ((link->ap->flags & ATA_FLAG_PMP) && ata_is_host_link(link)) {
3635 /* If PMP is supported, we have to do follow-up SRST.
3636 * Some PMPs don't send D2H Reg FIS after hardreset if
3637 * the first port is empty. Wait only for
3638 * ATA_TMOUT_PMP_SRST_WAIT.
3639 */
3640 if (check_ready) {
3641 unsigned long pmp_deadline;
3642
3643 pmp_deadline = jiffies + ATA_TMOUT_PMP_SRST_WAIT;
3644 if (time_after(pmp_deadline, deadline))
3645 pmp_deadline = deadline;
3646 ata_wait_ready(link, pmp_deadline, check_ready);
3647 }
3648 rc = -EAGAIN;
3649 goto out;
3650 }
3651
3652 rc = 0;
3653 if (check_ready)
3654 rc = ata_wait_ready(link, deadline, check_ready);
3610 out: 3655 out:
3656 if (rc && rc != -EAGAIN)
3657 ata_link_printk(link, KERN_ERR,
3658 "COMRESET failed (errno=%d)\n", rc);
3611 DPRINTK("EXIT, rc=%d\n", rc); 3659 DPRINTK("EXIT, rc=%d\n", rc);
3612 return rc; 3660 return rc;
3613} 3661}