Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Nov 2005 22:22:29 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 87056 for review
Message-ID:  <200511212222.jALMMTvW082033@repoman.freebsd.org>

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

Change 87056 by jhb@jhb_slimer on 2005/11/21 22:22:15

	IFC @87054.

Affected files ...

.. //depot/projects/smpng/sys/alpha/conf/DEFAULTS#1 branch
.. //depot/projects/smpng/sys/alpha/conf/GENERIC#52 integrate
.. //depot/projects/smpng/sys/amd64/conf/DEFAULTS#2 integrate
.. //depot/projects/smpng/sys/conf/files.i386#90 integrate
.. //depot/projects/smpng/sys/dev/acpica/acpi_pci_link.c#32 integrate
.. //depot/projects/smpng/sys/dev/nve/if_nve.c#9 integrate
.. //depot/projects/smpng/sys/dev/nve/if_nvereg.h#3 integrate
.. //depot/projects/smpng/sys/dev/puc/puc.c#26 integrate
.. //depot/projects/smpng/sys/i386/conf/DEFAULTS#2 integrate
.. //depot/projects/smpng/sys/ia64/conf/DEFAULTS#1 branch
.. //depot/projects/smpng/sys/ia64/conf/GENERIC#46 integrate
.. //depot/projects/smpng/sys/pc98/conf/DEFAULTS#2 integrate
.. //depot/projects/smpng/sys/pci/if_de.c#30 integrate
.. //depot/projects/smpng/sys/pci/if_devar.h#12 integrate
.. //depot/projects/smpng/sys/powerpc/conf/DEFAULTS#1 branch
.. //depot/projects/smpng/sys/powerpc/conf/GENERIC#30 integrate
.. //depot/projects/smpng/sys/sparc64/conf/DEFAULTS#1 branch
.. //depot/projects/smpng/sys/sparc64/conf/GENERIC#60 integrate

Differences ...

==== //depot/projects/smpng/sys/alpha/conf/GENERIC#52 (text+ko) ====

@@ -18,7 +18,7 @@
 #
 # For hardware specific information check HARDWARE.TXT
 #
-# $FreeBSD: src/sys/alpha/conf/GENERIC,v 1.189 2005/11/05 19:48:53 marcel Exp $
+# $FreeBSD: src/sys/alpha/conf/GENERIC,v 1.190 2005/11/21 20:17:45 jhb Exp $
 
 machine		alpha
 cpu		EV4
@@ -183,7 +183,6 @@
 
 # Pseudo devices.
 device		loop		# Network loopback
-device		mem		# Memory and kernel memory devices
 device		random		# Entropy device
 device		ether		# Ethernet support
 device		sl		# Kernel SLIP

==== //depot/projects/smpng/sys/amd64/conf/DEFAULTS#2 (text+ko) ====

@@ -1,7 +1,7 @@
 #
 # DEFAULTS -- Default kernel configuration file for FreeBSD/amd64
 #
-# $FreeBSD: src/sys/amd64/conf/DEFAULTS,v 1.2 2005/10/27 18:54:43 peter Exp $
+# $FreeBSD: src/sys/amd64/conf/DEFAULTS,v 1.3 2005/11/21 20:22:34 jhb Exp $
 
 # Not yet, this would break all existing configs
 #machine		amd64
@@ -12,3 +12,5 @@
 # Pseudo devices.
 device		mem		# Memory and kernel memory devices
 device		io		# I/O device
+
+options 	PUC_FASTINTR

==== //depot/projects/smpng/sys/conf/files.i386#90 (text+ko) ====

@@ -1,7 +1,7 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
-# $FreeBSD: src/sys/conf/files.i386,v 1.544 2005/11/11 09:57:30 ru Exp $
+# $FreeBSD: src/sys/conf/files.i386,v 1.545 2005/11/21 20:11:39 ru Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -232,7 +232,7 @@
 i386/acpica/acpi_machdep.c	optional acpi
 i386/acpica/acpi_wakeup.c	optional acpi
 acpi_wakecode.h			optional acpi			\
-	dependency 	"$S/i386/acpica/acpi_wakecode.S"		\
+	dependency 	"$S/i386/acpica/acpi_wakecode.S assym.s"	\
 	compile-with	"${MAKE} -f $S/i386/acpica/Makefile MAKESRCPATH=$S/i386/acpica"	\
 	no-obj no-implicit-rule before-depend				\
 	clean		"acpi_wakecode.h acpi_wakecode.o acpi_wakecode.bin"

==== //depot/projects/smpng/sys/dev/acpica/acpi_pci_link.c#32 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci_link.c,v 1.48 2005/11/01 22:44:07 jkim Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci_link.c,v 1.49 2005/11/21 22:01:16 jhb Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -608,7 +608,19 @@
 {
 	struct link *link;
 	uint8_t bios_irq;
+	uintptr_t bus;
 
+	/*
+	 * Look up the PCI bus for the specified PCI bridge device.  Note
+	 * that the PCI bridge device might not have any children yet.
+	 * However, looking up its bus number doesn't require a valid child
+	 * device, so we just pass NULL.
+	 */
+	if (BUS_READ_IVAR(pcib, NULL, PCIB_IVAR_BUS, &bus) != 0) {
+		device_printf(pcib, "Unable to read PCI bus number");
+		panic("this is bad");
+	}
+		
 	/* Bump the reference count. */
 	ACPI_SERIAL_BEGIN(pci_link);
 	link = acpi_pci_link_lookup(dev, index);
@@ -619,7 +631,7 @@
 		pci_link_interrupt_weights[link->l_irq]++;
 
 	/* Try to find a BIOS IRQ setting from any matching devices. */
-	bios_irq = acpi_pci_link_search_irq(pcib_get_bus(pcib), slot, pin);
+	bios_irq = acpi_pci_link_search_irq(bus, slot, pin);
 	if (!PCI_INTERRUPT_VALID(bios_irq)) {
 		ACPI_SERIAL_END(pci_link);
 		return;
@@ -628,7 +640,7 @@
 	/* Validate the BIOS IRQ. */
 	if (!link_valid_irq(link, bios_irq)) {
 		device_printf(dev, "BIOS IRQ %u for %d.%d.INT%c is invalid\n",
-		    bios_irq, pcib_get_bus(pcib), slot, pin + 'A');
+		    bios_irq, (int)bus, slot, pin + 'A');
 	} else if (!PCI_INTERRUPT_VALID(link->l_bios_irq)) {
 		link->l_bios_irq = bios_irq;
 		if (bios_irq < NUM_ISA_INTERRUPTS)
@@ -641,7 +653,7 @@
 	} else if (bios_irq != link->l_bios_irq)
 		device_printf(dev,
 	    "BIOS IRQ %u for %d.%d.INT%c does not match previous BIOS IRQ %u\n",
-		    bios_irq, pcib_get_bus(pcib), slot, pin + 'A',
+		    bios_irq, (int)bus, slot, pin + 'A',
 		    link->l_bios_irq);
 	ACPI_SERIAL_END(pci_link);
 }

==== //depot/projects/smpng/sys/dev/nve/if_nve.c#9 (text+ko) ====

@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/nve/if_nve.c,v 1.14 2005/11/11 16:04:53 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/nve/if_nve.c,v 1.15 2005/11/21 22:14:49 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -130,12 +130,14 @@
 static int      nve_attach(device_t);
 static int      nve_detach(device_t);
 static void     nve_init(void *);
+static void     nve_init_locked(struct nve_softc *);
 static void     nve_stop(struct nve_softc *);
 static void     nve_shutdown(device_t);
 static int      nve_init_rings(struct nve_softc *);
 static void     nve_free_rings(struct nve_softc *);
 
 static void     nve_ifstart(struct ifnet *);
+static void     nve_ifstart_locked(struct ifnet *);
 static int      nve_ioctl(struct ifnet *, u_long, caddr_t);
 static void     nve_intr(void *);
 static void     nve_tick(void *);
@@ -144,6 +146,7 @@
 static void     nve_update_stats(struct nve_softc *);
 
 static int      nve_ifmedia_upd(struct ifnet *);
+static void	nve_ifmedia_upd_locked(struct ifnet *);
 static void     nve_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 static int      nve_miibus_readreg(device_t, int, int);
 static void     nve_miibus_writereg(device_t, int, int, int);
@@ -304,20 +307,19 @@
 	struct ifnet		*ifp;
 	OS_API			*osapi;
 	ADAPTER_OPEN_PARAMS	OpenParams;
-	int			error = 0, i, rid, unit;
+	int			error = 0, i, rid;
 
 	DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_attach - entry\n");
 
 	sc = device_get_softc(dev);
-	unit = device_get_unit(dev);
 
 	/* Allocate mutex */
 	mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
 	    MTX_DEF | MTX_RECURSE);
 	mtx_init(&sc->osmtx, device_get_nameunit(dev), NULL, MTX_SPIN);
+	callout_init_mtx(&sc->stat_callout, &sc->mtx, 0);
 
 	sc->dev = dev;
-	sc->unit = unit;
 
 	/* Preinitialize data structures */
 	bzero(&OpenParams, sizeof(ADAPTER_OPEN_PARAMS));
@@ -510,7 +512,7 @@
 
 	/* Setup interface parameters */
 	ifp->if_softc = sc;
-	if_initname(ifp, "nve", unit);
+	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = nve_ioctl;
 	ifp->if_output = ether_output;
@@ -525,11 +527,10 @@
 
 	/* Attach to OS's managers. */
 	ether_ifattach(ifp, eaddr);
-	callout_handle_init(&sc->stat_ch);
 
 	/* Activate our interrupt handler. - attach last to avoid lock */
-	error = bus_setup_intr(sc->dev, sc->irq, INTR_TYPE_NET, nve_intr,
-	    sc, &sc->sc_ih);
+	error = bus_setup_intr(sc->dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
+	    nve_intr, sc, &sc->sc_ih);
 	if (error) {
 		device_printf(sc->dev, "couldn't set up interrupt handler\n");
 		goto fail;
@@ -551,15 +552,16 @@
 	struct ifnet *ifp;
 
 	KASSERT(mtx_initialized(&sc->mtx), ("mutex not initialized"));
-	NVE_LOCK(sc);
 
 	DEBUGOUT(NVE_DEBUG_DEINIT, "nve: nve_detach - entry\n");
 
 	ifp = sc->ifp;
 
 	if (device_is_attached(dev)) {
+		NVE_LOCK(sc);
 		nve_stop(sc);
-		/* XXX shouldn't hold lock over call to ether_ifdetch */
+		NVE_UNLOCK(sc);
+		callout_drain(&sc->stat_callout);
 		ether_ifdetach(ifp);
 	}
 
@@ -598,7 +600,6 @@
 	if (sc->rtag)
 		bus_dma_tag_destroy(sc->rtag);
 
-	NVE_UNLOCK(sc);
 	if (ifp)
 		if_free(ifp);
 	mtx_destroy(&sc->mtx);
@@ -614,17 +615,26 @@
 nve_init(void *xsc)
 {
 	struct nve_softc *sc = xsc;
+
+	NVE_LOCK(sc);
+	nve_init_locked(sc);
+	NVE_UNLOCK(sc);
+}
+
+static void
+nve_init_locked(struct nve_softc *sc)
+{
 	struct ifnet *ifp;
 	int error;
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 	DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init - entry (%d)\n", sc->linkup);
 
 	ifp = sc->ifp;
 
 	/* Do nothing if already running */
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-		goto fail;
+		return;
 
 	nve_stop(sc);
 	DEBUGOUT(NVE_DEBUG_INIT, "nve: do pfnInit\n");
@@ -640,7 +650,7 @@
 	if (error) {
 		device_printf(sc->dev,
 		    "failed to start NVIDIA Hardware interface\n");
-		goto fail;
+		return;
 	}
 	/* Set the MAC address */
 	sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, IF_LLADDR(sc->ifp));
@@ -649,19 +659,16 @@
 
 	/* Setup multicast filter */
 	nve_setmulti(sc);
-	nve_ifmedia_upd(ifp);
+	nve_ifmedia_upd_locked(ifp);
 
 	/* Update interface parameters */
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 
-	sc->stat_ch = timeout(nve_tick, sc, hz);
+	callout_reset(&sc->stat_callout, hz, nve_tick, sc);
 
 	DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init - exit\n");
 
-fail:
-	NVE_UNLOCK(sc);
-
 	return;
 }
 
@@ -671,7 +678,7 @@
 {
 	struct ifnet *ifp;
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 
 	DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_stop - entry\n");
 
@@ -679,7 +686,7 @@
 	ifp->if_timer = 0;
 
 	/* Cancel tick timer */
-	untimeout(nve_tick, sc, sc->stat_ch);
+	callout_stop(&sc->stat_callout);
 
 	/* Stop hardware activity */
 	sc->hwapi->pfnDisableInterrupts(sc->hwapi->pADCX);
@@ -699,8 +706,6 @@
 
 	DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_stop - exit\n");
 
-	NVE_UNLOCK(sc);
-
 	return;
 }
 
@@ -715,7 +720,9 @@
 	sc = device_get_softc(dev);
 
 	/* Stop hardware activity */
+	NVE_LOCK(sc);
 	nve_stop(sc);
+	NVE_UNLOCK(sc);
 }
 
 /* Allocate TX ring buffers */
@@ -724,8 +731,6 @@
 {
 	int error, i;
 
-	NVE_LOCK(sc);
-
 	DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init_rings - entry\n");
 
 	sc->cur_rx = sc->cur_tx = sc->pending_rxs = sc->pending_txs = 0;
@@ -738,8 +743,7 @@
 		if (buf->mbuf == NULL) {
 			device_printf(sc->dev, "couldn't allocate mbuf\n");
 			nve_free_rings(sc);
-			error = ENOBUFS;
-			goto fail;
+			return (ENOBUFS);
 		}
 		buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
 		m_adj(buf->mbuf, ETHER_ALIGN);
@@ -748,14 +752,14 @@
 		if (error) {
 			device_printf(sc->dev, "couldn't create dma map\n");
 			nve_free_rings(sc);
-			goto fail;
+			return (error);
 		}
 		error = bus_dmamap_load_mbuf(sc->mtag, buf->map, buf->mbuf,
 					  nve_dmamap_rx_cb, &desc->paddr, 0);
 		if (error) {
 			device_printf(sc->dev, "couldn't dma map mbuf\n");
 			nve_free_rings(sc);
-			goto fail;
+			return (error);
 		}
 		bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREREAD);
 
@@ -776,7 +780,7 @@
 		if (error) {
 			device_printf(sc->dev, "couldn't create dma map\n");
 			nve_free_rings(sc);
-			goto fail;
+			return (error);
 		}
 	}
 	bus_dmamap_sync(sc->ttag, sc->tmap,
@@ -784,9 +788,6 @@
 
 	DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init_rings - exit\n");
 
-fail:
-	NVE_UNLOCK(sc);
-
 	return (error);
 }
 
@@ -796,8 +797,6 @@
 {
 	int i;
 
-	NVE_LOCK(sc);
-
 	DEBUGOUT(NVE_DEBUG_DEINIT, "nve: nve_free_rings - entry\n");
 
 	for (i = 0; i < RX_RING_SIZE; i++) {
@@ -825,13 +824,21 @@
 	}
 
 	DEBUGOUT(NVE_DEBUG_DEINIT, "nve: nve_free_rings - exit\n");
+}
 
+/* Main loop for sending packets from OS to interface */
+static void
+nve_ifstart(struct ifnet *ifp)
+{
+	struct nve_softc *sc = ifp->if_softc;
+
+	NVE_LOCK(sc);
+	nve_ifstart_locked(ifp);
 	NVE_UNLOCK(sc);
 }
 
-/* Main loop for sending packets from OS to interface */
 static void
-nve_ifstart(struct ifnet *ifp)
+nve_ifstart_locked(struct ifnet *ifp)
 {
 	struct nve_softc *sc = ifp->if_softc;
 	struct nve_map_buffer *buf;
@@ -842,8 +849,11 @@
 
 	DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_ifstart - entry\n");
 
+	NVE_LOCK_ASSERT(sc);
+
 	/* If link is down/busy or queue is empty do nothing */
-	if (ifp->if_drv_flags & IFF_DRV_OACTIVE || ifp->if_snd.ifq_head == NULL)
+	if (ifp->if_drv_flags & IFF_DRV_OACTIVE ||
+	    IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 		return;
 
 	/* Transmit queued packets until sent or TX ring is full */
@@ -953,46 +963,54 @@
 	struct mii_data *mii;
 	int error = 0;
 
-	NVE_LOCK(sc);
-
 	DEBUGOUT(NVE_DEBUG_IOCTL, "nve: nve_ioctl - entry\n");
 
 	switch (command) {
 	case SIOCSIFMTU:
 		/* Set MTU size */
-		if (ifp->if_mtu == ifr->ifr_mtu)
+		NVE_LOCK(sc);
+		if (ifp->if_mtu == ifr->ifr_mtu) {
+			NVE_UNLOCK(sc);
 			break;
+		}
 		if (ifr->ifr_mtu + ifp->if_hdrlen <= MAX_PACKET_SIZE_1518) {
 			ifp->if_mtu = ifr->ifr_mtu;
 			nve_stop(sc);
-			nve_init(sc);
+			nve_init_locked(sc);
 		} else
 			error = EINVAL;
+		NVE_UNLOCK(sc);
 		break;
 
 	case SIOCSIFFLAGS:
 		/* Setup interface flags */
+		NVE_LOCK(sc);
 		if (ifp->if_flags & IFF_UP) {
 			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
-				nve_init(sc);
+				nve_init_locked(sc);
+				NVE_UNLOCK(sc);
 				break;
 			}
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 				nve_stop(sc);
+				NVE_UNLOCK(sc);
 				break;
 			}
 		}
 		/* Handle IFF_PROMISC and IFF_ALLMULTI flags. */
 		nve_setmulti(sc);
+		NVE_UNLOCK(sc);
 		break;
 
 	case SIOCADDMULTI:
 	case SIOCDELMULTI:
 		/* Setup multicast filter */
+		NVE_LOCK(sc);
 		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 			nve_setmulti(sc);
 		}
+		NVE_UNLOCK(sc);
 		break;
 
 	case SIOCGIFMEDIA:
@@ -1010,8 +1028,6 @@
 
 	DEBUGOUT(NVE_DEBUG_IOCTL, "nve: nve_ioctl - exit\n");
 
-	NVE_UNLOCK(sc);
-
 	return (error);
 }
 
@@ -1024,8 +1040,10 @@
 
 	DEBUGOUT(NVE_DEBUG_INTERRUPT, "nve: nve_intr - entry\n");
 
+	NVE_LOCK(sc);
 	if (!ifp->if_flags & IFF_UP) {
 		nve_stop(sc);
+		NVE_UNLOCK(sc);
 		return;
 	}
 	/* Handle interrupt event */
@@ -1033,12 +1051,13 @@
 		sc->hwapi->pfnHandleInterrupt(sc->hwapi->pADCX);
 		sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
 	}
-	if (ifp->if_snd.ifq_head != NULL)
-		nve_ifstart(ifp);
+	if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+		nve_ifstart_locked(ifp);
 
 	/* If no pending packets we don't need a timeout */
 	if (sc->pending_txs == 0)
 		sc->ifp->if_timer = 0;
+	NVE_UNLOCK(sc);
 
 	DEBUGOUT(NVE_DEBUG_INTERRUPT, "nve: nve_intr - exit\n");
 
@@ -1055,7 +1074,7 @@
 	int i;
 	u_int8_t andaddr[6], oraddr[6];
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 
 	DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_setmulti - entry\n");
 
@@ -1072,7 +1091,6 @@
 		/* Accept all packets */
 		hwfilter.ulFilterFlags |= ACCEPT_ALL_PACKETS;
 		sc->hwapi->pfnSetPacketFilter(sc->hwapi->pADCX, &hwfilter);
-		NVE_UNLOCK(sc);
 		return;
 	}
 	/* Setup multicast filter */
@@ -1099,8 +1117,6 @@
 	/* Send filter to NVIDIA API */
 	sc->hwapi->pfnSetPacketFilter(sc->hwapi->pADCX, &hwfilter);
 
-	NVE_UNLOCK(sc);
-
 	DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_setmulti - exit\n");
 
 	return;
@@ -1111,10 +1127,22 @@
 nve_ifmedia_upd(struct ifnet *ifp)
 {
 	struct nve_softc *sc = ifp->if_softc;
+
+	NVE_LOCK(sc);
+	nve_ifmedia_upd_locked(ifp);
+	NVE_UNLOCK(sc);
+	return (0);
+}
+
+static void
+nve_ifmedia_upd_locked(struct ifnet *ifp)
+{
+	struct nve_softc *sc = ifp->if_softc;
 	struct mii_data *mii;
 
 	DEBUGOUT(NVE_DEBUG_MII, "nve: nve_ifmedia_upd\n");
 
+	NVE_LOCK_ASSERT(sc);
 	mii = device_get_softc(sc->miibus);
 
 	if (mii->mii_instance) {
@@ -1125,8 +1153,6 @@
 		}
 	}
 	mii_mediachg(mii);
-
-	return (0);
 }
 
 /* Update current miibus PHY status of media */
@@ -1139,8 +1165,10 @@
 	DEBUGOUT(NVE_DEBUG_MII, "nve: nve_ifmedia_sts\n");
 
 	sc = ifp->if_softc;
+	NVE_LOCK(sc);
 	mii = device_get_softc(sc->miibus);
 	mii_pollstat(mii);
+	NVE_UNLOCK(sc);
 
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
@@ -1156,7 +1184,7 @@
 	struct mii_data *mii;
 	struct ifnet *ifp;
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 
 	ifp = sc->ifp;
 	nve_update_stats(sc);
@@ -1166,12 +1194,10 @@
 
 	if (mii->mii_media_status & IFM_ACTIVE &&
 	    IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
-		if (ifp->if_snd.ifq_head != NULL)
-			nve_ifstart(ifp);
+		if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+			nve_ifstart_locked(ifp);
 	}
-	sc->stat_ch = timeout(nve_tick, sc, hz);
-
-	NVE_UNLOCK(sc);
+	callout_reset(&sc->stat_callout, hz, nve_tick, sc);
 
 	return;
 }
@@ -1183,7 +1209,7 @@
 	struct ifnet *ifp = sc->ifp;
 	ADAPTER_STATS stats;
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 
 	if (sc->hwapi) {
 		sc->hwapi->pfnGetStatistics(sc->hwapi->pADCX, &stats);
@@ -1205,7 +1231,6 @@
 
 		ifp->if_collisions = stats.ulLateCollisionErrors;
 	}
-	NVE_UNLOCK(sc);
 
 	return;
 }
@@ -1249,14 +1274,16 @@
 
 	device_printf(sc->dev, "device timeout (%d)\n", sc->pending_txs);
 
+	NVE_LOCK(sc);
 	sc->tx_errors++;
 
 	nve_stop(sc);
 	ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
-	nve_init(sc);
+	nve_init_locked(sc);
 
-	if (ifp->if_snd.ifq_head != NULL)
-		nve_ifstart(ifp);
+	if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+		nve_ifstart_locked(ifp);
+	NVE_UNLOCK(sc);
 
 	return;
 }
@@ -1389,7 +1416,8 @@
 	struct nve_map_buffer *buf;
 	int error;
 
-	NVE_LOCK(sc);
+	if (device_is_attached(sc->dev))
+		NVE_LOCK_ASSERT(sc);
 
 	DEBUGOUT(NVE_DEBUG_API, "nve: nve_osallocrxbuf\n");
 
@@ -1429,11 +1457,9 @@
 	mem->uiLength = desc->buflength;
 	*id = (void *)desc;
 
-	NVE_UNLOCK(sc);
 	return (1);
 	
 fail:
-	NVE_UNLOCK(sc);
 	return (0);
 }
 
@@ -1445,8 +1471,6 @@
 	struct nve_rx_desc *desc;
 	struct nve_map_buffer *buf;
 
-	NVE_LOCK(sc);
-
 	DEBUGOUT(NVE_DEBUG_API, "nve: nve_osfreerxbuf\n");
 
 	desc = (struct nve_rx_desc *) id;
@@ -1460,8 +1484,6 @@
 	sc->pending_rxs--;
 	buf->mbuf = NULL;
 
-	NVE_UNLOCK(sc);
-
 	return (1);
 }
 
@@ -1474,7 +1496,7 @@
 	struct nve_tx_desc *desc = (struct nve_tx_desc *) id;
 	struct ifnet *ifp;
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 
 	DEBUGOUT(NVE_DEBUG_API, "nve: nve_ospackettx\n");
 
@@ -1495,11 +1517,10 @@
 	if (sc->pending_txs < TX_RING_SIZE)
 		sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 
-	if (ifp->if_snd.ifq_head != NULL && sc->pending_txs < TX_RING_SIZE)
-		nve_ifstart(ifp);
+	if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd) && sc->pending_txs < TX_RING_SIZE)
+		nve_ifstart_locked(ifp);
 
 fail:
-	NVE_UNLOCK(sc);
 
 	return (1);
 }
@@ -1515,8 +1536,9 @@
 	struct nve_rx_desc *desc;
 	struct nve_map_buffer *buf;
 	ADAPTER_READ_DATA *readdata;
+	struct mbuf *m;
 
-	NVE_LOCK(sc);
+	NVE_LOCK_ASSERT(sc);
 
 	DEBUGOUT(NVE_DEBUG_API, "nve: nve_ospacketrx\n");
 
@@ -1538,13 +1560,17 @@
 
 		bus_dmamap_unload(sc->mtag, buf->map);
 
+		/* Blat the mbuf pointer, kernel will free the mbuf cluster */
+		m = buf->mbuf;
+		buf->mbuf = NULL;
+
 		/* Give mbuf to OS. */
-		(*ifp->if_input) (ifp, buf->mbuf);
+		NVE_UNLOCK(sc);
+		(*ifp->if_input)(ifp, m);
+		NVE_LOCK(sc);
 		if (readdata->ulFilterMatch & ADREADFL_MULTICAST_MATCH)
 			ifp->if_imcasts++;
 
-		/* Blat the mbuf pointer, kernel will free the mbuf cluster */
-		buf->mbuf = NULL;
 	} else {
 		bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
 		bus_dmamap_unload(sc->mtag, buf->map);
@@ -1555,8 +1581,6 @@
 	sc->cur_rx = desc - sc->rx_desc;
 	sc->pending_rxs--;
 
-	NVE_UNLOCK(sc);
-
 	return (1);
 }
 
@@ -1587,7 +1611,7 @@
 
 	DEBUGOUT(NVE_DEBUG_BROKEN, "nve: nve_osalloctimer\n");
 
-	callout_handle_init(&sc->ostimer);
+	callout_init(&sc->ostimer, CALLOUT_MPSAFE);
 	*timer = &sc->ostimer;
 
 	return (1);
@@ -1600,6 +1624,8 @@
 
 	DEBUGOUT(NVE_DEBUG_BROKEN, "nve: nve_osfreetimer\n");
 
+	callout_drain((struct callout *)timer);
+
 	return (1);
 }
 
@@ -1625,8 +1651,8 @@
 
 	DEBUGOUT(NVE_DEBUG_BROKEN, "nve: nve_ossettimer\n");
 
-	*(struct callout_handle *)timer = timeout(sc->ostimer_func,
-	    sc->ostimer_params, delay);
+	callout_reset((struct callout *)timer, delay, sc->ostimer_func,
+	    sc->ostimer_params);
 
 	return (1);
 }
@@ -1635,12 +1661,10 @@
 static NV_SINT32
 nve_oscanceltimer(PNV_VOID ctx, PNV_VOID timer)
 {
-	struct nve_softc *sc = ctx;
 
 	DEBUGOUT(NVE_DEBUG_BROKEN, "nve: nve_oscanceltimer\n");
 
-	untimeout(sc->ostimer_func, sc->ostimer_params,
-	    *(struct callout_handle *)timer);
+	callout_stop((struct callout *)timer);
 
 	return (1);
 }

==== //depot/projects/smpng/sys/dev/nve/if_nvereg.h#3 (text+ko) ====

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $Id: if_nvreg.h,v 1.6 2004/08/12 14:00:05 q Exp $
- * $FreeBSD: src/sys/dev/nve/if_nvereg.h,v 1.3 2005/06/10 16:49:12 brooks Exp $
+ * $FreeBSD: src/sys/dev/nve/if_nvereg.h,v 1.4 2005/11/21 22:14:49 jhb Exp $
  */
  
 #ifndef _IF_NVEREG_H_
@@ -117,9 +117,8 @@
 		
 	device_t miibus;
 	device_t dev;
-	struct callout_handle stat_ch;
+	struct callout stat_callout;
 
-	u_int32_t unit;
 	void *sc_ih;
 	bus_space_tag_t sc_st;
 	bus_space_handle_t sc_sh;
@@ -140,13 +139,11 @@
 	u_int32_t pending_rxs;
 	u_int32_t pending_txs;
 
-	u_int32_t flags;
-	u_int32_t miicfg;
 	struct mtx mtx;
 	struct mtx osmtx;
 
 	/* Stuff for dealing with the NVIDIA OS API */
-	struct callout_handle ostimer;
+	struct callout ostimer;
 	PTIMER_FUNC ostimer_func;
 	void *ostimer_params;
 	int linkup;
@@ -167,6 +164,7 @@
 
 #define NVE_LOCK(_sc)		mtx_lock(&(_sc)->mtx)
 #define NVE_UNLOCK(_sc)		mtx_unlock(&(_sc)->mtx)
+#define NVE_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->mtx, MA_OWNED)
 #define NVE_OSLOCK(_sc)		mtx_lock_spin(&(_sc)->osmtx)
 #define NVE_OSUNLOCK(_sc)	mtx_unlock_spin(&(_sc)->osmtx)
 

==== //depot/projects/smpng/sys/dev/puc/puc.c#26 (text+ko) ====

