linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Mikko Rapeli <mikko.rapeli@iki.fi>, linux-ide@vger.kernel.org
Subject: Re: ST340823A disk size issue
Date: Fri, 3 Aug 2007 00:34:13 +0200	[thread overview]
Message-ID: <200708030034.13193.bzolnier@gmail.com> (raw)
In-Reply-To: <20070802214246.63a54fe6@the-village.bc.nu>


On Thursday 02 August 2007, Alan Cox wrote:
> > hdd: reading: block=78165360, sectors=1, buffer=0xc1e63000
> > hdd: dma_intr: status=0x51 { DriveReady SeekComplete Error }
> > hdd: dma_intr: error=0x10 { SectorIdNotFound }, LBAsect=78165360,
> 
> Ok this one does look like its actually a specific drive firmware error
> 
> > ide1: reset: master: error (0x00?)
> > ide1: start_request: current=0xc1e0b408
> 
> and the drive then shits itself in style. Bart's right - this drive does
> need a blacklisting. Presumably thats why it shipped with a default HPA
> to clip the non-sector 

Mikko, please verify that the following patch fixes the issue.

[PATCH] ide-disk: workaround for buggy HPA support on ST340823A (take 2)

This disk reports total number of sectors instead of maximum sector address
in response to READ_NATIVE_MAX_ADDRESS command and also happily accepts
SET_MAX_ADDRESS command with the bogus value.  This results in +1 sector
capacity being used and errors on attempts to use the last sector.

...
hdd: Host Protected Area detected.
        current capacity is 78165360 sectors (40020 MB)
        native  capacity is 78165361 sectors (40020 MB)
hdd: Host Protected Area disabled.
...
hdd: reading: block=78165360, sectors=1, buffer=0xc1e63000
hdd: dma_intr: status=0x51 { DriveReady SeekComplete Error }
hdd: dma_intr: error=0x10 { SectorIdNotFound }, LBAsect=78165360, sector=78165360
...

Add hpa_list[] table and workaround the issue in idedisk_check_hpa().

Fixes kernel bugzilla bug #8816.

Thanks to Mikko for investigating the issue and testing this patch.

v2:
* Add missing export and improve patch description a bit.

Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
This patch depends on CONFIG_BLK_DEV_IDEDMA=y but for testing purposes
it is OK.  Final version wouldn't depend on CONFIG_BLK_DEV_IDEDMA,
"[PATCH] ide: add cable detection for early UDMA66 devices (take 3)"
which is in IDE quilt tree moves ide_in_drive_list() out of ide-dma.c.

 drivers/ide/ide-disk.c |   17 +++++++++++++++++
 drivers/ide/ide-dma.c  |    2 ++
 2 files changed, 19 insertions(+)

Index: b/drivers/ide/ide-disk.c
===================================================================
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -481,6 +481,14 @@ static inline int idedisk_supports_lba48
 	       && id->lba_capacity_2;
 }
 
+/*
+ * Some disks report total number of sectors instead of
+ * maximum sector address.  We list them here.
+ */
+static const struct drive_list_entry hpa_list[] = {
+	{ "ST340823A",	NULL },
+};
+
 static void idedisk_check_hpa(ide_drive_t *drive)
 {
 	unsigned long long capacity, set_max;
@@ -492,6 +500,15 @@ static void idedisk_check_hpa(ide_drive_
 	else
 		set_max = idedisk_read_native_max_address(drive);
 
+	if (ide_in_drive_list(drive->id, hpa_list)) {
+		/*
+		 * Since we are inclusive wrt to firmware revisions do this
+		 * extra check and apply the workaround only when needed.
+		 */
+		if (set_max == capacity + 1)
+			set_max--;
+	}
+
 	if (set_max <= capacity)
 		return;
 
Index: b/drivers/ide/ide-dma.c
===================================================================
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -153,6 +153,8 @@ int ide_in_drive_list(struct hd_driveid 
 	return 0;
 }
 
+EXPORT_SYMBOL_GPL(ide_in_drive_list);
+
 /**
  *	ide_dma_intr	-	IDE DMA interrupt handler
  *	@drive: the drive the interrupt is for

  reply	other threads:[~2007-08-02 22:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-01  9:29 ST340823A disk size issue Mikko Rapeli
2007-08-01 13:05 ` Alan Cox
2007-08-02 12:35   ` Mikko Rapeli
2007-08-01 20:34 ` Bartlomiej Zolnierkiewicz
2007-08-01 21:50   ` Mikko Rapeli
2007-08-01 22:19     ` Bartlomiej Zolnierkiewicz
2007-08-01 22:32       ` Alan Cox
2007-08-01 23:17         ` Bartlomiej Zolnierkiewicz
2007-08-02 11:33           ` Alan Cox
2007-08-02 12:27             ` Bartlomiej Zolnierkiewicz
2007-08-02 13:09               ` Alan Cox
2007-08-02 20:03           ` Mikko Rapeli
2007-08-02 20:42             ` Alan Cox
2007-08-02 22:34               ` Bartlomiej Zolnierkiewicz [this message]
2007-08-02 23:11                 ` Mikko Rapeli
2007-08-02 23:35                   ` Bartlomiej Zolnierkiewicz
2007-08-05 19:06                     ` [PATCH] ST340823A, HPA and libata Mikko Rapeli
2007-08-05 19:32                       ` Alan Cox
2007-08-08 13:25                       ` Alan Cox
2007-08-15 13:56                         ` Mikko Rapeli
2007-09-20 21:37                         ` Jeff Garzik
2007-08-02  0:33       ` ST340823A disk size issue Bartlomiej Zolnierkiewicz
2007-08-02 12:17     ` Sergei Shtylyov
2007-08-02 12:38       ` Sergei Shtylyov
2007-08-01 22:25   ` 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=200708030034.13193.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-ide@vger.kernel.org \
    --cc=mikko.rapeli@iki.fi \
    /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).