public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] off-by-1 error in ide-probe (2.4.x)
@ 2001-03-18  9:19 Paul Gortmaker
  2001-03-18 21:35 ` Jens Axboe
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Gortmaker @ 2001-03-18  9:19 UTC (permalink / raw)
  To: torvalds, alan, andre; +Cc: linux-kernel

There is a potentially serious bug in ide-probe.c in which max_sectors
is set to 256 instead of 255.  I am surprised that this hasn't bit anyone
else yet.  Perhaps because you need a disk that is slow in comparison to 
the host in order for the queue to climb up to and then hit the 256, at
which point it then falls over.  

For example, with an old 700MB Maxtor on a "fast" 486, VL-bus, PIO, 
hdparm -c1 -m8 -u1, I could pretty much on demand generate the following 
error by multiple builds, or by the final linking of any big project:

   hdc: lost interrupt
   hdc: status error: status=0x58 { DriveReady SeekComplete DataRequest }
   hdc: drive not ready for command
   <user space sees binary cruft in source files, etc etc...>

(Note that nothing in the status is really an error).  With the following 
patch, everything works as it should & no errors even under high load.
Patch is against 2.4.3pre2.

Paul.

--- drivers/ide/ide-probe.c~	Sat Mar 17 16:50:14 2001
+++ drivers/ide/ide-probe.c	Sat Mar 17 16:58:33 2001
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/ide/ide-probe.c	Version 1.06	June 9, 2000
+ *  linux/drivers/ide/ide-probe.c	Version 1.07	March 18, 2001
  *
  *  Copyright (C) 1994-1998  Linus Torvalds & authors (see below)
  */
@@ -25,6 +25,8 @@
  *			allowed for secondary flash card to be detectable
  *			 with new flag : drive->ata_flash : 1;
  * Version 1.06		stream line request queue and prep for cascade project.
+ * Version 1.07		max_sect <= 255; slower disks would get behind and
+ * 			then fall over when they get to 256.	Paul G.
  */
 
 #undef REALLY_SLOW_IO		/* most systems can safely undef this */
@@ -772,10 +774,10 @@
 	for (unit = 0; unit < minors; ++unit) {
 		*bs++ = BLOCK_SIZE;
 #ifdef CONFIG_BLK_DEV_PDC4030
-		*max_sect++ = ((hwif->chipset == ide_pdc4030) ? 127 : 256);
+		*max_sect++ = ((hwif->chipset == ide_pdc4030) ? 127 : 255);
 #else
 		/* IDE can do up to 128K per request. */
-		*max_sect++ = 256;
+		*max_sect++ = 255;
 #endif
 		*max_ra++ = MAX_READAHEAD;
 	}



^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH] off-by-1 error in ide-probe (2.4.x)
@ 2001-03-19  0:18 Andries.Brouwer
  2001-03-19  1:24 ` Linus Torvalds
  0 siblings, 1 reply; 9+ messages in thread
From: Andries.Brouwer @ 2001-03-19  0:18 UTC (permalink / raw)
  To: axboe, torvalds; +Cc: alan, andre, linux-kernel, p_gortmaker


    On Sun, 18 Mar 2001, Jens Axboe wrote:
    >
    > The 256 is _not_ a bug in the driver, it's more likely a bug in your
    > drive. 256 is a perfectly legal transfer size. That said, maybe it is
    > a good idea to leave it at 255 just for safety on drives not handling
    > 0 sectors == 128kB transfer.

    Agreed. That would be a trivially easy bug in the firmware, limiting to
    255 sectors seems safer.

            Linus

Yes, possibly.
I checked old standards, and see that "0 means 256 as a sector count"
is already in ATA-1.

Is there any evidence that other people have been hit by this?
Unfortunately, the
 "status error: status=0x58 { DriveReady SeekComplete DataRequest }"
is reported frequently these days, and has many causes.
In old reports it is rare. (E.g. none in lk for 1997.)

Paul: is there only one disk that you can make fail this way?

Andries

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-03-22 21:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-18  9:19 [PATCH] off-by-1 error in ide-probe (2.4.x) Paul Gortmaker
2001-03-18 21:35 ` Jens Axboe
2001-03-18 23:27   ` Linus Torvalds
2001-03-18 23:32     ` Andre Hedrick
2001-03-22  9:26   ` Paul Gortmaker
2001-03-22 13:32     ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2001-03-19  0:18 Andries.Brouwer
2001-03-19  1:24 ` Linus Torvalds
2001-03-19  2:23   ` Andre Hedrick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox