Subject: port-i386/2109: ultra14f.c byte-read of board ID fails on 34f (mine at least)
To: None <gnats-bugs@NetBSD.ORG>
From: None <mhw@netris.org>
List: netbsd-bugs
Date: 02/22/1996 07:16:56
>Number:         2109
>Category:       port-i386
>Synopsis:       ultra14f.c byte-read of board ID fails on 34f (mine at least)
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   mhw
>Arrival-Date:   Thu Feb 22 08:20:03 1996
>Last-Modified:
>Originator:     Mark Weaver
>Organization:
Brown University Department of Computer Science
>Release:        NetBSD-current 2/21/96
>Environment:
NetBSD peace.netris.org 1.1A NetBSD 1.1A (WEAVER) #2: Thu Feb 22 06:58:20 EST 1996     mhw@peace.netris.org:/usr/src/sys/arch/i386/compile/WEAVER i386
Gateway 2k 486/dx2-66 VLB, 16m RAM
Ultrastor 34f VLB
...

>Description:
Recent changes to ultra14f.c cause it to read the board ID and
configuration using byte-reads instead of word-reads, perhaps because
this was necessary for someone else.  On my 34f (VLB), the byte-reads
don't yield a valid board ID, and the board is not recognized.

>How-To-Repeat:
Boot a new kernel on my machine, and it won't recognize my 34f.
If I apply the following patch, the driver will recognize my board and
function properly, and it prints the following message (part of my
patch):

uha0: byte-read of board ID failed, using word-read instead (OK)
uha0 at isa0 port 0x330-0x33f irq 11
...

>Fix:
The following patch causes the driver to first attempt byte-read, and
then use word-read if that fails.

*** usr/src/sys/dev/isa/ultra14f.c.mhw1	Sat Feb 10 07:31:52 1996
--- usr/src/sys/dev/isa/ultra14f.c	Thu Feb 22 06:57:31 1996
***************
*** 184,189 ****
--- 184,198 ----
  #define	U24_HOSTID_MASK		0x07
  
  /*
+  * U14_ID bits (read only)
+  */
+ #define U14_ID_ALLOWED_MASK	0xfff0
+ #define U14_ID_ALLOWED		0x5640
+ 
+ #define U14_ID_REV_MASK		0x000f
+ #define U14_ID_REV_34		0x0001
+ 
+ /*
   * EISA registers (offset from slot base)
   */
  #define	EISA_VENDOR		0x0c80	/* vendor ID (2 ports) */
***************
*** 917,929 ****
  		return ENXIO;
  
  	model = inb(iobase + U14_ID) | (inb(iobase + U14_ID + 1) << 8);
! 	if ((model & 0xfff0) != 0x5640)
! 		return ENXIO;
! 
! 	config = inb(iobase + U14_CONFIG) | (inb(iobase + U14_CONFIG + 1) << 8);
  
! 	switch (model & 0x000f) {
! 	case 0x0001:
  		/* This is a 34f, and doesn't need an ISA DMA channel. */
  		uha->sc_drq = DRQUNK;
  		break;
--- 926,949 ----
  		return ENXIO;
  
  	model = inb(iobase + U14_ID) | (inb(iobase + U14_ID + 1) << 8);
! 	if ((model & U14_ID_ALLOWED_MASK) == U14_ID_ALLOWED)
! 		config = inb(iobase + U14_CONFIG) |
! 		    (inb(iobase + U14_CONFIG + 1) << 8);
! 	else {
! 		/*
! 		 * Byte access failed, try word access
! 		 */
! 		model = htons(inw(iobase + U14_ID));
! 		if ((model & U14_ID_ALLOWED_MASK) != U14_ID_ALLOWED)
! 			return ENXIO;
! 		printf("%s: byte-read of board ID failed, "
! 		    "using word-read instead (OK)\n",
! 		    uha->sc_dev.dv_xname, config & U14_DMA_MASK);
! 		config = htons(inw(iobase + U14_CONFIG));
! 	}
  
! 	switch (model & U14_ID_REV_MASK) {
! 	case U14_ID_REV_34:
  		/* This is a 34f, and doesn't need an ISA DMA channel. */
  		uha->sc_drq = DRQUNK;
  		break;
>Audit-Trail:
>Unformatted: