[PATCH] - was: Re: Cylinder limits ...

From: Andries.Brouwer@cwi.nl
Date: Mon Apr 03 2000 - 14:28:39 EST


    From: "John Anthony Kazos Jr." <jkazos@vt.edu>
    Subject: New Information -- Re: Answer (Re: Cylinder limits jumper ...)

    I have a Maxtor 40G (54098U8) and an M748LMRT mainboard.
    My BIOS locks up on autodetecting the drive. ...
    I boot into Linux and it recognizes that it is over 32G.
    However, I can't get the full capacity. I run fdisk and it gives the
    drive 4982/255/63 (about 38G). If I increase the cylinder count to the
    appropriate drive size, I get buku sector-not-found errors on mk32fs.

Of course. All is perfectly allright, and the drive really is 4982/255/63.
The cause of your confusion is that the boot messages give the size
in mebibytes (binary megabytes) instead of megabytes like the disk
manufacturers and fdisk and cfdisk and sfdisk do.

    So, obviously, Linux appropriately is ignoring what the BIOS says,
    but it still is not doing it correctly.

Let me add a patch to eliminate this mebibyte problem. Too many
people stumble over it. And now that I have this fragment of code
in front of me: another tiny problem is the Linux message "w/0kB Cache".
This field is optional in the ATA spec, and many disks do not specify
a buffer size, but many people worry that their disk is broken when
"Linux says it has no cache".

Linus, please find a patch below.

Andries

--- linux-2.3.99p3/linux/drivers/ide/ide-disk.c Sun Mar 26 13:06:12 2000
+++ ./ide-disk.c Mon Apr 3 20:01:28 2000
@@ -813,14 +813,18 @@
             (!drive->forced_geom) && drive->bios_sect && drive->bios_head)
                 drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head;
 
-#if 0 /* done instead for entire identify block in arch/ide.h stuff */
- /* fix byte-ordering of buffer size field */
- id->buf_size = le16_to_cpu(id->buf_size);
-#endif
- printk (KERN_INFO "%s: %.40s, %ldMB w/%dkB Cache, CHS=%d/%d/%d",
- drive->name, id->model,
- capacity/2048L, id->buf_size/2,
- drive->bios_cyl, drive->bios_head, drive->bios_sect);
+ printk (KERN_INFO "%s: %ld sectors", drive->name, capacity);
+
+ /* Give size in megabytes (MB), not mebibytes (MiB). */
+ /* We compute the exact rounded value, avoiding overflow. */
+ printk (" (%ld MB)", (capacity - capacity/625 + 974)/1950);
+
+ /* Only print cache size when it was specified */
+ if (id->buf_size)
+ printk (" w/%dKiB Cache", id->buf_size/2);
+
+ printk(", CHS=%d/%d/%d",
+ drive->bios_cyl, drive->bios_head, drive->bios_sect);
 #ifdef CONFIG_BLK_DEV_IDEDMA
         if (drive->using_dma)
                 (void) HWIF(drive)->dmaproc(ide_dma_verbose, drive);

[Yes, the strange expression above really computes
 (512*capacity+500000)/1000000 exactly.]

[I now see
hda: Maxtor 91728D8, ATA DISK drive
hde: Maxtor 93652U8, ATA DISK drive
hda: 33750864 sectors (17280 MB) w/512KiB Cache, CHS=2100/255/63, UDMA(33)
hde: 71346240 sectors (36529 MB) w/2048KiB Cache, CHS=70780/16/63, UDMA(66)
and lo and behold! The Maxtor type name contains the size
in tens of megabytes.]

-
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/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:10 EST