Commit dd5d2d84 authored by Tejun Heo's avatar Tejun Heo Committed by Greg Kroah-Hartman

libata: always do follow-up SRST if hardreset returned -EAGAIN

commit 5dbfc9cb upstream

As an optimization, follow-up SRST used to be skipped if
classification wasn't requested even when hardreset requested it via
-EAGAIN.  However, some hardresets can't wait for device readiness and
skipping SRST can cause timeout or other failures during revalidation.
Always perform follow-up SRST if hardreset returns -EAGAIN.  This
makes reset paths more predictable and thus less error-prone.

While at it, move hardreset error checking such that it's done right
after hardreset is finished.  This simplifies followup SRST condition
check a bit and makes the reset path easier to modify.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c8d4a26c
...@@ -2050,18 +2050,12 @@ static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, ...@@ -2050,18 +2050,12 @@ static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
} }
static int ata_eh_followup_srst_needed(struct ata_link *link, static int ata_eh_followup_srst_needed(struct ata_link *link,
int rc, int classify, int rc, const unsigned int *classes)
const unsigned int *classes)
{ {
if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link))
return 0; return 0;
if (rc == -EAGAIN) { if (rc == -EAGAIN)
if (classify)
return 1; return 1;
rc = 0;
}
if (rc != 0)
return 0;
if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
return 1; return 1;
return 0; return 0;
...@@ -2174,9 +2168,11 @@ int ata_eh_reset(struct ata_link *link, int classify, ...@@ -2174,9 +2168,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
ehc->i.flags |= ATA_EHI_DID_SOFTRESET; ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
rc = ata_do_reset(link, reset, classes, deadline); rc = ata_do_reset(link, reset, classes, deadline);
if (rc && rc != -EAGAIN)
goto fail;
if (reset == hardreset && if (reset == hardreset &&
ata_eh_followup_srst_needed(link, rc, classify, classes)) { ata_eh_followup_srst_needed(link, rc, classes)) {
/* okay, let's do follow-up softreset */ /* okay, let's do follow-up softreset */
reset = softreset; reset = softreset;
...@@ -2191,10 +2187,6 @@ int ata_eh_reset(struct ata_link *link, int classify, ...@@ -2191,10 +2187,6 @@ int ata_eh_reset(struct ata_link *link, int classify,
ata_eh_about_to_do(link, NULL, ATA_EH_RESET); ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
rc = ata_do_reset(link, reset, classes, deadline); rc = ata_do_reset(link, reset, classes, deadline);
} }
/* -EAGAIN can happen if we skipped followup SRST */
if (rc && rc != -EAGAIN)
goto fail;
} else { } else {
if (verbose) if (verbose)
ata_link_printk(link, KERN_INFO, "no reset method " ata_link_printk(link, KERN_INFO, "no reset method "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment