Subject: kern/5279: EISA drivers incorrectly claim their complete slot space
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@rumolt.teuto.de>
List: netbsd-bugs
Date: 04/10/1998 11:29:15
>Number:         5279
>Category:       kern
>Synopsis:       EISA drivers reservere unnecessary parts of their slot space
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 10 02:50:00 1998
>Last-Modified:
>Originator:     Martin Husemann
>Organization:
UP-Vision Computergraphik GmbH, Bad Arolsen
>Release:        Found in 1.3.1, probably still in -current
>Environment:
System: NetBSD rumolt.teuto.de 1.3.1 NetBSD 1.3.1 (RUMOLT) #10: Fri Apr 10 13:03:45 CEST 1998 root@hwart.teuto.de:/usr/src-1.3.1/sys-i4b/arch/i386/compile/RUMOLT i386


>Description:

EISA drivers bus_space_map their whole io-port slot space. This is incorrect.
There are no other EISA devices in this address io-range, but there may be
other ISA cards. Although this ISA cards are IMHO broken by design, the user
can not fix this. And: these cards work with i386 specific drivers in the
same setup, so they should work with bus_space.h drivers as well.

>How-To-Repeat:

Install an AHB 1742 in EISA slot 1 and an AVM A1 (or Fritz!) ISDN card.
No matter at what IO-port you place the ISDN card, it will need a small
io-range somewhere in the port range between 0x1a00 and 0x1bff. Note that
this doesn't conflict with any register of the AHB controller, but lives
in EISA slot space 1.

A bus-spacified driver for the ISDN card (i.e. the driver in ISDN4BSD)
will fail to bus_space_map this extend and not probe/attach the card.

>Fix:

Since I don't have access to any other hardware supported by drivers under
sys/dev/eisa I only fixed it for the ahb.c driver.

diff -rbBc5 sys/dev/eisa/ahb.c sys-i4b/dev/eisa/ahb.c
*** sys/dev/eisa/ahb.c	Tue Nov  4 13:28:11 1997
--- sys-i4b/dev/eisa/ahb.c	Fri Apr 10 10:54:17 1998
***************
*** 226,242 ****
  	    strcmp(ea->ea_idstring, "ADP0001") &&
  	    strcmp(ea->ea_idstring, "ADP0002") &&
  	    strcmp(ea->ea_idstring, "ADP0400"))
  		return (0);
  
! 	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot),
! 	    EISA_SLOT_SIZE, 0, &ioh))
  		return (0);
  
  	rv = !ahb_find(iot, ioh, NULL);
  
! 	bus_space_unmap(iot, ioh, EISA_SLOT_SIZE);
  
  	return (rv);
  }
  
  /*
--- 226,242 ----
  	    strcmp(ea->ea_idstring, "ADP0001") &&
  	    strcmp(ea->ea_idstring, "ADP0002") &&
  	    strcmp(ea->ea_idstring, "ADP0400"))
  		return (0);
  
! 	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + AHB_PORT_OFFSET,
! 	    AHB_PORT_SIZE, 0, &ioh))
  		return (0);
  
  	rv = !ahb_find(iot, ioh, NULL);
  
! 	bus_space_unmap(iot, ioh, AHB_PORT_SIZE);
  
  	return (rv);
  }
  
  /*
***************
*** 266,277 ****
  		model = EISA_PRODUCT_ADP0400;
  	else
  		model = "unknown model!";
  	printf(": %s\n", model);
  
! 	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot),
! 	   EISA_SLOT_SIZE, 0, &ioh))
  		panic("ahbattach: could not map I/O addresses");
  
  	sc->sc_iot = iot;
  	sc->sc_ioh = ioh;
  	sc->sc_dmat = ea->ea_dmat;
--- 266,277 ----
  		model = EISA_PRODUCT_ADP0400;
  	else
  		model = "unknown model!";
  	printf(": %s\n", model);
  
! 	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + AHB_PORT_OFFSET,
! 	   AHB_PORT_SIZE, 0, &ioh))
  		panic("ahbattach: could not map I/O addresses");
  
  	sc->sc_iot = iot;
  	sc->sc_ioh = ioh;
  	sc->sc_dmat = ea->ea_dmat;
diff -rbBc5 sys/dev/eisa/ahbreg.h sys-i4b/dev/eisa/ahbreg.h
*** sys/dev/eisa/ahbreg.h	Wed Aug 27 13:31:02 1997
--- sys-i4b/dev/eisa/ahbreg.h	Fri Apr 10 10:39:15 1998
***************
*** 83,103 ****
  
  typedef u_long physaddr;
  typedef u_long physlen;
  
  /*
!  * AHA1740 EISA board mode registers (Offset from slot base)
   */
