Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jul 2007 16:11:31 GMT
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 123802 for review
Message-ID:  <200707201611.l6KGBVfm087773@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123802

Change 123802 by rpaulo@rpaulo_epsilon on 2007/07/20 16:11:03

	IFC

Affected files ...

.. //depot/projects/soc2007/rpaulo-macbook/conf/NOTES#14 integrate
.. //depot/projects/soc2007/rpaulo-macbook/conf/files#19 integrate
.. //depot/projects/soc2007/rpaulo-macbook/dev/firewire/firewire.c#8 integrate
.. //depot/projects/soc2007/rpaulo-macbook/dev/firewire/firewirereg.h#7 integrate
.. //depot/projects/soc2007/rpaulo-macbook/dev/msk/if_msk.c#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/eth_z8e.dat.gz.uu#5 delete
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/eth_z8e.h#1 branch
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/ethp_z8e.dat.gz.uu#5 delete
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/ethp_z8e.h#1 branch
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/if_mxge.c#10 integrate
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/mxge_eth_z8e.c#1 branch
.. //depot/projects/soc2007/rpaulo-macbook/dev/mxge/mxge_ethp_z8e.c#1 branch
.. //depot/projects/soc2007/rpaulo-macbook/fs/coda/coda_vfsops.c#2 integrate
.. //depot/projects/soc2007/rpaulo-macbook/fs/coda/coda_vnops.c#2 integrate
.. //depot/projects/soc2007/rpaulo-macbook/fs/tmpfs/tmpfs_vnops.c#6 integrate
.. //depot/projects/soc2007/rpaulo-macbook/i386/linux/linux_machdep.c#5 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/kern_mutex.c#6 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/kern_rwlock.c#6 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/kern_sig.c#5 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/kern_switch.c#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/sched_4bsd.c#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/sched_ule.c#7 integrate
.. //depot/projects/soc2007/rpaulo-macbook/kern/tty.c#5 integrate
.. //depot/projects/soc2007/rpaulo-macbook/modules/Makefile#12 integrate
.. //depot/projects/soc2007/rpaulo-macbook/modules/mxge/mxge_eth_z8e/Makefile#2 integrate
.. //depot/projects/soc2007/rpaulo-macbook/modules/mxge/mxge_ethp_z8e/Makefile#2 integrate
.. //depot/projects/soc2007/rpaulo-macbook/net80211/ieee80211_scan_sta.c#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netinet/icmp_var.h#2 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netinet/ip_icmp.c#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netinet6/in6.h#5 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netinet6/udp6_usrreq.c#6 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netipsec/ipsec_input.c#3 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netipsec/ipsec_output.c#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/netipsec/xform_ipip.c#3 integrate
.. //depot/projects/soc2007/rpaulo-macbook/sparc64/sparc64/pmap.c#5 integrate
.. //depot/projects/soc2007/rpaulo-macbook/sys/mutex.h#3 integrate
.. //depot/projects/soc2007/rpaulo-macbook/sys/rwlock.h#4 integrate
.. //depot/projects/soc2007/rpaulo-macbook/vm/vm_fault.c#7 integrate

Differences ...

==== //depot/projects/soc2007/rpaulo-macbook/conf/NOTES#14 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/NOTES,v 1.1444 2007/07/14 21:49:23 rwatson Exp $
+# $FreeBSD: src/sys/conf/NOTES,v 1.1446 2007/07/19 16:15:58 gallatin Exp $
 #
 # NOTES -- Lines that can be cut/pasted into kernel and hints configs.
 #
@@ -176,10 +176,11 @@
 # queue and no CPU affinity which makes it suboptimal for SMP.  It has very
 # good interactivity and priority selection.
 #
-# SCHED_ULE is a new scheduler that has been designed for SMP and has some
-# advantages for UP as well.  It is intended to replace the 4BSD scheduler
-# over time.  NOTE: SCHED_ULE is currently considered experimental and is
-# not recommended for production use at this time.
+# SCHED_ULE provides significant performance advantages over 4BSD on many
+# workloads on SMP machines.  It supports cpu-affinity, per-cpu runqueues
+# and scheduler locks.  It also has a stronger notion of interactivity 
+# which leads to better responsiveness even on uniprocessor machines.  This
+# will eventually become the default scheduler.
 #
 options 	SCHED_4BSD
 #options 	SCHED_ULE
@@ -1898,6 +1899,7 @@
 # PCI Ethernet NICs.
 device		de		# DEC/Intel DC21x4x (``Tulip'')
 device		le		# AMD Am7900 LANCE and Am79C9xx PCnet
+device		mxge		# Myricom Myri-10G 10GbE NIC
 device		nxge		# Neterion Xframe 10GbE Server/Storage Adapter
 device		txp		# 3Com 3cR990 (``Typhoon'')
 device		vx		# 3Com 3c590, 3c595 (``Vortex'')

==== //depot/projects/soc2007/rpaulo-macbook/conf/files#19 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.1238 2007/07/14 21:49:23 rwatson Exp $
+# $FreeBSD: src/sys/conf/files,v 1.1239 2007/07/19 16:15:58 gallatin Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -812,6 +812,10 @@
 dev/mpt/mpt_pci.c		optional mpt pci
 dev/mpt/mpt_raid.c		optional mpt
 dev/msk/if_msk.c		optional msk
