From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, axboe@suse.de,
albertcc@tw.ibm.com, forrest.zhao@intel.com, efalk@google.com,
linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 1/7] libata-pm-prep: add @new_class to ata_dev_revalidate()
Date: Fri, 12 May 2006 01:37:50 +0900 [thread overview]
Message-ID: <11473654703989-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11473654703440-git-send-email-htejun@gmail.com>
Consider newly found class code while revalidating. PM resetting
always results in valid class code and issuing PM commands to
ATA/ATAPI devices isn't a very attractive idea. Add @new_class to
ata_dev_revalidate() and check class during revalidation.
---
drivers/scsi/libata-core.c | 20 +++++++++++++++-----
drivers/scsi/libata-eh.c | 2 +-
include/linux/libata.h | 3 ++-
3 files changed, 18 insertions(+), 7 deletions(-)
e9ad06f7ef8413f1027baad8b64bc860b85fa85e
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 32ea394..71f9ea7 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -2052,7 +2052,7 @@ static int ata_dev_set_mode(struct ata_d
return -EIO;
}
- rc = ata_dev_revalidate(dev, 0);
+ rc = ata_dev_revalidate(dev, ATA_DEV_UNKNOWN, 0);
if (rc)
return rc;
@@ -2813,6 +2813,7 @@ static int ata_dev_same_device(struct at
/**
* ata_dev_revalidate - Revalidate ATA device
* @dev: device to revalidate
+ * @new_class: new class code
* @post_reset: is this revalidation after reset?
*
* Re-read IDENTIFY page and make sure @dev is still attached to
@@ -2824,9 +2825,9 @@ static int ata_dev_same_device(struct at
* RETURNS:
* 0 on success, negative errno otherwise
*/
-int ata_dev_revalidate(struct ata_device *dev, int post_reset)
+int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
+ int post_reset)
{
- unsigned int class = dev->class;
u16 *id = (void *)dev->link->ap->sector_buf;
int rc;
@@ -2835,13 +2836,22 @@ int ata_dev_revalidate(struct ata_device
goto fail;
}
+ if (ata_class_enabled(new_class)) {
+ /* sometimes wrong class is reported, let it retry */
+ if (new_class != ATA_DEV_ATA && new_class != ATA_DEV_ATAPI) {
+ rc = -EIO;
+ goto fail;
+ }
+ } else
+ new_class = dev->class;
+
/* read ID data */
- rc = ata_dev_read_id(dev, &class, post_reset, id);
+ rc = ata_dev_read_id(dev, &new_class, post_reset, id);
if (rc)
goto fail;
/* is the device still there? */
- if (!ata_dev_same_device(dev, class, id)) {
+ if (!ata_dev_same_device(dev, new_class, id)) {
rc = -ENODEV;
goto fail;
}
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index ecfb9c5..7abeb11 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -1570,7 +1570,7 @@ static int ata_eh_revalidate_and_attach(
}
ata_eh_about_to_do(link, ATA_EH_REVALIDATE);
- rc = ata_dev_revalidate(dev,
+ rc = ata_dev_revalidate(dev, ehc->classes[dev->devno],
ehc->flags & ATA_EHC_DID_RESET);
if (rc)
break;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 7db9b80..1fec322 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -633,7 +633,8 @@ extern int ata_std_prereset(struct ata_l
extern int ata_std_softreset(struct ata_link *link, unsigned int *classes);
extern int sata_std_hardreset(struct ata_link *link, unsigned int *class);
extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
-extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
+extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
+ int post_reset);
extern void ata_port_disable(struct ata_port *);
extern void ata_std_ports(struct ata_ioports *ioaddr);
#ifdef CONFIG_PCI
--
1.2.4
next prev parent reply other threads:[~2006-05-11 16:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-11 16:37 [PATCHSET 10/11] prep for PM support Tejun Heo
2006-05-11 16:37 ` [PATCH 4/7] libata-pm-prep: add @is_cmd to ata_tf_to_fis() Tejun Heo
2006-05-11 16:37 ` Tejun Heo [this message]
2006-05-11 16:37 ` [PATCH 2/7] libata-pm-prep: make a number of functions global to libata Tejun Heo
2006-05-11 16:37 ` [PATCH 3/7] libata-pm-prep: separate out sata_link_hardreset() Tejun Heo
2006-05-11 16:37 ` [PATCH 5/7] libata-pm-prep: implement ops->qc_defer() Tejun Heo
2006-05-11 16:37 ` [PATCH 7/7] libata-pm-prep: add HRST_TO_RESUME and implement resume action helpers Tejun Heo
2006-05-11 16:37 ` [PATCH 6/7] libata-pm-prep: implement qc_defer helpers Tejun Heo
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=11473654703989-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=albertcc@tw.ibm.com \
--cc=axboe@suse.de \
--cc=efalk@google.com \
--cc=forrest.zhao@intel.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).