Call for bge(4) testers

Pyun YongHyeon pyunyh at gmail.com
Thu Nov 19 20:37:50 UTC 2009


On Thu, Nov 19, 2009 at 01:27:03AM -0300, Gonzalo Nemmi wrote:
> On Wed, Nov 18, 2009 at 8:32 PM, Pyun YongHyeon <pyunyh at gmail.com> wrote:
> 
> > On Wed, Nov 18, 2009 at 01:40:24AM -0300, Gonzalo Nemmi wrote:
> >
> > [...]
> >
> > > I just tried ...
> > > echo 'hw.bge.allow_asf="1"' >> /boot/loader.conf
> > > reboot
> > > load if_bge
> > > acpiconf -s3
> > > same results :(
> > >
> >
> > Ok, here is new try.
> >
> 
> Let's get on to it then !
> 
> Well now, the situation has improved .. here's what I got:
> http://pastebin.com/f2d152f91
> 
> lines 2 to 8 == kldload if_bge
> line 9 == acpiconf -s3
> lines 10 to 18 == resume (notice there are only 2 messages now: lines 12 and
> 13!)
> lines 19 to 36 == ifconfig bge0
> lines 37 to 42 == me mounting the pendrive to get the messages from
> /var/log/messages =P
> lines 43 to 46 == kldunload if_bge0
> 
> I think you narrowed it down quite a lot this time !
> 

Hmm, not actually. I guess it just removed unnecessary operation
for PHY but it still failed to get functional state. :-(

> I have to warn you though, that this time, my kernel was compiled using a
> ... certainly modified /etc/make.conf file ... just in case you need to know
> how it looks like, you'll fin it in here:
> http://pastebin.com/f42e356d2
> 
> If you think that make.conf config may interfere with your pourposes or
> tests, just let me know and I'll use a default one.

I think that's ok.

> The good thing about that make.conf is that it saves me quite a time on
> every recompile ;)
> 
> > im at your service .. tell me what to do and I'll do it :)
> > >
> >
> > Thanks a lot for your patience and continuous support to fixing
> > bugs.
> >
> 
> Thank _YOU_ for keeping the good work up and for trying to solve a really
> nasty bug that makes every bge(4) user (think of it
> _as_every_dell_notebook_owner_) unable to get his laptop to resume .. or
> even use FreeBSD altoghether just because of this.
> 
> Dear Pyung, rest assured that as long as you remain commited to fix this, or
> any other bug that I can help you with, you can count on me to do everything
> that may be within the reach of my hand. As long as you remain commited,
> I'll be there, commited just as well :)
> 

Thanks a lot! This really helps me a lot to fix the bug.
Here is 4-th try. I added a couple of debug messages to see what
register contents it have after resume.

Thanks in advance.
-------------- next part --------------
Index: sys/dev/bge/if_bgereg.h
===================================================================
--- sys/dev/bge/if_bgereg.h	(revision 199499)
+++ sys/dev/bge/if_bgereg.h	(working copy)
@@ -1732,7 +1732,8 @@
 #define	BGE_MODE_CTL			0x6800
 #define	BGE_MISC_CFG			0x6804
 #define	BGE_MISC_LOCAL_CTL		0x6808
-#define	BGE_CPU_EVENT			0x6810
+#define	BGE_RX_CPU_EVENT		0x6810
+#define	BGE_TX_CPU_EVENT		0x6820
 #define	BGE_EE_ADDR			0x6838
 #define	BGE_EE_DATA			0x683C
 #define	BGE_EE_CTL			0x6840
@@ -1853,6 +1854,9 @@
 #define	BGE_SSRAMSIZE_8MB		0x00140000
 #define	BGE_SSRAMSIZE_16M		0x00180000
 
+/* RX CPU event register */
+#define	BGE_RX_CPU_EVENT_SW7		0x00004000
+
 /* EEPROM address register */
 #define	BGE_EEADDR_ADDRESS		0x0000FFFC
 #define	BGE_EEADDR_HALFCLK		0x01FF0000
Index: sys/dev/bge/if_bge.c
===================================================================
--- sys/dev/bge/if_bge.c	(revision 199499)
+++ sys/dev/bge/if_bge.c	(working copy)
@@ -1320,11 +1320,12 @@
 
 	if (sc->bge_asf_mode) {
 		bge_writemem_ind(sc, BGE_SOFTWARE_GENCOMM_FW, BGE_FW_PAUSE);
-		CSR_WRITE_4(sc, BGE_CPU_EVENT,
-		    CSR_READ_4(sc, BGE_CPU_EVENT) | (1 << 14));
+		CSR_WRITE_4(sc, BGE_RX_CPU_EVENT,
+		    CSR_READ_4(sc, BGE_RX_CPU_EVENT) | BGE_RX_CPU_EVENT_SW7);
 
 		for (i = 0; i < 100; i++ ) {
-			if (!(CSR_READ_4(sc, BGE_CPU_EVENT) & (1 << 14)))
+			if (!(CSR_READ_4(sc, BGE_RX_CPU_EVENT) &
+			    BGE_RX_CPU_EVENT_SW7))
 				break;
 			DELAY(10);
 		}
@@ -1540,12 +1541,13 @@
 	/* Wait until queue initialization is complete */
 	for (i = 0; i < BGE_TIMEOUT; i++) {
 		DELAY(10);
-		if (CSR_READ_4(sc, BGE_FTQ_RESET) == 0)
+		if ((val = CSR_READ_4(sc, BGE_FTQ_RESET)) == 0)
 			break;
 	}
 
 	if (i == BGE_TIMEOUT) {
-		device_printf(sc->bge_dev, "flow-through queue init failed\n");
+		device_printf(sc->bge_dev,
+		    "flow-through queue init failed(0x%08x)\n", val);
 		return (ENXIO);
 	}
 
@@ -2995,6 +2997,15 @@
 		}
 	}
 
+	if (sc->bge_asicrev == BGE_ASICREV_BCM5906) {
+		val = CSR_READ_4(sc, BGE_VCPU_STATUS);
+		CSR_WRITE_4(sc, BGE_VCPU_STATUS,
+		    val | BGE_VCPU_STATUS_DRV_RESET);
+		val = CSR_READ_4(sc, BGE_VCPU_EXT_CTRL);
+		CSR_WRITE_4(sc, BGE_VCPU_EXT_CTRL,
+		    val & ~BGE_VCPU_EXT_CTRL_HALT_CPU);
+	}
+
 	/* 
 	 * Set GPHY Power Down Override to leave GPHY
 	 * powered up in D0 uninitialized.
@@ -3005,15 +3016,6 @@
 	/* Issue global reset */
 	write_op(sc, BGE_MISC_CFG, reset);
 
-	if (sc->bge_asicrev == BGE_ASICREV_BCM5906) {
-		val = CSR_READ_4(sc, BGE_VCPU_STATUS);
-		CSR_WRITE_4(sc, BGE_VCPU_STATUS,
-		    val | BGE_VCPU_STATUS_DRV_RESET);
-		val = CSR_READ_4(sc, BGE_VCPU_EXT_CTRL);
-		CSR_WRITE_4(sc, BGE_VCPU_EXT_CTRL,
-		    val & ~BGE_VCPU_EXT_CTRL_HALT_CPU);
-	}
-
 	DELAY(1000);
 
 	/* XXX: Broadcom Linux driver. */
@@ -3491,8 +3493,9 @@
 			    BGE_FW_DRV_ALIVE);
 			bge_writemem_ind(sc, BGE_SOFTWARE_GENNCOMM_FW_LEN, 4);
 			bge_writemem_ind(sc, BGE_SOFTWARE_GENNCOMM_FW_DATA, 3);
-			CSR_WRITE_4(sc, BGE_CPU_EVENT,
-			    CSR_READ_4(sc, BGE_CPU_EVENT) | (1 << 14));
+			CSR_WRITE_4(sc, BGE_RX_CPU_EVENT,
+			    CSR_READ_4(sc, BGE_RX_CPU_EVENT) |
+			    BGE_RX_CPU_EVENT_SW7);
 		}
 	}
 }
@@ -3919,6 +3922,7 @@
 	/* Init RX ring. */
 	if (bge_init_rx_ring_std(sc) != 0) {
 		device_printf(sc->bge_dev, "no memory for std Rx buffers.\n");
+		ifp->if_drv_flags |= IFF_DRV_RUNNING;
 		bge_stop(sc);
 		return;
 	}