+dev/mxge/if_mxge.c		optional mxge pci
+dev/mxge/mxge_lro.c		optional mxge pci
+dev/mxge/mxge_eth_z8e.c		optional mxge pci
+dev/mxge/mxge_ethp_z8e.c	optional mxge pci
 dev/my/if_my.c			optional my
 dev/ncv/ncr53c500.c		optional ncv
 dev/ncv/ncr53c500_pccard.c	optional ncv pccard
@@ -1631,7 +1635,7 @@
 net/slcompress.c		optional netgraph_vjc | ppp | sl | sppp | \
 					 netgraph_sppp
 net/zlib.c			optional crypto | geom_uzip | ipsec | \
-					 ppp_deflate | netgraph_deflate
+					 mxge | ppp_deflate | netgraph_deflate
 net80211/ieee80211.c		optional wlan
 net80211/ieee80211_acl.c	optional wlan_acl
 net80211/ieee80211_amrr.c	optional wlan_amrr

==== //depot/projects/soc2007/rpaulo-macbook/dev/firewire/firewire.c#8 (text+ko) ====

@@ -31,7 +31,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  * 
- * $FreeBSD: src/sys/dev/firewire/firewire.c,v 1.99 2007/07/15 13:00:29 simokawa Exp $
+ * $FreeBSD: src/sys/dev/firewire/firewire.c,v 1.100 2007/07/20 03:42:57 simokawa Exp $
  *
  */
 
@@ -360,7 +360,7 @@
 	STAILQ_INIT(&xfer_timeout);
 
 	s = splfw();
-	FW_GLOCK(fc);
+	mtx_lock(&fc->tlabel_lock);
 	for (i = 0; i < 0x40; i ++) {
 		while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
 			if ((xfer->flag & FWXF_SENT) == 0)
@@ -378,7 +378,7 @@
 			STAILQ_INSERT_TAIL(&xfer_timeout, xfer, tlabel);
 		}
 	}
-	FW_GUNLOCK(fc);
+	mtx_unlock(&fc->tlabel_lock);
 	splx(s);
 	fc->timeout(fc);
 
@@ -430,6 +430,7 @@
 	fwdev_makedev(sc);
 
 	mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF);
+	mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF);
 	CALLOUT_INIT(&fc->timeout_callout);
 	CALLOUT_INIT(&fc->bmr_callout);
 	CALLOUT_INIT(&fc->busprobe_callout);
@@ -527,6 +528,7 @@
 	free(fc->speed_map, M_FW);
 	free(fc->crom_src_buf, M_FW);
 
+	mtx_destroy(&fc->tlabel_lock);
 	mtx_destroy(&fc->wait_lock);
 	return(0);
 }
@@ -569,7 +571,9 @@
 	fw_xferq_drain(fc->ats);
 	for(i = 0; i < fc->nisodma; i++)
 		fw_xferq_drain(fc->it[i]);
+	FW_GUNLOCK(fc);
 
+	mtx_lock(&fc->tlabel_lock);
 	for (i = 0; i < 0x40; i ++)
 		while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
 			if (firewire_debug)
@@ -578,7 +582,7 @@
 			STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel);
 			STAILQ_INSERT_TAIL(&xfer_drain, xfer, tlabel);
 		}
-	FW_GUNLOCK(fc);
+	mtx_unlock(&fc->tlabel_lock);
 
 	STAILQ_FOREACH_SAFE(xfer, &xfer_drain, tlabel, txfer)
 		xfer->hand(xfer);	
@@ -1011,7 +1015,7 @@
 		return;
 
 	s = splfw();
-	FW_GLOCK(fc);
+	mtx_lock(&fc->tlabel_lock);
 #if 1	/* make sure the label is allocated */
 	STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel)
 		if(txfer == xfer)
@@ -1023,14 +1027,14 @@
 		fw_dump_hdr(&xfer->send.hdr, "send");
 		fw_dump_hdr(&xfer->recv.hdr, "recv");
 		kdb_backtrace();
-		FW_GUNLOCK(fc);
+		mtx_unlock(&fc->tlabel_lock);
 		splx(s);
 		return;
 	}
 #endif
 
 	STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel);
-	FW_GUNLOCK(fc);
+	mtx_unlock(&fc->tlabel_lock);
 	splx(s);
 	return;
 }
@@ -1045,10 +1049,10 @@
 	int s = splfw();
 	int req;
 
-	FW_GLOCK(fc);
+	mtx_lock(&fc->tlabel_lock);
 	STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel)
 		if(xfer->send.hdr.mode.hdr.dst == node) {
-			FW_GUNLOCK(fc);
+			mtx_unlock(&fc->tlabel_lock);
 			splx(s);
 			KASSERT(xfer->tl == tlabel,
 				("xfer->tl 0x%x != 0x%x", xfer->tl, tlabel));
@@ -1065,7 +1069,7 @@
 				printf("fw_tl2xfer: found tl=%d\n", tlabel);
 			return(xfer);
 		}
-	FW_GUNLOCK(fc);
+	mtx_unlock(&fc->tlabel_lock);
 	if (firewire_debug > 1)
 		printf("fw_tl2xfer: not found tl=%d\n", tlabel);
 	splx(s);
@@ -1717,7 +1721,7 @@
 
 	dst = xfer->send.hdr.mode.hdr.dst & 0x3f;
 	s = splfw();
-	FW_GLOCK(fc);
+	mtx_lock(&fc->tlabel_lock);
 	new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f;
 	STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel)
 		if ((txfer->send.hdr.mode.hdr.dst & 0x3f) == dst)
@@ -1725,7 +1729,7 @@
 	if(txfer == NULL) {
 		fc->last_tlabel[dst] = new_tlabel;
 		STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel);
-		FW_GUNLOCK(fc);
+		mtx_unlock(&fc->tlabel_lock);
 		splx(s);
 		xfer->tl = new_tlabel;
 		xfer->send.hdr.mode.hdr.tlrt = new_tlabel << 2;
@@ -1733,7 +1737,7 @@
 			printf("fw_get_tlabel: dst=%d tl=%d\n", dst, new_tlabel);
 		return (new_tlabel);
 	}
-	FW_GUNLOCK(fc);
+	mtx_unlock(&fc->tlabel_lock);
 	splx(s);
 
 	if (firewire_debug > 1)

==== //depot/projects/soc2007/rpaulo-macbook/dev/firewire/firewirereg.h#7 (text+ko) ====

@@ -31,7 +31,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  * 
- * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.49 2007/07/15 13:00:29 simokawa Exp $
+ * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.50 2007/07/20 03:42:57 simokawa Exp $
  *
  */
 
@@ -134,6 +134,7 @@
 		*arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH];
 	struct fw_xferlist tlabels[0x40];
 	u_char last_tlabel[0x40];
+	struct mtx tlabel_lock;
 	STAILQ_HEAD(, fw_bind) binds;
 	STAILQ_HEAD(, fw_device) devices;
 	u_int  sid_cnt;

==== //depot/projects/soc2007/rpaulo-macbook/dev/msk/if_msk.c#4 (text+ko) ====

@@ -99,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.17 2007/06/11 02:00:50 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.18 2007/07/20 00:25:20 yongari Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -154,6 +154,8 @@
 /* Tunables. */
 static int msi_disable = 0;
 TUNABLE_INT("hw.msk.msi_disable", &msi_disable);
+static int legacy_intr = 0;
+TUNABLE_INT("hw.msk.legacy_intr", &legacy_intr);
 
 #define MSK_CSUM_FEATURES	(CSUM_TCP | CSUM_UDP)
 
@@ -229,6 +231,7 @@
 static int msk_detach(device_t);
 
 static void msk_tick(void *);
+static void msk_legacy_intr(void *);
 static int msk_intr(void *);
 static void msk_int_task(void *, int);
 static void msk_intr_phy(struct msk_if_softc *);
@@ -1709,6 +1712,8 @@
 	 * port cards with separate MSI messages, so for now I disable MSI
 	 * on dual port cards.
 	 */
+	if (legacy_intr != 0)
+		msi_disable = 1;
 	if (msic == 2 && msi_disable == 0 && sc->msk_num_port == 1 &&
 	    pci_alloc_msi(dev, &msic) == 0) {
 		if (msic == 2) {
@@ -1778,18 +1783,25 @@
 		goto fail;
 	}
 
-	TASK_INIT(&sc->msk_int_task, 0, msk_int_task, sc);
-	sc->msk_tq = taskqueue_create_fast("msk_taskq", M_WAITOK,
-	    taskqueue_thread_enqueue, &sc->msk_tq);
-	taskqueue_start_threads(&sc->msk_tq, 1, PI_NET, "%s taskq",
-	    device_get_nameunit(sc->msk_dev));
 	/* Hook interrupt last to avoid having to lock softc. */
-	error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET |
-	    INTR_MPSAFE, msk_intr, NULL, sc, &sc->msk_intrhand[0]);
+	if (legacy_intr)
+		error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET |
+		    INTR_MPSAFE, NULL, msk_legacy_intr, sc,
+		    &sc->msk_intrhand[0]);
+	else {
+		TASK_INIT(&sc->msk_int_task, 0, msk_int_task, sc);
+		sc->msk_tq = taskqueue_create_fast("msk_taskq", M_WAITOK,
+		    taskqueue_thread_enqueue, &sc->msk_tq);
+		taskqueue_start_threads(&sc->msk_tq, 1, PI_NET, "%s taskq",
+		    device_get_nameunit(sc->msk_dev));
+		error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET |
+		    INTR_MPSAFE, msk_intr, NULL, sc, &sc->msk_intrhand[0]);
+	}
 
 	if (error != 0) {
 		device_printf(dev, "couldn't set up interrupt handler\n");
-		taskqueue_free(sc->msk_tq);
+		if (legacy_intr == 0)
+			taskqueue_free(sc->msk_tq);
 		sc->msk_tq = NULL;
 		goto fail;
 	}
@@ -1892,7 +1904,7 @@
 
 	msk_status_dma_free(sc);
 
-	if (sc->msk_tq != NULL) {
+	if (legacy_intr == 0 && sc->msk_tq != NULL) {
 		taskqueue_drain(sc->msk_tq, &sc->msk_int_task);
 		taskqueue_free(sc->msk_tq);
 		sc->msk_tq = NULL;
@@ -3503,6 +3515,75 @@
 	return (sc->msk_stat_cons != CSR_READ_2(sc, STAT_PUT_IDX));
 }
 
+/* Legacy interrupt handler for shared interrupt. */
+static void
+msk_legacy_intr(void *xsc)
+{
+	struct msk_softc *sc;
+	struct msk_if_softc *sc_if0, *sc_if1;
+	struct ifnet *ifp0, *ifp1;
+	uint32_t status;
+
+	sc = xsc;
+	MSK_LOCK(sc);
+
+	/* Reading B0_Y2_SP_ISRC2 masks further interrupts. */
+	status = CSR_READ_4(sc, B0_Y2_SP_ISRC2);
+	if (status == 0 || status == 0xffffffff || sc->msk_suspended != 0 ||
+	    (status & sc->msk_intrmask) == 0) {
+		CSR_WRITE_4(sc, B0_Y2_SP_ICR, 2);
+		return;
+	}
+
+	sc_if0 = sc->msk_if[MSK_PORT_A];
+	sc_if1 = sc->msk_if[MSK_PORT_B];
+	ifp0 = ifp1 = NULL;
+	if (sc_if0 != NULL)
+		ifp0 = sc_if0->msk_ifp;
+	if (sc_if1 != NULL)
+		ifp1 = sc_if1->msk_ifp;
+
+	if ((status & Y2_IS_IRQ_PHY1) != 0 && sc_if0 != NULL)
+		msk_intr_phy(sc_if0);
+	if ((status & Y2_IS_IRQ_PHY2) != 0 && sc_if1 != NULL)
+		msk_intr_phy(sc_if1);
+	if ((status & Y2_IS_IRQ_MAC1) != 0 && sc_if0 != NULL)
+		msk_intr_gmac(sc_if0);
+	if ((status & Y2_IS_IRQ_MAC2) != 0 && sc_if1 != NULL)
+		msk_intr_gmac(sc_if1);
+	if ((status & (Y2_IS_CHK_RX1 | Y2_IS_CHK_RX2)) != 0) {
+		device_printf(sc->msk_dev, "Rx descriptor error\n");
+		sc->msk_intrmask &= ~(Y2_IS_CHK_RX1 | Y2_IS_CHK_RX2);
+		CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask);
+		CSR_READ_4(sc, B0_IMSK);
+	}
+        if ((status & (Y2_IS_CHK_TXA1 | Y2_IS_CHK_TXA2)) != 0) {
+		device_printf(sc->msk_dev, "Tx descriptor error\n");
+		sc->msk_intrmask &= ~(Y2_IS_CHK_TXA1 | Y2_IS_CHK_TXA2);
+		CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask);
+		CSR_READ_4(sc, B0_IMSK);
+	}
+	if ((status & Y2_IS_HW_ERR) != 0)
+		msk_intr_hwerr(sc);
+
+	while (msk_handle_events(sc) != 0)
+		;
+	if ((status & Y2_IS_STAT_BMU) != 0)
+		CSR_WRITE_4(sc, STAT_CTRL, SC_STAT_CLR_IRQ);
+
+	/* Reenable interrupts. */
+	CSR_WRITE_4(sc, B0_Y2_SP_ICR, 2);
+
+	if (ifp0 != NULL && (ifp0->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
+	    !IFQ_DRV_IS_EMPTY(&ifp0->if_snd))
+		taskqueue_enqueue(taskqueue_fast, &sc_if0->msk_tx_task);
+	if (ifp1 != NULL && (ifp1->if_drv_flags & IFF_DRV_RUNNING) != 0 &&
+	    !IFQ_DRV_IS_EMPTY(&ifp1->if_snd))
+		taskqueue_enqueue(taskqueue_fast, &sc_if1->msk_tx_task);
+
+	MSK_UNLOCK(sc);
+}
+
 static int
 msk_intr(void *xsc)
 {

==== //depot/projects/soc2007/rpaulo-macbook/dev/mxge/if_mxge.c#10 (text+ko) ====

@@ -28,7 +28,7 @@
 ***************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mxge/if_mxge.c,v 1.39 2007/07/12 16:04:54 gallatin Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mxge/if_mxge.c,v 1.40 2007/07/19 16:15:59 gallatin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -124,6 +124,7 @@
 /* Declare ourselves to be a child of the PCI bus.*/
 DRIVER_MODULE(mxge, pci, mxge_driver, mxge_devclass, 0, 0);
 MODULE_DEPEND(mxge, firmware, 1, 1, 1);
+MODULE_DEPEND(mxge, zlib, 1, 1, 1);
 
 static int mxge_load_firmware(mxge_softc_t *sc);
 static int mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data);
@@ -145,6 +146,7 @@
 static void
 mxge_enable_wc(mxge_softc_t *sc)
 {
+#if defined(__i386) || defined(__amd64)
 	struct mem_range_desc mrdesc;
 	vm_paddr_t pa;
 	vm_offset_t len;
@@ -152,7 +154,6 @@
 
 	sc->wc = 1;
 	len = rman_get_size(sc->mem_res);
-#if defined(__i386) || defined(__amd64)
 	err = pmap_change_attr((vm_offset_t) sc->sram,
 			       len, PAT_WRITE_COMBINING);
 	if (err == 0)
@@ -160,7 +161,6 @@
 	else
 		device_printf(sc->dev, "pmap_change_attr failed, %d\n",
 			      err);
-#endif		
 	pa = rman_get_start(sc->mem_res);
 	mrdesc.mr_base = pa;
 	mrdesc.mr_len = len;
@@ -174,6 +174,7 @@
 			      "w/c failed for pa 0x%lx, len 0x%lx, err = %d\n",
 			      (unsigned long)pa, (unsigned long)len, err);
 	}
+#endif		
 }
 
 
@@ -423,7 +424,7 @@
 }
 #else
 static void
-mxge_enable_nvidia_ecrc(mxge_softc_t *sc, device_t pdev)
+mxge_enable_nvidia_ecrc(mxge_softc_t *sc)
 {
 	device_printf(sc->dev,
 		      "Nforce 4 chipset on non-x86/amd64!?!?!\n");
@@ -644,62 +645,101 @@
 
 }
 
+static void *
+z_alloc(void *nil, u_int items, u_int size)
+{
+        void *ptr;
+
+        ptr = malloc(items * size, M_TEMP, M_NOWAIT);
+        return ptr;
+}
+
+static void
+z_free(void *nil, void *ptr)
+{
+        free(ptr, M_TEMP);
+}
+
+
 static int
 mxge_load_firmware_helper(mxge_softc_t *sc, uint32_t *limit)
 {
+	z_stream zs;
+	char *inflate_buffer;
 	const struct firmware *fw;
 	const mcp_gen_header_t *hdr;
 	unsigned hdr_offset;
-	const char *fw_data;
-	union qualhack hack;
 	int status;
 	unsigned int i;
 	char dummy;
-	
+	size_t fw_len;
 
 	fw = firmware_get(sc->fw_name);
-
 	if (fw == NULL) {
 		device_printf(sc->dev, "Could not find firmware image %s\n",
 			      sc->fw_name);
 		return ENOENT;
 	}
-	if (fw->datasize > *limit || 
-	    fw->datasize < MCP_HEADER_PTR_OFFSET + 4) {
-		device_printf(sc->dev, "Firmware image %s too large (%d/%d)\n",
-			      sc->fw_name, (int)fw->datasize, (int) *limit);
-		status = ENOSPC;
+
+
+
+	/* setup zlib and decompress f/w */
+	bzero(&zs, sizeof (zs));
+	zs.zalloc = z_alloc;
+	zs.zfree = z_free;
+	status = inflateInit(&zs);
+	if (status != Z_OK) {
+		status = EIO;
 		goto abort_with_fw;
 	}
-	*limit = fw->datasize;
+
+	/* the uncompressed size is stored as the firmware version,
+	   which would otherwise go unused */
+	fw_len = (size_t) fw->version; 
+	inflate_buffer = malloc(fw_len, M_TEMP, M_NOWAIT);
+	if (inflate_buffer == NULL)
+		goto abort_with_zs;
+	zs.avail_in = fw->datasize;
+	zs.next_in = __DECONST(char *, fw->data);
+	zs.avail_out = fw_len;
+	zs.next_out = inflate_buffer;
+	status = inflate(&zs, Z_FINISH);
+	if (status != Z_STREAM_END) {
+		device_printf(sc->dev, "zlib %d\n", status);
+		status = EIO;
+		goto abort_with_buffer;
+	}
 
 	/* check id */
-	fw_data = (const char *)fw->data;
 	hdr_offset = htobe32(*(const uint32_t *)
-			     (fw_data + MCP_HEADER_PTR_OFFSET));
-	if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->datasize) {
+			     (inflate_buffer + MCP_HEADER_PTR_OFFSET));
+	if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw_len) {
 		device_printf(sc->dev, "Bad firmware file");
 		status = EIO;
-		goto abort_with_fw;
+		goto abort_with_buffer;
 	}
-	hdr = (const void*)(fw_data + hdr_offset); 
+	hdr = (const void*)(inflate_buffer + hdr_offset); 
 
 	status = mxge_validate_firmware(sc, hdr);
 	if (status != 0)
-		goto abort_with_fw;
+		goto abort_with_buffer;
 
-	hack.ro_char = fw_data;
 	/* Copy the inflated firmware to NIC SRAM. */
