Re: IDE fix... ("obviously correct").

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Tue, 18 May 1999 01:48:07 +0200 (MEST)


Guest section DW wrote:
> From: R.E.Wolff@BitWizard.nl (Rogier Wolff)
>
> diff -ur linux-2.2.9.clean/drivers/block/ide-disk.c linux/drivers/block/ide-disk.c
> --- linux-2.2.9.clean/drivers/block/ide-disk.c Wed Apr 7 17:03:50 1999
> +++ linux/drivers/block/ide-disk.c Mon May 17 07:53:48 1999
> @@ -106,7 +106,8 @@
> return 1; /* lba_capacity is good */
> }
> /* some drives have the word order reversed */
> - lba_sects = (lba_sects << 16) | (lba_sects >> 16);
> + lba_sects = ((lba_sects & 0xffff) << 16) |
> + ((lba_sects >> 16) & 0xffff);
> if ((lba_sects - chs_sects) < _10_percent) {
> id->lba_capacity = lba_sects; /* fix it */
> return 1; /* lba_capacity is (now) good */
>
>
> Yes. It looks like the second `& 0xffff' is superfluous.

Correct. You could leave it out, but it is "cheap" programming like
that which caused this bug in the first place. I want the C-code to
say exactly what I meant. Let the compiler optimize the stupid stuff
away. If it doesn't find this optimization this time, it's __initfunc
code, which gets executed up to 8 times per system restart.

Timing critical code is something else.

> > It looks as if noone with a 64 bit machine has gotten bitten by this yet
>
> This is something that only applies to old broken disks,
> and is only used to prefer LBA capacity over BIOS capacity
> if possible. I do not know whether there are any old broken
> disks in use on an Alpha that require this (e.g., because
> they are larger than 8.4 GB). Maybe none exist.

Correct. I said probably noone was bitten by this yet, and I'll add
now that probably nobody ever will. But fixing it is easier than
bitching about it all day. So lets get this fixed, and drop it.

Actually, I think this code is NOT relevant for > 8G disks.

If a disk is > 8G, it will report something that is close to 8G as the
CHS geometry, and something (much) larger as the LBA capacity. This
code tries to prefer the LBA geometry over the CHS geometry, when they
are reasonably close to eachother.

A disk having say 1040 sectors, might proclaim 4 heads, 8 sectors, 32
tracks = 1024 sectors. One track more, and you drop off the disk. But
Linux wants to be able to write those last 16 sectors....

Rogier.

> Waiting to be contradicted... - Andries
>

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

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