@@ -3946,6 +3950,7 @@
 	    (MCLBYTES - ETHER_ALIGN)) {
 		if (bge_init_rx_ring_jumbo(sc) != 0) {
 			device_printf(sc->bge_dev, "no memory for std Rx buffers.\n");
+			ifp->if_drv_flags |= IFF_DRV_RUNNING;
 			bge_stop(sc);
 			return;
 		}
@@ -4181,11 +4186,8 @@
 					bge_setmulti(sc);
 			} else
 				bge_init_locked(sc);
-		} else {
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-				bge_stop(sc);
-			}
-		}
+		} else
+			bge_stop(sc);
 		sc->bge_if_flags = ifp->if_flags;
 		BGE_UNLOCK(sc);
 		error = 0;
@@ -4301,17 +4303,15 @@
 bge_stop(struct bge_softc *sc)
 {
 	struct ifnet *ifp;
-	struct ifmedia_entry *ifm;
-	struct mii_data *mii = NULL;
-	int mtmp, itmp;
+	uint32_t val;
+	int i;
 
 	BGE_LOCK_ASSERT(sc);
 
 	ifp = sc->bge_ifp;
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+		return;
 
-	if ((sc->bge_flags & BGE_FLAG_TBI) == 0)
-		mii = device_get_softc(sc->bge_miibus);
-
 	callout_stop(&sc->bge_stat_ch);
 
 	/* Disable host interrupts. */
@@ -4328,6 +4328,7 @@
 	 * Disable all of the receiver blocks.
 	 */
 	BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE);
+	DELAY(10);
 	BGE_CLRBIT(sc, BGE_RBDI_MODE, BGE_RBDIMODE_ENABLE);
 	BGE_CLRBIT(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE);
 	if (!(BGE_IS_5705_PLUS(sc)))
@@ -4347,6 +4348,18 @@
 	if (!(BGE_IS_5705_PLUS(sc)))
 		BGE_CLRBIT(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE);
 	BGE_CLRBIT(sc, BGE_SBDC_MODE, BGE_SBDCMODE_ENABLE);
+	BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_TXDMA_ENB);
+	DELAY(40);
+	BGE_CLRBIT(sc, BGE_TX_MODE, BGE_TXMODE_ENABLE);
+	for (i = 1000; i > 0; i--) {
+		val = CSR_READ_4(sc, BGE_TX_MODE);
+		if ((val & BGE_TXMODE_ENABLE) == 0)
+			break;
+		DELAY(10);
+	}
+	if (i == 0)
+		device_printf(sc->bge_dev, "Disabling TX mode failed(0x%08x)",
+		    val);
 
 	/*
 	 * Shut down all of the memory managers and related
@@ -4385,27 +4398,6 @@
 	/* Free TX buffers. */
 	bge_free_tx_ring(sc);
 
-	/*
-	 * Isolate/power down the PHY, but leave the media selection
-	 * unchanged so that things will be put back to normal when
-	 * we bring the interface back up.
-	 */
-	if ((sc->bge_flags & BGE_FLAG_TBI) == 0) {
-		itmp = ifp->if_flags;
-		ifp->if_flags |= IFF_UP;
-		/*
-		 * If we are called from bge_detach(), mii is already NULL.
-		 */
-		if (mii != NULL) {
-			ifm = mii->mii_media.ifm_cur;
-			mtmp = ifm->ifm_media;
-			ifm->ifm_media = IFM_ETHER | IFM_NONE;
-			mii_mediachg(mii);
-			ifm->ifm_media = mtmp;
-		}
-		ifp->if_flags = itmp;
-	}
-
 	sc->bge_tx_saved_considx = BGE_TXCONS_UNSET;
 
 	/* Clear MAC's link state (PHY may still have link UP). */
@@ -4452,9 +4444,18 @@
 {
 	struct bge_softc *sc;
 	struct ifnet *ifp;
+	uint16_t pmstat;
+	int pmc;
 
 	sc = device_get_softc(dev);
 	BGE_LOCK(sc);
+	if (pci_find_extcap(dev, PCIY_PMG, &pmc) != 0) {
+		pmstat = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2);
+		device_printf(dev, "pmstat = 0x%04x\n", pmstat);
+		pmstat &= ~PCIM_PSTAT_PMEENABLE;
+		pmstat &= ~PCIM_PSTAT_DMASK;
+		pci_write_config(dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
+	}
 	ifp = sc->bge_ifp;
 	if (ifp->if_flags & IFF_UP) {
 		bge_init_locked(sc);


More information about the freebsd-current mailing list