@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.44 2005/11/07 13:10:45 rodrigc Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/puc/puc.c,v 1.45 2005/11/21 20:22:34 jhb Exp $");
 
 /*
  * PCI "universal" communication card device driver, glues com, lpt,
@@ -83,10 +83,6 @@
 
 #include "opt_puc.h"
 
-#ifndef PUC_FASTINTR
-#define PUC_FASTINTR
-#endif
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>

==== //depot/projects/smpng/sys/i386/conf/DEFAULTS#2 (text+ko) ====

@@ -1,7 +1,7 @@
 #
 # DEFAULTS -- Default kernel configuration file for FreeBSD/i386
 #
-# $FreeBSD: src/sys/i386/conf/DEFAULTS,v 1.1 2005/10/27 17:34:35 jhb Exp $
+# $FreeBSD: src/sys/i386/conf/DEFAULTS,v 1.2 2005/11/21 20:22:34 jhb Exp $
 
 # Not yet, this would break all existing configs
 #machine		i386
@@ -15,3 +15,5 @@
 # Pseudo devices.
 device		mem		# Memory and kernel memory devices
 device		io		# I/O device
+
+options 	PUC_FASTINTR

==== //depot/projects/smpng/sys/ia64/conf/GENERIC#46 (text+ko) ====

@@ -18,7 +18,7 @@
 #
 # For hardware specific information check HARDWARE.TXT
 #
-# $FreeBSD: src/sys/ia64/conf/GENERIC,v 1.74 2005/09/05 21:36:28 marcel Exp $
+# $FreeBSD: src/sys/ia64/conf/GENERIC,v 1.75 2005/11/21 20:17:45 jhb Exp $
 
 machine		ia64
 cpu		ITANIUM
@@ -56,7 +56,6 @@
 options 	_KPOSIX_PRIORITY_SCHEDULING	# Posix P1003_1B RT extensions
 
 # Various "busses"
-device 		acpi		# ACPI support (mandatory)
 device		firewire	# FireWire bus code
 device		miibus		# MII bus support (Ethernet)
 device		pci		# PCI bus support
@@ -141,7 +140,6 @@
 device		gif		# IPv6 and IPv4 tunneling
 device		loop		# Network loopback
 device		md		# Memory "disks"
-device		mem		# Memory and kernel memory devices
 device		pty		# Pseudo-ttys (telnet etc)
 device		puc		# Multi I/O cards and multi-channel UARTs
 device		random		# Entropy device

==== //depot/projects/smpng/sys/pc98/conf/DEFAULTS#2 (text+ko) ====

@@ -1,7 +1,7 @@
 #
 # DEFAULTS -- Default kernel configuration file for FreeBSD/pc98
 #
-# $FreeBSD: src/sys/pc98/conf/DEFAULTS,v 1.1 2005/10/28 15:30:51 nyan Exp $
+# $FreeBSD: src/sys/pc98/conf/DEFAULTS,v 1.2 2005/11/21 20:22:35 jhb Exp $
 
 # Not yet, this would break all existing configs
 #machine		pc98 i386
@@ -16,3 +16,5 @@
 # Pseudo devices.
 device		mem		# Memory and kernel memory devices
 device		io		# I/O device
+
+options 	PUC_FASTINTR

==== //depot/projects/smpng/sys/pci/if_de.c#30 (text+ko) ====

@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/pci/if_de.c,v 1.174 2005/11/11 16:04:57 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/pci/if_de.c,v 1.175 2005/11/21 21:50:07 jhb Exp $");
 
 #define	TULIP_HDR_DATA
 
@@ -3084,9 +3084,9 @@
 		hash = tulip_mchash(IF_LLADDR(ifp));
 		sp[hash >> 4] |= htole32(1 << (hash & 0xF));
 	    } else {
-		sp[39] = TULIP_SP_MAC(((u_int16_t *)IF_LLADDR(ifp))[0]); 
-		sp[40] = TULIP_SP_MAC(((u_int16_t *)IF_LLADDR(ifp))[1]); 
-		sp[41] = TULIP_SP_MAC(((u_int16_t *)IF_LLADDR(ifp))[2]);
+		sp[39] = TULIP_SP_MAC((u_int16_t *)IF_LLADDR(ifp) + 0); 
+		sp[40] = TULIP_SP_MAC((u_int16_t *)IF_LLADDR(ifp) + 1); 
+		sp[41] = TULIP_SP_MAC((u_int16_t *)IF_LLADDR(ifp) + 2);
 	    }
 	}
     }
@@ -3101,26 +3101,32 @@
 		    if (ifma->ifma_addr->sa_family != AF_LINK)
 			    continue;
 		    addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-		    *sp++ = TULIP_SP_MAC(((u_int16_t *)addrp)[0]); 
-		    *sp++ = TULIP_SP_MAC(((u_int16_t *)addrp)[1]); 
-		    *sp++ = TULIP_SP_MAC(((u_int16_t *)addrp)[2]);
+		    *sp++ = TULIP_SP_MAC((u_int16_t *)addrp + 0); 
+		    *sp++ = TULIP_SP_MAC((u_int16_t *)addrp + 1); 
+		    *sp++ = TULIP_SP_MAC((u_int16_t *)addrp + 2);
 		    idx++;
 	    }
 	    /*
 	     * Add the broadcast address.
 	     */
 	    idx++;
-	    *sp++ = TULIP_SP_MAC(0xFFFF);
-	    *sp++ = TULIP_SP_MAC(0xFFFF);

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



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