From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, albertcc@tw.ibm.com,
linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 6/7] libata: improve ata_bus_probe()
Date: Sun, 2 Apr 2006 17:54:46 +0900 [thread overview]
Message-ID: <11439680863401-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11439680863256-git-send-email-htejun@gmail.com>
Improve ata_bus_probe() such that configuration failures are handled
better. Each device is given ATA_PROBE_MAX_TRIES chances, but any
non-transient error (revalidation failure with -ENODEV, configuration
failure with -EINVAL...) disables the device directly. Any IO error
results in SATA PHY speed down and ata_set_mode() failure lowers
transfer mode. The last try always puts a device into PIO-0.
After each failure, the whole port is reset to make sure that the
controller and all the devices are in a known and stable state. The
reset also applies SATA SPD configuration if necessary.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/scsi/libata-core.c | 65 +++++++++++++++++++++++++++++++++-----------
include/linux/libata.h | 3 ++
2 files changed, 52 insertions(+), 16 deletions(-)
5dfcc0a5314aa0524b389503fe12a7ee4446ea99
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 42a3147..1460cb3 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1370,11 +1370,18 @@ err_out_nosup:
static int ata_bus_probe(struct ata_port *ap)
{
unsigned int classes[ATA_MAX_DEVICES];
- int i, rc, found = 0;
+ int tries[ATA_MAX_DEVICES];
+ int i, rc, down_xfermask;
struct ata_device *dev;
ata_port_probe(ap);
+ for (i = 0; i < ATA_MAX_DEVICES; i++)
+ tries[i] = ATA_PROBE_MAX_TRIES;
+
+ retry:
+ down_xfermask = 0;
+
/* reset and determine device classes */
for (i = 0; i < ATA_MAX_DEVICES; i++)
classes[i] = ATA_DEV_UNKNOWN;
@@ -1404,21 +1411,23 @@ static int ata_bus_probe(struct ata_port
dev = &ap->device[i];
dev->class = classes[i];
- if (!ata_dev_enabled(dev))
- continue;
-
- WARN_ON(dev->id != NULL);
- if (ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id)) {
- dev->class = ATA_DEV_NONE;
- continue;
+ if (!tries[i]) {
+ ata_down_xfermask_limit(ap, dev, 1);
+ ata_dev_disable(ap, dev);
}
- if (ata_dev_configure(ap, dev, 1)) {
- ata_dev_disable(ap, dev);
+ if (!ata_dev_enabled(dev))
continue;
- }
- found = 1;
+ kfree(dev->id);
+ dev->id = NULL;
+ rc = ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id);
+ if (rc)
+ goto fail;
+
+ rc = ata_dev_configure(ap, dev, 1);
+ if (rc)
+ goto fail;
}
/* configure transfer mode */
@@ -1427,12 +1436,18 @@ static int ata_bus_probe(struct ata_port
* return error code and failing device on failure as
* ata_set_mode() does.
*/
- if (found)
- ap->ops->set_mode(ap);
+ for (i = 0; i < ATA_MAX_DEVICES; i++)
+ if (ata_dev_enabled(&ap->device[i])) {
+ ap->ops->set_mode(ap);
+ break;
+ }
rc = 0;
} else {
- while (ata_set_mode(ap, &dev))
- ata_dev_disable(ap, dev);
+ rc = ata_set_mode(ap, &dev);
+ if (rc) {
+ down_xfermask = 1;
+ goto fail;
+ }
}
for (i = 0; i < ATA_MAX_DEVICES; i++)
@@ -1443,6 +1458,24 @@ static int ata_bus_probe(struct ata_port
ata_port_disable(ap);
ap->ops->port_disable(ap);
return -ENODEV;
+
+ fail:
+ switch (rc) {
+ case -EINVAL:
+ case -ENODEV:
+ tries[dev->devno] = 0;
+ break;
+ case -EIO:
+ ata_down_sata_spd_limit(ap);
+ /* fall through */
+ default:
+ tries[dev->devno]--;
+ if (down_xfermask &&
+ ata_down_xfermask_limit(ap, dev, tries[dev->devno] == 1))
+ tries[dev->devno] = 0;
+ }
+
+ goto retry;
}
/**
diff --git a/include/linux/libata.h b/include/linux/libata.h
index a5207e6..a4a1e63 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -211,6 +211,9 @@ enum {
/* Masks for port functions */
ATA_PORT_PRIMARY = (1 << 0),
ATA_PORT_SECONDARY = (1 << 1),
+
+ /* how hard are we gonna try to probe/recover devices */
+ ATA_PROBE_MAX_TRIES = 3,
};
enum hsm_task_states {
--
1.2.4
next prev parent reply other threads:[~2006-04-02 8:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-02 8:54 [PATCHSET] libata: improve ata_bus_probe failure handling, take 2 Tejun Heo
2006-04-02 8:54 ` Tejun Heo [this message]
2006-04-02 10:47 ` [PATCH 6/7] libata: improve ata_bus_probe() Jeff Garzik
2006-04-02 8:54 ` [PATCH 4/7] libata: add 5s sleep between resets Tejun Heo
2006-04-02 11:55 ` Tejun Heo
2006-04-02 8:54 ` [PATCH 3/7] libata: use SATA speed down in ata_drive_probe_reset() Tejun Heo
2006-04-02 8:54 ` [PATCH 1/7] libata: implement ata_dev_absent() Tejun Heo
2006-04-02 8:54 ` [PATCH 5/7] libata: implement ata_down_xfermask_limit() Tejun Heo
2006-04-02 8:54 ` [PATCH 2/7] libata: implement ap->sata_spd_limit and helpers Tejun Heo
2006-04-02 10:43 ` Jeff Garzik
2006-04-02 11:04 ` Tejun Heo
2006-04-02 11:18 ` Jeff Garzik
2006-04-02 11:53 ` Tejun Heo
2006-04-02 8:54 ` [PATCH 7/7] libata: consider disabled devices in ata_dev_xfermask() Tejun Heo
2006-04-02 14:35 ` [PATCHSET] libata: improve ata_bus_probe failure handling, take 2 Jeff Garzik
2006-04-03 9:37 ` Albert Lee
2006-04-03 10:38 ` Jeff Garzik
2006-04-03 14:37 ` Greg Freemyer
2006-04-03 16:20 ` Jeff Garzik
2006-04-04 13:02 ` Greg Freemyer
2006-04-04 13:11 ` Jeff Garzik
2006-04-04 5:02 ` Albert Lee
2006-04-03 9:43 ` [PATCH] libata-dev: irq-pio minor fix Albert Lee
2006-04-04 12:42 ` Jeff Garzik
2006-04-03 10:31 ` [PATCH] libata-dev: irq-pio minor fix 2 Albert Lee
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=11439680863401-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=albertcc@tw.ibm.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/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).