NetBSD Problem Report #37809

From martin@duskware.de  Sat Jan 19 16:43:59 2008
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 7FA6363B90D
	for <gnats-bugs@gnats.netbsd.org>; Sat, 19 Jan 2008 16:43:59 +0000 (UTC)
Message-Id: <20080119160434.EDFAF63BA67@narn.NetBSD.org>
Date: Sat, 19 Jan 2008 16:04:34 +0000 (UTC)
From: aymeric@netbsd.org
Reply-To: aymeric@netbsd.org
To: netbsd-bugs-owner@NetBSD.org
Subject: new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8
X-Send-Pr-Version: www-1.0

>Number:         37809
>Category:       kern
>Synopsis:       new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jdc
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 19 16:45:00 +0000 2008
>Closed-Date:    Sun Jan 20 15:21:15 +0000 2008
>Last-Modified:  Sun Jan 20 15:21:15 +0000 2008
>Originator:     Aymeric Vincent
>Release:        -current
>Organization:
>Environment:
NetBSD/macppc
>Description:
rev 1.68 of dev/ic/gem.c introduces a regression which prevents gem from correctly working on my powerbook. It still works fine on my iBook.

Apparently, no interrupt is received when a packet arrives on the interface. Packets are sent correctly.

>How-To-Repeat:
$ ping -n <some IP>

in another terminal:

$ systat vm 1

see irq of gem0 being triggered only once per second instead of twice when dev/ic/gem.c is reverted to 1.67 and works properly.

Also see that the leds on the switch blink at each ping.

# ifconfig gem0 debug

also shows that tx is working properly, but that the irq for reception is never taken.

>Fix:
unfortunately, I read the whole diff but it's too big for me to understand in a reasonable time.

Reverting to dev/ic/gem.c to 1.67 makes my gem adapter work.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->jdc
Responsible-Changed-By: jdc@narn.netbsd.org
Responsible-Changed-When: Sat, 19 Jan 2008 18:54:09 +0000
Responsible-Changed-Why:
I broke it, so I should fix it.


