From dan@dan.kolej.mff.cuni.cz  Sun Jun  2 21:17:13 1996
Received: from mail.barrnet.net (mail.barrnet.net [131.119.246.7])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id VAA01927
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 2 Jun 1996 21:15:49 -0700 (PDT)
Received: from dan.kolej.mff.cuni.cz (dan.kolej.mff.cuni.cz [193.84.91.70]) by mail.barrnet.net (8.7.5/MAIL-RELAY-LEN) with ESMTP id VAA01438 for <FreeBSD-gnats-submit@freebsd.org>; Sun, 2 Jun 1996 21:15:33 -0700 (PDT)
Received: (from root@localhost) by dan.kolej.mff.cuni.cz (8.7.5/8.7.3) id FAA02280; Mon, 3 Jun 1996 05:54:04 +0200 (MET DST)
Message-Id: <199606030354.FAA02280@dan.kolej.mff.cuni.cz>
Date: Mon, 3 Jun 1996 05:54:04 +0200 (MET DST)
From: dan@obluda.kolej.mff.cuni.cz
Reply-To: dan@obluda.kolej.mff.cuni.cz
To: FreeBSD-gnats-submit@freebsd.org
Subject: Bad number of cyls detected by wd.c 
X-Send-Pr-Version: 3.2

>Number:         1288
>Category:       i386
>Synopsis:       wdgetctlr (wd.c) return incorrect number of cylinders
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bde
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun  2 21:20:01 PDT 1996
>Closed-Date:    Mon Apr 13 02:11:40 PDT 1998
>Last-Modified:  Mon Apr 13 02:12:09 PDT 1998
>Originator:     Dan Lukes
>Release:        FreeBSD 2.2-960501-SNAP i386
>Organization:
Obludarium 
>Environment:
	i586+Triton chipset, HDD SyQuest

>Description:
	wdgetctlr function (part of wd.c) return incorrect number of cylinders

after obtaining drive parameters (via IDENTIFY DRIVE command), this
function return dn->dk_dd.dncylinders as wp->wpd_fixedcyl+wp->wpd_removcyl.

There are no reason to add these two values. Field wpd_remov is
declared as reserved by all ATA-x specifications (only very old drafts
of ATA-1 describe it as number of removable cylinders). 
ATA compliant drives (either removable or non-removable) should report
number of cylinders in wpd_fixedcyl field. Some removable drives report
number of cylinders in wpd_removcyl also (for compatibility with
old, pre-ATA drives) and wdgetctlr return number of cyls doubled.  

>How-To-Repeat:
	Attach any ATA compliant IDE disk with non-zero value on offset +2
	(word) of IDENTIFY DRIVE structure, boot FreeBSD and look for
	detected drive geometry.

>Fix:
Change wdgetctrl/wd.c line dn->dk_dd.dncylinders=wp->wpd_fixedcyl+wp->wpd_removcyl
to dn->dk_dd.dncylinders=wp_wpd_fixedcyl;      (strict ATA compliant)
or (more sophisticated and tolerant):
#define WD0_ISREMOVABLE 0x0080  /* removable drive flag on word 0 of IDENTIFY DRIVE table */
dn->dk_dd.dncylinders=((WD0_ISREMOVABLE & wp->wpd_config) && !(wp->wpd_fixed)) ? wp->wpd_removcyl : wp->wpd_fixedcyl;
e.g. only if drive is flagged as removable and apropriate ATA field is not filled use removable field else use field defined by ATA

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: jkh 
Responsible-Changed-When: Sun Jun 2 21:26:40 PDT 1996 
Responsible-Changed-Why:  
Bruce's dept. 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Mon Apr 13 02:11:40 PDT 1998 
State-Changed-Why:  
fixed some time ago 
>Unformatted:
