Subject: PROBLEMS WITH LBA/CHS SELECTION ON OLDER IDE DRIVES
To: None <netbsd-help@NetBSD.ORG, port-i386@NetBSD.ORG, tech-kern@NetBSD.ORG>
From: Brian Buhrow <buhrow@cats.ucsc.edu>
List: tech-kern
Date: 02/02/1996 15:31:10
	Hello fellow NetBSD users.  I've identified what I think is a bug in the 
WD driver under NetBSD 1.1.  The problem has to do with the correct
selection of LBA or CHS addressing modes at boot time.  My understanding of
this problem is that it has something, or could have something to do with
the BIOS of the machine and the way the IDE card gets initialized.  In any
case, I have an I386DX machine with a Seagate ST1144AT IDE drive in it, and
an older IDE controller which is not capable of using LBA addressing.
Unfortunately, the wdprobe sets LBA to true, so the generic install disks
fail when they try to label and newfs the disk.  I've built a kernel using
a variant of pr#1506, but this requires that the CHS/LBA addressing
selection be a kernel compile time option.  This is a less than optimal
situation, as I'd like to have as generic a kernel as possible to use on a
wide variety of workstations in student laboratories.  
	So, is there anyone who can shed some light on how the lba/chs adressing selection
is done at boot time, and how one might be more certain of getting the
probe right more of the time?  Perhaps it should error on the side of
conservatism and not take advantage of the capabilities of some of the EIDE
cards in favor  of backward compatibility?

-thanks
-Brian

                          NETBSD PROBLEM REPORT #1506
                                       

>From gnats  Mon Sep 25 12:50:13 1995
sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id MAA01357 for <gnats-bugs@g
nats.netbsd.org>; Mon, 25 Sep 1995 12:50:08 -0400
70 for gnats-bugs@gnats.netbsd.org; Tue, 26 Sep 1995 02:50:41 +1000
Message-Id: <199509251650.CAA16570@scrooge.ee.swin.oz.au>
Date: Tue, 26 Sep 1995 02:50:40 +1000 (EST)
From: Douglas Thomas Crosher  <dtc@scrooge.ee.swin.oz.au>
To: gnats-bugs@gnats.netbsd.org
Subject: My WD340 IDE drive fails  when on a second controller; + hack to disab
le LBA makes it work.

>Number:         1506
>Category:       port-i386
>Synopsis:       My WD340 IDE drive fails when on a second controller. + hack
 to disable LBA makes it work.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 25 13:05:02 1995
>Originator:     Douglas Crosher
>Organization:
        Swinburne University of Technology
>Release:        NetBSD-current 24/9/1995
>Environment:

System: NetBSD dtc-pc 1.0A NetBSD 1.0A (DTC) #6: Tue Sep 26 00:50:49 EST 1995 d
tc@dtc-pc:/usr/src/sys/arch/i386/compile/DTC i386


>Description:

My WD340 IDE drive fails to work when attached to a second IDE
controller - it cannot even read the MBR.

>How-To-Repeat:

Using the configuration below, I boot to single user mode, then try to
read a disklabel from the WD drive on the second controller - this
fails.

I have enabled WDDEBUG with a few patches and the output is included
below.  Note: that in wd.c the number of retries was reduced to 1 so I
could record it all; more retries didn't help.

-=-=-=-=-=-=-

Configuration
--------------
1. BIOS
It may be significant that my BIOS has no support for the second
controller.  Does NetBSD depend on the BIOS performing some
initialisations?

2. Disk Configuration
wdc0 at isa0 port 0x1f0-0x1f7 irq 14
wd0 at wdc0 drive 0: 696MB, 1416 cyl, 16 head, 63 sec, 512 bytes/sec <QUANTUM L
IGHTNING 730A>
wd0: using 8-sector 16-bit pio transfers, lba addressing
wd1 at wdc0 drive 1: 234MB, 723 cyl, 13 head, 51 sec, 512 bytes/sec <QUANTUM LP
240A GM240A01X>
wd1: using 8-sector 16-bit pio transfers, chs addressing
wdc1 at isa0 port 0x170-0x177 irq 15
wd2 at wdc1 drive 0: 325MB, 1010 cyl, 12 head, 55 sec, 512 bytes/sec <WDC AC234
0F>
wd2: using 16-sector 16-bit pio transfers, lba addressing
-=-=-=-=-=-=-=-

