Subject: port-i386/7428: 3c509B etherlink III detected twice
To: None <gnats-bugs@gnats.netbsd.org>
From: None <onno@simplex.nl>
List: netbsd-bugs
Date: 04/20/1999 13:35:59
>Number:         7428
>Category:       port-i386
>Synopsis:       3c509B can be detected twice
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer (NetBSD/i386 Portmaster)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 20 13:35:00 1999
>Last-Modified:
>Originator:     Onno van der Linden
>Organization:
	
>Release:        1.4_ALPHA April 6 1999	<NetBSD-current source date>
>Environment:
	
System: NetBSD sheep 1.4_ALPHA NetBSD 1.4_ALPHA (SHEEP) #17: Tue Apr 20 22:03:31 MEST 1999 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEP i386


>Description:
With the following lines in your config file

   isapnp0 at isa?

   ep* at isapnp?

   ep0 at isa? irq ?

and

  a 3c509B etherlink III card in Plug 'N Play mode

The card will be detected as ep0 and ep1.
The last two lines before the machine hanging (DDB works, but call cpu_reboot
gets you nowhere):
biomask c040 netmask cc40 ttymask ccc2
ep0: adapter failure (ffff)
	
>How-To-Repeat:
Get your 3c509 in pnp mode with the 3com 3c5x9cfg DOS tool using the following
commands
- 3c5x9cfg /pnprst
- 3c5x9cfg configure /pnp:enabled

and boot your netbsd kernel which was made with a config file containing
the lines given earlier.
	
>Fix:
The diff below fixes this by using the construction Christoph Badura
choose in /sys/dev/isa/if_trtcm_isa.c only with slightly different
checks for the PNP mode of the card.
*** /usr/src/sys/dev/isa/if_ep_isa.c.orig	Wed Nov  4 13:11:21 1998
--- /usr/src/sys/dev/isa/if_ep_isa.c	Tue Apr 20 21:33:17 1999
***************
*** 184,189 ****
  	struct isa_attach_args *ia = aux;
  	bus_space_tag_t iot = ia->ia_iot;
! 	bus_space_handle_t ioh, ioh2;
! 	int slot, iobase, irq, i;
  	u_int16_t vendor, model;
  	struct ep_isa_done_probe *er;
--- 184,189 ----
  	struct isa_attach_args *ia = aux;
  	bus_space_tag_t iot = ia->ia_iot;
! 	bus_space_handle_t ioh;
! 	int slot, iobase, irq, i, pnp;
  	u_int16_t vendor, model;
  	struct ep_isa_done_probe *er;
***************
*** 253,260 ****
--- 253,269 ----
  		irq >>= 12;
  
+ 		pnp = epreadeeprom(iot, ioh, 19) & 8;
+ 
  		/* so card will not respond to contention again */
  		bus_space_write_1(iot, ioh, 0, TAG_ADAPTER + 1);
  
  		/*
+ 		 * Don't attach a 3c509 in PnP mode.
+ 		 */
+ 		if ((model & 0xfff0) == PROD_ID_3C509 && pnp != 0) {
+ 			printf("3COM 3C509 Ethernet card in PnP mode\n");
+ 			continue;
+ 		}
+ 		/*
  		 * XXX: this should probably not be done here
  		 * because it enables the drq/irq lines from
***************
*** 263,284 ****
  		 */
  		bus_space_write_1(iot, ioh, 0, ACTIVATE_ADAPTER_TO_CONFIG);
- 
- 		/*
- 		 * Don't attach a 3c509 in PnP mode.
- 		 */
- 		if ((model & 0xfff0) == PROD_ID_3C509) {
- 			if (bus_space_map(iot, iobase, 1, 0, &ioh2)) {
- 				printf(
- 				"ep_isa_probe: can't map Etherlink iobase\n");
- 				return 0;
- 			}
- 			if (bus_space_read_2(iot, ioh2, ELINK_W0_EEPROM_COMMAND)
- 			    & EEPROM_TST_MODE) {
- 				printf(
- 				 "3COM 3C509 Ethernet card in PnP mode\n");
- 				continue;
- 			}
- 			bus_space_unmap(iot, ioh2, 1);
- 		}
  		epaddcard(bus, iobase, irq, model);
  	}
--- 272,275 ----
>Audit-Trail:
>Unformatted: