[PATCH] Re: 2.2.0pre5/6 IDE disk geometry detection problem

Andries.Brouwer@cwi.nl
Tue, 12 Jan 1999 20:53:53 +0100 (MET)


From msiladin@athos.mas.vcu.edu Tue Jan 12 17:09:48 1999

>
> From: marko@207-172-63-169.s169.tnt3.rcm.erols.com (Marko Siladin)
>
> in 2.1.131 cat /proc/ide/hda/geometry results in:
> physical 4092/16/63
> logical 847/128/63
>
> in 2.2.0 pre5/6 I get :
> physical 4092/16/63
> logical 511/128/63
>
> the actual physical geometry of the disk is 6780/16/63
> so both kernels get that one wrng - but at least the 2.1.131
> get the logical correctly (from the BIOS)
>
> Hmm. Such things can happen. For example, I could imagine
> that the BIOS has 847/128/63, CurCHS has 4092/16/63,
> and RawCHS and LBAsects have certain suitable values
> such that the end result is as you describe above.
> Still I would be interested in the results of hdparm -i /dev/hda
> and hdparm -I /dev/hda both for 2.1.131 and for 2.2.0 pre5/6.
>
> Andries - aeb@cwi.nl

zaphod# hdparm -i /dev/hda

/dev/hda:

Model=FUJITSU MPA3035ATU, FwRev=9517, SerialNo=01113969
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=4092/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=0(?), BuffSize=0kB, MaxMultSect=32, MultSect=32
DblWordIO=no, maxPIO=2(fast), DMA=yes, maxDMA=0(slow)
CurCHS=4092/16/63, CurSects=4124736, LBA=yes, LBAsects=4124736
tDMA={min:120,rec:120}, DMA modes: mword0 mword1 *mword2
IORDY=yes, tPIO={min:240,w/IORDY:120}, PIO modes: mode3 mode4

It looks like the results of the hdparm are the same.

(Except for CurCHS.)

My guess is that 2.1.131 get the logical params from the BIOS
and 2.2.0pre5/6 calculates them from the physical ones.
I'll try to set the geometry manually tonight.

Your guess is close to the truth. But reading the code is easier
than experimenting.

It is a funny disk. Fujitsu model numbers have the size in the last
three digits, so a FUJITSU MPA3035ATU is a 3.5 GB disk, which agrees
with your claim that it has 6780 cylinders (6780*16*63*512=3499130880).
However, RawCHS and CurCHS and LBAsects and CurSects all say that the
disk has 4092*16*63=4124736 sectors. Strange..

Anyway, this gives me the opportunity to change a strange line
in the ide-disk.c source:

--- ide-disk.c~ Thu Jan 7 21:15:02 1999
+++ ide-disk.c Tue Jan 12 20:21:41 1999
@@ -742,8 +742,8 @@
* if possible, give fdisk access to more of the drive,
* by correcting bios_cyls:
*/
- if ((capacity >= (id->cyls * id->heads * id->sectors)) &&
- (!drive->forced_geom)) {
+ if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) &&
+ (!drive->forced_geom) && drive->bios_sect && drive->bios_head) {
drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head;
#ifdef DEBUG
printk("Fixing Geometry :: CHS=%d/%d/%d to CHS=%d/%d/%d\n",

Andries

[Of course the DEBUG part can also be deleted, since we have
all information that is printed by it, and the lines like
drive->id->cur_cyls = drive->bios_cyl;
should also be deleted everywhere. After all, the idea of the
HDIO_GET_IDENTITY ioctl is to tell the users what the disk
hardware replied to the IDENTIFY DRIVE command. This is read-only
information that we should not fiddle with. But the above patch
is the minimal one that fixes the problem, if I am not mistaken.]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/