From: Tejun Heo <htejun@gmail.com>
To: jeff@garzik.org, mjg59@srcf.ucam.org, rdunlap@xenotime.net,
alan@lxorguk.ukuu.org.uk, forrest.zhao@gmail.com,
lenb@kernel.org, linux-acpi@vger.kernel.org, hare@suse.de,
linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 2/9] libata: during revalidation, check n_sectors after device is configured
Date: Tue, 15 May 2007 03:28:15 +0900 [thread overview]
Message-ID: <1179167295984-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11791672953697-git-send-email-htejun@gmail.com>
Device might be resized during ata_dev_configure() due to HPA or
(later) ACPI _GTF. Currently it's worked around by caching n_sectors
before turning off HPA. The cached original size is overwritten if
the device is reconfigured without being hardreset - which always
happens after configuring trasnfer mode. If the device gets hardreset
for some reason after that, revalidation fails with -ENODEV.
This patch makes size checking more robust by moving n_sectors check
from ata_dev_reread_id() to ata_dev_revalidate() after the device is
fully configured. No matter what happens during configuration, a
device must have the same n_sectors after fully configured to be
treated as the same device.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/ata/libata-core.c | 33 +++++++++++++++------------------
include/linux/libata.h | 1 -
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6f266c8..d5939e6 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1919,7 +1919,6 @@ int ata_dev_configure(struct ata_device *dev)
snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
dev->n_sectors = ata_id_n_sectors(id);
- dev->n_sectors_boot = dev->n_sectors;
/* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
@@ -3632,7 +3631,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
const u16 *old_id = dev->id;
unsigned char model[2][ATA_ID_PROD_LEN + 1];
unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
- u64 new_n_sectors;
if (dev->class != new_class) {
ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n",
@@ -3644,7 +3642,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
- new_n_sectors = ata_id_n_sectors(new_id);
if (strcmp(model[0], model[1])) {
ata_dev_printk(dev, KERN_INFO, "model number mismatch "
@@ -3658,19 +3655,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
return 0;
}
- if (dev->class == ATA_DEV_ATA && dev->n_sectors != new_n_sectors) {
- ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
- "%llu != %llu\n",
- (unsigned long long)dev->n_sectors,
- (unsigned long long)new_n_sectors);
- /* Are we the boot time size - if so we appear to be the
- same disk at this point and our HPA got reapplied */
- if (ata_ignore_hpa && dev->n_sectors_boot == new_n_sectors
- && ata_id_hpa_enabled(new_id))
- return 1;
- return 0;
- }
-
return 1;
}
@@ -3723,6 +3707,7 @@ int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags)
*/
int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
{
+ u64 n_sectors = dev->n_sectors;
int rc;
if (!ata_dev_enabled(dev))
@@ -3735,8 +3720,20 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
/* configure device according to the new ID */
rc = ata_dev_configure(dev);
- if (rc == 0)
- return 0;
+ if (rc)
+ goto fail;
+
+ /* verify n_sectors hasn't changed */
+ if (dev->class == ATA_DEV_ATA && dev->n_sectors != n_sectors) {
+ ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
+ "%llu != %llu\n",
+ (unsigned long long)n_sectors,
+ (unsigned long long)dev->n_sectors);
+ rc = -ENODEV;
+ goto fail;
+ }
+
+ return 0;
fail:
ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 27d9362..b38a0f9 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -431,7 +431,6 @@ struct ata_device {
struct scsi_device *sdev; /* attached SCSI device */
/* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
u64 n_sectors; /* size of device, if ATA */
- u64 n_sectors_boot; /* size of ATA device at startup */
unsigned int class; /* ATA_DEV_xxx */
u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
u8 pio_mode;
--
1.5.0.3
next prev parent reply other threads:[~2007-05-14 18:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-14 18:28 [PATCHSET] libata: improve ATA ACPI support, take#3 Tejun Heo
2007-05-14 18:28 ` [PATCH 1/9] libata: separate out ata_dev_reread_id() Tejun Heo
2007-05-16 5:21 ` Jeff Garzik
2007-05-14 18:28 ` Tejun Heo [this message]
2007-05-14 18:28 ` [PATCH 3/9] libata-acpi: add ATA_FLAG_ACPI_SATA port flag Tejun Heo
2007-05-14 18:28 ` [PATCH 9/9] libata-acpi: implement _GTM/_STM support Tejun Heo
2007-05-14 18:28 ` [PATCH 7/9] libata: reimplement ACPI invocation Tejun Heo
2007-05-14 18:28 ` [PATCH 6/9] libata-acpi: miscellaneous cleanups Tejun Heo
2007-05-14 18:28 ` [PATCH 5/9] libata-acpi: clean up ata_acpi_exec_tfs() Tejun Heo
2007-05-14 18:28 ` [PATCH 8/9] libata-acpi: remove redundant checks Tejun Heo
2007-05-14 18:28 ` [PATCH 4/9] libata-acpi: implement ata_acpi_associate() Tejun Heo
2007-05-25 2:50 ` Jeff Garzik
2007-05-14 18:47 ` [PATCHSET] libata: improve ATA ACPI support, take#3 Alan Cox
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=1179167295984-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=forrest.zhao@gmail.com \
--cc=hare@suse.de \
--cc=jeff@garzik.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=rdunlap@xenotime.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.