From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, lkml@rtr.ca,
forrest.zhao@intel.com, linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 15/17] libata-link: update EH to deal with PMP links
Date: Sat, 8 Jul 2006 14:45:38 +0900 [thread overview]
Message-ID: <11523375383806-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11523375353473-git-send-email-htejun@gmail.com>
Update ata_eh_autopsy(), ata_eh_report() and ata_eh_recover() to deal
with PMP links. ata_eh_autopsy() and ata_eh_report() updates are
straightforward. They just repeat the same operation over all
configured links.
ata_eh_recover() update is more complex as it first processes all
resets and then performs the rest. This is necessary as thawing with
some links in unknown state can be dangerous. ehi->action is cleared
on successful recovery of a link to avoid repeating recovery due to
failures in other links.
ata_eh_recover() iterates over only PMP links if PMP is attached, and,
on failure, the failing link is returned in @failed_link instead of
disabling devices directly. These are to integrate ata_eh_recover()
into PMP EH later.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/scsi/libata-eh.c | 248 ++++++++++++++++++++++++++++++++--------------
1 files changed, 170 insertions(+), 78 deletions(-)
fe716b0b5e94af07f10f1d07397c5e7ebf4d4e5b
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 6c473af..1805769 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -1315,8 +1315,8 @@ static int ata_eh_speed_down(struct ata_
}
/**
- * ata_eh_autopsy - analyze error and determine recovery action
- * @link: ATA link to perform autopsy on
+ * ata_eh_link_autopsy - analyze error and determine recovery action
+ * @link: host link to perform autopsy on
*
* Analyze why @link failed and determine which recovery actions
* are needed. This function also sets more detailed AC_ERR_*
@@ -1325,7 +1325,7 @@ static int ata_eh_speed_down(struct ata_
* LOCKING:
* Kernel thread context (may sleep).
*/
-static void ata_eh_autopsy(struct ata_link *link)
+static void ata_eh_link_autopsy(struct ata_link *link)
{
struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context;
@@ -1418,7 +1418,25 @@ static void ata_eh_autopsy(struct ata_li
}
/**
- * ata_eh_report - report error handling to user
+ * ata_eh_autopsy - analyze error and determine recovery action
+ * @ap: host port to perform autopsy on
+ *
+ * Analyze all links of @ap and determine why they failed and
+ * which recovery actions are needed.
+ *
+ * LOCKING:
+ * Kernel thread context (may sleep).
+ */
+static void ata_eh_autopsy(struct ata_port *ap)
+{
+ struct ata_link *link;
+
+ __ata_port_for_each_link(link, ap)
+ ata_eh_link_autopsy(link);
+}
+
+/**
+ * ata_eh_link_report - report error handling to user
* @link: ATA link EH is going on
*
* Report EH to user.
@@ -1426,7 +1444,7 @@ static void ata_eh_autopsy(struct ata_li
* LOCKING:
* None.
*/
-static void ata_eh_report(struct ata_link *link)
+static void ata_eh_link_report(struct ata_link *link)
{
struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context;
@@ -1486,6 +1504,23 @@ static void ata_eh_report(struct ata_lin
}
}
+/**
+ * ata_eh_report - report error handling to user
+ * @ap: ATA port to report EH about
+ *
+ * Report EH to user.
+ *
+ * LOCKING:
+ * None.
+ */
+static void ata_eh_report(struct ata_port *ap)
+{
+ struct ata_link *link;
+
+ __ata_port_for_each_link(link, ap)
+ ata_eh_link_report(link);
+}
+
static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
unsigned int *classes)
{
@@ -1883,6 +1918,17 @@ static int ata_link_nr_enabled(struct at
return cnt;
}
+static int ata_port_nr_enabled(struct ata_port *ap)
+{
+ struct ata_link *link;
+ int cnt = 0;
+
+ ata_port_for_each_link(link, ap)
+ cnt += ata_link_nr_enabled(link);
+
+ return cnt;
+}
+
static int ata_link_nr_vacant(struct ata_link *link)
{
struct ata_device *dev;
@@ -1978,12 +2024,13 @@ static void ata_eh_handle_dev_fail(struc
* @softreset: softreset method (can be NULL)
* @hardreset: hardreset method (can be NULL)
* @postreset: postreset method (can be NULL)
+ * @r_failed_link: out parameter for failed link
*
* This is the alpha and omega, eum and yang, heart and soul of
* libata exception handling. On entry, actions required to
- * recover the port and hotplug requests are recorded in
- * eh_context. This function executes all the operations with
- * appropriate retrials and fallbacks to resurrect failed
+ * recover each link and hotplug requests are recorded in the
+ * link's eh_context. This function executes all the operations
+ * with appropriate retrials and fallbacks to resurrect failed
* devices, detach goners and greet newcomers.
*
* LOCKING:
@@ -1994,115 +2041,147 @@ static void ata_eh_handle_dev_fail(struc
*/
static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
- ata_postreset_fn_t postreset)
+ ata_postreset_fn_t postreset,
+ struct ata_link **r_failed_link)
{
- struct ata_link *link = &ap->link;
- struct ata_eh_context *ehc = &link->eh_context;
+ struct ata_link *link;
struct ata_device *dev;
- int down_xfermask, rc;
+ int nr_failed_devs;
+ int reset, rc;
DPRINTK("ENTER\n");
/* prep for recovery */
- ata_link_for_each_dev(dev, link) {
- ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
+ ata_port_for_each_link(link, ap) {
+ struct ata_eh_context *ehc = &link->eh_context;
- /* process hotplug request */
- if (dev->flags & ATA_DFLAG_DETACH)
- ata_eh_detach_dev(dev);
+ ata_link_for_each_dev(dev, link) {
+ ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
- if (!ata_dev_enabled(dev) &&
- ((ehc->i.probe_mask & (1 << dev->devno)) &&
- !(ehc->did_probe_mask & (1 << dev->devno)))) {
- ata_eh_detach_dev(dev);
- ata_dev_init(dev);
- ehc->did_probe_mask |= (1 << dev->devno);
- ehc->i.action |= ATA_EH_SOFTRESET;
+ /* process hotplug request */
+ if (dev->flags & ATA_DFLAG_DETACH)
+ ata_eh_detach_dev(dev);
+
+ if (!ata_dev_enabled(dev) &&
+ (ehc->i.probe_mask & (1 << dev->devno) &&
+ !(ehc->did_probe_mask & (1 << dev->devno)))) {
+ ata_eh_detach_dev(dev);
+ ata_dev_init(dev);
+ ehc->did_probe_mask |= (1 << dev->devno);
+ ehc->i.action |= ATA_EH_SOFTRESET;
+ }
}
}
retry:
- down_xfermask = 0;
rc = 0;
+ nr_failed_devs = 0;
+ reset = 0;
/* if UNLOADING, finish immediately */
if (ap->pflags & ATA_PFLAG_UNLOADING)
goto out;
- /* prep for resume */
- ata_eh_prep_resume(link);
+ /* prep for EH */
+ ata_port_for_each_link(link, ap) {
+ struct ata_eh_context *ehc = &link->eh_context;
- /* skip EH if possible. */
- if (ata_eh_skip_recovery(link))
- ehc->i.action = 0;
+ /* prep for resume */
+ ata_eh_prep_resume(link);
- ata_link_for_each_dev(dev, link)
- ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
+ /* skip EH if possible. */
+ if (ata_eh_skip_recovery(link))
+ ehc->i.action = 0;
+
+ /* do we need to reset? */
+ if (ehc->i.action & ATA_EH_RESET_MASK)
+ reset = 1;
+
+ ata_link_for_each_dev(dev, link)
+ ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
+ }
/* reset */
- if (ehc->i.action & ATA_EH_RESET_MASK) {
+ if (reset) {
ata_eh_freeze_port(ap);
- rc = ata_eh_reset(link, ata_link_nr_vacant(link), prereset,
- softreset, hardreset, postreset);
- if (rc) {
- ata_link_printk(link, KERN_ERR,
- "reset failed, giving up\n");
- goto out;
+ ata_port_for_each_link(link, ap) {
+ struct ata_eh_context *ehc = &link->eh_context;
+
+ if (!(ehc->i.action & ATA_EH_RESET_MASK))
+ continue;
+
+ rc = ata_eh_reset(link, ata_link_nr_vacant(link),
+ prereset, softreset, hardreset,
+ postreset);
+ if (rc) {
+ ata_link_printk(link, KERN_ERR,
+ "reset failed, giving up\n");
+ goto out;
+ }
}
ata_eh_thaw_port(ap);
}
- /* revalidate existing devices and attach new ones */
- rc = ata_eh_revalidate_and_attach(link, &dev);
- if (rc)
- goto dev_fail;
+ /* the rest */
+ ata_port_for_each_link(link, ap) {
+ struct ata_eh_context *ehc = &link->eh_context;
+ int down_xfermask = 0;
- /* resume devices */
- rc = ata_eh_resume(link, &dev);
- if (rc)
- goto dev_fail;
+ /* revalidate existing devices and attach new ones */
+ rc = ata_eh_revalidate_and_attach(link, &dev);
+ if (rc)
+ goto dev_fail;
- /* configure transfer mode if the port has been reset */
- if (ehc->i.flags & ATA_EHI_DID_RESET) {
- rc = ata_set_mode(link, &dev);
- if (rc) {
- down_xfermask = 1;
+ /* resume devices */
+ rc = ata_eh_resume(link, &dev);
+ if (rc)
goto dev_fail;
+
+ /* configure transfer mode if the port has been reset */
+ if (ehc->i.flags & ATA_EHI_DID_RESET) {
+ rc = ata_set_mode(link, &dev);
+ if (rc) {
+ down_xfermask = 1;
+ goto dev_fail;
+ }
}
- }
- /* suspend devices */
- rc = ata_eh_suspend(link, &dev);
- if (rc)
- goto dev_fail;
+ /* suspend devices */
+ rc = ata_eh_suspend(link, &dev);
+ if (rc)
+ goto dev_fail;
- goto out;
+ /* this link is okay now */
+ ehc->i.flags &= ~ATA_EHI_DID_RESET;
+ continue;
- dev_fail:
- ata_eh_handle_dev_fail(dev, rc, down_xfermask);
+ dev_fail:
+ ata_eh_handle_dev_fail(dev, rc, down_xfermask);
+ nr_failed_devs++;
- if (ata_link_nr_enabled(link)) {
- ata_link_printk(link, KERN_WARNING, "failed to recover some "
- "devices, retrying in 5 secs\n");
- ssleep(5);
- } else {
- /* no device left, repeat fast */
- msleep(500);
+ if (ap->pflags & ATA_PFLAG_FROZEN)
+ break;
}
- goto retry;
-
- out:
- if (rc) {
- /* recovery failed, activate hp-poll */
- ata_hp_poll_activate(ap);
+ if (nr_failed_devs) {
+ if (ata_port_nr_enabled(ap)) {
+ ata_port_printk(ap, KERN_WARNING, "failed to recover "
+ "some devices, retrying in 5 secs\n");
+ ssleep(5);
+ } else {
+ /* no device left, repeat fast */
+ msleep(500);
+ }
- ata_link_for_each_dev(dev, link);
- ata_dev_disable(dev);
+ goto retry;
}
+ out:
+ if (rc && r_failed_link)
+ *r_failed_link = link;
+
DPRINTK("EXIT, rc=%d\n", rc);
return rc;
}
@@ -2166,9 +2245,22 @@ void ata_do_eh(struct ata_port *ap, ata_
ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
ata_postreset_fn_t postreset)
{
- ata_eh_autopsy(&ap->link);
- ata_eh_report(&ap->link);
- ata_eh_recover(ap, prereset, softreset, hardreset, postreset);
+ struct ata_device *dev;
+ int rc;
+
+ ata_eh_autopsy(ap);
+ ata_eh_report(ap);
+
+ rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset,
+ NULL);
+ if (rc) {
+ /* recovery failed, activate hp-poll */
+ ata_hp_poll_activate(ap);
+
+ ata_link_for_each_dev(dev, &ap->link)
+ ata_dev_disable(dev);
+ }
+
ata_eh_finish(ap);
}
--
1.3.2
prev parent reply other threads:[~2006-07-08 5:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-08 5:45 [PATCHSET 1/3] implement ata_link, take 2 Tejun Heo
2006-07-08 5:45 ` [PATCH 01/17] libata-link: separate out ata_eh_handle_dev_fail() Tejun Heo
2006-07-08 5:45 ` [PATCH 02/17] libata-link: add PMP related ATA constants Tejun Heo
2006-07-19 20:24 ` Jeff Garzik
2006-07-08 5:45 ` [PATCH 03/17] libata-link: introduce ata_link Tejun Heo
2006-07-19 20:26 ` Jeff Garzik
2006-07-24 6:19 ` Tejun Heo
2006-07-08 5:45 ` [PATCH 05/17] libata-link: linkify PHY-related functions Tejun Heo
2006-07-08 5:45 ` [PATCH 08/17] libata-link: linkify config/EH related functions Tejun Heo
2006-07-08 5:45 ` [PATCH 04/17] libata-link: implement and use link/device iterators Tejun Heo
2006-07-08 5:45 ` [PATCH 07/17] libata-link: linkify reset Tejun Heo
2006-07-08 5:45 ` [PATCH 06/17] libata-link: linkify EH action helpers Tejun Heo
2006-07-08 5:45 ` [PATCH 10/17] libata-link: implement link->reset_tries Tejun Heo
2006-07-08 5:45 ` [PATCH 13/17] libata-link: update ata_scsi_error() to handle PMP links Tejun Heo
2006-07-08 5:45 ` [PATCH 11/17] libata-link: implement ata_link_abort() Tejun Heo
2006-07-08 5:45 ` [PATCH 09/17] libata-link: separate out link initialization functions Tejun Heo
2006-07-08 5:45 ` [PATCH 12/17] libata-link: add PMP links Tejun Heo
2006-07-08 5:45 ` [PATCH 14/17] libata-link: update ata_dev_configure() to deal with " Tejun Heo
2006-07-08 5:45 ` [PATCH 17/17] libata-link: update Power Management to handle " Tejun Heo
2006-07-19 20:29 ` Jeff Garzik
2006-07-08 5:45 ` [PATCH 16/17] libata-link: update hotplug " Tejun Heo
2006-07-08 5:45 ` Tejun Heo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11523375383806-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=forrest.zhao@intel.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=lkml@rtr.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).