! #define PORTADDR	0xCC0
  #define	 PORTADDR_ENHANCED	0x80
! #define BIOSADDR	0xCC1
! #define	INTDEF		0xCC2
! #define	SCSIDEF		0xCC3
! #define	BUSDEF		0xCC4
! #define	RESV0		0xCC5
! #define	RESV1		0xCC6
! #define	RESV2		0xCC7
  /**** bit definitions for INTDEF ****/
  #define	INT9	0x00
  #define	INT10	0x01
  #define	INT11	0x02
  #define	INT12	0x03
--- 83,109 ----
  
  typedef u_long physaddr;
  typedef u_long physlen;
  
  /*
!  * Bus space mapping (relative to slot base)
   */
! #define	AHB_PORT_OFFSET	0xCC0
! #define	AHB_PORT_SIZE	32
! 
! /*
!  * AHA1740 EISA board mode registers (Offset from AHB_PORT_OFFSET)
!  */
! #define PORTADDR	0x00
  #define	 PORTADDR_ENHANCED	0x80
! #define BIOSADDR	0x01
! #define	INTDEF		0x02
! #define	SCSIDEF		0x03
! #define	BUSDEF		0x04
! #define	RESV0		0x05
! #define	RESV1		0x06
! #define	RESV2		0x07
  /**** bit definitions for INTDEF ****/
  #define	INT9	0x00
  #define	INT10	0x01
  #define	INT11	0x02
  #define	INT12	0x03
***************
*** 112,139 ****
  #define	B0uS	0x00		/* give up bus immediatly */
  #define	B4uS	0x01		/* delay 4uSec. */
  #define	B8uS	0x02
  
  /*
!  * AHA1740 ENHANCED mode mailbox control regs (Offset from slot base)
   */
! #define MBOXOUT0	0xCD0
! #define MBOXOUT1	0xCD1
! #define MBOXOUT2	0xCD2
! #define MBOXOUT3	0xCD3
  
! #define	ATTN		0xCD4
! #define	G2CNTRL		0xCD5
! #define	G2INTST		0xCD6
! #define G2STAT		0xCD7
  
! #define	MBOXIN0		0xCD8
! #define	MBOXIN1		0xCD9
! #define	MBOXIN2		0xCDA
! #define	MBOXIN3		0xCDB
  
! #define G2STAT2		0xCDC
  
  /*
   * Bit definitions for the 5 control/status registers
   */
  #define	ATTN_TARGET		0x0F
--- 118,145 ----
  #define	B0uS	0x00		/* give up bus immediatly */
  #define	B4uS	0x01		/* delay 4uSec. */
  #define	B8uS	0x02
  
  /*
!  * AHA1740 ENHANCED mode mailbox control regs (Offset from AHB_PORT_OFFSET)
   */
! #define MBOXOUT0	0x10
! #define MBOXOUT1	0x11
! #define MBOXOUT2	0x12
! #define MBOXOUT3	0x13
  
! #define	ATTN		0x14
! #define	G2CNTRL		0x15
! #define	G2INTST		0x16
! #define G2STAT		0x17
  
! #define	MBOXIN0		0x18
! #define	MBOXIN1		0x19
! #define	MBOXIN2		0x1A
! #define	MBOXIN3		0x1B
  
! #define G2STAT2		0x1C
  
  /*
   * Bit definitions for the 5 control/status registers
   */
  #define	ATTN_TARGET		0x0F
>Audit-Trail:
>Unformatted: