Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Feb 2007 01:39:51 GMT
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 114529 for review
Message-ID:  <200702150139.l1F1dpNE003933@repoman.freebsd.org>

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

Change 114529 by jkim@jkim_hammer on 2007/02/15 01:38:56

	IFC

Affected files ...

.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux.h#18 integrate
.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#36 integrate
.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_proto.h#19 integrate
.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_syscall.h#19 integrate
.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_sysent.c#18 integrate
.. //depot/projects/linuxolator/src/sys/amd64/linux32/syscalls.master#18 integrate
.. //depot/projects/linuxolator/src/sys/dev/bge/if_bge.c#13 integrate
.. //depot/projects/linuxolator/src/sys/dev/mii/brgphy.c#9 integrate
.. //depot/projects/linuxolator/src/sys/dev/mpt/mpt_pci.c#6 integrate
.. //depot/projects/linuxolator/src/sys/dev/pci/pci.c#17 integrate
.. //depot/projects/linuxolator/src/sys/dev/sound/pci/envy24.c#4 integrate
.. //depot/projects/linuxolator/src/sys/dev/sound/pci/envy24ht.c#3 integrate
.. //depot/projects/linuxolator/src/sys/dev/sound/pci/spicds.c#2 integrate
.. //depot/projects/linuxolator/src/sys/i386/linux/linux.h#14 integrate
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#30 integrate
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_proto.h#19 integrate
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_syscall.h#18 integrate
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_sysent.c#18 integrate
.. //depot/projects/linuxolator/src/sys/i386/linux/syscalls.master#17 integrate
.. //depot/projects/linuxolator/src/sys/kern/uipc_usrreq.c#7 integrate

Differences ...

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux.h#18 (text+ko) ====

@@ -27,7 +27,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/linux32/linux.h,v 1.11 2007/02/01 13:36:19 kib Exp $
+ * $FreeBSD: src/sys/amd64/linux32/linux.h,v 1.12 2007/02/15 00:54:40 jkim Exp $
  */
 
 #ifndef _AMD64_LINUX_LINUX_H_

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#36 (text+ko) ====

@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.30 2007/02/01 13:27:51 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.33 2007/02/15 01:20:43 jkim Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -53,7 +53,10 @@
 #include <sys/unistd.h>
 
 #include <machine/frame.h>
+#include <machine/pcb.h>
+#include <machine/psl.h>
 #include <machine/segments.h>
+#include <machine/specialreg.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -63,15 +66,11 @@
 
 #include <amd64/linux32/linux.h>
 #include <amd64/linux32/linux32_proto.h>
-#include <amd64/include/psl.h>
-#include <amd64/include/specialreg.h>
 #include <compat/linux/linux_ipc.h>
 #include <compat/linux/linux_signal.h>
 #include <compat/linux/linux_util.h>
 #include <compat/linux/linux_emul.h>
 
-#include <amd64/include/pcb.h>                   /* needed for pcb definition in linux_set_thread_area */
-
 /*
  * Memory and System segment descriptors
  */

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_proto.h#19 (text+ko) ====

@@ -2,8 +2,8 @@
  * System call prototypes.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.25 2006/12/31 13:16:00 netchild Exp 
+ * $FreeBSD: src/sys/amd64/linux32/linux32_proto.h,v 1.29 2007/02/15 01:15:31 jkim Exp $
+ * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.26 2007/02/15 01:13:36 jkim Exp 
  */
 
 #ifndef _LINUX_SYSPROTO_H_

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_syscall.h#19 (text+ko) ====

@@ -2,8 +2,8 @@
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.25 2006/12/31 13:16:00 netchild Exp 
+ * $FreeBSD: src/sys/amd64/linux32/linux32_syscall.h,v 1.29 2007/02/15 01:15:31 jkim Exp $
+ * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.26 2007/02/15 01:13:36 jkim Exp 
  */
 
 #define	LINUX_SYS_exit	1

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_sysent.c#18 (text+ko) ====

@@ -2,8 +2,8 @@
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.25 2006/12/31 13:16:00 netchild Exp 
+ * $FreeBSD: src/sys/amd64/linux32/linux32_sysent.c,v 1.29 2007/02/15 01:15:31 jkim Exp $
+ * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.26 2007/02/15 01:13:36 jkim Exp 
  */
 
 #include <bsm/audit_kevents.h>
@@ -130,7 +130,7 @@
 	{ AS(linux_newlstat_args), (sy_call_t *)linux_newlstat, AUE_LSTAT, NULL, 0, 0 },	/* 107 = linux_newlstat */
 	{ AS(linux_newfstat_args), (sy_call_t *)linux_newfstat, AUE_FSTAT, NULL, 0, 0 },	/* 108 = linux_newfstat */
 	{ 0, (sy_call_t *)linux_uname, AUE_NULL, NULL, 0, 0 },	/* 109 = linux_uname */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 110 = iopl */
+	{ AS(linux_iopl_args), (sy_call_t *)linux_iopl, AUE_NULL, NULL, 0, 0 },	/* 110 = linux_iopl */
 	{ 0, (sy_call_t *)linux_vhangup, AUE_NULL, NULL, 0, 0 },	/* 111 = linux_vhangup */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 112 = idle */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 113 = vm86old */

==== //depot/projects/linuxolator/src/sys/amd64/linux32/syscalls.master#18 (text+ko) ====

@@ -1,4 +1,4 @@
- $FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.25 2006/12/31 13:16:00 netchild Exp $
+ $FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.26 2007/02/15 01:13:36 jkim Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 ; System call name/number master file (or rather, slave, from LINUX).

==== //depot/projects/linuxolator/src/sys/dev/bge/if_bge.c#13 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/bge/if_bge.c,v 1.176 2007/02/12 23:58:52 jkim Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/bge/if_bge.c,v 1.178 2007/02/14 19:44:15 jkim Exp $");
 
 /*
  * Broadcom BCM570x family gigabit ethernet driver for FreeBSD.
@@ -256,7 +256,7 @@
 	{ BGE_CHIPID_BCM5714_B3,	"BCM5714 B3" },
 	{ BGE_CHIPID_BCM5715_A0,	"BCM5715 A0" },
 	{ BGE_CHIPID_BCM5715_A1,	"BCM5715 A1" },
-	/* 5784 and 5787 share the same ASIC ID */
+	/* 5754 and 5787 share the same ASIC ID */
 	{ BGE_CHIPID_BCM5787_A0,	"BCM5754/5787 A0" }, 
 	{ BGE_CHIPID_BCM5787_A1,	"BCM5754/5787 A1" },
 	{ BGE_CHIPID_BCM5787_A2,	"BCM5754/5787 A2" },
@@ -280,7 +280,7 @@
 	{ BGE_ASICREV_BCM5780,		"unknown BCM5780" },
 	{ BGE_ASICREV_BCM5714,		"unknown BCM5714" },
 	{ BGE_ASICREV_BCM5755,		"unknown BCM5755" },
-	/* 5784 and 5787 share the same ASIC ID */
+	/* 5754 and 5787 share the same ASIC ID */
 	{ BGE_ASICREV_BCM5787,		"unknown BCM5754/5787" },
 
 	{ 0, NULL }
@@ -2593,7 +2593,7 @@
 
 	dev = sc->bge_dev;
 
-	if (BGE_IS_5705_PLUS(sc) && !BGE_IS_5714_FAMILY(sc)) {
+	if (BGE_IS_575X_PLUS(sc) && !BGE_IS_5714_FAMILY(sc)) {
 		if (sc->bge_flags & BGE_FLAG_PCIE)
 			write_op = bge_writemem_direct;
 		else

==== //depot/projects/linuxolator/src/sys/dev/mii/brgphy.c#9 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mii/brgphy.c,v 1.63 2007/02/13 00:34:32 jkim Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mii/brgphy.c,v 1.64 2007/02/14 18:21:32 jkim Exp $");
 
 /*
  * Driver for the Broadcom BCM54xx/57xx 1000baseTX PHY.
@@ -619,7 +619,7 @@
 		int		reg;
 		uint16_t	val;
 	} dspcode[] = {
-		{ BRGPHY_MII_DSP_ADDR_REG,	0x0a75 },
+		{ BRGPHY_MII_DSP_RW_PORT,	0x0a75 },
 		{ 0x1c,				0x8c68 },
 		{ 0x1c,				0x8d68 },
 		{ 0x1c,				0x8c68 },

==== //depot/projects/linuxolator/src/sys/dev/mpt/mpt_pci.c#6 (text+ko) ====

@@ -99,16 +99,17 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.46 2007/01/05 22:49:05 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.47 2007/02/14 22:31:21 jhb Exp $");
 
 #include <dev/mpt/mpt.h>
 #include <dev/mpt/mpt_cam.h>
 #include <dev/mpt/mpt_raid.h>
 
 #if __FreeBSD_version < 700000
+#define	pci_msix_count(x)	0
 #define	pci_msi_count(x)	0
-#define	pci_msi_enable(x)	0
 #define	pci_alloc_msi(x, y)	1
+#define	pci_alloc_msix(x, y)	1
 #define	pci_release_msi(x)	do { ; } while (0)
 #endif
 
@@ -527,14 +528,28 @@
 
 	/* Get a handle to the interrupt */
 	iqd = 0;
-	if (mpt->msi_enable && pci_msi_count(dev) == 1) {
-		mpt->pci_msi_count = 1;
-		if (pci_alloc_msi(dev, &mpt->pci_msi_count) == 0) {
-			iqd = 1;
-		} else {
-			mpt->pci_msi_count = 0;
+	if (mpt->msi_enable) {
+		/*
+		 * First try to alloc an MSI-X message.  If that
+		 * fails, then try to alloc an MSI message instead.
+		 */
+		if (pci_msix_count(dev) == 1) {
+			mpt->pci_msi_count = 1;
+			if (pci_alloc_msix(dev, &mpt->pci_msi_count) == 0) {
+				iqd = 1;
+			} else {
+				mpt->pci_msi_count = 0;
+			}
+		}
+		if (iqd == 0 && pci_msi_count(dev) == 1) {
+			mpt->pci_msi_count = 1;
+			if (pci_alloc_msi(dev, &mpt->pci_msi_count) == 0) {
+				iqd = 1;
+			} else {
+				mpt->pci_msi_count = 0;
+			}
 		}
-	}	
+	}
 	mpt->pci_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd,
 	    RF_ACTIVE | RF_SHAREABLE);
 	if (mpt->pci_irq == NULL) {

==== //depot/projects/linuxolator/src/sys/dev/pci/pci.c#17 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pci/pci.c,v 1.339 2007/02/08 14:33:07 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pci/pci.c,v 1.342 2007/02/14 22:36:27 jhb Exp $");
 
 #include "opt_bus.h"
 
@@ -217,6 +217,7 @@
 struct devlist pci_devq;
 uint32_t pci_generation;
 uint32_t pci_numdevs = 0;
+static int pcie_chipset, pcix_chipset;
 
 /* sysctl vars */
 SYSCTL_NODE(_hw, OID_AUTO, pci, CTLFLAG_RD, 0, "PCI bus tuning parameters");
@@ -585,6 +586,28 @@
 				cfg->subvendor = val & 0xffff;
 				cfg->subdevice = val >> 16;
 			}
+			break;
+		case PCIY_PCIX:		/* PCI-X */
+			/*
+			 * Assume we have a PCI-X chipset if we have
+			 * at least one PCI-PCI bridge with a PCI-X
+			 * capability.  Note that some systems with
+			 * PCI-express or HT chipsets might match on
+			 * this check as well.
+			 */
+			if ((cfg->hdrtype & PCIM_HDRTYPE) == 1)
+				pcix_chipset = 1;
+			break;
+		case PCIY_EXPRESS:	/* PCI-express */
+			/*
+			 * Assume we have a PCI-express chipset if we have
+			 * at least one PCI-express root port.
+			 */
+			val = REG(ptr + PCIR_EXPRESS_FLAGS, 2);
+			if ((val & PCIM_EXP_FLAGS_TYPE) ==
+			    PCIM_EXP_TYPE_ROOT_PORT)
+				pcie_chipset = 1;
+			break;
 		default:
 			break;
 		}
@@ -1141,7 +1164,7 @@
 
 			/* Unfinished range? */
 			if (run)
-				printf("%d", irq);
+				printf("-%d", irq);
 			printf(" for MSI-X\n");
 		}
 	}
