NetBSD Problem Report #9864
Received: (qmail 148 invoked from network); 12 Apr 2000 18:45:54 -0000
Message-Id: <20000412184202.55787463D@dr-evil.shagadelic.org>
Date: Wed, 12 Apr 2000 11:42:02 -0700 (PDT)
From: thorpej@zembu.com
Reply-To: thorpej@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: wd driver reports cylinders incorrectly on some drives
X-Send-Pr-Version: 3.95
>Number: 9864
>Category: kern
>Synopsis: wd driver reports cylinders incorrectly on some drives
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bouyer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Apr 12 18:46:01 +0000 2000
>Closed-Date: Sat Mar 13 16:12:26 +0000 2004
>Last-Modified: Sun Mar 28 08:14:01 +0000 2004
>Originator: Jason R. Thorpe
>Release: 20000331
>Organization:
Zembu Labs, Inc.
>Environment:
NetBSD 1.4X on Intel server hardware.
>Description:
The wd driver reports the incorrect number of cylinders on
some drives, specifically drives that report the magic number
16383, which apparently indicates that LBA is the only way the
drive can be addressed.
This causes programs like disklabel(8) do bounds-check incorrectly.
>How-To-Repeat:
This bug was found while testing a highly customized automated
installation program.
>Fix:
The following patch fixes the bug by recognizing the magic
cylinder count and then recomputing it based on the capacity
and the reported number of heads and sectors/track.
Index: wd.c
===================================================================
RCS file: /home/cvsfiles/netbsd/src/sys/dev/ata/wd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** wd.c 2000/03/31 20:00:16 1.1
--- wd.c 2000/04/11 19:19:47 1.2
***************
*** 846,852 ****
lp->d_secsize = DEV_BSIZE;
lp->d_ntracks = wd->sc_params.atap_heads;
lp->d_nsectors = wd->sc_params.atap_sectors;
! lp->d_ncylinders = wd->sc_params.atap_cylinders;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
if (strcmp(wd->sc_params.atap_model, "ST506") == 0)
--- 846,862 ----
lp->d_secsize = DEV_BSIZE;
lp->d_ntracks = wd->sc_params.atap_heads;
lp->d_nsectors = wd->sc_params.atap_sectors;
! if (wd->sc_params.atap_cylinders == ATAP_CYLINDERS_LBA_ONLY) {
! /*
! * If we get the magic "LBA is the only reliably way"
! * value for ncylinders, compute the `actual' number
! * of cylinders that would correspond to our capacity
! * and reported number of heads and sectors per track.
! */
! lp->d_ncylinders = wd->sc_capacity /
! lp->d_ntracks / lp->d_nsectors;
! } else
! lp->d_ncylinders = wd->sc_params.atap_cylinders;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
if (strcmp(wd->sc_params.atap_model, "ST506") == 0)
Index: atareg.h
===================================================================
RCS file: /home/cvsfiles/netbsd/src/sys/dev/ata/atareg.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** atareg.h 2000/03/31 20:00:16 1.1
--- atareg.h 2000/04/11 19:19:47 1.2
***************
*** 25,30 ****
--- 25,31 ----
#define ATAPI_CFG_CMD_16 0x0001
/* words 1-9 are ATA only */
u_int16_t atap_cylinders; /* 1: # of non-removable cylinders */
+ #define ATAP_CYLINDERS_LBA_ONLY 16383 /* Stupid Evil ATA Crap */
u_int16_t __reserved1;
u_int16_t atap_heads; /* 3: # of heads */
u_int16_t __retired1[2]; /* 4-5: # of unform. bytes/track */
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->bouyer
Responsible-Changed-By: bouyer
Responsible-Changed-When: Fri Aug 2 07:27:40 PDT 2002
Responsible-Changed-Why:
I'll look at this.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: pr/9864 CVS commit: src/sys/dev/ata
Date: Sun, 3 Aug 2003 17:53:05 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sun Aug 3 17:53:05 UTC 2003
Modified Files:
src/sys/dev/ata: wd.c
Log Message:
For LBA drives, compute the number of cylinders from the drive capacity
in the default disklabel and the boot message, instead of using the
value reported by the drive (which is 16383 if the drive is larger than 8G).
Should fix PR 9864
To generate a diff of this commit:
cvs rdiff -r1.259 -r1.260 src/sys/dev/ata/wd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: bouyer
State-Changed-When: Sun Aug 3 17:54:29 UTC 2003
State-Changed-Why:
Hi,
can you double-check that this is fixed with wd.c 1.260 ? Thanks.
State-Changed-From-To: feedback->closed
State-Changed-By: bouyer
State-Changed-When: Sat Mar 13 16:12:07 UTC 2004
State-Changed-Why:
should fixed by wd.c 1.260.
From: James Chacon <jmc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: pr/9864 CVS commit: [netbsd-1-6] src/sys/dev/ata
Date: Sun, 28 Mar 2004 08:13:09 +0000 (UTC)
Module Name: src
Committed By: jmc
Date: Sun Mar 28 08:13:09 UTC 2004
Modified Files:
src/sys/dev/ata [netbsd-1-6]: wd.c
Log Message:
Pullup rev 1.260 via patch (requested by bouyer in ticket #1629)
For LBA drives, compute the number of cylinders from the drive capacity
in the default disklabel and the boot message, instead of using the
value reported by the drive (which is 16383 if the drive is larger than 8G).
Fixes PR#9864
To generate a diff of this commit:
cvs rdiff -r1.220.10.5 -r1.220.10.6 src/sys/dev/ata/wd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.