From: Julian Coleman <jdc@coris.org.uk>
To: Aymeric Vincent <vincent@labri.fr>
Cc: macallan@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)
Date: Sat, 19 Jan 2008 22:59:25 +0000

 --6WlEvdN9Dv0WHSBl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Hi,

 > I enclose my full dmesg (with your patch) in case you spot something
 > interesting: most notably (even without your patch), I fall into the
 > category of those adapters for which the second phy is now ruled out
 > due to the stricter test.
 > But this only seems to have an incidence on this MIF register in the
 > old code.

 > gem0 at pci2 dev 15 function 0: Apple Computer Intrepid 2 GMAC (rev. 0x00)
 > gem0: interrupting at irq 41
 > ukphy0 at gem0 phy 0: Generic IEEE 802.3u media interface
 > ukphy0: OUI 0x001018, model 0x000d, rev. 3
 > ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 > ukphy1 at gem0 phy 1: Generic IEEE 802.3u media interface
 > ukphy1: OUI 0x604112, model 0x0031, rev. 10
 > ukphy1: 
 > gem0: cannot accommodate MII device ukphy1 at PHY 1, instance 1
 > gem0: using PHY at MDIO_0
 > gem0: Ethernet address 00:14:51:19:93:74, 10KB RX fifo, 4KB TX fifo

 That's useful.  It does look like the problem is that we're now selecting the
 wrong PHY.  Can you try the attached patch (instead of the previous), please?
 It should put back the PHY handling behaviour of 1.67.  It's not quite final,
 because it breaks my fibre interface, but it might get the Apple ones working.

 There are also some other bugs I'd like to fix when this one is fixed:
  - some odd interaction with ipfilter (see PR 34799)
  - TCP checksums are probably wrong for received traffic on the
    underlying interface when VLAN's are configured
  - the card error counters aren't collected anywhere

 Hopefully, I'll not break anything else when I get to those ;-)

 Thanks,

 J

 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

 --6WlEvdN9Dv0WHSBl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="gem.c.diffs"

 --- sys/dev/ic/gem.c.dist	2008-01-05 20:27:44.000000000 +0000
 +++ sys/dev/ic/gem.c	2008-01-19 22:52:39.000000000 +0000
 @@ -283,6 +283,8 @@
  	 * GEM_MIF_CONFIG_MDI0 nor GEM_MIF_CONFIG_MDI1 are set
  	 * being set, as both are set on Sun X1141A (with SERDES).  So,
  	 * we rely on our bus attachment setting GEM_SERDES or GEM_SERIAL.
 +	 * Also, for Apple variants with 2 PHY's, we prefer the external
 +	 * PHY over the internal PHY.
  	 */
  	gem_mifinit(sc);

 @@ -320,17 +322,29 @@
  				sc->sc_phys[child->mii_inst] = child->mii_phy;
  			}

 -			if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI0) {
 +			/*
 +			 * Now select and activate the PHY we will use.
 +			 *
 +			 * The order of preference is External (MDI1),
 +			 * then Internal (MDI0),
 +			 */
 +			if (sc->sc_phys[1]) {
 +printf("%s: using external PHY\n", sc->sc_dev.dv_xname);
  #ifdef GEM_DEBUG
 -				aprint_debug("%s: using PHY at MDIO_0\n",
 +				aprint_debug("%s: using external PHY\n",
  				    sc->sc_dev.dv_xname);
  #endif
 +				sc->sc_mif_config |= GEM_MIF_CONFIG_PHY_SEL;
  			} else {
 +printf("%s: using internal PHY\n", sc->sc_dev.dv_xname);
  #ifdef GEM_DEBUG
 -				aprint_debug("%s: using PHY at MDIO_1\n",
 +				aprint_debug("%s: using internal PHY\n",
  				    sc->sc_dev.dv_xname);
 +				sc->sc_mif_config &= ~GEM_MIF_CONFIG_PHY_SEL;
  #endif
  			}
 +			bus_space_write_4(t, h, GEM_MIF_CONFIG,
 +			    sc->sc_mif_config);
  			if (sc->sc_variant != GEM_SUN_ERI)
  				bus_space_write_4(t, h, GEM_MII_DATAPATH_MODE,
  				    GEM_MII_DATAPATH_MII);
 @@ -1233,10 +1247,16 @@
  	/*
  	 * Enable MII outputs.  Enable GMII if there is a gigabit PHY.
  	 */
 +	sc->sc_mif_config = bus_space_read_4(t, h, GEM_MIF_CONFIG);
  	v = GEM_MAC_XIF_TX_MII_ENA;
 -	if (sc->sc_flags & GEM_GIGABIT)
 -		v |= GEM_MAC_XIF_GMII_MODE;
 -	bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v);
 +	if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0) {
 +		if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) {
 +			v |= GEM_MAC_XIF_FDPLX_LED;
 +			if (sc->sc_flags & GEM_GIGABIT)
 +				v |= GEM_MAC_XIF_GMII_MODE;
 +		}
 +		bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v);
 +	}
  }

  #ifdef GEM_DEBUG
 @@ -2303,16 +2323,10 @@
  	else
  		sc->sc_flags &= ~GEM_LINK;

 -	switch (IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
 -	case IFM_1000_SX:
 -	case IFM_1000_LX:
 -	case IFM_1000_CX:
 -	case IFM_1000_T:
 +	if (sc->sc_ethercom.ec_if.if_baudrate == IF_Mbps(1000))
  		gigabit = 1;
 -		break;
 -	default:
 +	else
  		gigabit = 0;
 -	}

  	/*
  	 * The configuration done here corresponds to the steps F) and
 @@ -2363,17 +2377,29 @@
  	else
  		v = 0;
  	v |= GEM_MAC_XIF_TX_MII_ENA;
 -	if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) & IFM_FDX) == 0) {
 -		/* MII/GMII needs echo disable if half duplex. */
 -		if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0)
 -			v |= GEM_MAC_XIF_ECHO_DISABL;
 -		v &= ~GEM_MAC_XIF_FDPLX_LED;
 -	} else {
 -		v |= GEM_MAC_XIF_MII_BUF_ENA;
 -		v |= GEM_MAC_XIF_FDPLX_LED;
 +
 +	/* If an external transceiver is connected, enable its MII drivers */
 +	sc->sc_mif_config = bus_space_read_4(t, mac, GEM_MIF_CONFIG);
 +	if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0) {
 +		if ((sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) != 0) {
 +			/* External MII needs echo disable if half duplex. */
 +			if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) &
 +			    IFM_FDX) != 0)
 +				/* turn on full duplex LED */
 +				v |= GEM_MAC_XIF_FDPLX_LED;
 +			else
 +				/* half duplex -- disable echo */
 +				v |= GEM_MAC_XIF_ECHO_DISABL;
 +			if (gigabit)
 +				v |= GEM_MAC_XIF_GMII_MODE;
 +			else
 +				v &= ~GEM_MAC_XIF_GMII_MODE;
 +		} else
 +			/* Internal MII needs buf enable */
 +			v |= GEM_MAC_XIF_MII_BUF_ENA;
 +		bus_space_write_4(t, mac, GEM_MAC_XIF_CONFIG, v);
  	}
 -	if (gigabit != 0)
 -		v |= GEM_MAC_XIF_GMII_MODE;
 +
  	if ((ifp->if_flags & IFF_RUNNING) != 0 &&
  	    (sc->sc_flags & GEM_LINK) != 0) {
  		bus_space_write_4(t, mac, GEM_MAC_TX_CONFIG,

 --6WlEvdN9Dv0WHSBl--

From: Aymeric Vincent <vincent@labri.fr>
To: Julian Coleman <jdc@coris.org.uk>
Cc: macallan@netbsd.org,  gnats-bugs@netbsd.org
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)
Date: Sun, 20 Jan 2008 00:16:46 +0100

 Julian Coleman <jdc@coris.org.uk> writes:

 > That's useful.  It does look like the problem is that we're now selecting the
 > wrong PHY.  Can you try the attached patch (instead of the previous), please?
 > It should put back the PHY handling behaviour of 1.67.  It's not quite final,
 > because it breaks my fibre interface, but it might get the Apple
 > ones working.

 It works!
 ... and says it's using the internal PHY.

 Thanks for your quick answers, and I'll patiently wait for the final
 committed version.

 Regards,
  Aymeric

From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@NetBSD.org
Cc: macallan@NetBSD.org
Subject: Re: kern/37809: new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8
Date: Sat, 19 Jan 2008 19:18:08 +0000

 --i0/AhcQY5QxfSsSZ
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Hi,

 > rev 1.68 of dev/ic/gem.c introduces a regression which prevents gem from correctly working on my powerbook. It still works fine on my iBook.

 Do either of them have a gigabit PHY?  I have also broken gem in the PowerMac
 G4 (gem + gigabit brgphy).

 Can you try the attached patch, please?  It reverts some of the changes that
 came in with 1.68.  However, I'm not sure why any of the changes should be
 stopping RX interrupts, so if this doesn't work, I'll do a patch that reverts
 more.

 Thanks,

 J

 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

 --i0/AhcQY5QxfSsSZ
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="gem.c.diffs"

 --- sys/dev/ic/gem.c.dist	2008-01-05 20:27:44.000000000 +0000
 +++ sys/dev/ic/gem.c	2008-01-19 19:03:22.000000000 +0000
 @@ -321,20 +321,24 @@
  			}

  			if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI0) {
 +printf("%s: using PHY at MDIO_0\n", sc->sc_dev.dv_xname);
  #ifdef GEM_DEBUG
  				aprint_debug("%s: using PHY at MDIO_0\n",
  				    sc->sc_dev.dv_xname);
  #endif
  			} else {
 +printf("%s: using PHY at MDIO_1\n", sc->sc_dev.dv_xname);
  #ifdef GEM_DEBUG
  				aprint_debug("%s: using PHY at MDIO_1\n",
  				    sc->sc_dev.dv_xname);
  #endif
  			}
 +/* XXX jdc
  			if (sc->sc_variant != GEM_SUN_ERI)
  				bus_space_write_4(t, h, GEM_MII_DATAPATH_MODE,
  				    GEM_MII_DATAPATH_MII);

 +*/
  			/*
  			 * XXX - we can really do the following ONLY if the
  			 * PHY indeed has the auto negotiation capability!!
 @@ -1045,10 +1049,12 @@
  	gem_mifinit(sc);

  	/* Set up correct datapath for non-SERDES/Serialink */
 +/* XXX jdc
  	if ((sc->sc_flags & (GEM_SERDES | GEM_SERIAL)) == 0 &&
  	    sc->sc_variant != GEM_SUN_ERI)
  		bus_space_write_4(t, h, GEM_MII_DATAPATH_MODE,
  		    GEM_MII_DATAPATH_MII);
 +*/

  	/* Call MI reset function if any */
  	if (sc->sc_hwreset)
 @@ -1079,10 +1085,13 @@
  	bus_space_write_4(t, h, GEM_RX_RING_PTR_LO, GEM_CDRXADDR(sc, 0));

  	/* step 8. Global Configuration & Interrupt Mask */
 +/* XXX jdc
  	if ((sc->sc_flags & (GEM_SERDES | GEM_SERIAL)) != 0)
  		v = GEM_INTR_PCS;
  	else
  		v = GEM_INTR_MIF;
 +*/
 +v = GEM_INTR_PCS | GEM_INTR_MIF;
  	bus_space_write_4(t, h, GEM_INTMASK,
  		      ~(GEM_INTR_TX_INTME |
  			GEM_INTR_TX_EMPTY |
 @@ -1093,8 +1102,11 @@
  	bus_space_write_4(t, h, GEM_MAC_RX_MASK,
  			GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT);
  	bus_space_write_4(t, h, GEM_MAC_TX_MASK, 0xffff); /* XXX */
 +/* XXX jdc
  	bus_space_write_4(t, h, GEM_MAC_CONTROL_MASK,
  	    GEM_MAC_PAUSED | GEM_MAC_PAUSE | GEM_MAC_RESUME);
 +*/
 +bus_space_write_4(t, h, GEM_MAC_CONTROL_MASK, 0);

  	/* step 9. ETX Configuration: use mostly default values */

 @@ -1209,7 +1221,10 @@
  	bus_space_write_4(t, h, GEM_MAC_RX_CODE_VIOL, 0);

  	/* Set XOFF PAUSE time. */
 +/* XXX jdc
  	bus_space_write_4(t, h, GEM_MAC_SEND_PAUSE_CMD, 0x1BF0);
 +*/
 +bus_space_write_4(t, h, GEM_MAC_SEND_PAUSE_CMD, 0);

  	/*
  	 * Set the internal arbitration to "infinite" bursts of the
 @@ -1218,10 +1233,12 @@
  	 * especially RX performance.
  	 * Enable silicon bug workarounds for the Apple variants.
  	 */
 +/* XXX jdc
  	bus_space_write_4(t, h, GEM_CONFIG,
  	    GEM_CONFIG_TXDMA_LIMIT | GEM_CONFIG_RXDMA_LIMIT |
  	    GEM_CONFIG_BURST_INF | (GEM_IS_APPLE(sc) ?
  	    GEM_CONFIG_RONPAULBIT | GEM_CONFIG_BUG2FIX : 0));
 +*/

  	/*
  	 * Set the station address.
 @@ -1235,7 +1252,11 @@
  	 */
  	v = GEM_MAC_XIF_TX_MII_ENA;
  	if (sc->sc_flags & GEM_GIGABIT)
 +/* XXX jdc */
 +{
 +printf("%s: gem_init_regs: gigabit phy\n", sc->sc_dev.dv_xname);
  		v |= GEM_MAC_XIF_GMII_MODE;
 +}
  	bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v);
  }


 --i0/AhcQY5QxfSsSZ--

From: Julian Coleman <jdc@coris.org.uk>
To: Aymeric Vincent <vincent@labri.fr>
Cc: macallan@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)
Date: Sun, 20 Jan 2008 10:28:29 +0000

 --phCU5ROyZO6kBE05
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Hi,

 > It works!
 > ... and says it's using the internal PHY.

 That's good!  I thought that it would be using the external one.  Oh well.

 > Thanks for your quick answers, and I'll patiently wait for the final
 > committed version.

 No problem.  I think the attached patch (against r1.69) will still work on
 your machines and also works on my gem interfaces.  If you could check, that
 would be great, then I'll check it in.

 I've just noticed that `ifconfig -m` isn't working on my gem interfaces.
 It looks like the changes in r1.69 have broken that, but I'll fix that
 after getting this done.

 Thanks,

 J

 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

 --phCU5ROyZO6kBE05
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="gem.c.diffs"

 --- sys/dev/ic/gem.c.dist	2008-01-20 09:59:45.000000000 +0000
 +++ sys/dev/ic/gem.c	2008-01-20 10:01:34.000000000 +0000
 @@ -282,6 +282,8 @@
  	 * GEM_MIF_CONFIG_MDI0 nor GEM_MIF_CONFIG_MDI1 are set
  	 * being set, as both are set on Sun X1141A (with SERDES).  So,
  	 * we rely on our bus attachment setting GEM_SERDES or GEM_SERIAL.
 +	 * Also, for Apple variants with 2 PHY's, we prefer the external
 +	 * PHY over the internal PHY.
  	 */
  	gem_mifinit(sc);

 @@ -321,17 +323,27 @@
  				sc->sc_phys[child->mii_inst] = child->mii_phy;
  			}

 -			if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI0) {
 +			/*
 +			 * Now select and activate the PHY we will use.
 +			 *
 +			 * The order of preference is External (MDI1),
 +			 * then Internal (MDI0),
 +			 */
 +			if (sc->sc_phys[1]) {
  #ifdef GEM_DEBUG
 -				aprint_debug("%s: using PHY at MDIO_0\n",
 +				aprint_debug("%s: using external PHY\n",
  				    sc->sc_dev.dv_xname);
  #endif
 +				sc->sc_mif_config |= GEM_MIF_CONFIG_PHY_SEL;
  			} else {
  #ifdef GEM_DEBUG
 -				aprint_debug("%s: using PHY at MDIO_1\n",
 +				aprint_debug("%s: using internal PHY\n",
  				    sc->sc_dev.dv_xname);
 +				sc->sc_mif_config &= ~GEM_MIF_CONFIG_PHY_SEL;
  #endif
  			}
 +			bus_space_write_4(t, h, GEM_MIF_CONFIG,
 +			    sc->sc_mif_config);
  			if (sc->sc_variant != GEM_SUN_ERI)
  				bus_space_write_4(t, h, GEM_MII_DATAPATH_MODE,
  				    GEM_MII_DATAPATH_MII);
 @@ -423,10 +435,9 @@
  		    IFM_SUBTYPE(ifm->ifm_media) == IFM_1000_SX ||
  		    IFM_SUBTYPE(ifm->ifm_media) == IFM_1000_LX ||
  		    IFM_SUBTYPE(ifm->ifm_media) == IFM_1000_CX) {
 -			if (sc->sc_variant != GEM_APPLE_GMAC)
 +			if (!GEM_IS_APPLE(sc))
  				sc->sc_ethercom.ec_capabilities
  				    |= ETHERCAP_JUMBO_MTU;
 -
  			sc->sc_flags |= GEM_GIGABIT;
  			break;
  		}
 @@ -1237,9 +1248,17 @@
  	/*
  	 * Enable MII outputs.  Enable GMII if there is a gigabit PHY.
  	 */
 +	sc->sc_mif_config = bus_space_read_4(t, h, GEM_MIF_CONFIG);
  	v = GEM_MAC_XIF_TX_MII_ENA;
 -	if (sc->sc_flags & GEM_GIGABIT)
 +	if ((sc->sc_flags & (GEM_SERDES | GEM_SERIAL)) == 0)  {
 +		if (sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) {
 +			v |= GEM_MAC_XIF_FDPLX_LED;
 +				if (sc->sc_flags & GEM_GIGABIT)
 +					v |= GEM_MAC_XIF_GMII_MODE;
 +		}
 +	} else {
  		v |= GEM_MAC_XIF_GMII_MODE;
 +	}
  	bus_space_write_4(t, h, GEM_MAC_XIF_CONFIG, v);
  }

 @@ -2307,16 +2326,10 @@
  	else
  		sc->sc_flags &= ~GEM_LINK;

 -	switch (IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
 -	case IFM_1000_SX:
 -	case IFM_1000_LX:
 -	case IFM_1000_CX:
 -	case IFM_1000_T:
 +	if (sc->sc_ethercom.ec_if.if_baudrate == IF_Mbps(1000))
  		gigabit = 1;
 -		break;
 -	default:
 +	else
  		gigabit = 0;
 -	}

  	/*
  	 * The configuration done here corresponds to the steps F) and
 @@ -2367,17 +2380,33 @@
  	else
  		v = 0;
  	v |= GEM_MAC_XIF_TX_MII_ENA;
 -	if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) & IFM_FDX) == 0) {
 -		/* MII/GMII needs echo disable if half duplex. */
 -		if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0)
 -			v |= GEM_MAC_XIF_ECHO_DISABL;
 -		v &= ~GEM_MAC_XIF_FDPLX_LED;
 +
 +	/* If an external transceiver is connected, enable its MII drivers */
 +	sc->sc_mif_config = bus_space_read_4(t, mac, GEM_MIF_CONFIG);
 +	if ((sc->sc_flags &(GEM_SERDES | GEM_SERIAL)) == 0) {
 +		if ((sc->sc_mif_config & GEM_MIF_CONFIG_MDI1) != 0) {
 +			/* External MII needs echo disable if half duplex. */
 +			if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) &
 +			    IFM_FDX) != 0)
 +				/* turn on full duplex LED */
 +				v |= GEM_MAC_XIF_FDPLX_LED;
 +			else
 +				/* half duplex -- disable echo */
 +				v |= GEM_MAC_XIF_ECHO_DISABL;
 +			if (gigabit)
 +				v |= GEM_MAC_XIF_GMII_MODE;
 +			else
 +				v &= ~GEM_MAC_XIF_GMII_MODE;
 +		} else
 +			/* Internal MII needs buf enable */
 +			v |= GEM_MAC_XIF_MII_BUF_ENA;
  	} else {
 -		v |= GEM_MAC_XIF_MII_BUF_ENA;
 -		v |= GEM_MAC_XIF_FDPLX_LED;
 -	}
 -	if (gigabit != 0)
 +		if ((IFM_OPTIONS(sc->sc_mii.mii_media_active) & IFM_FDX) != 0)
 +			v |= GEM_MAC_XIF_FDPLX_LED;
  		v |= GEM_MAC_XIF_GMII_MODE;
 +	}
 +	bus_space_write_4(t, mac, GEM_MAC_XIF_CONFIG, v);
 +
  	if ((ifp->if_flags & IFF_RUNNING) != 0 &&
  	    (sc->sc_flags & GEM_LINK) != 0) {
  		bus_space_write_4(t, mac, GEM_MAC_TX_CONFIG,

 --phCU5ROyZO6kBE05--

From: Aymeric Vincent <vincent@labri.fr>
To: Julian Coleman <jdc@coris.org.uk>
Cc: macallan@netbsd.org,  gnats-bugs@netbsd.org
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)
Date: Sun, 20 Jan 2008 13:01:17 +0100

 Your new patch works with a recent kernel of this morning (to get
 gem.c 1.69).

 Thanks a lot!

  Aymeric



From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@NetBSD.org
Cc: aymeric@NetBSD.org, macallan@NetBSD.org
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)
Date: Sun, 20 Jan 2008 14:46:04 +0000

 Hi,

 >  Your new patch works with a recent kernel of this morning (to get
 >  gem.c 1.69).

 Thanks for testing.  I was wrong about the media setting problem - I must
 have had a stale dependency when I rebuilt my kernel.  So, all looks fine
 so far.

 Thanks,

 J
 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

From: Michael Lorenz <macallan@netbsd.org>
To: Julian Coleman <jdc@coris.org.uk>
Cc: Aymeric Vincent <vincent@labri.fr>,
 gnats-bugs@netbsd.org
Subject: Re: kern/37809 (new version of dev/ic/gem.c doesn't work on Apple Powerbook5,8)
Date: Sun, 20 Jan 2008 10:03:04 -0500

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 This patch makes my gem work again:
 gem0 at pci3 dev 15 function 0: Apple Computer GMAC Ethernet (rev. 0x01)
 gem0: interrupting at irq 41
 brgphy0 at gem0 phy 0: BCM5400 1000BASE-T media interface, rev. 7
 brgphy0: using BCM5401 DSP patch
 brgphy0: 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 gem0: using internal PHY
 gem0: Ethernet address 00:30:65:a8:ba:3a, 10KB RX fifo, 4KB TX fifo
 ( for the records - that's a PowerMac G4 with built-in gigabit  
 ethernet )

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.7 (Darwin)

 iQEVAwUBR5NiqcpnzkX8Yg2nAQIVHAgAm+Zc8tk00o1EXfSYNE9Qdq6kJLbZfcwJ
 YyA16QLwVNerIbwA9qZrhPdLDlDfwhxAda9vUX9JOCj20UEpLNLMdVbHi9Oa7LwS
 9024V+yb2/oDqApHHJJVLUNFrcFd1GbsyJXct3JaZzsMDSa03uWkLoCGPdfaHkJa
 R+KksMkI/jZyePUSTN5RqS01J6jq1Ud/u9MhlMVZLA2pBona9FJ1TCcqC70Jdx+M
 s75D/DGu7gQ0N0Yr1jLXSNwi0i9ObTBxJs+zxF7Wk0hGS1HgMG6T7BhmIkNwB2Hs
 IH7tyOBrUvzlMYFUH2b0ii/LLP9skAdFg93eYuf38cvUN+nJokVQ8A==
 =pMeV
 -----END PGP SIGNATURE-----

From: Julian Coleman <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/37809 CVS commit: src/sys/dev/ic
Date: Sun, 20 Jan 2008 15:12:33 +0000 (UTC)

 Module Name:	src
 Committed By:	jdc
 Date:		Sun Jan 20 15:12:33 UTC 2008

 Modified Files:
 	src/sys/dev/ic: gem.c

 Log Message:
 Fix Apple gigabit gem interfaces by restoring some of the code from r1.67,
 with some minor alterations to make Sun fibre cards work too.
 Tested by aymeric@ and macallan@.
 Fixes PR kern/37809.


 To generate a diff of this commit:
 cvs rdiff -r1.69 -r1.70 src/sys/dev/ic/gem.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: jdc@narn.netbsd.org
State-Changed-When: Sun, 20 Jan 2008 15:21:15 +0000
State-Changed-Why:
Fixed by r1.70 of src/sys/dev/ic/gem.c.
Thanks for testing!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.