WDDEBUG output for the failure
------------------------------
The Kernel wd driver debug messages for:
disklabel -r /dev/rwd0d

wdc1: warning: busy-wait took 1700us
I1 I1
wd2: wdcstart read 512@0; map sector 0 cylin 0 head 64 addr f8e10000 sts d0
I1 wd2: wdcintr: status 0 error 0

wd2: wdcstart read 512@0; map sector 0 cylin 0 head 64 addr f8e10000 sts d1
I1 wd2: wdcintr: status 0 error 0
wd2d: hard error reading fsbn 0 (wd2 bn 0; cn 0 tn 0 sn 0)
I1
wd2: wdcstart read 512@0; map sector 0 cylin 0 head 64 addr f8e10000 sts d0
I1 wd2: wdcintr: status 0 error 0

wd2: wdcstart read 512@0; map sector 0 cylin 0 head 64 addr f8e10000 sts d1
I1 wd2: wdcintr: status 0 error 0
wd2d: hard error reading fsbn 0 (wd2 bn 0; cn 0 tn 0 sn 0)
wd2: dos partition I/O error

wd2: wdcstart read 512@0; map sector 0 cylin 0 head 64 addr f926c574 sts d1
I1 wd2: wdcintr: status 0 error 0

wd2: wdcstart read 512@0; map sector 0 cylin 0 head 64 addr f926c574 sts d1
I1 wd2: wdcintr: status 0 error 0
wd2d: hard error reading fsbn 0 (wd2 bn 0; cn 0 tn 0 sn 0)

wd2: wdcstart read 8192@0; map sector 0 cylin 0 head 64 addr f926ca94 sts d1
I1 wd2: wdcintr: status 0 error 0

wd2: wdcstart read 8192@0; map sector 0 cylin 0 head 64 addr f926ca94 sts d1
I1 wd2: wdcintr: status 0 error 0
wd2d: hard error reading fsbn 0 of 0-15 (wd2 bn 0; cn 0 tn 0 sn 0)

-=-=-=-=-=-

>Fix:

I found that by disabling the LBA feature that it all worked.  The
output is included below.  It seems that an LBA read from the WD340
drive will not work. The WD340 drive will work in LBA mode under
NetBSD if it is attached as a second drive on controller 1 - perhaps
the BIOS initialises something in this case?

The disklabel -r command works with a patched wd.c to disable LBA
mode. The Kernel wd driver debug messages for:
disklabel -r /dev/rwd0d

wdc1: warning: busy-wait took 1700us
I1 wd(2,0) C1010H12S55
I1 I1
wd2: wdcstart read 512@0; map sector 1 cylin 0 head 0 addr f8d18000 sts d0
I1
wd2: wdcstart read 512@34; map sector 2 cylin 0 head 1 addr f8d18000 sts d0
I1 wd(2,0) C1010H8S33
I1 I1
wd2: wdcstart read 512@0; map sector 1 cylin 0 head 0 addr f8d18000 sts d0
I1
wd2: wdcstart read 512@34; map sector 2 cylin 0 head 1 addr f8d18000 sts d0
I1 wd(2,0) C0H8S33
I1 I1
wd2: wdcstart read 512@0; map sector 1 cylin 0 head 0 addr f926c574 sts d0
I1
wd2: wdcstart read 8192@33; map sector 1 cylin 0 head 1 addr f926ca94 sts d0
I1

Note: this has worked without error.
-=-=-=-=-=-

Patch - Hack
------------
The hack to disable LBA mode:

***************
*** 1277,1280 ****
--- 1278,1282 ----
                        *p = ntohs(*p);
                }
+       wd->sc_params.wdp_capabilities &= ~WD_CAP_LBA;
        }

-=-=-=-=-=-

>Audit-Trail:
>Unformatted:

>Last-Modified:

   
     _________________________________________________________________
   
   NetBSD Problem Database Query Form
     _________________________________________________________________
   
   NetBSD Home Page
     _________________________________________________________________
   
    www@NetBSD.ORG
    $NetBSD: query-full-pr,v 1.9 1995/12/19 03:05:25 cgd Exp $
    $NetBSD: gnats_config.sh,v 1.3 1995/12/19 06:12:53 cgd Exp $
    Copyright (c) 1995 The NetBSD Project. ALL RIGHTS RESERVED.