2002-10-17 08:53:29

by James Finnie

[permalink] [raw]
Subject: [PATCH]: Sanity checking for drives that claim to be LBA-48, but aren't!

Hi guys,

I had previously posted about a relatively new Seagate drive that had worked
prior to 2.4.19, but in 2.4.19 failed to identify it's geometry properly.

http://marc.theaimsgroup.com/?l=linux-kernel&m=103253071519548&w=2

Upon investigation of this with Seagate, it turns out that the firmware
version in question is for CE (consumer electronics) use. They have used
bit 10 of word 86 (0x56) of the IDENTIFY DEVICE information to indicate some
feature in their "AV streaming data transfer set". This breaks ATA-7, which
says this bit indicates that the drive understands LBA-48 commands.

The kernel sees this bit set, tries to use LBA-48 commands, and the drive
errors, complaining that it doesn't understand! Meaning this drive is
unusable with the >=2.4.19 kernels. I think at least one other person has
reported something very similar, IIRC with a very old Maxtor IDE drive.

Here is a patch that does some basic sanity checking. If the drive has an
lba_capacity_2==0, and has the bit set claiming to be LBA-48, it ignores
this claim.

I think this should go into the kernel, but I don't have any LBA-48 kit to
check that I'm not breaking things for other people. Hope this helps anyone
else scratching their heads with drives that used to work.


James Finnie


Standard disclaimer: it works for me, use at your own risk.

--BEGIN PATCH

diff -Naur linux-2.4.19/drivers/ide/ide-disk.c
linux-2.4.19-lba48sanity/drivers/ide/ide-disk.c
--- linux-2.4.19/drivers/ide/ide-disk.c Sat Aug 3 01:39:44 2002
+++ linux-2.4.19-lba48sanity/drivers/ide/ide-disk.c Thu Oct 17 09:51:10
2002
@@ -924,6 +924,15 @@
unsigned long long capacity_2 = capacity;
unsigned long long set_max_ext;

+ // if the disk claims to be LBA-48, and yet has a capacity of 0,
+ // it's fairly safe to say that the firmware doesn't comply with
ATA-7
+ if ((id->cfs_enable_2 & 0x0400) && (id->lba_capacity_2==0)) {
+ printk ("%s: Broken firmware - this is NOT an LBA-48
drive!\n",drive->name);
+ printk ("%s: Disabling LBA-48 addressing for this
drive\n",drive->name);
+ //reset bit 10 so that we can use the disk in a non LBA-48
fashion
+ id->cfs_enable_2 &= ~ 0x0400;
+ }
+
drive->capacity48 = 0;
drive->select.b.lba = 0;

--END PATCH





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imerge Limited Tel :- +44 (0)1954 783600
Unit 6 Bar Hill Business Park Fax :- +44 (0)1954 783601
Saxon Way Web :- http://www.imerge.co.uk
Bar Hill
Cambridge
CB3 8SL
United Kingdom
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



2002-10-17 09:31:03

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH]: Sanity checking for drives that claim to be LBA-48, but aren't!

James Finnie <[email protected]> writes:

> The kernel sees this bit set, tries to use LBA-48 commands, and the drive
> errors, complaining that it doesn't understand! Meaning this drive is
> unusable with the >=2.4.19 kernels. I think at least one other person has
> reported something very similar, IIRC with a very old Maxtor IDE drive.
>
> Here is a patch that does some basic sanity checking. If the drive has an
> lba_capacity_2==0, and has the bit set claiming to be LBA-48, it ignores
> this claim.
>
There are also a set of bits that reports which revs of the ATA standard
a drive complies with. Should we check that one as well?

Eric

2002-10-17 09:53:47

by James Finnie

[permalink] [raw]
Subject: RE: [PATCH]: Sanity checking for drives that claim to be LBA-48, but aren't!


> There are also a set of bits that reports which revs of the
> ATA standard
> a drive complies with. Should we check that one as well?
>
> Eric
>

Knowing my luck, those bits are probably broken on my drives too :)

Sounds like common sense though. I don't pretend to know enough about how
the IDE driver works in order fix it... Andre? :)


James


Oh, appologies to everyone for the line-wrapped patch, M$Exchange has *LOTS*
to answer for. If you want the patch without line-wraps, email me and I'll
send it as an attachment. Didn't want to polute the list.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imerge Limited Tel :- +44 (0)1954 783600
Unit 6 Bar Hill Business Park Fax :- +44 (0)1954 783601
Saxon Way Web :- http://www.imerge.co.uk
Bar Hill
Cambridge
CB3 8SL
United Kingdom
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


2002-10-17 10:20:42

by Andries Brouwer

[permalink] [raw]
Subject: Re: [PATCH]: Sanity checking for drives that claim to be LBA-48, but aren't!

On Thu, Oct 17, 2002 at 10:02:00AM +0100, James Finnie wrote:

> Upon investigation of this with Seagate, it turns out that the firmware
> version in question is for CE (consumer electronics) use. They have used
> bit 10 of word 86 (0x56) of the IDENTIFY DEVICE information to indicate some
> feature in their "AV streaming data transfer set". This breaks ATA-7, which
> says this bit indicates that the drive understands LBA-48 commands.
>
> The kernel sees this bit set, tries to use LBA-48 commands, and the drive
> errors, complaining that it doesn't understand! Meaning this drive is
> unusable with the >=2.4.19 kernels. I think at least one other person has
> reported something very similar, IIRC with a very old Maxtor IDE drive.

Could you post the identify data for your disks? (cat /proc/ide/*/identify)

Andries