linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: William Thompson <wt@electro-mechanical.com>,
	Jeff Garzik <jgarzik@pobox.com>
Cc: Mark Lord <liml@rtr.ca>,
	linux-kernel@vger.kernel.org,
	IDE/ATA development list <linux-ide@vger.kernel.org>,
	albertcc@tw.ibm.com
Subject: [PATCH] libata: fallback to the other IDENTIFY on device error
Date: Mon, 07 May 2007 18:42:26 +0200	[thread overview]
Message-ID: <463F56F2.3010106@gmail.com> (raw)
In-Reply-To: <20070501172117.GA20328@electro-mechanical.com>

It seems the world isn't as frank as we thought and some devices lie
about who they are.  Fallback to the other IDENTIFY if IDENTIFY fails
with device error.  As this is the strategy used by IDE for a long
time, it shouldn't cause too much problem.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: William Thompson <wt@electro-mechanical.com>
---
Willam, please verify this fixes your problem.  Jeff, after all, we
seem to need this.  :-(

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ca67484..f543109 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1652,7 +1652,7 @@ int ata_dev_read_id(struct ata_device *d
 	struct ata_taskfile tf;
 	unsigned int err_mask = 0;
 	const char *reason;
-	int tried_spinup = 0;
+	int may_fallback = 1, tried_spinup = 0;
 	int rc;
 
 	if (ata_msg_ctl(ap))
@@ -1696,11 +1696,30 @@ int ata_dev_read_id(struct ata_device *d
 			return -ENOENT;
 		}
 
+		if (may_fallback && (err_mask == AC_ERR_DEV)) {
+			may_fallback = 0;
+
+			/* Device or controller might have reported
+			 * the wrong device class.  Give a shot at then
+			 * other IDENTIFY
+			 */
+			if (class == ATA_DEV_ATA)
+				class = ATA_DEV_ATAPI;
+			else
+				class = ATA_DEV_ATA;
+			goto retry;
+		}
+
 		rc = -EIO;
 		reason = "I/O error";
 		goto err_out;
 	}
 
+	/* Falling back doesn't make sense if ID data was read
+	 * successfully at least once.
+	 */
+	may_fallback = 0;
+
 	swap_buf_le16(id, ATA_ID_WORDS);
 
 	/* sanity check */

  reply	other threads:[~2007-05-07 16:42 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070427175205.GD7809@electro-mechanical.com>
     [not found] ` <4635C35D.1020807@gmail.com>
     [not found]   ` <20070430202107.GF5942@electro-mechanical.com>
2007-05-01  4:32     ` 2.6.20 libata cdrom Tejun Heo
2007-05-01 12:17       ` William Thompson
2007-05-01 13:04         ` Mark Lord
2007-05-01 13:18           ` William Thompson
2007-05-01 13:24             ` Mark Lord
2007-05-01 13:36               ` Alan Cox
2007-05-01 13:40             ` Tejun Heo
2007-05-01 13:51               ` Mark Lord
2007-05-01 14:19                 ` Jeff Garzik
2007-05-01 14:23                   ` Mark Lord
2007-05-01 14:28                   ` Alan Cox
2007-05-01 17:21               ` William Thompson
2007-05-07 16:42                 ` Tejun Heo [this message]
2007-05-07 18:05                   ` [PATCH] libata: fallback to the other IDENTIFY on device error William Thompson
2007-05-08  8:02                     ` Tejun Heo
2007-05-10  0:08                   ` Jeff Garzik
2007-05-11 12:35                     ` [PATCH] libata: fallback to the other IDENTIFY on device error, take#2 Tejun Heo
2007-05-11 22:10                       ` Jeff Garzik
2007-05-11 22:10                       ` Jeff Garzik
2007-05-13 12:57                         ` Tejun Heo
2007-05-13 16:13                           ` Dave Jones
2007-05-13 17:50                             ` Tejun Heo
2007-05-13 18:13                               ` Dave Jones
2007-05-01 18:11             ` 2.6.20 libata cdrom Bartlomiej Zolnierkiewicz
2007-05-01 12:54       ` Mark Lord
2007-05-01 12:55         ` Mark Lord
2007-05-01 13:32           ` Tejun Heo
2007-05-01 13:41             ` Mark Lord

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=463F56F2.3010106@gmail.com \
    --to=htejun@gmail.com \
    --cc=albertcc@tw.ibm.com \
    --cc=jgarzik@pobox.com \
    --cc=liml@rtr.ca \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wt@electro-mechanical.com \
    /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).