-	for (i = 0; i < *limit; i += 256) {
+	for (i = 0; i < fw_len; i += 256) {
 		mxge_pio_copy(sc->sram + MXGE_FW_OFFSET + i,
-			      hack.rw_char + i,
-			      min(256U, (unsigned)(*limit - i)));
+			      inflate_buffer + i,
+			      min(256U, (unsigned)(fw_len - i)));
 		mb();
 		dummy = *sc->sram;
 		mb();
 	}
 
+	*limit = fw_len;
 	status = 0;
+abort_with_buffer:
+	free(inflate_buffer, M_TEMP);
+abort_with_zs:
+	inflateEnd(&zs);
 abort_with_fw:
 	firmware_put(fw, FIRMWARE_UNLOAD);
 	return status;
@@ -3205,7 +3245,6 @@
 			  &mxge_verbose);	
 	TUNABLE_INT_FETCH("hw.mxge.ticks", &mxge_ticks);
 	TUNABLE_INT_FETCH("hw.mxge.lro_cnt", &sc->lro_cnt);
-	printf("%d %d\n", sc->lro_cnt, mxge_lro_cnt);
 	if (sc->lro_cnt != 0)
 		mxge_lro_cnt = sc->lro_cnt;
 

==== //depot/projects/soc2007/rpaulo-macbook/fs/coda/coda_vfsops.c#2 (text+ko) ====

@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/coda/coda_vfsops.c,v 1.66 2007/07/12 21:04:57 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/coda/coda_vfsops.c,v 1.67 2007/07/20 11:14:51 rwatson Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -227,6 +227,7 @@
 	printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
 #endif
 	vrele(mi->mi_rootvp);
+	vrele(coda_ctlvp);
 	active = coda_kill(vfsp, NOT_DOWNCALL);
 	ASSERT_VOP_LOCKED(mi->mi_rootvp, "coda_unmount");
 	mi->mi_rootvp->v_vflag &= ~VV_ROOT;

==== //depot/projects/soc2007/rpaulo-macbook/fs/coda/coda_vnops.c#2 (text+ko) ====

@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/coda/coda_vnops.c,v 1.75 2007/07/12 21:04:57 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/coda/coda_vnops.c,v 1.76 2007/07/20 11:14:51 rwatson Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -745,11 +745,6 @@
     /* We don't need to send inactive to venus - DCS */
     MARK_ENTRY(CODA_INACTIVE_STATS);
 
-    if (IS_CTL_VP(vp)) {
-	MARK_INT_SAT(CODA_INACTIVE_STATS);
-	return 0;
-    }
-
     CODADEBUG(CODA_INACTIVE, myprintf(("in inactive, %s, vfsp %p\n",
 				  coda_f2s(&cp->c_fid), vp->v_mount));)
  

==== //depot/projects/soc2007/rpaulo-macbook/fs/tmpfs/tmpfs_vnops.c#6 (text+ko) ====

@@ -41,7 +41,7 @@
  * tmpfs vnode interface.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/tmpfs/tmpfs_vnops.c,v 1.7 2007/07/08 15:56:12 delphij Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/tmpfs/tmpfs_vnops.c,v 1.8 2007/07/19 03:34:50 delphij Exp $");
 
 #include <sys/param.h>
 #include <sys/fcntl.h>
@@ -440,72 +440,80 @@
 }
 
 /* --------------------------------------------------------------------- */
+
 static int
-tmpfs_uio_xfer(struct tmpfs_mount *tmp, struct tmpfs_node *node,
-    struct uio *uio, vm_object_t uobj)
+tmpfs_mappedread(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *uio)
 {
-	struct sf_buf *sf;
-	vm_pindex_t idx;
-	vm_offset_t d;
-	vm_page_t m;
-	size_t len;
-	int error = 0;
-	int behind = 0, ahead = 0;
+	vm_pindex_t	idx;
+	vm_page_t	m;
+	struct sf_buf	*sf;
+	off_t		offset, addr;
+	size_t		tlen;
+	caddr_t		va;
+	int		error;
 
-	/* uobj - locked by caller */
+	addr = uio->uio_offset;
+	idx = OFF_TO_IDX(addr);
+	offset = addr & PAGE_MASK;
+	tlen = MIN(PAGE_SIZE - offset, len);
 
-	VM_OBJECT_LOCK(uobj);
-	vm_object_pip_add(uobj, 1);
-	while (error == 0 && uio->uio_resid > 0) {
-		if (node->tn_size <= uio->uio_offset)
-			break;
+	if ((vobj == NULL) || (vobj->resident_page_count == 0))
+		goto nocache;
 
-		len = MIN(node->tn_size - uio->uio_offset, uio->uio_resid);
-		if (len == 0)
-			break;
-
-		idx = OFF_TO_IDX(uio->uio_offset);
-		d = uio->uio_offset - IDX_TO_OFF(idx);
-		len = MIN(len, (PAGE_SIZE - d));
-		m = vm_page_grab(uobj, idx, VM_ALLOC_WIRED | VM_ALLOC_ZERO |
-				VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
-		if (m->valid != VM_PAGE_BITS_ALL){
-			if (vm_pager_has_page(uobj, idx, &behind, &ahead)){
-				error = vm_pager_get_pages(uobj, &m, 1, 0);
-				if (error == VM_PAGER_ERROR){
-					printf("vm_pager_get_pages error\n");
-					goto	out;
-				}
-#ifdef DIAGNOSTIC
-				/* XXX */
-				printf("tmpfs gets page from pager\n");
-#endif
-			} else {
-				vm_page_zero_invalid(m, TRUE);
-			}
-		}
-		VM_OBJECT_UNLOCK(uobj);
+	VM_OBJECT_LOCK(vobj);
+lookupvpg:
+	if (((m = vm_page_lookup(vobj, idx)) != NULL) &&
+	    vm_page_is_valid(m, offset, tlen)) {
+		if (vm_page_sleep_if_busy(m, FALSE, "tmfsmr"))
+			goto lookupvpg;
+		vm_page_busy(m);
+		VM_OBJECT_UNLOCK(vobj);
 		sched_pin();
 		sf = sf_buf_alloc(m, SFB_CPUPRIVATE);
-		error = uiomove((void *)(sf_buf_kva(sf) + d), len, uio);
+		va = (caddr_t)sf_buf_kva(sf);
+		error = uiomove(va + offset, tlen, uio);
 		sf_buf_free(sf);
 		sched_unpin();
-		VM_OBJECT_LOCK(uobj);
-		vm_page_lock_queues();
-		if (error == 0 && uio->uio_rw == UIO_WRITE) {
-			vm_page_set_validclean(m, d, len);
+		VM_OBJECT_LOCK(vobj);
+		vm_page_wakeup(m);
+		VM_OBJECT_UNLOCK(vobj);
+		return	(error);
+	} 
+	VM_OBJECT_UNLOCK(vobj);
+nocache:
+	VM_OBJECT_LOCK(tobj);
+	vm_object_pip_add(tobj, 1);
+	m = vm_page_grab(tobj, idx, VM_ALLOC_WIRED |
+	    VM_ALLOC_ZERO | VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
+	if (m->valid != VM_PAGE_BITS_ALL) {
+		int behind, ahead;
+		if (vm_pager_has_page(tobj, idx, &behind, &ahead)) {
+			error = vm_pager_get_pages(tobj, &m, 1, 0);
+			if (error != 0) {
+				printf("tmpfs get pages from pager error [read]\n");
+				goto out;
+			}
+		} else
 			vm_page_zero_invalid(m, TRUE);
-			vm_page_dirty(m);
-		}
-		vm_page_unwire(m, 0);
-		vm_page_activate(m);
-		vm_page_wakeup(m);
-		vm_page_unlock_queues();
 	}
+	VM_OBJECT_UNLOCK(tobj);
+	sched_pin();
+	sf = sf_buf_alloc(m, SFB_CPUPRIVATE);
+	va = (caddr_t)sf_buf_kva(sf);
+	error = uiomove(va + offset, tlen, uio);
+	sf_buf_free(sf);
+	sched_unpin();
+	VM_OBJECT_LOCK(tobj);
 out:
-	vm_object_pip_subtract(uobj, 1);
-	VM_OBJECT_UNLOCK(uobj);
-	return error;
+	vm_page_lock_queues();
+	vm_page_unwire(m, 0);
+	vm_page_activate(m);
+	vm_page_unlock_queues();
+	vm_page_wakeup(m);
+	vm_object_pip_subtract(tobj, 1);
+	VM_OBJECT_UNLOCK(tobj);
+
+	return	(error);
 }
 
 static int
@@ -516,6 +524,8 @@
 
 	struct tmpfs_node *node;
 	vm_object_t uobj;
+	size_t len;
+	int resid;
 
 	int error;
 
@@ -534,7 +544,17 @@
 	node->tn_status |= TMPFS_NODE_ACCESSED;
 
 	uobj = node->tn_reg.tn_aobj;
-	error = tmpfs_uio_xfer(VFS_TO_TMPFS(vp->v_mount), node, uio, uobj);
+	while ((resid = uio->uio_resid) > 0) {
+		error = 0;
+		if (node->tn_size <= uio->uio_offset)
+			break;
+		len = MIN(node->tn_size - uio->uio_offset, resid);
+		if (len == 0)
+			break;
+		error = tmpfs_mappedread(vp->v_object, uobj, len, uio);
+		if ((error != 0) || (resid == uio->uio_resid))
+			break;
+	}
 
 out:
 
@@ -544,6 +564,100 @@
 /* --------------------------------------------------------------------- */
 
 static int
+tmpfs_mappedwrite(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *uio)
+{
+	vm_pindex_t	idx;
+	vm_page_t	vpg, tpg;
+	struct sf_buf	*sf;
+	off_t		offset, addr;
+	size_t		tlen;
+	caddr_t		va;
+	int		error;
+
+	addr = uio->uio_offset;
+	idx = OFF_TO_IDX(addr);
+	offset = addr & PAGE_MASK;
+	tlen = MIN(PAGE_SIZE - offset, len);
+
+	if ((vobj == NULL) || (vobj->resident_page_count == 0)) {
+		vpg = NULL;
+		goto nocache;
+	}
+
+	VM_OBJECT_LOCK(vobj);
+lookupvpg:
+	if (((vpg = vm_page_lookup(vobj, idx)) != NULL) &&
+	    vm_page_is_valid(vpg, offset, tlen)) {
+		if (vm_page_sleep_if_busy(vpg, FALSE, "tmfsmw"))
+			goto lookupvpg;
+		vm_page_busy(vpg);
+		vm_page_lock_queues();
+		vm_page_undirty(vpg);
+		vm_page_unlock_queues();
+		VM_OBJECT_UNLOCK(vobj);
+		sched_pin();
+		sf = sf_buf_alloc(vpg, SFB_CPUPRIVATE);
+		va = (caddr_t)sf_buf_kva(sf);
+		error = uiomove(va + offset, tlen, uio);
+		sf_buf_free(sf);
+		sched_unpin();
+	} else {
+		VM_OBJECT_UNLOCK(vobj);
+		vpg = NULL;
+	}
+nocache:
+	VM_OBJECT_LOCK(tobj);
+	vm_object_pip_add(tobj, 1);
+	tpg = vm_page_grab(tobj, idx, VM_ALLOC_WIRED |
+	    VM_ALLOC_ZERO | VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
+	if (tpg->valid != VM_PAGE_BITS_ALL) {
+		int behind, ahead;
+		if (vm_pager_has_page(tobj, idx, &behind, &ahead)) {
+			error = vm_pager_get_pages(tobj, &tpg, 1, 0);
+			if (error != 0) {
+				printf("tmpfs get pages from pager error [write]\n");
+				goto out;
+			}
+		} else
+			vm_page_zero_invalid(tpg, TRUE);
+	}
+	VM_OBJECT_UNLOCK(tobj);
+	if (vpg == NULL) {
+		sched_pin();
+		sf = sf_buf_alloc(tpg, SFB_CPUPRIVATE);
+		va = (caddr_t)sf_buf_kva(sf);
+		error = uiomove(va + offset, tlen, uio);
+		sf_buf_free(sf);
+		sched_unpin();
+	} else {
+		KASSERT(vpg->valid == VM_PAGE_BITS_ALL, ("parts of vpg invalid"));
+		pmap_copy_page(vpg, tpg);
+	}
+	VM_OBJECT_LOCK(tobj);
+out:
+	if (vobj != NULL)
+		VM_OBJECT_LOCK(vobj);
+	vm_page_lock_queues();
+	if (error == 0) {
+		vm_page_set_validclean(tpg, offset, tlen);
+		vm_page_zero_invalid(tpg, TRUE);
+		vm_page_dirty(tpg);
+	}
+	vm_page_unwire(tpg, 0);
+	vm_page_activate(tpg);
+	vm_page_unlock_queues();
+	vm_page_wakeup(tpg);
+	if (vpg != NULL)
+		vm_page_wakeup(vpg);
+	if (vobj != NULL)
+		VM_OBJECT_UNLOCK(vobj);
+	vm_object_pip_subtract(tobj, 1);
+	VM_OBJECT_UNLOCK(tobj);
+
+	return	(error);
+}
+
+static int
 tmpfs_write(struct vop_write_args *v)
 {
 	struct vnode *vp = v->a_vp;
@@ -552,10 +666,12 @@
 	struct thread *td = uio->uio_td;
 
 	boolean_t extended;
-	int error;
+	int error = 0;
 	off_t oldsize;
 	struct tmpfs_node *node;
 	vm_object_t uobj;
+	size_t len;
+	int resid;
 
 	node = VP_TO_TMPFS_NODE(vp);
 	oldsize = node->tn_size;
@@ -596,7 +712,16 @@
 	}
 
 	uobj = node->tn_reg.tn_aobj;
-	error = tmpfs_uio_xfer(VFS_TO_TMPFS(vp->v_mount), node, uio, uobj);
+	while ((resid = uio->uio_resid) > 0) {
+		if (node->tn_size <= uio->uio_offset)
+			break;
+		len = MIN(node->tn_size - uio->uio_offset, resid);
+		if (len == 0)
+			break;
+		error = tmpfs_mappedwrite(vp->v_object, uobj, len, uio);
+		if ((error != 0) || (resid == uio->uio_resid))
+			break;
+	}
 
 	node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
 	    (extended ? TMPFS_NODE_CHANGED : 0);

==== //depot/projects/soc2007/rpaulo-macbook/i386/linux/linux_machdep.c#5 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.77 2007/07/04 23:06:43 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.78 2007/07/20 08:35:18 attilio Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -846,9 +846,7 @@
 	iia.start = args->start;
 	iia.length = args->length;
 	iia.enable = args->enable;
-	mtx_lock(&Giant);
 	error = i386_set_ioperm(td, &iia);
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -884,10 +882,8 @@
 		ldt.start = 0;
 		ldt.descs = uap->ptr;
 		ldt.num = uap->bytecount / sizeof(union descriptor);
-		mtx_lock(&Giant);
 		error = i386_get_ldt(td, &ldt);
 		td->td_retval[0] *= sizeof(union descriptor);
-		mtx_unlock(&Giant);
 		break;
 	case 0x01: /* write_ldt */

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707201611.l6KGBVfm087773>