@@ -1220,8 +1243,16 @@
 	for (i = 0; i < cfg->msix.msix_alloc; i++) {
 		resource_list_add(&dinfo->resources, SYS_RES_IRQ, indices[i],
 		    irqs[i], irqs[i], 1);
+
+		/*
+		 * The indices in the backend code (PCIB_* methods and the
+		 * MI helper routines for MD code such as pci_enable_msix())
+		 * are all zero-based.  However, the indices passed to this
+		 * function are 1-based so that the correspond 1:1 with the
+		 * SYS_RES_IRQ resource IDs.
+		 */
 		error = PCIB_REMAP_MSIX(device_get_parent(dev), child,
-		    indices[i], irqs[i]);
+		    indices[i] - 1, irqs[i]);
 		KASSERT(error == 0, ("Failed to remap MSI-X message"));
 	}
 	if (bootverbose) {
@@ -1395,6 +1426,10 @@
 	if (!pci_honor_msi_blacklist)
 		return (0);
 
+	/* Blacklist all non-PCI-express and non-PCI-X chipsets. */
+	if (!(pcie_chipset || pcix_chipset))
+		return (1);
+
 	dev = pci_find_bsf(0, 0, 0);
 	if (dev != NULL)
 		return (pci_msi_device_blacklisted(dev));

==== //depot/projects/linuxolator/src/sys/dev/sound/pci/envy24.c#4 (text+ko) ====

@@ -35,7 +35,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/envy24.c,v 1.5 2006/12/17 16:06:45 ariff Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/envy24.c,v 1.6 2007/02/14 15:23:44 ariff Exp $");
 
 MALLOC_DEFINE(M_ENVY24, "envy24", "envy24 audio");
 
@@ -109,7 +109,7 @@
 /* device private data */
 struct sc_info {
 	device_t	dev;
-	void		*lock;
+	struct mtx	*lock;
 
 	/* Control/Status registor */
 	struct resource *cs;

==== //depot/projects/linuxolator/src/sys/dev/sound/pci/envy24ht.c#3 (text+ko) ====

@@ -36,7 +36,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/envy24ht.c,v 1.6 2006/12/17 16:06:45 ariff Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/envy24ht.c,v 1.7 2007/02/14 15:23:44 ariff Exp $");
 
 MALLOC_DEFINE(M_ENVY24HT, "envy24ht", "envy24ht audio");
 
@@ -110,7 +110,7 @@
 /* device private data */
 struct sc_info {
 	device_t	dev;
-	void		*lock;
+	struct mtx	*lock;
 
 	/* Control/Status registor */
 	struct resource *cs;

==== //depot/projects/linuxolator/src/sys/dev/sound/pci/spicds.c#2 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/sound/pci/spicds.c,v 1.4 2006/09/30 16:53:40 netchild Exp $
+ * $FreeBSD: src/sys/dev/sound/pci/spicds.c,v 1.5 2007/02/14 15:23:44 ariff Exp $
  */
 
 #include <dev/sound/pcm/sound.h>
@@ -45,7 +45,7 @@
 	unsigned int dvc;    /* De-emphasis and Volume Control */
 	unsigned int left, right;
 	char name[SPICDS_NAMELEN];
-	void *lock;
+	struct mtx *lock;
 };
 
 static void

==== //depot/projects/linuxolator/src/sys/i386/linux/linux.h#14 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/i386/linux/linux.h,v 1.73 2007/02/01 13:36:19 kib Exp $
+ * $FreeBSD: src/sys/i386/linux/linux.h,v 1.74 2007/02/15 00:54:40 jkim Exp $
  */
 
 #ifndef _I386_LINUX_LINUX_H_

==== //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#30 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.69 2007/02/01 13:27:52 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.70 2007/02/15 00:54:40 jkim Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

==== //depot/projects/linuxolator/src/sys/i386/linux/linux_proto.h#19 (text+ko) ====

@@ -2,8 +2,8 @@
  * System call prototypes.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.85 2006/12/31 13:16:00 netchild Exp 
+ * $FreeBSD: src/sys/i386/linux/linux_proto.h,v 1.91 2007/02/15 00:57:03 jkim Exp $
+ * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.86 2007/02/15 00:54:40 jkim Exp 
  */
 
 #ifndef _LINUX_SYSPROTO_H_

==== //depot/projects/linuxolator/src/sys/i386/linux/linux_syscall.h#18 (text+ko) ====

@@ -2,8 +2,8 @@
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.85 2006/12/31 13:16:00 netchild Exp 
+ * $FreeBSD: src/sys/i386/linux/linux_syscall.h,v 1.84 2007/02/15 00:57:04 jkim Exp $
+ * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.86 2007/02/15 00:54:40 jkim Exp 
  */
 
 #define	LINUX_SYS_exit	1

==== //depot/projects/linuxolator/src/sys/i386/linux/linux_sysent.c#18 (text+ko) ====

@@ -2,8 +2,8 @@
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.85 2006/12/31 13:16:00 netchild Exp 
+ * $FreeBSD: src/sys/i386/linux/linux_sysent.c,v 1.91 2007/02/15 00:57:04 jkim Exp $
+ * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.86 2007/02/15 00:54:40 jkim Exp 
  */
 
 #include <bsm/audit_kevents.h>

==== //depot/projects/linuxolator/src/sys/i386/linux/syscalls.master#17 (text+ko) ====

@@ -1,4 +1,4 @@
- $FreeBSD: src/sys/i386/linux/syscalls.master,v 1.85 2006/12/31 13:16:00 netchild Exp $
+ $FreeBSD: src/sys/i386/linux/syscalls.master,v 1.86 2007/02/15 00:54:40 jkim Exp $
 
 ;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93
 ; System call name/number master file (or rather, slave, from LINUX).

==== //depot/projects/linuxolator/src/sys/kern/uipc_usrreq.c#7 (text+ko) ====

@@ -1,7 +1,7 @@
 /*-
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
  *	The Regents of the University of California.
- * Copyright (c) 2004-2006 Robert N. M. Watson
+ * Copyright (c) 2004-2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,10 +47,16 @@
  * passing UNIX domain sockets over other UNIX domain sockets requires the
  * implementation of a simple garbage collector to find and tear down cycles
  * of disconnected sockets.
+ *
+ * TODO:
+ *	SEQPACKET, RDM
+ *	rethink name space problems
+ *	need a proper out-of-band
+ *	lock pushdown
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.192 2007/02/13 21:00:57 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.194 2007/02/14 15:05:40 rwatson Exp $");
 
 #include "opt_mac.h"
 
@@ -87,24 +93,23 @@
 
 #include <vm/uma.h>
 
-static uma_zone_t unp_zone;
-static	unp_gen_t unp_gencnt;
-static	u_int unp_count;
+static uma_zone_t	unp_zone;
+static unp_gen_t	unp_gencnt;
+static u_int		unp_count;	/* Count of local sockets. */
+static ino_t		unp_ino;	/* Prototype for fake inode numbers. */
+static int		unp_rights;	/* File descriptors in flight. */
+static struct unp_head	unp_shead;	/* List of local stream sockets. */
+static struct unp_head	unp_dhead;	/* List of local datagram sockets. */
 
-static	struct unp_head unp_shead, unp_dhead;
+static const struct sockaddr	sun_noname = { sizeof(sun_noname), AF_LOCAL };
 
 /*
- * Unix communications domain.
- *
- * TODO:
- *	SEQPACKET, RDM
- *	rethink name space problems
- *	need a proper out-of-band
- *	lock pushdown
+ * Garbage collection of cyclic file descriptor/socket references occurs
+ * asynchronously in a taskqueue context in order to avoid recursion and
+ * reentrance in the UNIX domain socket, file descriptor, and socket layer
+ * code.  See unp_gc() for a full description.
  */
-static const struct	sockaddr sun_noname = { sizeof(sun_noname), AF_LOCAL };
-static ino_t	unp_ino;		/* prototype for fake inode numbers */
-struct mbuf *unp_addsockcred(struct thread *, struct mbuf *);
+static struct task	unp_gc_task;
 
 /*
  * Both send and receive buffers are allocated PIPSIZ bytes of buffering for
@@ -123,8 +128,6 @@
 static u_long	unpdg_sendspace = 2*1024;	/* really max datagram size */
 static u_long	unpdg_recvspace = 4*1024;
 
-static int	unp_rights;			/* file descriptors in flight */
-
 SYSCTL_NODE(_net, PF_LOCAL, local, CTLFLAG_RW, 0, "Local domain");
 SYSCTL_NODE(_net_local, SOCK_STREAM, stream, CTLFLAG_RW, 0, "SOCK_STREAM");
 SYSCTL_NODE(_net_local, SOCK_DGRAM, dgram, CTLFLAG_RW, 0, "SOCK_DGRAM");
@@ -159,35 +162,29 @@
  * and exposes weaknesses in the socket->protocol API by offering poor
  * failure modes.
  */
-static struct mtx unp_mtx;
+static struct mtx	unp_mtx;
 #define	UNP_LOCK_INIT() \
-	mtx_init(&unp_mtx, "unp", NULL, MTX_DEF)
+	mtx_init(&unp_mtx, "unp", NULL, MTX_DEF | MTX_RECURSE)
 #define	UNP_LOCK()		mtx_lock(&unp_mtx)
 #define	UNP_UNLOCK()		mtx_unlock(&unp_mtx)
 #define	UNP_LOCK_ASSERT()	mtx_assert(&unp_mtx, MA_OWNED)
 #define	UNP_UNLOCK_ASSERT()	mtx_assert(&unp_mtx, MA_NOTOWNED)
 
-/*
- * Garbage collection of cyclic file descriptor/socket references occurs
- * asynchronously in a taskqueue context in order to avoid recursion and
- * reentrance in the UNIX domain socket, file descriptor, and socket layer
- * code.  See unp_gc() for a full description.
- */
-static struct task	unp_gc_task;
-
-static int     unp_connect(struct socket *,struct sockaddr *, struct thread *);
-static int     unp_connect2(struct socket *so, struct socket *so2, int);
-static void    unp_disconnect(struct unpcb *);
-static void    unp_shutdown(struct unpcb *);
-static void    unp_drop(struct unpcb *, int);
-static void    unp_gc(__unused void *, int);
-static void    unp_scan(struct mbuf *, void (*)(struct file *));
-static void    unp_mark(struct file *);
-static void    unp_discard(struct file *);
-static void    unp_freerights(struct file **, int);
-static int     unp_internalize(struct mbuf **, struct thread *);
-static int     unp_listen(struct socket *, struct unpcb *, int,
+static int	 unp_connect(struct socket *, struct sockaddr *,
+		    struct thread *);
+static int	 unp_connect2(struct socket *so, struct socket *so2, int);
+static void	 unp_disconnect(struct unpcb *);
+static void	 unp_shutdown(struct unpcb *);
+static void	 unp_drop(struct unpcb *, int);
+static void	 unp_gc(__unused void *, int);
+static void	 unp_scan(struct mbuf *, void (*)(struct file *));
+static void	 unp_mark(struct file *);
+static void	 unp_discard(struct file *);
+static void	 unp_freerights(struct file **, int);
+static int	 unp_internalize(struct mbuf **, struct thread *);
+static int	 unp_listen(struct socket *, struct unpcb *, int,
 		   struct thread *);
+struct mbuf	*unp_addsockcred(struct thread *, struct mbuf *);
 
 /*
  * Definitions of protocols supported in the LOCAL domain.
@@ -278,7 +275,7 @@
 		if (error)
 			return (error);
 	}
-	unp = uma_zalloc(unp_zone, M_WAITOK | M_ZERO);
+	unp = uma_zalloc(unp_zone, M_NOWAIT | M_ZERO);
 	if (unp == NULL)
 		return (ENOBUFS);
 	LIST_INIT(&unp->unp_refs);
@@ -988,17 +985,9 @@
 		goto bad2;
 	}
 	if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
-		if (so2->so_options & SO_ACCEPTCONN) {
-			/*
-			 * NB: drop locks here so unp_attach is entered w/o
-			 * locks; this avoids a recursive lock of the head
-			 * and holding sleep locks across a (potentially)
-			 * blocking malloc.
-			 */
-			UNP_UNLOCK();
+		if (so2->so_options & SO_ACCEPTCONN)
 			so3 = sonewconn(so2, 0);
-			UNP_LOCK();
-		} else
+		else
 			so3 = NULL;
 		if (so3 == NULL) {
 			error = ECONNREFUSED;



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