[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Thu Aug 16 18:15:17 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/00e5fe011396
changeset: 527:00e5fe011396
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Thu Aug 16 21:15:49 2012 +0300
description:
FreeBSD HEAD @svn r239333.

diffstat:

 head/share/man/man4/Makefile                                 |    4 +-
 head/share/man/man4/aout.4                                   |  146 ++++++++++
 head/share/man/man9/devfs_set_cdevpriv.9                     |    8 +-
 head/sys/arm/at91/board_eb9200.c                             |   68 ++++
 head/sys/arm/at91/files.at91                                 |    3 +-
 head/sys/arm/at91/std.at91sam9                               |    3 +-
 head/sys/arm/at91/std.at91sam9g45                            |    3 +-
 head/sys/arm/at91/std.atmel                                  |    3 +-
 head/sys/arm/at91/std.eb9200                                 |   10 +
 head/sys/arm/conf/EB9200                                     |  109 +++++++
 head/sys/arm/conf/EB9200.hints                               |    6 +
 head/sys/arm/conf/HL201.hints                                |  112 +++----
 head/sys/arm/lpc/lpc_machdep.c                               |   42 +--
 head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c |    4 +-
 head/sys/compat/freebsd32/freebsd32_proto.h                  |    4 +-
 head/sys/compat/freebsd32/freebsd32_syscall.h                |    8 +-
 head/sys/compat/freebsd32/freebsd32_syscalls.c               |    8 +-
 head/sys/compat/freebsd32/freebsd32_sysent.c                 |    8 +-
 head/sys/compat/freebsd32/syscalls.master                    |    7 +-
 head/sys/dev/ath/ath_rate/sample/sample.c                    |    6 +-
 head/sys/dev/drm/drm_fops.c                                  |   16 +-
 head/sys/dev/drm2/drm_fops.c                                 |   16 +-
 head/sys/dev/e1000/if_em.c                                   |    4 +-
 head/sys/dev/isp/isp_freebsd.c                               |   21 +-
 head/sys/dev/ksyms/ksyms.c                                   |    4 +-
 head/sys/dev/sound/pci/hda/hdaa.c                            |   15 +-
 head/sys/dev/usb/net/if_usie.c                               |   20 +-
 head/sys/dev/usb/net/uhso.c                                  |   20 +-
 head/sys/dev/usb/quirk/usb_quirk.c                           |    4 +-
 head/sys/dev/usb/serial/u3g.c                                |   20 +-
 head/sys/dev/usb/serial/uark.c                               |   20 +-
 head/sys/dev/usb/serial/ubsa.c                               |   20 +-
 head/sys/dev/usb/serial/ubser.c                              |   20 +-
 head/sys/dev/usb/serial/uchcom.c                             |   20 +-
 head/sys/dev/usb/serial/ucycom.c                             |   20 +-
 head/sys/dev/usb/serial/ufoma.c                              |   20 +-
 head/sys/dev/usb/serial/uftdi.c                              |   20 +-
 head/sys/dev/usb/serial/ugensa.c                             |   20 +-
 head/sys/dev/usb/serial/uipaq.c                              |   20 +-
 head/sys/dev/usb/serial/umcs.c                               |   20 +-
 head/sys/dev/usb/serial/umct.c                               |   20 +-
 head/sys/dev/usb/serial/umodem.c                             |   20 +-
 head/sys/dev/usb/serial/umoscom.c                            |   20 +-
 head/sys/dev/usb/serial/uplcom.c                             |   20 +-
 head/sys/dev/usb/serial/usb_serial.c                         |   60 ++-
 head/sys/dev/usb/serial/usb_serial.h                         |    6 +-
 head/sys/dev/usb/serial/uslcom.c                             |   20 +-
 head/sys/dev/usb/serial/uvisor.c                             |   20 +-
 head/sys/dev/usb/serial/uvscom.c                             |   20 +-
 head/sys/dev/usb/usbdevs                                     |    6 +-
 head/sys/fs/devfs/devfs_vnops.c                              |    5 +-
 head/sys/ia64/ia64/sscdisk.c                                 |   34 +-
 head/sys/kern/device_if.m                                    |   13 +-
 head/sys/kern/init_main.c                                    |    3 +-
 head/sys/kern/kern_fork.c                                    |   10 +-
 head/sys/kern/kern_mib.c                                     |   30 +-
 head/sys/kern/kern_ntptime.c                                 |   13 +-
 head/sys/kern/kern_proc.c                                    |    4 +-
 head/sys/kern/kern_thread.c                                  |    8 +-
 head/sys/kern/subr_bus.c                                     |   49 ++-
 head/sys/kern/subr_param.c                                   |   18 +-
 head/sys/kern/vfs_cluster.c                                  |    4 +-
 head/sys/mips/mips/pmap.c                                    |  160 +++++-----
 head/sys/net80211/ieee80211_node.c                           |  129 +++++++-
 head/sys/net80211/ieee80211_node.h                           |    4 +-
 head/sys/nfs/bootp_subr.c                                    |   18 +-
 head/sys/nlm/nlm_advlock.c                                   |    3 +-
 head/sys/ofed/include/linux/linux_compat.c                   |    1 -
 head/sys/sys/buf.h                                           |    5 +-
 head/sys/sys/bus.h                                           |    5 +-
 head/sys/sys/proc.h                                          |    7 +-
 head/sys/vm/swap_pager.c                                     |   36 ++-
 72 files changed, 1112 insertions(+), 561 deletions(-)

diffs (3955 lines):

diff -r 02b2b55f6449 -r 00e5fe011396 head/share/man/man4/Makefile
--- a/head/share/man/man4/Makefile	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/share/man/man4/Makefile	Thu Aug 16 21:15:49 2012 +0300
@@ -1,5 +1,5 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
-# $FreeBSD: head/share/man/man4/Makefile 238983 2012-08-02 08:46:08Z luigi $
+# $FreeBSD: head/share/man/man4/Makefile 239302 2012-08-15 16:01:45Z kib $
 
 MAN=	aac.4 \
 	acpi.4 \
@@ -40,6 +40,7 @@
 	${_bxe.4} \
 	amr.4 \
 	an.4 \
+	${_aout.4} \
 	${_apic.4} \
 	arcmsr.4 \
 	${_asmc.4} \
@@ -710,6 +711,7 @@
 _acpi_toshiba.4=acpi_toshiba.4
 _acpi_wmi.4=	acpi_wmi.4
 _aesni.4=	aesni.4
+_aout.4=	aout.4
 _apic.4=	apic.4
 _atrtc.4=	atrtc.4
 _attimer.4=	attimer.4
diff -r 02b2b55f6449 -r 00e5fe011396 head/share/man/man4/aout.4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/share/man/man4/aout.4	Thu Aug 16 21:15:49 2012 +0300
@@ -0,0 +1,146 @@
+.\" Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (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: head/share/man/man4/aout.4 239306 2012-08-15 18:00:52Z kib $
+.\"
+.Dd August 14, 2012
+.Dt AOUT 4
+.Os
+.Sh NAME
+.Nm aout
+.Nd kernel support for executing binary files in legacy a.out format
+.Sh SYNOPSIS
+.Bd -literal -offset indent
+kldload a.out
+.Ed
+.Sh DESCRIPTION
+The
+.Xr a.out 5
+executable format was used before the release of
+.Fx 3.0 .
+Since i386 was the only supported architecture at that time,
+.Xr a.out 5
+executables can only be activated on platforms that support
+execution of i386 code, such as i386, amd64 and (partially) ia64.
+.Pp
+To add kernel support for old syscalls and old syscall invocation methods,
+place the following options in the kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "options COMPAT_43"
+.br
+.Cd "options COMPAT_FREEBSD32"
+.Ed
+.Pp
+The
+.Va COMPAT_FREEBSD32
+option is only required on 64-bit CPU architectures.
+.Pp
+The
+.Va aout.ko
+module needs to be loaded with the
+.Xr kldload 8
+utility in order to support the
+.Xr a.out 5
+image activator:
+.Bd -ragged -offset indent
+.Ic kldload aout
+.Ed
+.Pp
+Alternatively, to load the module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+aout_load="YES"
+.Ed
+.Pp
+The
+.Xr a.out 5
+format was mainstream quite a long time ago.
+Reasonable default settings and security requirements of
+modern operating systems today contradict the default environment of that time
+and require adjustments of the system to mimic natural environment for
+old binaries.
+.Pp
+The following
+.Xr sysctl 8
+tunables are useful for this:
+.Bl -tag -offset indent -width "XXXXXXXXXXXXXXXXXXXXXXXXX"
+.It Xo Va security.bsd.map_at_zero
+.Xc
+Set to 1 to allow mapping of process pages at address 0.
+Some very old
+.Va ZMAGIC
+executable images require text mapping at address 0.
+.It Xo Va kern.pid_max
+.Xc
+Old versions of
+.Fx
+used signed 16-bit type for
+.Vt pid_t .
+Current kernels use 32-bit type for
+.Vt pid_t ,
+and allow process id's up to 99999.
+Such values cannot be represented by old
+.Vt pid_t ,
+mostly causing issues for processes using
+.Xr wait 2
+syscalls, for example shells.
+Set the sysctl to 30000 to work around the problem.
+.It Xo Va kern.elf32.read_exec
+.Xc
+Set to 1 to force any accessible memory mapping performed by 32-bit
+process to allow execution, see
+.Xr mmap 2 .
+Old i386 CPUs did not have a bit in PTE which disallowed execution
+from the page, so many old programs did not specify
+.Va PROT_EXEC
+even for mapping of executable code.
+The sysctl forces
+.Va PROT_EXEC
+if mapping has any access allowed at all.
+The setting is only needed if the host architecture allows
+non-executable mappings.
+.El
+.Sh SEE ALSO
+.Xr execve 2 ,
+.Xr a.out 5 ,
+.Xr elf 5 ,
+.Xr sysctl 8 .
+.Sh HISTORY
+The
+.Xr a.out 5
+executable format was used on ancient
+.At
+and served as the main executable format for
+.Fx
+from the beginning up to
+.Fx 2.2.9 .
+In
+.Fx 3.0
+it was superseded by
+.Xr elf 5 .
+.Sh AUTHORS
+The
+.Nm
+manual page was written by
+.An Konstantin Belousov Aq kib at FreeBSD.org .
+.Sh BUGS
+On 64bit architectures, not all wrappers for older syscalls are implemented.
diff -r 02b2b55f6449 -r 00e5fe011396 head/share/man/man9/devfs_set_cdevpriv.9
--- a/head/share/man/man9/devfs_set_cdevpriv.9	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/share/man/man9/devfs_set_cdevpriv.9	Thu Aug 16 21:15:49 2012 +0300
@@ -22,9 +22,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/share/man/man9/devfs_set_cdevpriv.9 222286 2011-05-25 14:13:53Z ru $
+.\" $FreeBSD: head/share/man/man9/devfs_set_cdevpriv.9 239303 2012-08-15 16:19:39Z hselasky $
 .\"
-.Dd September 8, 2008
+.Dd August 15, 2012
 .Dt DEVFS_CDEVPRIV 9
 .Os
 .Sh NAME
@@ -79,6 +79,10 @@
 callback is called, with private data supplied
 .Va data
 argument.
+The
+.Fn devfs_clear_cdevpriv
+function will be also be called if the open callback
+function returns an error code.
 .Pp
 On the last filedescriptor close, system automatically arranges
 .Fn devfs_clear_cdevpriv
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/at91/board_eb9200.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/arm/at91/board_eb9200.c	Thu Aug 16 21:15:49 2012 +0300
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2005-2008 Olivier Houchard.  All rights reserved.
+ * Copyright (c) 2005-2012 Warner Losh.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: head/sys/arm/at91/board_eb9200.c 239324 2012-08-16 05:03:59Z imp $");
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <machine/board.h>
+#include <arm/at91/at91board.h>
+#include <arm/at91/at91var.h>
+#include <arm/at91/at91rm9200var.h>
+
+BOARD_INIT long
+board_init(void)
+{
+
+	at91rm9200_set_subtype(AT91_ST_RM9200_BGA);
+
+	/*
+	 * Setup the serial ports.
+	 * DBGU and USART0 are DB9 ports.
+	 * USART2 is IrDA.
+	 */
+	at91rm9200_config_uart(AT91_ID_DBGU, 0, 0);   /* DBGU just Tx and Rx */
+	at91rm9200_config_uart(AT91RM9200_ID_USART0, 1,
+	    AT91_UART_CTS | AT91_UART_RTS | AT91_UART_DTR | AT91_UART_DSR |
+	    AT91_UART_DCD | AT91_UART_RI);
+	at91rm9200_config_uart(AT91RM9200_ID_USART1, 2, 0);
+
+	at91rm9200_config_mci(1);
+
+	/* CFE interface */
+	/* SPI interface */
+	/* ethernet interface */
+	/* USB host */
+	/* USB device (gadget) */
+	/* TWI */
+	/* CF interface */
+	/* SmartMedia Interface */
+
+	return (at91_ramsize());
+}
+
+ARM_BOARD(KB9200, "Kwikbyte KB920x")
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/at91/files.at91
--- a/head/sys/arm/at91/files.at91	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/arm/at91/files.at91	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
-# $FreeBSD: head/sys/arm/at91/files.at91 238922 2012-07-30 21:30:43Z imp $
+# $FreeBSD: head/sys/arm/at91/files.at91 239324 2012-08-16 05:03:59Z imp $
 arm/arm/cpufunc_asm_arm9.S	standard
 arm/arm/irq_dispatch.S		standard
 arm/at91/at91_machdep.c		standard
@@ -38,6 +38,7 @@
 # All the boards we support
 #
 arm/at91/board_bwct.c		optional	at91_board_bwct
+arm/at91/board_eb9200.c		optional	at91_board_eb9200
 arm/at91/board_ethernut5.c	optional	at91_board_ethernut5
 arm/at91/board_hl200.c		optional	at91_board_hl200
 arm/at91/board_hl201.c		optional	at91_board_hl201
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/at91/std.at91sam9
--- a/head/sys/arm/at91/std.at91sam9	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/arm/at91/std.at91sam9	Thu Aug 16 21:15:49 2012 +0300
@@ -1,9 +1,10 @@
-# $FreeBSD: head/sys/arm/at91/std.at91sam9 237881 2012-07-01 06:34:17Z imp $
+# $FreeBSD: head/sys/arm/at91/std.at91sam9 239308 2012-08-15 18:33:58Z gonzo $
 
 files		"../at91/files.at91"
 cpu		CPU_ARM9
 makeoptions	CONF_CFLAGS=-mcpu=arm9
 options 	PHYSADDR=0x20000000
+options		NO_EVENTTIMERS
 
 # bring in the sam specific timers and such
 device		at91sam9
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/at91/std.at91sam9g45
--- a/head/sys/arm/at91/std.at91sam9g45	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/arm/at91/std.at91sam9g45	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
-# $FreeBSD: head/sys/arm/at91/std.at91sam9g45 238921 2012-07-30 21:19:19Z imp $
+# $FreeBSD: head/sys/arm/at91/std.at91sam9g45 239308 2012-08-15 18:33:58Z gonzo $
 #
 # Unlike other Atmel SoCs, which have their SDRAM at CS1, the
 # at91sam9g45 family has it on CS6, so PHYSADDR must be adjusted
@@ -9,6 +9,7 @@
 cpu		CPU_ARM9
 makeoptions	CONF_CFLAGS=-mcpu=arm9
 options 	PHYSADDR=0x70000000
+options		NO_EVENTTIMERS
 
 # bring in the sam specific timers and such
 device		at91sam9
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/at91/std.atmel
--- a/head/sys/arm/at91/std.atmel	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/arm/at91/std.atmel	Thu Aug 16 21:15:49 2012 +0300
@@ -1,9 +1,10 @@
-# $FreeBSD: head/sys/arm/at91/std.atmel 238922 2012-07-30 21:30:43Z imp $
+# $FreeBSD: head/sys/arm/at91/std.atmel 239291 2012-08-15 08:34:31Z gonzo $
 
 files		"../at91/files.at91"
 cpu		CPU_ARM9
 makeoptions	CONF_CFLAGS=-mcpu=arm9
 options 	PHYSADDR=0x20000000
+options		NO_EVENTTIMERS
 
 # Supported SoCs for the at91 platform
 device		at91rm9200
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/at91/std.eb9200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/arm/at91/std.eb9200	Thu Aug 16 21:15:49 2012 +0300
@@ -0,0 +1,10 @@
+#$FreeBSD: head/sys/arm/at91/std.eb9200 239324 2012-08-16 05:03:59Z imp $
+include "../at91/std.at91"
+
+options		STARTUP_PAGETABLE_ADDR=0x20800000
+makeoptions	KERNPHYSADDR=0x20000000
+options		KERNPHYSADDR=0x20000000	
+makeoptions	KERNVIRTADDR=0xc0000000
+options		KERNVIRTADDR=0xc0000000
+
+device		at91_board_eb9200
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/conf/EB9200
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/arm/conf/EB9200	Thu Aug 16 21:15:49 2012 +0300
@@ -0,0 +1,109 @@
+# EB9200 - Custom kernel for the Embest ATEB9200 AT91RM9200 evaluation board.
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+#    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD: head/sys/arm/conf/EB9200 239324 2012-08-16 05:03:59Z imp $
+
+ident		EB9200
+
+include		"../at91/std.eb9200"
+# The AT91 platform doesn't use /boot/loader, so we have to statically wire
+# hints.
+hints		"EB9200.hints"
+makeoptions	MODULES_OVERRIDE=""
+
+makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+options 	DDB
+options 	KDB
+
+options 	SCHED_4BSD		#4BSD scheduler
+options 	INET			#InterNETworking
+#options 	INET6			#IPv6 communications protocols
+options 	FFS			#Berkeley Fast Filesystem
+#options 	SOFTUPDATES		#Enable FFS soft updates support
+#options 	UFS_ACL			#Support for access control lists
+#options 	UFS_DIRHASH		#Improve performance on big directories
+#options 	MD_ROOT			#MD is a potential root device
+#options 	MD_ROOT_SIZE=4096	# 4MB ram disk
+#options 	ROOTDEVNAME=\"ufs:/dev/da0s1a\"
+options 	NFSCL			#New Network Filesystem Client
+options 	NFSD			#New Network Filesystem Server
+options 	NFSLOCKD		#Network Lock Manager
+options 	NFS_ROOT		#NFS usable as /, requires NFSCL
+options 	BOOTP_NFSROOT
+options 	BOOTP
+
+#options 	MSDOSFS			#MSDOS Filesystem
+#options 	CD9660			#ISO 9660 Filesystem
+#options 	PROCFS			#Process filesystem (requires PSEUDOFS)
+options 	PSEUDOFS		#Pseudo-filesystem framework
+#options 	SCSI_DELAY=5000		#Delay (in ms) before probing SCSI
+#options 	KTRACE			#ktrace(1) support
+options 	SYSVSHM			#SYSV-style shared memory
+options 	SYSVMSG			#SYSV-style message queues
+options 	SYSVSEM			#SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+#options 	NO_SYSCTL_DESCR
+# Disable the inlining of mutex, rwlock and sx locks.  These eat up a lot
+# of space.
+options 	MUTEX_NOINLINE
+options 	RWLOCK_NOINLINE
+options 	SX_NOINLINE
+options 	NO_FFS_SNAPSHOT
+options 	NO_SWAPPING
+device		random
+device		loop
+device		ether
+device		uart
+device		ate
+device		miibus
+#device		lxtphy
+
+device		at91_cfata
+device		ata
+
+# Debugging for use in -current
+#options 	DEADLKRES		#Enable the deadlock resolver
+#options 	INVARIANTS		#Enable calls of extra sanity checking
+#options 	INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
+#options 	WITNESS			#Enable checks to detect deadlocks and cycles
+#options 	WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
+
+device		md
+device		at91_twi		# TWI: Two Wire Interface
+device		at91_spi		# SPI:
+device		spibus
+# MMC/SD
+device		at91_mci
+device		mmc
+device		mmcsd
+# iic
+device		iic
+device		iicbus
+device		icee
+
+device		bpf
+# USB support
+options 	USB_DEBUG	# enable debug msgs
+device		ohci		# OHCI localbus->USB interface
+device		usb		# USB Bus (required)
+device		umass		# Disks/Mass storage - Requires scbus and da
+# SCSI peripherals
+device		scbus		# SCSI bus (required for SCSI)
+device		da		# Direct Access (disks)
+device		cd		# CD
+device		pass		# Passthrough device (direct SCSI access)
+
+# USB device (gadget) support
+#device		at91_dci	# Atmel's usb device
+#device		usfs		# emulate a flash
+#device		cdce		# emulate an ethernet
+#device		usb_template	# Control of the gadget
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/conf/EB9200.hints
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/arm/conf/EB9200.hints	Thu Aug 16 21:15:49 2012 +0300
@@ -0,0 +1,6 @@
+# $FreeBSD: head/sys/arm/conf/EB9200.hints 239324 2012-08-16 05:03:59Z imp $
+
+# should likely list CF here since its address isn't fixed.
+# but since it is at an external chip select, do we use that or the address
+# to configure it as its bus address?  Need to fix arbitrary bus mapping
+# before I can list it here.
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/conf/HL201.hints
--- a/head/sys/arm/conf/HL201.hints	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/arm/conf/HL201.hints	Thu Aug 16 21:15:49 2012 +0300
@@ -1,68 +1,48 @@
-# $FreeBSD$
-#
+# $FreeBSD: head/sys/arm/conf/HL201.hints 239323 2012-08-16 04:53:30Z imp $
 
-# These are the wiring for the at91sam9261.  These are the built-in devices
-# for that cpu.
+# Atmel AT45DB21D
+hint.at45d.0.at="spibus0"
+hint.at45d.0.cs=0
+# Area 0:	00000000 to 000041FF (RO) Bootstrap
+# Area 1:	00004200 to 000083FF      Environment
+# Area 2:	00008400 to 00041FFF (RO) U-Boot
+# Area 3:	00042000 to 00251FFF      Kernel
+# Area 4:	00252000 to 0083FFFF      FS
+# bootstrap
+hint.map.0.at="flash/spi0"
+hint.map.0.start=0x00000000
+hint.map.0.end=0x000041ff
+hint.map.0.name="bootstrap"
+hint.map.0.readonly=1
+# uboot environment
+hint.map.1.at="flash/spi0"
+hint.map.1.start=0x00004200
+hint.map.1.end=0x00083ff
+hint.map.1.name="uboot-env"
+#hint.map.1.readonly=1
+# uboot
+hint.map.2.at="flash/spi0"
+hint.map.2.start=0x00008400
+hint.map.2.end=0x00041fff
+hint.map.2.name="uboot"
+hint.map.2.readonly=1
+# kernel
+hint.map.3.at="flash/spi0"
+hint.map.3.start=0x00042000
+hint.map.3.end=0x00251fff
+hint.map.3.name="fs"
+#hint.map.3.readonly=1
+# fs
+hint.map.4.at="flash/spi0"
+hint.map.4.start=0x00252000
+hint.map.4.end=0x0083ffff
+hint.map.4.name="fs"
+#hint.map.4.readonly=1
 
-# DBGU is unit 0
-hint.uart.0.at="apb"
-hint.uart.0.maddr="0xfffff200"
-hint.uart.0.flags=0x10
-# USART0 is unit 1
-hint.uart.1.at="apb"
-hint.uart.1.maddr="0xfffb0000"
-# USART1 is unit 2
-hint.uart.2.at="apb"
-hint.uart.2.maddr="0xfffb4000"
-# USART2 is unit 3
-hint.uart.3.at="apb"
-hint.uart.3.maddr="0xfffb8000"
-# USART3 is unit 4
-hint.uart.4.at="apb"
-hint.uart.4.maddr="0xfffbc000"
-
-# TC0, TC1, TC2
-hint.tc.0.at="apb"
-hint.tc.0.maddr="0xfffa0000"
-
-# USB Device
-hint.udp.0.at="apb"
-hint.udp.0.maddr="0xfffa4000"
-
-# MCI
-hint.mci.0.at="apb"
-hint.mci.0.maddr="0xfffa8000"
-
-# TWI
-hint.twi.0.at="apb"
-hint.twi.0.maddr="0xfffac000"
-
-# SSC0
-hint.ssc.0.at="apb"
-hint.ssc.0.maddr="0xfffbc000"
-# SSC1
-hint.ssc.1.at="apb"
-hint.ssc.1.maddr="0xfffc0000"
-# SSC2
-hint.ssc.1.at="apb"
-hint.ssc.1.maddr="0xfffc4000"
-
-# SPI0
-hint.spi.0.at="apb"
-hint.spi.0.maddr="0xfffc8000"
-# SSC1
-hint.spi.1.at="apb"
-hint.spi.1.maddr="0xfffcc000"
-
-# PMC
-hint.pmc.0.at="apb"
-hint.pmc.0.maddr="0xfffffc00"
-
-# USB host (ohci)
-#??? maybe this needs to be on asb instead of apb
-hint.ohci.at="apb"
-hint.ohci.maddr="0x00500000"
-# LCD controller
-hint.atlcd.at="apb"
-hint.atlcd.maddr="0x00600000"
-
+# EEPROM at24c512 - 512kbit 65,536x8 memory
+hint.icee.0.at="iicbus0"
+hint.icee.0.addr=0xa0
+hint.icee.0.type=16
+hint.icee.0.size=65536
+hint.icee.0.rd_sz=128
+hint.icee.0.wr_sz=128
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/arm/lpc/lpc_machdep.c
--- a/head/sys/arm/lpc/lpc_machdep.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/arm/lpc/lpc_machdep.c	Thu Aug 16 21:15:49 2012 +0300
@@ -39,7 +39,7 @@
 #include "opt_platform.h"
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/arm/lpc/lpc_machdep.c 239278 2012-08-15 05:37:10Z gonzo $");
+__FBSDID("$FreeBSD: head/sys/arm/lpc/lpc_machdep.c 239307 2012-08-15 18:18:29Z jceel $");
 
 #define _ARM32_BUS_DMA_PRIVATE
 #include <sys/param.h>
@@ -296,7 +296,7 @@
 }
 
 void *
-initarm(void *mdp, void *unused __unused)
+initarm(struct arm_boot_params *abp)
 {
 	struct pv_addr kernel_l1pt;
 	struct pv_addr dpcpu;
@@ -306,41 +306,15 @@
 	u_int l1pagetable;
 	int i = 0, j = 0;
 
-	kmdp = NULL;
-	lastaddr = 0;
+	lastaddr = parse_boot_param(abp);
 	memsize = 0;
-	dtbp = (vm_offset_t)NULL;
-
 	set_cpufuncs();
 
-	/*
-	 * Mask metadata pointer: it is supposed to be on page boundary. If
-	 * the first argument (mdp) doesn't point to a valid address the
-	 * bootloader must have passed us something else than the metadata
-	 * ptr... In this case we want to fall back to some built-in settings.
-	 */
-	mdp = (void *)((uint32_t)mdp & ~PAGE_MASK);
-
-	/* Parse metadata and fetch parameters */
-	if (mdp != NULL) {
-		preload_metadata = mdp;
-		kmdp = preload_search_by_type("elf kernel");
-		if (kmdp != NULL) {
-			boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
-			kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
-			dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
-			lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND,
-			    vm_offset_t);
-#ifdef DDB
-			ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
-			ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
-#endif
-		}
-
-	} else {
-		/* Fall back to hardcoded metadata. */
-		lastaddr = fake_preload_metadata();
-	}
+	kmdp = preload_search_by_type("elf kernel");
+	if (kmdp != NULL) 
+		dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
+	else
+		dtbp = (vm_offset_t)NULL;
 
 #if defined(FDT_DTB_STATIC)
 	/*
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
--- a/head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Thu Aug 16 21:15:49 2012 +0300
@@ -18,7 +18,7 @@
  *
  * CDDL HEADER END
  *
- * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 237817 2012-06-29 18:49:14Z pfg $
+ * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 239303 2012-08-15 16:19:39Z hselasky $
  */
 
 /*
@@ -15517,8 +15517,6 @@
 		kmem_free(state, 0);
 #if __FreeBSD_version < 800039
 		dev->si_drv1 = NULL;
-#else
-		devfs_clear_cdevpriv();
 #endif
 #endif
 	}
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/compat/freebsd32/freebsd32_proto.h
--- a/head/sys/compat/freebsd32/freebsd32_proto.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/compat/freebsd32/freebsd32_proto.h	Thu Aug 16 21:15:49 2012 +0300
@@ -2,8 +2,8 @@
  * System call prototypes.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: head/sys/compat/freebsd32/freebsd32_proto.h 239249 2012-08-14 12:09:36Z kib $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239248 2012-08-14 12:09:09Z kib 
+ * $FreeBSD: head/sys/compat/freebsd32/freebsd32_proto.h 239297 2012-08-15 15:18:20Z kib $
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239296 2012-08-15 15:17:56Z kib 
  */
 
 #ifndef _FREEBSD32_SYSPROTO_H_
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/compat/freebsd32/freebsd32_syscall.h
--- a/head/sys/compat/freebsd32/freebsd32_syscall.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/compat/freebsd32/freebsd32_syscall.h	Thu Aug 16 21:15:49 2012 +0300
@@ -2,8 +2,8 @@
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: head/sys/compat/freebsd32/freebsd32_syscall.h 239249 2012-08-14 12:09:36Z kib $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239248 2012-08-14 12:09:09Z kib 
+ * $FreeBSD: head/sys/compat/freebsd32/freebsd32_syscall.h 239297 2012-08-15 15:18:20Z kib $
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239296 2012-08-15 15:17:56Z kib 
  */
 
 #define	FREEBSD32_SYS_syscall	0
@@ -132,8 +132,8 @@
 #define	FREEBSD32_SYS_setreuid	126
 #define	FREEBSD32_SYS_setregid	127
 #define	FREEBSD32_SYS_rename	128
-				/* 129 is obsolete otruncate */
-				/* 130 is obsolete ftruncate */
+				/* 129 is old truncate */
+				/* 130 is old ftruncate */
 #define	FREEBSD32_SYS_flock	131
 #define	FREEBSD32_SYS_mkfifo	132
 #define	FREEBSD32_SYS_sendto	133
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/compat/freebsd32/freebsd32_syscalls.c
--- a/head/sys/compat/freebsd32/freebsd32_syscalls.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/compat/freebsd32/freebsd32_syscalls.c	Thu Aug 16 21:15:49 2012 +0300
@@ -2,8 +2,8 @@
  * System call names.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: head/sys/compat/freebsd32/freebsd32_syscalls.c 239249 2012-08-14 12:09:36Z kib $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239248 2012-08-14 12:09:09Z kib 
+ * $FreeBSD: head/sys/compat/freebsd32/freebsd32_syscalls.c 239297 2012-08-15 15:18:20Z kib $
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239296 2012-08-15 15:17:56Z kib 
  */
 
 const char *freebsd32_syscallnames[] = {
@@ -139,8 +139,8 @@
 	"setreuid",			/* 126 = setreuid */
 	"setregid",			/* 127 = setregid */
 	"rename",			/* 128 = rename */
-	"obs_otruncate",			/* 129 = obsolete otruncate */
-	"obs_ftruncate",			/* 130 = obsolete ftruncate */
+	"compat.truncate",		/* 129 = old truncate */
+	"compat.ftruncate",		/* 130 = old ftruncate */
 	"flock",			/* 131 = flock */
 	"mkfifo",			/* 132 = mkfifo */
 	"sendto",			/* 133 = sendto */
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/compat/freebsd32/freebsd32_sysent.c
--- a/head/sys/compat/freebsd32/freebsd32_sysent.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/compat/freebsd32/freebsd32_sysent.c	Thu Aug 16 21:15:49 2012 +0300
@@ -2,8 +2,8 @@
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD: head/sys/compat/freebsd32/freebsd32_sysent.c 239249 2012-08-14 12:09:36Z kib $
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239248 2012-08-14 12:09:09Z kib 
+ * $FreeBSD: head/sys/compat/freebsd32/freebsd32_sysent.c 239297 2012-08-15 15:18:20Z kib $
+ * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 239296 2012-08-15 15:17:56Z kib 
  */
 
 #include "opt_compat.h"
@@ -176,8 +176,8 @@
 	{ AS(setreuid_args), (sy_call_t *)sys_setreuid, AUE_SETREUID, NULL, 0, 0, 0, SY_THR_STATIC },	/* 126 = setreuid */
 	{ AS(setregid_args), (sy_call_t *)sys_setregid, AUE_SETREGID, NULL, 0, 0, 0, SY_THR_STATIC },	/* 127 = setregid */
 	{ AS(rename_args), (sy_call_t *)sys_rename, AUE_RENAME, NULL, 0, 0, 0, SY_THR_STATIC },	/* 128 = rename */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },			/* 129 = obsolete otruncate */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },			/* 130 = obsolete ftruncate */
+	{ compat(AS(otruncate_args),truncate), AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC },	/* 129 = old truncate */
+	{ compat(AS(oftruncate_args),ftruncate), AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC },	/* 130 = old ftruncate */
 	{ AS(flock_args), (sy_call_t *)sys_flock, AUE_FLOCK, NULL, 0, 0, 0, SY_THR_STATIC },	/* 131 = flock */
 	{ AS(mkfifo_args), (sy_call_t *)sys_mkfifo, AUE_MKFIFO, NULL, 0, 0, 0, SY_THR_STATIC },	/* 132 = mkfifo */
 	{ AS(sendto_args), (sy_call_t *)sys_sendto, AUE_SENDTO, NULL, 0, 0, 0, SY_THR_STATIC },	/* 133 = sendto */
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/compat/freebsd32/syscalls.master
--- a/head/sys/compat/freebsd32/syscalls.master	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/compat/freebsd32/syscalls.master	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
- $FreeBSD: head/sys/compat/freebsd32/syscalls.master 239248 2012-08-14 12:09:09Z kib $
+ $FreeBSD: head/sys/compat/freebsd32/syscalls.master 239296 2012-08-15 15:17:56Z kib $
 ;	from: @(#)syscalls.master	8.2 (Berkeley) 1/13/94
 ;	from: src/sys/kern/syscalls.master 1.107
 ;
@@ -257,8 +257,9 @@
 126	AUE_SETREUID	NOPROTO	{ int setreuid(int ruid, int euid); }
 127	AUE_SETREGID	NOPROTO	{ int setregid(int rgid, int egid); }
 128	AUE_RENAME	NOPROTO	{ int rename(char *from, char *to); }
-129	AUE_TRUNCATE	OBSOL	otruncate
-130	AUE_FTRUNCATE	OBSOL	ftruncate
+129	AUE_TRUNCATE	COMPAT|NOPROTO	{ int truncate(char *path, \
+					    int length); }
+130	AUE_FTRUNCATE	COMPAT|NOPROTO	{ int ftruncate(int fd, int length); }
 131	AUE_FLOCK	NOPROTO	{ int flock(int fd, int how); }
 132	AUE_MKFIFO	NOPROTO	{ int mkfifo(char *path, int mode); }
 133	AUE_SENDTO	NOPROTO	{ int sendto(int s, caddr_t buf, \
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/ath/ath_rate/sample/sample.c
--- a/head/sys/dev/ath/ath_rate/sample/sample.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/ath/ath_rate/sample/sample.c	Thu Aug 16 21:15:49 2012 +0300
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ath/ath_rate/sample/sample.c 239284 2012-08-15 07:10:10Z adrian $");
+__FBSDID("$FreeBSD: head/sys/dev/ath/ath_rate/sample/sample.c 239300 2012-08-15 15:53:27Z kib $");
 
 /*
  * John Bicket's SampleRate control algorithm.
@@ -1296,11 +1296,11 @@
 	uint64_t mask;
 	int rix, y;
 
-	printf("\n[%s] refcnt %d static_rix (%d %s) ratemask 0x%qx\n",
+	printf("\n[%s] refcnt %d static_rix (%d %s) ratemask 0x%jx\n",
 	    ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni),
 	    dot11rate(rt, sn->static_rix),
 	    dot11rate_label(rt, sn->static_rix),
-	    sn->ratemask);
+	    (uintmax_t)sn->ratemask);
 	for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) {
 		printf("[%4u] cur rix %d (%d %s) since switch: packets %d ticks %u\n",
 		    bin_to_size(y), sn->current_rix[y],
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/drm/drm_fops.c
--- a/head/sys/dev/drm/drm_fops.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/drm/drm_fops.c	Thu Aug 16 21:15:49 2012 +0300
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/dev/drm/drm_fops.c 239303 2012-08-15 16:19:39Z hselasky $");
 
 /** @file drm_fops.c
  * Support code for dealing with the file privates associated with each
@@ -57,12 +57,6 @@
 		return ENOMEM;
 	}
 
-	retcode = devfs_set_cdevpriv(priv, drm_close);
-	if (retcode != 0) {
-		free(priv, DRM_MEM_FILES);
-		return retcode;
-	}
-
 	DRM_LOCK();
 	priv->dev		= dev;
 	priv->uid		= p->td_ucred->cr_svuid;
@@ -76,7 +70,6 @@
 		/* shared code returns -errno */
 		retcode = -dev->driver->open(dev, priv);
 		if (retcode != 0) {
-			devfs_clear_cdevpriv();
 			free(priv, DRM_MEM_FILES);
 			DRM_UNLOCK();
 			return retcode;
@@ -89,7 +82,12 @@
 	TAILQ_INSERT_TAIL(&dev->files, priv, link);
 	DRM_UNLOCK();
 	kdev->si_drv1 = dev;
-	return 0;
+
+	retcode = devfs_set_cdevpriv(priv, drm_close);
+	if (retcode != 0)
+		drm_close(priv);
+
+	return (retcode);
 }
 
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/drm2/drm_fops.c
--- a/head/sys/dev/drm2/drm_fops.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/drm2/drm_fops.c	Thu Aug 16 21:15:49 2012 +0300
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/drm2/drm_fops.c 235783 2012-05-22 11:07:44Z kib $");
+__FBSDID("$FreeBSD: head/sys/dev/drm2/drm_fops.c 239303 2012-08-15 16:19:39Z hselasky $");
 
 /** @file drm_fops.c
  * Support code for dealing with the file privates associated with each
@@ -57,12 +57,6 @@
 		return ENOMEM;
 	}
 
-	retcode = devfs_set_cdevpriv(priv, drm_close);
-	if (retcode != 0) {
-		free(priv, DRM_MEM_FILES);
-		return retcode;
-	}
-
 	DRM_LOCK(dev);
 	priv->dev		= dev;
 	priv->uid		= p->td_ucred->cr_svuid;
@@ -83,7 +77,6 @@
 		/* shared code returns -errno */
 		retcode = -dev->driver->open(dev, priv);
 		if (retcode != 0) {
-			devfs_clear_cdevpriv();
 			free(priv, DRM_MEM_FILES);
 			DRM_UNLOCK(dev);
 			return retcode;
@@ -96,7 +89,12 @@
 	TAILQ_INSERT_TAIL(&dev->files, priv, link);
 	DRM_UNLOCK(dev);
 	kdev->si_drv1 = dev;
-	return 0;
+
+	retcode = devfs_set_cdevpriv(priv, drm_close);
+	if (retcode != 0)
+		drm_close(priv);
+
+	return (retcode);
 }
 
 static bool
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/e1000/if_em.c
--- a/head/sys/dev/e1000/if_em.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/e1000/if_em.c	Thu Aug 16 21:15:49 2012 +0300
@@ -30,7 +30,7 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/e1000/if_em.c 238214 2012-07-07 20:21:05Z jfv $*/
+/*$FreeBSD: head/sys/dev/e1000/if_em.c 239304 2012-08-15 17:12:40Z jfv $*/
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS
 #include "opt_device_polling.h"
@@ -1570,6 +1570,8 @@
 	bool		more;
 
 	++rxr->rx_irq;
+	if (!(adapter->ifp->if_drv_flags & IFF_DRV_RUNNING))
+		return;
 	more = em_rxeof(rxr, adapter->rx_process_limit, NULL);
 	if (more)
 		taskqueue_enqueue(rxr->tq, &rxr->rx_task);
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/isp/isp_freebsd.c
--- a/head/sys/dev/isp/isp_freebsd.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/isp/isp_freebsd.c	Thu Aug 16 21:15:49 2012 +0300
@@ -28,7 +28,7 @@
  * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 239218 2012-08-12 20:45:47Z mjacob $");
+__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 239330 2012-08-16 15:32:16Z mjacob $");
 #include <dev/isp/isp_freebsd.h>
 #include <sys/unistd.h>
 #include <sys/kthread.h>
@@ -1154,10 +1154,27 @@
 static ISP_INLINE void
 destroy_lun_state(ispsoftc_t *isp, tstate_t *tptr)
 {
+	union ccb *ccb;
 	struct tslist *lhp;
 
 	KASSERT((tptr->hold != 0), ("tptr is not held"));
 	KASSERT((tptr->hold == 1), ("tptr still held (%d)", tptr->hold));
+	do {
+		ccb = (union ccb *)SLIST_FIRST(&tptr->atios);
+		if (ccb) {
+			SLIST_REMOVE_HEAD(&tptr->atios, sim_links.sle);
+			ccb->ccb_h.status = CAM_REQ_ABORTED;
+			xpt_done(ccb);
+		}
+	} while (ccb);
+	do {
+		ccb = (union ccb *)SLIST_FIRST(&tptr->inots);
+		if (ccb) {
+			SLIST_REMOVE_HEAD(&tptr->inots, sim_links.sle);
+			ccb->ccb_h.status = CAM_REQ_ABORTED;
+			xpt_done(ccb);
+		}
+	} while (ccb);
 	ISP_GET_PC_ADDR(isp, cam_sim_bus(xpt_path_sim(tptr->owner)), lun_hash[LUN_HASH_FUNC(xpt_path_lun_id(tptr->owner))], lhp);
 	SLIST_REMOVE(lhp, tptr, tstate, next);
 	ISP_PATH_PRT(isp, ISP_LOGTDEBUG0, tptr->owner, "destroyed tstate\n");
@@ -1472,8 +1489,8 @@
 	}
 	ccb->ccb_h.status = status;
 	if (status == CAM_REQ_CMP) {
+		destroy_lun_state(isp, tptr);
 		xpt_print(ccb->ccb_h.path, "lun now disabled for target mode\n");
-		destroy_lun_state(isp, tptr);
 	} else {
 		if (tptr)
 			rls_lun_statep(isp, tptr);
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/ksyms/ksyms.c
--- a/head/sys/dev/ksyms/ksyms.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/ksyms/ksyms.c	Thu Aug 16 21:15:49 2012 +0300
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sys/dev/ksyms/ksyms.c 226500 2011-10-18 08:09:44Z ed $
+ * $FreeBSD: head/sys/dev/ksyms/ksyms.c 239303 2012-08-15 16:19:39Z hselasky $
  */
 
 #include <sys/param.h>
@@ -579,8 +579,6 @@
 	/* Unmap the buffer from the process address space. */
 	error = copyout_unmap(td, sc->sc_uaddr, sc->sc_usize);
 
-	devfs_clear_cdevpriv();
-
 	return (error);
 }
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/sound/pci/hda/hdaa.c
--- a/head/sys/dev/sound/pci/hda/hdaa.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/sound/pci/hda/hdaa.c	Thu Aug 16 21:15:49 2012 +0300
@@ -45,7 +45,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pci/hda/hdaa.c 239254 2012-08-14 14:07:34Z mav $");
+SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pci/hda/hdaa.c 239326 2012-08-16 07:43:15Z mav $");
 
 #define hdaa_lock(devinfo)	snd_mtxlock((devinfo)->lock)
 #define hdaa_unlock(devinfo)	snd_mtxunlock((devinfo)->lock)
@@ -2127,11 +2127,14 @@
 		w = hdaa_widget_get(devinfo, i);
 		if (w == NULL || w->enable == 0)
 			continue;
-		if (w->bindas < 0 && pdevinfo->index != 0)
-			continue;
-		if (w->bindas != pdevinfo->playas &&
-		    w->bindas != pdevinfo->recas)
-			continue;
+		if (w->bindas < 0) {
+			if (pdevinfo->index != 0)
+				continue;
+		} else {
+			if (w->bindas != pdevinfo->playas &&
+			    w->bindas != pdevinfo->recas)
+				continue;
+		}
 		if (dev == SOUND_MIXER_RECLEV &&
 		    w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
 			hdaa_audio_ctl_dest_volume(pdevinfo, dev,
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/net/if_usie.c
--- a/head/sys/dev/usb/net/if_usie.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/net/if_usie.c	Thu Aug 16 21:15:49 2012 +0300
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/net/if_usie.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/net/if_usie.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -95,7 +95,7 @@
 static device_probe_t usie_probe;
 static device_attach_t usie_attach;
 static device_detach_t usie_detach;
-static device_free_softc_t usie_free_softc;
+static void usie_free_softc(struct usie_softc *);
 
 static void usie_free(struct ucom_softc *);
 static void usie_uc_update_line_state(struct ucom_softc *, uint8_t);
@@ -191,7 +191,6 @@
 	DEVMETHOD(device_probe, usie_probe),
 	DEVMETHOD(device_attach, usie_attach),
 	DEVMETHOD(device_detach, usie_detach),
-	DEVMETHOD(device_free_softc, usie_free_softc),
 	DEVMETHOD_END
 };
 
@@ -488,27 +487,28 @@
 		usbd_transfer_unsetup(sc->sc_uc_xfer[x], USIE_UC_N_XFER);
 
 
+	device_claim_softc(self);
+
+	usie_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(usie);
 
 static void
-usie_free_softc(device_t dev, void *arg)
+usie_free_softc(struct usie_softc *sc)
 {
-	struct usie_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 usie_free(struct ucom_softc *ucom)
 {
-	usie_free_softc(NULL, ucom->sc_parent);
+	usie_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/net/uhso.c
--- a/head/sys/dev/usb/net/uhso.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/net/uhso.c	Thu Aug 16 21:15:49 2012 +0300
@@ -24,7 +24,7 @@
  *
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/net/uhso.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/net/uhso.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -474,13 +474,12 @@
 static device_probe_t uhso_probe;
 static device_attach_t uhso_attach;
 static device_detach_t uhso_detach;
-static device_free_softc_t uhso_free_softc;
+static void uhso_free_softc(struct uhso_softc *);
 
 static device_method_t uhso_methods[] = {
 	DEVMETHOD(device_probe,		uhso_probe),
 	DEVMETHOD(device_attach,	uhso_attach),
 	DEVMETHOD(device_detach,	uhso_detach),
-	DEVMETHOD(device_free_softc,	uhso_free_softc),
 	{ 0, 0 }
 };
 
@@ -697,27 +696,28 @@
 		usbd_transfer_unsetup(sc->sc_if_xfer, UHSO_IFNET_MAX);
 	}
 
+	device_claim_softc(self);
+
+	uhso_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uhso);
 
 static void
-uhso_free_softc(device_t dev, void *arg)
+uhso_free_softc(struct uhso_softc *sc)
 {
-	struct uhso_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uhso_free(struct ucom_softc *ucom)
 {
-	uhso_free_softc(NULL, ucom->sc_parent);
+	uhso_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/quirk/usb_quirk.c
--- a/head/sys/dev/usb/quirk/usb_quirk.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/quirk/usb_quirk.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/dev/usb/quirk/usb_quirk.c 238718 2012-07-23 15:14:28Z emaste $ */
+/* $FreeBSD: head/sys/dev/usb/quirk/usb_quirk.c 239298 2012-08-15 15:35:20Z hselasky $ */
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
  * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
@@ -125,6 +125,8 @@
 	/* MS keyboards do weird things */
 	USB_QUIRK(MICROSOFT, NATURAL4000, 0x0000, 0xFFFF, UQ_KBD_BOOTPROTO),
 	USB_QUIRK(MICROSOFT, WLINTELLIMOUSE, 0x0000, 0xffff, UQ_MS_LEADING_BYTE),
+	/* Quirk for Corsair Vengeance K60 keyboard */
+	USB_QUIRK(CORSAIR, K60, 0x0000, 0xffff, UQ_KBD_BOOTPROTO),
 	/* umodem(4) device quirks */
 	USB_QUIRK(METRICOM, RICOCHET_GS, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA),
 	USB_QUIRK(SANYO, SCP4900, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA),
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/u3g.c
--- a/head/sys/dev/usb/serial/u3g.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/u3g.c	Thu Aug 16 21:15:49 2012 +0300
@@ -16,7 +16,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/usb/serial/u3g.c 239182 2012-08-10 17:43:20Z hselasky $
+ * $FreeBSD: head/sys/dev/usb/serial/u3g.c 239299 2012-08-15 15:42:57Z hselasky $
  */
 
 /*
@@ -124,7 +124,7 @@
 static device_probe_t u3g_probe;
 static device_attach_t u3g_attach;
 static device_detach_t u3g_detach;
-static device_free_softc_t u3g_free_softc;
+static void u3g_free_softc(struct u3g_softc *);
 
 static usb_callback_t u3g_write_callback;
 static usb_callback_t u3g_read_callback;
@@ -179,7 +179,6 @@
 	DEVMETHOD(device_probe, u3g_probe),
 	DEVMETHOD(device_attach, u3g_attach),
 	DEVMETHOD(device_detach, u3g_detach),
-	DEVMETHOD(device_free_softc, u3g_free_softc),
 	DEVMETHOD_END
 };
 
@@ -915,6 +914,10 @@
 	for (subunit = 0; subunit != U3G_MAXPORTS; subunit++)
 		usbd_transfer_unsetup(sc->sc_xfer[subunit], U3G_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	u3g_free_softc(sc);
+
 	return (0);
 }
 
@@ -977,21 +980,18 @@
 }
 
 static void
-u3g_free_softc(device_t dev, void *arg)
+u3g_free_softc(struct u3g_softc *sc)
 {
-	struct u3g_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 u3g_free(struct ucom_softc *ucom)
 {
-	u3g_free_softc(NULL, ucom->sc_parent);
+	u3g_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uark.c
--- a/head/sys/dev/usb/serial/uark.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uark.c	Thu Aug 16 21:15:49 2012 +0300
@@ -15,7 +15,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/usb/serial/uark.c 239180 2012-08-10 15:29:41Z hselasky $
+ * $FreeBSD: head/sys/dev/usb/serial/uark.c 239299 2012-08-15 15:42:57Z hselasky $
  */
 
 /*
@@ -99,7 +99,7 @@
 static device_probe_t uark_probe;
 static device_attach_t uark_attach;
 static device_detach_t uark_detach;
-static device_free_softc_t uark_free_softc;
+static void uark_free_softc(struct uark_softc *);
 
 static usb_callback_t uark_bulk_write_callback;
 static usb_callback_t uark_bulk_read_callback;
@@ -157,7 +157,6 @@
 	DEVMETHOD(device_probe, uark_probe),
 	DEVMETHOD(device_attach, uark_attach),
 	DEVMETHOD(device_detach, uark_detach),
-	DEVMETHOD(device_free_softc, uark_free_softc),
 	DEVMETHOD_END
 };
 
@@ -248,27 +247,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UARK_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uark_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uark);
 
 static void
-uark_free_softc(device_t dev, void *arg)
+uark_free_softc(struct uark_softc *sc)
 {
-	struct uark_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uark_free(struct ucom_softc *ucom)
 {
-	uark_free_softc(NULL, ucom->sc_parent);
+	uark_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/ubsa.c
--- a/head/sys/dev/usb/serial/ubsa.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/ubsa.c	Thu Aug 16 21:15:49 2012 +0300
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ubsa.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ubsa.c 239299 2012-08-15 15:42:57Z hselasky $");
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -176,7 +176,7 @@
 static device_probe_t ubsa_probe;
 static device_attach_t ubsa_attach;
 static device_detach_t ubsa_detach;
-static device_free_softc_t ubsa_free_softc;
+static void ubsa_free_softc(struct ubsa_softc *);
 
 static usb_callback_t ubsa_write_callback;
 static usb_callback_t ubsa_read_callback;
@@ -265,7 +265,6 @@
 	DEVMETHOD(device_probe, ubsa_probe),
 	DEVMETHOD(device_attach, ubsa_attach),
 	DEVMETHOD(device_detach, ubsa_detach),
-	DEVMETHOD(device_free_softc, ubsa_free_softc),
 	DEVMETHOD_END
 };
 
@@ -354,27 +353,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UBSA_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	ubsa_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(ubsa);
 
 static void
-ubsa_free_softc(device_t dev, void *arg)
+ubsa_free_softc(struct ubsa_softc *sc)
 {
-	struct ubsa_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 ubsa_free(struct ucom_softc *ucom)
 {
-	ubsa_free_softc(NULL, ucom->sc_parent);
+	ubsa_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/ubser.c
--- a/head/sys/dev/usb/serial/ubser.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/ubser.c	Thu Aug 16 21:15:49 2012 +0300
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ubser.c 239181 2012-08-10 17:42:14Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ubser.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*
  * BWCT serial adapter driver
@@ -148,7 +148,7 @@
 static device_probe_t ubser_probe;
 static device_attach_t ubser_attach;
 static device_detach_t ubser_detach;
-static device_free_softc_t ubser_free_softc;
+static void ubser_free_softc(struct ubser_softc *);
 
 static usb_callback_t ubser_write_callback;
 static usb_callback_t ubser_read_callback;
@@ -201,7 +201,6 @@
 	DEVMETHOD(device_probe, ubser_probe),
 	DEVMETHOD(device_attach, ubser_attach),
 	DEVMETHOD(device_detach, ubser_detach),
-	DEVMETHOD(device_free_softc, ubser_free_softc),
 	DEVMETHOD_END
 };
 
@@ -321,27 +320,28 @@
 	ucom_detach(&sc->sc_super_ucom, sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UBSER_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	ubser_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(ubser);
 
 static void
-ubser_free_softc(device_t dev, void *arg)
+ubser_free_softc(struct ubser_softc *sc)
 {
-	struct ubser_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 ubser_free(struct ucom_softc *ucom)
 {
-	ubser_free_softc(NULL, ucom->sc_parent);
+	ubser_free_softc(ucom->sc_parent);
 }
 
 static int
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uchcom.c
--- a/head/sys/dev/usb/serial/uchcom.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uchcom.c	Thu Aug 16 21:15:49 2012 +0300
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uchcom.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uchcom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*
  * Driver for WinChipHead CH341/340, the worst USB-serial chip in the
@@ -235,7 +235,7 @@
 static device_probe_t uchcom_probe;
 static device_attach_t uchcom_attach;
 static device_detach_t uchcom_detach;
-static device_free_softc_t uchcom_free_softc;
+static void uchcom_free_softc(struct uchcom_softc *);
 
 static usb_callback_t uchcom_intr_callback;
 static usb_callback_t uchcom_write_callback;
@@ -376,27 +376,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UCHCOM_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uchcom_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uchcom);
 
 static void
-uchcom_free_softc(device_t dev, void *arg)
+uchcom_free_softc(struct uchcom_softc *sc)
 {
-	struct uchcom_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uchcom_free(struct ucom_softc *ucom)
 {
-	uchcom_free_softc(NULL, ucom->sc_parent);
+	uchcom_free_softc(ucom->sc_parent);
 }
 
 /* ----------------------------------------------------------------------
@@ -864,7 +865,6 @@
 	DEVMETHOD(device_probe, uchcom_probe),
 	DEVMETHOD(device_attach, uchcom_attach),
 	DEVMETHOD(device_detach, uchcom_detach),
-	DEVMETHOD(device_free_softc, uchcom_free_softc),
 	DEVMETHOD_END
 };
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/ucycom.c
--- a/head/sys/dev/usb/serial/ucycom.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/ucycom.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ucycom.c 239181 2012-08-10 17:42:14Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ucycom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2004 Dag-Erling Coïdan Smørgrav
@@ -110,7 +110,7 @@
 static device_probe_t ucycom_probe;
 static device_attach_t ucycom_attach;
 static device_detach_t ucycom_detach;
-static device_free_softc_t ucycom_free_softc;
+static void ucycom_free_softc(struct ucycom_softc *);
 
 static usb_callback_t ucycom_ctrl_write_callback;
 static usb_callback_t ucycom_intr_read_callback;
@@ -163,7 +163,6 @@
 	DEVMETHOD(device_probe, ucycom_probe),
 	DEVMETHOD(device_attach, ucycom_attach),
 	DEVMETHOD(device_detach, ucycom_detach),
-	DEVMETHOD(device_free_softc, ucycom_free_softc),
 	DEVMETHOD_END
 };
 
@@ -299,27 +298,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UCYCOM_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	ucycom_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(ucycom);
 
 static void
-ucycom_free_softc(device_t dev, void *arg)
+ucycom_free_softc(struct ucycom_softc *sc)
 {
-	struct ucycom_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 ucycom_free(struct ucom_softc *ucom)
 {
-	ucycom_free_softc(NULL, ucom->sc_parent);
+	ucycom_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/ufoma.c
--- a/head/sys/dev/usb/serial/ufoma.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/ufoma.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,7 +1,7 @@
 /*	$NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ufoma.c 239181 2012-08-10 17:42:14Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ufoma.c 239299 2012-08-15 15:42:57Z hselasky $");
 #define UFOMA_HANDSFREE
 /*-
  * Copyright (c) 2005, Takanori Watanabe
@@ -202,7 +202,7 @@
 static device_probe_t ufoma_probe;
 static device_attach_t ufoma_attach;
 static device_detach_t ufoma_detach;
-static device_free_softc_t ufoma_free_softc;
+static void ufoma_free_softc(struct ufoma_softc *);
 
 static usb_callback_t ufoma_ctrl_read_callback;
 static usb_callback_t ufoma_ctrl_write_callback;
@@ -313,7 +313,6 @@
 	DEVMETHOD(device_probe, ufoma_probe),
 	DEVMETHOD(device_attach, ufoma_attach),
 	DEVMETHOD(device_detach, ufoma_detach),
-	DEVMETHOD(device_free_softc, ufoma_free_softc),
 	DEVMETHOD_END
 };
 
@@ -498,27 +497,28 @@
 	}
 	cv_destroy(&sc->sc_cv);
 
+	device_claim_softc(dev);
+
+	ufoma_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(ufoma);
 
 static void
-ufoma_free_softc(device_t dev, void *arg)
+ufoma_free_softc(struct ufoma_softc *sc)
 {
-	struct ufoma_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 ufoma_free(struct ucom_softc *ucom)
 {
-	ufoma_free_softc(NULL, ucom->sc_parent);
+	ufoma_free_softc(ucom->sc_parent);
 }
 
 static void *
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uftdi.c
--- a/head/sys/dev/usb/serial/uftdi.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uftdi.c	Thu Aug 16 21:15:49 2012 +0300
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uftdi.c 239181 2012-08-10 17:42:14Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uftdi.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*
  * NOTE: all function names beginning like "uftdi_cfg_" can only
@@ -125,7 +125,7 @@
 static device_probe_t uftdi_probe;
 static device_attach_t uftdi_attach;
 static device_detach_t uftdi_detach;
-static device_free_softc_t uftdi_free_softc;
+static void uftdi_free_softc(struct uftdi_softc *);
 
 static usb_callback_t uftdi_write_callback;
 static usb_callback_t uftdi_read_callback;
@@ -190,7 +190,6 @@
 	DEVMETHOD(device_probe, uftdi_probe),
 	DEVMETHOD(device_attach, uftdi_attach),
 	DEVMETHOD(device_detach, uftdi_detach),
-	DEVMETHOD(device_free_softc, uftdi_free_softc),
 	DEVMETHOD_END
 };
 
@@ -960,27 +959,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UFTDI_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uftdi_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uftdi);
 
 static void
-uftdi_free_softc(device_t dev, void *arg)
+uftdi_free_softc(struct uftdi_softc *sc)
 {
-	struct uftdi_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uftdi_free(struct ucom_softc *ucom)
 {
-	uftdi_free_softc(NULL, ucom->sc_parent);
+	uftdi_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/ugensa.c
--- a/head/sys/dev/usb/serial/ugensa.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/ugensa.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/dev/usb/serial/ugensa.c 239180 2012-08-10 15:29:41Z hselasky $ */
+/* $FreeBSD: head/sys/dev/usb/serial/ugensa.c 239299 2012-08-15 15:42:57Z hselasky $ */
 /*	$NetBSD: ugensa.c,v 1.9.2.1 2007/03/24 14:55:50 yamt Exp $	*/
 
 /*
@@ -94,7 +94,7 @@
 static device_probe_t ugensa_probe;
 static device_attach_t ugensa_attach;
 static device_detach_t ugensa_detach;
-static device_free_softc_t ugensa_free_softc;
+static void ugensa_free_softc(struct ugensa_softc *);
 
 static usb_callback_t ugensa_bulk_write_callback;
 static usb_callback_t ugensa_bulk_read_callback;
@@ -141,7 +141,6 @@
 	DEVMETHOD(device_probe, ugensa_probe),
 	DEVMETHOD(device_attach, ugensa_attach),
 	DEVMETHOD(device_detach, ugensa_detach),
-	DEVMETHOD(device_free_softc, ugensa_free_softc),
 	DEVMETHOD_END
 };
 
@@ -272,27 +271,28 @@
 		usbd_transfer_unsetup(sc->sc_sub[x].sc_xfer, UGENSA_N_TRANSFER);
 	}
 
+	device_claim_softc(dev);
+
+	ugensa_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(ugensa);
 
 static void
-ugensa_free_softc(device_t dev, void *arg)
+ugensa_free_softc(struct ugensa_softc *sc)
 {
-	struct ugensa_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 ugensa_free(struct ucom_softc *ucom)
 {
-	ugensa_free_softc(NULL, ucom->sc_parent);
+	ugensa_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uipaq.c
--- a/head/sys/dev/usb/serial/uipaq.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uipaq.c	Thu Aug 16 21:15:49 2012 +0300
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uipaq.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uipaq.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 #include <sys/stdint.h>
 #include <sys/stddef.h>
@@ -103,7 +103,7 @@
 static device_probe_t uipaq_probe;
 static device_attach_t uipaq_attach;
 static device_detach_t uipaq_detach;
-static device_free_softc_t uipaq_free_softc;
+static void uipaq_free_softc(struct uipaq_softc *);
 
 static usb_callback_t uipaq_write_callback;
 static usb_callback_t uipaq_read_callback;
@@ -1073,7 +1073,6 @@
 	DEVMETHOD(device_probe, uipaq_probe),
 	DEVMETHOD(device_attach, uipaq_attach),
 	DEVMETHOD(device_detach, uipaq_detach),
-	DEVMETHOD(device_free_softc, uipaq_free_softc),
 	DEVMETHOD_END
 };
 
@@ -1182,27 +1181,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UIPAQ_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uipaq_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uipaq);
 
 static void
-uipaq_free_softc(device_t dev, void *arg)
+uipaq_free_softc(struct uipaq_softc *sc)
 {
-	struct uipaq_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uipaq_free(struct ucom_softc *ucom)
 {
-	uipaq_free_softc(NULL, ucom->sc_parent);
+	uipaq_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/umcs.c
--- a/head/sys/dev/usb/serial/umcs.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/umcs.c	Thu Aug 16 21:15:49 2012 +0300
@@ -38,7 +38,7 @@
  *
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/umcs.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/umcs.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 #include <sys/stdint.h>
 #include <sys/stddef.h>
@@ -176,7 +176,7 @@
 static device_probe_t umcs7840_probe;
 static device_attach_t umcs7840_attach;
 static device_detach_t umcs7840_detach;
-static device_free_softc_t umcs7840_free_softc;
+static void umcs7840_free_softc(struct umcs7840_softc *);
 
 static usb_callback_t umcs7840_intr_callback;
 static usb_callback_t umcs7840_read_callback1;
@@ -265,7 +265,6 @@
 	DEVMETHOD(device_probe, umcs7840_probe),
 	DEVMETHOD(device_attach, umcs7840_attach),
 	DEVMETHOD(device_detach, umcs7840_detach),
-	DEVMETHOD(device_free_softc, umcs7840_free_softc),
 	DEVMETHOD_END
 };
 
@@ -413,27 +412,28 @@
 		usbd_transfer_unsetup(sc->sc_ports[sc->sc_ucom[subunit].sc_portno].sc_xfer, UMCS7840_N_TRANSFERS);
 	usbd_transfer_unsetup(&sc->sc_intr_xfer, 1);
 
+	device_claim_softc(dev);
+
+	umcs7840_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(umcs7840);
 
 static void
-umcs7840_free_softc(device_t dev, void *arg)
+umcs7840_free_softc(struct umcs7840_softc *sc)
 {
-	struct umcs7840_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 umcs7840_free(struct ucom_softc *ucom)
 {
-	umcs7840_free_softc(NULL, ucom->sc_parent);
+	umcs7840_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/umct.c
--- a/head/sys/dev/usb/serial/umct.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/umct.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/umct.c 239181 2012-08-10 17:42:14Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/umct.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2003 Scott Long
@@ -122,7 +122,7 @@
 static device_probe_t umct_probe;
 static device_attach_t umct_attach;
 static device_detach_t umct_detach;
-static device_free_softc_t umct_free_softc;
+static void umct_free_softc(struct umct_softc *);
 
 static usb_callback_t umct_intr_callback;
 static usb_callback_t umct_intr_callback_sub;
@@ -206,7 +206,6 @@
 	DEVMETHOD(device_probe, umct_probe),
 	DEVMETHOD(device_attach, umct_attach),
 	DEVMETHOD(device_detach, umct_detach),
-	DEVMETHOD(device_free_softc, umct_free_softc),
 	DEVMETHOD_END
 };
 
@@ -314,27 +313,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UMCT_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	umct_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(umct);
 
 static void
-umct_free_softc(device_t dev, void *arg)
+umct_free_softc(struct umct_softc *sc)
 {
-	struct umct_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 umct_free(struct ucom_softc *ucom)
 {
-	umct_free_softc(NULL, ucom->sc_parent);
+	umct_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/umodem.c
--- a/head/sys/dev/usb/serial/umodem.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/umodem.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,7 +1,7 @@
 /*	$NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/umodem.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/umodem.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2003, M. Warner Losh <imp at FreeBSD.org>.
@@ -178,7 +178,7 @@
 static device_probe_t umodem_probe;
 static device_attach_t umodem_attach;
 static device_detach_t umodem_detach;
-static device_free_softc_t umodem_free_softc;
+static void umodem_free_softc(struct umodem_softc *);
 
 static usb_callback_t umodem_intr_callback;
 static usb_callback_t umodem_write_callback;
@@ -259,7 +259,6 @@
 	DEVMETHOD(device_probe, umodem_probe),
 	DEVMETHOD(device_attach, umodem_attach),
 	DEVMETHOD(device_detach, umodem_detach),
-	DEVMETHOD(device_free_softc, umodem_free_softc),
 	DEVMETHOD_END
 };
 
@@ -881,27 +880,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UMODEM_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	umodem_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(umodem);
 
 static void
-umodem_free_softc(device_t dev, void *arg)
+umodem_free_softc(struct umodem_softc *sc)
 {
-	struct umodem_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 umodem_free(struct ucom_softc *ucom)
 {
-	umodem_free_softc(NULL, ucom->sc_parent);
+	umodem_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/umoscom.c
--- a/head/sys/dev/usb/serial/umoscom.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/umoscom.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/dev/usb/serial/umoscom.c 239180 2012-08-10 15:29:41Z hselasky $ */
+/* $FreeBSD: head/sys/dev/usb/serial/umoscom.c 239299 2012-08-15 15:42:57Z hselasky $ */
 /*	$OpenBSD: umoscom.c,v 1.2 2006/10/26 06:02:43 jsg Exp $	*/
 
 /*
@@ -189,7 +189,7 @@
 static device_probe_t umoscom_probe;
 static device_attach_t umoscom_attach;
 static device_detach_t umoscom_detach;
-static device_free_softc_t umoscom_free_softc;
+static void umoscom_free_softc(struct umoscom_softc *);
 
 static usb_callback_t umoscom_write_callback;
 static usb_callback_t umoscom_read_callback;
@@ -267,7 +267,6 @@
 	DEVMETHOD(device_probe, umoscom_probe),
 	DEVMETHOD(device_attach, umoscom_attach),
 	DEVMETHOD(device_detach, umoscom_detach),
-	DEVMETHOD(device_free_softc, umoscom_free_softc),
 	DEVMETHOD_END
 };
 
@@ -360,27 +359,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UMOSCOM_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	umoscom_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(umoscom);
 
 static void
-umoscom_free_softc(device_t dev, void *arg)
+umoscom_free_softc(struct umoscom_softc *sc)
 {
-	struct umoscom_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 umoscom_free(struct ucom_softc *ucom)
 {
-	umoscom_free_softc(NULL, ucom->sc_parent);
+	umoscom_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uplcom.c
--- a/head/sys/dev/usb/serial/uplcom.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uplcom.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,7 +1,7 @@
 /*	$NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uplcom.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uplcom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama at jp.FreeBSD.org>.
@@ -193,7 +193,7 @@
 static device_probe_t uplcom_probe;
 static device_attach_t uplcom_attach;
 static device_detach_t uplcom_detach;
-static device_free_softc_t uplcom_free_softc;
+static void uplcom_free_softc(struct uplcom_softc *);
 
 static usb_callback_t uplcom_intr_callback;
 static usb_callback_t uplcom_write_callback;
@@ -318,7 +318,6 @@
 	DEVMETHOD(device_probe, uplcom_probe),
 	DEVMETHOD(device_attach, uplcom_attach),
 	DEVMETHOD(device_detach, uplcom_detach),
-	DEVMETHOD(device_free_softc, uplcom_free_softc),
 	DEVMETHOD_END
 };
 
@@ -471,27 +470,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UPLCOM_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uplcom_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uplcom);
 
 static void
-uplcom_free_softc(device_t dev, void *arg)
+uplcom_free_softc(struct uplcom_softc *sc)
 {
-	struct uplcom_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uplcom_free(struct ucom_softc *ucom)
 {
-	uplcom_free_softc(NULL, ucom->sc_parent);
+	uplcom_free_softc(ucom->sc_parent);
 }
 
 static usb_error_t
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/usb_serial.c
--- a/head/sys/dev/usb/serial/usb_serial.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/usb_serial.c	Thu Aug 16 21:15:49 2012 +0300
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 239179 2012-08-10 15:21:12Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -284,11 +284,14 @@
 		return (error);
 	}
 	ssc->sc_subunits = subunits;
+	ssc->sc_flag = UCOM_FLAG_ATTACHED |
+	    UCOM_FLAG_FREE_UNIT;
 
-	if (callback->ucom_free == NULL) {
-		ssc->sc_wait_refs = 1;
-		ucom_ref(ssc);
-	}
+	if (callback->ucom_free == NULL)
+		ssc->sc_flag |= UCOM_FLAG_WAIT_REFS;
+
+	/* increment reference count */
+	ucom_ref(ssc);
 
 	for (subunit = 0; subunit < ssc->sc_subunits; subunit++) {
 		sc[subunit].sc_subunit = subunit;
@@ -316,15 +319,15 @@
 }
 
 /*
- * NOTE: the following function will do nothing if
- * the structure pointed to by "ssc" and "sc" is zero.
+ * The following function will do nothing if the structure pointed to
+ * by "ssc" and "sc" is zero or has already been detached.
  */
 void
 ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc)
 {
 	int subunit;
 
-	if (ssc->sc_subunits == 0)
+	if (!(ssc->sc_flag & UCOM_FLAG_ATTACHED))
 		return;		/* not initialized */
 
 	if (ssc->sc_sysctl_ttyname != NULL) {
@@ -350,17 +353,20 @@
 	}
 	usb_proc_free(&ssc->sc_tq);
 
-	if (ssc->sc_wait_refs != 0) {
-		ucom_unref(ssc);
+	ucom_unref(ssc);
+
+	if (ssc->sc_flag & UCOM_FLAG_WAIT_REFS)
 		ucom_drain(ssc);
-	}
+
+	/* make sure we don't detach twice */
+	ssc->sc_flag &= ~UCOM_FLAG_ATTACHED;
 }
 
 void
 ucom_drain(struct ucom_super_softc *ssc)
 {
 	mtx_lock(&ucom_mtx);
-	while (ssc->sc_refs >= 2) {
+	while (ssc->sc_refs > 0) {
 		printf("ucom: Waiting for a TTY device to close.\n");
 		usb_pause_mtx(&ucom_mtx, hz);
 	}
@@ -1506,6 +1512,24 @@
 }
 
 /*------------------------------------------------------------------------*
+ *	ucom_free_unit
+ *
+ * This function will free the super UCOM's allocated unit
+ * number. This function can be called on a zero-initialized
+ * structure. This function can be called multiple times.
+ *------------------------------------------------------------------------*/
+static void
+ucom_free_unit(struct ucom_super_softc *ssc)
+{
+	if (!(ssc->sc_flag & UCOM_FLAG_FREE_UNIT))
+		return;
+
+	ucom_unit_free(ssc->sc_unit);
+
+	ssc->sc_flag &= ~UCOM_FLAG_FREE_UNIT;
+}
+
+/*------------------------------------------------------------------------*
  *	ucom_unref
  *
  * This function will decrement the super UCOM reference count.
@@ -1518,21 +1542,15 @@
 ucom_unref(struct ucom_super_softc *ssc)
 {
 	int retval;
-	int free_unit;
 
 	mtx_lock(&ucom_mtx);
 	retval = (ssc->sc_refs < 2);
-	free_unit = (ssc->sc_refs == 1);
 	ssc->sc_refs--;
 	mtx_unlock(&ucom_mtx);
 
-	/*
-	 * This function might be called when the "ssc" is only zero
-	 * initialized and in that case the unit number should not be
-	 * freed.
-	 */
-	if (free_unit)
-		ucom_unit_free(ssc->sc_unit);
+	if (retval)
+		ucom_free_unit(ssc);
+
 	return (retval);
 }
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/usb_serial.h
--- a/head/sys/dev/usb/serial/usb_serial.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/usb_serial.h	Thu Aug 16 21:15:49 2012 +0300
@@ -1,5 +1,5 @@
 /*	$NetBSD: ucomvar.h,v 1.9 2001/01/23 21:56:17 augustss Exp $	*/
-/*	$FreeBSD: head/sys/dev/usb/serial/usb_serial.h 239179 2012-08-10 15:21:12Z hselasky $	*/
+/*	$FreeBSD: head/sys/dev/usb/serial/usb_serial.h 239299 2012-08-15 15:42:57Z hselasky $	*/
 
 /*-
  * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama at jp.FreeBSD.org>.
@@ -137,7 +137,7 @@
 	int sc_unit;
 	int sc_subunits;
 	int sc_refs;
-	int sc_wait_refs;
+	int sc_flag;	/* see UCOM_FLAG_XXX */
 	struct sysctl_oid *sc_sysctl_ttyname;
 	struct sysctl_oid *sc_sysctl_ttyports;
 	char sc_ttyname[16];
@@ -178,6 +178,8 @@
 #define	UCOM_FLAG_LL_READY	0x20	/* set if low layer is ready */
 #define	UCOM_FLAG_HL_READY	0x40	/* set if high layer is ready */
 #define	UCOM_FLAG_CONSOLE	0x80	/* set if device is a console */
+#define	UCOM_FLAG_WAIT_REFS   0x0100	/* set if we must wait for refs */
+#define	UCOM_FLAG_FREE_UNIT   0x0200	/* set if we must free the unit */
 	uint8_t	sc_lsr;
 	uint8_t	sc_msr;
 	uint8_t	sc_mcr;
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uslcom.c
--- a/head/sys/dev/usb/serial/uslcom.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uslcom.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,7 +1,7 @@
 /*	$OpenBSD: uslcom.c,v 1.17 2007/11/24 10:52:12 jsg Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uslcom.c 239260 2012-08-14 22:21:46Z gavin $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uslcom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*
  * Copyright (c) 2006 Jonathan Gray <jsg at openbsd.org>
@@ -146,7 +146,7 @@
 static device_probe_t uslcom_probe;
 static device_attach_t uslcom_attach;
 static device_detach_t uslcom_detach;
-static device_free_softc_t uslcom_free_softc;
+static void uslcom_free_softc(struct uslcom_softc *);
 
 static usb_callback_t uslcom_write_callback;
 static usb_callback_t uslcom_read_callback;
@@ -331,7 +331,6 @@
 	DEVMETHOD(device_probe, uslcom_probe),
 	DEVMETHOD(device_attach, uslcom_attach),
 	DEVMETHOD(device_detach, uslcom_detach),
-	DEVMETHOD(device_free_softc, uslcom_free_softc),
 	DEVMETHOD_END
 };
 
@@ -435,27 +434,28 @@
 
 	usb_callout_drain(&sc->sc_watchdog);
 
+	device_claim_softc(dev);
+
+	uslcom_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uslcom);
 
 static void
-uslcom_free_softc(device_t dev, void *arg)
+uslcom_free_softc(struct uslcom_softc *sc)
 {
-	struct uslcom_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uslcom_free(struct ucom_softc *ucom)
 {
-	uslcom_free_softc(NULL, ucom->sc_parent);
+	uslcom_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uvisor.c
--- a/head/sys/dev/usb/serial/uvisor.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uvisor.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,5 +1,5 @@
 /*	$NetBSD: uvisor.c,v 1.9 2001/01/23 14:04:14 augustss Exp $	*/
-/*      $FreeBSD: head/sys/dev/usb/serial/uvisor.c 239180 2012-08-10 15:29:41Z hselasky $ */
+/*      $FreeBSD: head/sys/dev/usb/serial/uvisor.c 239299 2012-08-15 15:42:57Z hselasky $ */
 
 /* Also already merged from NetBSD:
  *	$NetBSD: uvisor.c,v 1.12 2001/11/13 06:24:57 lukem Exp $
@@ -189,7 +189,7 @@
 static device_probe_t uvisor_probe;
 static device_attach_t uvisor_attach;
 static device_detach_t uvisor_detach;
-static device_free_softc_t uvisor_free_softc;
+static void uvisor_free_softc(struct uvisor_softc *);
 
 static usb_callback_t uvisor_write_callback;
 static usb_callback_t uvisor_read_callback;
@@ -240,7 +240,6 @@
 	DEVMETHOD(device_probe, uvisor_probe),
 	DEVMETHOD(device_attach, uvisor_attach),
 	DEVMETHOD(device_detach, uvisor_detach),
-	DEVMETHOD(device_free_softc, uvisor_free_softc),
 	DEVMETHOD_END
 };
 
@@ -371,27 +370,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UVISOR_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uvisor_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uvisor);
 
 static void
-uvisor_free_softc(device_t dev, void *arg)
+uvisor_free_softc(struct uvisor_softc *sc)
 {
-	struct uvisor_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uvisor_free(struct ucom_softc *ucom)
 {
-	uvisor_free_softc(NULL, ucom->sc_parent);
+	uvisor_free_softc(ucom->sc_parent);
 }
 
 static usb_error_t
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/serial/uvscom.c
--- a/head/sys/dev/usb/serial/uvscom.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/serial/uvscom.c	Thu Aug 16 21:15:49 2012 +0300
@@ -1,7 +1,7 @@
 /*	$NetBSD: usb/uvscom.c,v 1.1 2002/03/19 15:08:42 augustss Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uvscom.c 239180 2012-08-10 15:29:41Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uvscom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama at jp.FreeBSD.org>.
@@ -163,7 +163,7 @@
 static device_probe_t uvscom_probe;
 static device_attach_t uvscom_attach;
 static device_detach_t uvscom_detach;
-static device_free_softc_t uvscom_free_softc;
+static void uvscom_free_softc(struct uvscom_softc *);
 
 static usb_callback_t uvscom_write_callback;
 static usb_callback_t uvscom_read_callback;
@@ -253,7 +253,6 @@
 	DEVMETHOD(device_probe, uvscom_probe),
 	DEVMETHOD(device_attach, uvscom_attach),
 	DEVMETHOD(device_detach, uvscom_detach),
-	DEVMETHOD(device_free_softc, uvscom_free_softc),
 	DEVMETHOD_END
 };
 
@@ -354,27 +353,28 @@
 	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
 	usbd_transfer_unsetup(sc->sc_xfer, UVSCOM_N_TRANSFER);
 
+	device_claim_softc(dev);
+
+	uvscom_free_softc(sc);
+
 	return (0);
 }
 
 UCOM_UNLOAD_DRAIN(uvscom);
 
 static void
-uvscom_free_softc(device_t dev, void *arg)
+uvscom_free_softc(struct uvscom_softc *sc)
 {
-	struct uvscom_softc *sc = arg;
-
 	if (ucom_unref(&sc->sc_super_ucom)) {
-		if (mtx_initialized(&sc->sc_mtx))
-			mtx_destroy(&sc->sc_mtx);
-		device_free_softc(dev, sc);
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
 	}
 }
 
 static void
 uvscom_free(struct ucom_softc *ucom)
 {
-	uvscom_free_softc(NULL, ucom->sc_parent);
+	uvscom_free_softc(ucom->sc_parent);
 }
 
 static void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/dev/usb/usbdevs
--- a/head/sys/dev/usb/usbdevs	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/dev/usb/usbdevs	Thu Aug 16 21:15:49 2012 +0300
@@ -1,4 +1,4 @@
-$FreeBSD: head/sys/dev/usb/usbdevs 239275 2012-08-15 04:03:55Z gonzo $
+$FreeBSD: head/sys/dev/usb/usbdevs 239298 2012-08-15 15:35:20Z hselasky $
 /* $NetBSD: usbdevs,v 1.392 2004/12/29 08:38:44 imp Exp $ */
 
 /*-
@@ -687,6 +687,7 @@
 vendor BAYER		0x1a79	Bayer
 vendor WCH2		0x1a86	QinHeng Electronics
 vendor STELERA		0x1a8d	Stelera Wireless
+vendor CORSAIR		0x1b1c	Corsair
 vendor MATRIXORBITAL	0x1b3d	Matrix Orbital
 vendor OVISLINK		0x1b75	OvisLink
 vendor TML		0x1b91	The Mobility Lab
@@ -1374,6 +1375,9 @@
 product COREGA WLUSB_11_STICK	0x7613	WLAN USB Stick 11
 product COREGA FETHER_USB_TXC	0x9601	FEther USB-TXC
 
+/* Corsair products */
+product CORSAIR K60		0x0a60	Corsair Vengeance K60 keyboard
+
 /* Creative products */
 product CREATIVE NOMAD_II	0x1002	Nomad II MP3 player
 product CREATIVE NOMAD_IIMG	0x4004	Nomad II MG
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/fs/devfs/devfs_vnops.c
--- a/head/sys/fs/devfs/devfs_vnops.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/fs/devfs/devfs_vnops.c	Thu Aug 16 21:15:49 2012 +0300
@@ -31,7 +31,7 @@
  *	@(#)kernfs_vnops.c	8.15 (Berkeley) 5/21/95
  * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vnops.c 1.43
  *
- * $FreeBSD: head/sys/fs/devfs/devfs_vnops.c 238029 2012-07-02 21:01:03Z kib $
+ * $FreeBSD: head/sys/fs/devfs/devfs_vnops.c 239303 2012-08-15 16:19:39Z hselasky $
  */
 
 /*
@@ -1081,6 +1081,9 @@
 		error = dsw->d_fdopen(dev, ap->a_mode, td, fp);
 	else
 		error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td);
+	/* cleanup any cdevpriv upon error */
+	if (error != 0)
+		devfs_clear_cdevpriv();
 	td->td_fpop = fpop;
 
 	vn_lock(vp, vlocked | LK_RETRY);
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/ia64/ia64/sscdisk.c
--- a/head/sys/ia64/ia64/sscdisk.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/ia64/ia64/sscdisk.c	Thu Aug 16 21:15:49 2012 +0300
@@ -6,7 +6,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $FreeBSD: head/sys/ia64/ia64/sscdisk.c 227293 2011-11-07 06:44:47Z ed $
+ * $FreeBSD: head/sys/ia64/ia64/sscdisk.c 239331 2012-08-16 17:17:08Z jhb $
  *
  */
 
@@ -77,13 +77,15 @@
 static d_strategy_t sscstrategy;
 
 static LIST_HEAD(, ssc_s) ssc_softc_list = LIST_HEAD_INITIALIZER(ssc_softc_list);
+static struct mtx ssc_list_lock;
+MTX_SYSINIT(ssc_list, &ssc_list_lock, "ssc list", MTX_DEF);
 
 struct ssc_s {
 	int unit;
 	LIST_ENTRY(ssc_s) list;
 	struct bio_queue_head bio_queue;
 	struct disk *disk;
-	struct cdev *dev;
+	struct mtx lock;
 	int busy;
 	int fd;
 };
@@ -94,30 +96,27 @@
 sscstrategy(struct bio *bp)
 {
 	struct ssc_s *sc;
-	int s;
 	struct disk_req req;
 	struct disk_stat stat;
 	u_long len, va, off;
 
 	sc = bp->bio_disk->d_drv1;
 
-	s = splbio();
-
+	mtx_lock(&sc->lock);
 	bioq_disksort(&sc->bio_queue, bp);
 
 	if (sc->busy) {
-		splx(s);
+		mtx_unlock(&sc->lock);
 		return;
 	}
+	sc->busy++;
 
-	sc->busy++;
-	
-	while (1) {
+	for (;;) {
 		bp = bioq_takefirst(&sc->bio_queue);
-		splx(s);
 		if (!bp)
 			break;
 
+		mtx_unlock(&sc->lock);
 		va = (u_long) bp->bio_data;
 		len = bp->bio_bcount;
 		off = bp->bio_pblkno << DEV_BSHIFT;
@@ -140,10 +139,11 @@
 		}
 		bp->bio_resid = 0;
 		biodone(bp);
-		s = splbio();
+		mtx_lock(&sc->lock);
 	}
 
 	sc->busy = 0;
+	mtx_unlock(&sc->lock);
 	return;
 }
 
@@ -158,17 +158,24 @@
 	if (fd == -1)
 		return (NULL);
 
+	sc = malloc(sizeof(*sc), M_SSC, M_WAITOK | M_ZERO);
+
+	mtx_lock(&ssc_list_lock);
 	if (unit == -1)
 		unit = sscunits++;
 	/* Make sure this unit isn't already in action */
 	LIST_FOREACH(sc, &ssc_softc_list, list) {
-		if (sc->unit == unit)
+		if (sc->unit == unit) {
+			mtx_unlock(&ssc_list_lock);
+			free(sc, M_SSC);
 			return (NULL);
+		}
 	}
-	sc = malloc(sizeof(*sc), M_SSC, M_WAITOK | M_ZERO);
 	LIST_INSERT_HEAD(&ssc_softc_list, sc, list);
 	sc->unit = unit;
+	mtx_unlock(&ssc_list_lock);
 	bioq_init(&sc->bio_queue);
+	mtx_init(&sc->lock, "ssc", NULL, MTX_DEF);
 
 	sc->disk = disk_alloc();
 	sc->disk->d_drv1 = sc;
@@ -180,7 +187,6 @@
 	sc->disk->d_sectorsize = DEV_BSIZE;
 	sc->disk->d_strategy = sscstrategy;
 	sc->disk->d_unit = sc->unit;
-	sc->disk->d_flags = DISKFLAG_NEEDSGIANT;
 	disk_create(sc->disk, DISK_VERSION);
 	sc->fd = fd;
 	if (sc->unit == 0) 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/device_if.m
--- a/head/sys/kern/device_if.m	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/device_if.m	Thu Aug 16 21:15:49 2012 +0300
@@ -23,7 +23,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD: head/sys/kern/device_if.m 239178 2012-08-10 15:02:49Z hselasky $
+# $FreeBSD: head/sys/kern/device_if.m 239299 2012-08-15 15:42:57Z hselasky $
 #
 
 #include <sys/bus.h>
@@ -316,14 +316,3 @@
 METHOD int quiesce {
 	device_t dev;
 } DEFAULT null_quiesce;
-
-/**
- * @brief Free the device softc
- *
- * @param _dev		device pointer
- * @param _softc	pointer to softc
- */
-METHOD void free_softc {
-	device_t	_dev;
-	void		*_softc;
-} DEFAULT device_free_softc;
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/init_main.c
--- a/head/sys/kern/init_main.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/init_main.c	Thu Aug 16 21:15:49 2012 +0300
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/init_main.c 236404 2012-06-01 15:42:37Z jhb $");
+__FBSDID("$FreeBSD: head/sys/kern/init_main.c 239328 2012-08-16 13:01:56Z kib $");
 
 #include "opt_ddb.h"
 #include "opt_init_path.h"
@@ -476,6 +476,7 @@
 	knlist_init_mtx(&p->p_klist, &p->p_mtx);
 	STAILQ_INIT(&p->p_ktr);
 	p->p_nice = NZERO;
+	/* pid_max cannot be greater than PID_MAX */
 	td->td_tid = PID_MAX + 1;
 	LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash);
 	td->td_state = TDS_RUNNING;
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/kern_fork.c
--- a/head/sys/kern/kern_fork.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/kern_fork.c	Thu Aug 16 21:15:49 2012 +0300
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_fork.c 237276 2012-06-19 22:21:59Z pjd $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_fork.c 239301 2012-08-15 15:56:21Z kib $");
 
 #include "opt_kdtrace.h"
 #include "opt_ktrace.h"
@@ -209,8 +209,8 @@
 	pid = randompid;
 	error = sysctl_handle_int(oidp, &pid, 0, req);
 	if (error == 0 && req->newptr != NULL) {
-		if (pid < 0 || pid > PID_MAX - 100)	/* out of range */
-			pid = PID_MAX - 100;
+		if (pid < 0 || pid > pid_max - 100)	/* out of range */
+			pid = pid_max - 100;
 		else if (pid < 2)			/* NOP */
 			pid = 0;
 		else if (pid < 100)			/* Make it reasonable */
@@ -259,8 +259,8 @@
 	 * restart somewhat above 0, as the low-numbered procs
 	 * tend to include daemons that don't exit.
 	 */
-	if (trypid >= PID_MAX) {
-		trypid = trypid % PID_MAX;
+	if (trypid >= pid_max) {
+		trypid = trypid % pid_max;
 		if (trypid < 100)
 			trypid += 100;
 		pidchecked = 0;
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/kern_mib.c
--- a/head/sys/kern/kern_mib.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/kern_mib.c	Thu Aug 16 21:15:49 2012 +0300
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_mib.c 224159 2011-07-17 23:05:24Z rwatson $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_mib.c 239329 2012-08-16 13:04:21Z kib $");
 
 #include "opt_compat.h"
 #include "opt_posix.h"
@@ -499,6 +499,34 @@
 SYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD,
     0, sizeof(struct proc), "sizeof(struct proc)");
 
+static int
+sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS)
+{
+	int error, pm;
+
+	pm = pid_max;
+	error = sysctl_handle_int(oidp, &pm, 0, req);
+	if (error || !req->newptr)
+		return (error);
+	sx_xlock(&proctree_lock);
+	sx_xlock(&allproc_lock);
+
+	/*
+	 * Only permit the values less then PID_MAX.
+	 * As a safety measure, do not allow to limit the pid_max too much.
+	 */
+	if (pm < 300 || pm > PID_MAX)
+		error = EINVAL;
+	else
+		pid_max = pm;
+	sx_xunlock(&allproc_lock);
+	sx_xunlock(&proctree_lock);
+	return (error);
+}
+SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN |
+    CTLFLAG_MPSAFE, 0, 0, sysctl_kern_pid_max, "I",
+    "Maximum allowed pid");
+
 #include <sys/bio.h>
 #include <sys/buf.h>
 SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD,
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/kern_ntptime.c
--- a/head/sys/kern/kern_ntptime.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/kern_ntptime.c	Thu Aug 16 21:15:49 2012 +0300
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_ntptime.c 228856 2011-12-24 01:32:01Z lstewart $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_ntptime.c 239320 2012-08-16 02:35:44Z imp $");
 
 #include "opt_ntp.h"
 
@@ -832,8 +832,15 @@
 	 * discarded. otherwise, if so enabled, the time offset is
 	 * updated. We can tolerate a modest loss of data here without
 	 * much degrading time accuracy.
-	 */
-	if (u_nsec > (pps_jitter << PPS_POPCORN)) {
+	 *
+	 * The measurements being checked here were made with the system
+	 * timecounter, so the popcorn threshold is not allowed to fall below
+	 * the number of nanoseconds in two ticks of the timecounter.  For a
+	 * timecounter running faster than 1 GHz the lower bound is 2ns, just
+	 * to avoid a nonsensical threshold of zero.
+	*/
+	if (u_nsec > lmax(pps_jitter << PPS_POPCORN, 
+	    2 * (NANOSECOND / (long)qmin(NANOSECOND, tc_getfrequency())))) {
 		time_status |= STA_PPSJITTER;
 		pps_jitcnt++;
 	} else if (time_status & STA_PPSTIME) {
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/kern_proc.c
--- a/head/sys/kern/kern_proc.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/kern_proc.c	Thu Aug 16 21:15:49 2012 +0300
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_proc.c 239065 2012-08-05 14:11:42Z kib $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_proc.c 239295 2012-08-15 14:18:54Z obrien $");
 
 #include "opt_compat.h"
 #include "opt_ddb.h"
@@ -725,9 +725,7 @@
 	}
 }
 
-#include "opt_ddb.h"
 #ifdef DDB
-#include <ddb/ddb.h>
 
 DB_SHOW_COMMAND(pgrpdump, pgrpdump)
 {
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/kern_thread.c
--- a/head/sys/kern/kern_thread.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/kern_thread.c	Thu Aug 16 21:15:49 2012 +0300
@@ -31,7 +31,7 @@
 #include "opt_hwpmc_hooks.h"
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 236317 2012-05-30 16:06:38Z kib $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 239328 2012-08-16 13:01:56Z kib $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -269,7 +269,11 @@
 {
 
 	mtx_init(&tid_lock, "TID lock", NULL, MTX_DEF);
-	/* leave one number for thread0 */
+
+	/*
+	 * pid_max cannot be greater than PID_MAX.
+	 * leave one number for thread0.
+	 */
 	tid_unrhdr = new_unrhdr(PID_MAX + 2, INT_MAX, &tid_lock);
 
 	thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/subr_bus.c
--- a/head/sys/kern/subr_bus.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/subr_bus.c	Thu Aug 16 21:15:49 2012 +0300
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/subr_bus.c 239178 2012-08-10 15:02:49Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/kern/subr_bus.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 #include "opt_bus.h"
 
@@ -2505,8 +2505,8 @@
 void
 device_set_softc(device_t dev, void *softc)
 {
-	if (dev->softc != NULL && !(dev->flags & DF_EXTERNALSOFTC))
-		DEVICE_FREE_SOFTC(dev, dev->softc);
+	if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC))
+		free(dev->softc, M_BUS_SC);
 	dev->softc = softc;
 	if (dev->softc)
 		dev->flags |= DF_EXTERNALSOFTC;
@@ -2515,6 +2515,35 @@
 }
 
 /**
+ * @brief Free claimed softc
+ *
+ * Most drivers do not need to use this since the softc is freed
+ * automatically when the driver is detached.
+ */
+void
+device_free_softc(void *softc)
+{
+	free(softc, M_BUS_SC);
+}
+
+/**
+ * @brief Claim softc
+ *
+ * This function can be used to let the driver free the automatically
+ * allocated softc using "device_free_softc()". This function is
+ * useful when the driver is refcounting the softc and the softc
+ * cannot be freed when the "device_detach" method is called.
+ */
+void
+device_claim_softc(device_t dev)
+{
+	if (dev->softc)
+		dev->flags |= DF_EXTERNALSOFTC;
+	else
+		dev->flags &= ~DF_EXTERNALSOFTC;
+}
+
+/**
  * @brief Get the device's ivars field
  *
  * The ivars field is used by the parent device to store per-device
@@ -2703,8 +2732,8 @@
 	if (dev->driver == driver)
 		return (0);
 
-	if (dev->softc != NULL && !(dev->flags & DF_EXTERNALSOFTC)) {
-		DEVICE_FREE_SOFTC(dev, dev->softc);
+	if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) {
+		free(dev->softc, M_BUS_SC);
 		dev->softc = NULL;
 	}
 	device_set_desc(dev, NULL);
@@ -4899,13 +4928,3 @@
 		return (0);
 	return (bus_release_resource(dev, type, rman_get_rid(r), r));
 }
-
-/*
- * The "dev" argument passed to "device_free_softc()" is allowed to be
- * NULL, if the device freeing the soft is not available.
- */
-void
-device_free_softc(device_t dev, void *softc)
-{
-	free(softc, M_BUS_SC);
-}
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/subr_param.c
--- a/head/sys/kern/subr_param.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/subr_param.c	Thu Aug 16 21:15:49 2012 +0300
@@ -35,18 +35,19 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/kern/subr_param.c 239329 2012-08-16 13:04:21Z kib $");
 
 #include "opt_param.h"
 #include "opt_msgbuf.h"
 #include "opt_maxusers.h"
 
-#include <sys/limits.h>
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
+#include <sys/limits.h>
+#include <sys/msgbuf.h>
 #include <sys/sysctl.h>
-#include <sys/msgbuf.h>
+#include <sys/proc.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
@@ -92,6 +93,7 @@
 int	nbuf;
 int	ngroups_max;			/* max # groups per process */
 int	nswbuf;
+pid_t	pid_max = PID_MAX;
 long	maxswzone;			/* max swmeta KVA storage */
 long	maxbcache;			/* max buffer cache KVA storage */
 long	maxpipekva;			/* Limit on pipe KVA */
@@ -250,6 +252,16 @@
 	TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
 	if (ngroups_max < NGROUPS_MAX)
 		ngroups_max = NGROUPS_MAX;
+
+	/*
+	 * Only allow to lower the maximal pid.
+	 * Prevent setting up a non-bootable system if pid_max is too low.
+	 */
+	TUNABLE_INT_FETCH("kern.pid_max", &pid_max);
+	if (pid_max > PID_MAX)
+		pid_max = PID_MAX;
+	else if (pid_max < 300)
+		pid_max = 300;
 }
 
 /*
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/kern/vfs_cluster.c
--- a/head/sys/kern/vfs_cluster.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/kern/vfs_cluster.c	Thu Aug 16 21:15:49 2012 +0300
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/vfs_cluster.c 231204 2012-02-08 15:07:19Z kib $");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_cluster.c 239315 2012-08-15 22:12:01Z alc $");
 
 #include "opt_debug_cluster.h"
 
@@ -315,7 +315,7 @@
 	int i, inc, j, toff;
 
 	KASSERT(size == vp->v_mount->mnt_stat.f_iosize,
-	    ("cluster_rbuild: size %ld != filesize %jd\n",
+	    ("cluster_rbuild: size %ld != f_iosize %jd\n",
 	    size, (intmax_t)vp->v_mount->mnt_stat.f_iosize));
 
 	/*
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/mips/mips/pmap.c
--- a/head/sys/mips/mips/pmap.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/mips/mips/pmap.c	Thu Aug 16 21:15:49 2012 +0300
@@ -66,28 +66,35 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/mips/mips/pmap.c 239236 2012-08-13 17:38:38Z alc $");
+__FBSDID("$FreeBSD: head/sys/mips/mips/pmap.c 239321 2012-08-16 04:41:15Z alc $");
 
 #include "opt_ddb.h"
 #include "opt_pmap.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/mman.h>
+#include <sys/msgbuf.h>
+#include <sys/mutex.h>
+#include <sys/pcpu.h>
 #include <sys/proc.h>
-#include <sys/msgbuf.h>
+#include <sys/rwlock.h>
+#include <sys/sched.h>
+#ifdef SMP
+#include <sys/smp.h>
+#else
+#include <sys/cpuset.h>
+#endif
+#include <sys/sysctl.h>
 #include <sys/vmmeter.h>
-#include <sys/mman.h>
-#include <sys/smp.h>
-#include <sys/sysctl.h>
+
 #ifdef DDB
 #include <ddb/ddb.h>
 #endif
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
-#include <vm/vm_phys.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_page.h>
 #include <vm/vm_map.h>
@@ -96,11 +103,6 @@
 #include <vm/vm_pageout.h>
 #include <vm/vm_pager.h>
 #include <vm/uma.h>
-#include <sys/pcpu.h>
-#include <sys/sched.h>
-#ifdef SMP
-#include <sys/smp.h>
-#endif
 
 #include <machine/cache.h>
 #include <machine/md_var.h>
@@ -108,10 +110,6 @@
 
 #undef PMAP_DEBUG
 
-#ifndef PMAP_SHPGPERPROC
-#define	PMAP_SHPGPERPROC 200
-#endif
-
 #if !defined(DIAGNOSTIC)
 #define	PMAP_INLINE __inline
 #else
@@ -158,6 +156,17 @@
 static void pmap_asid_alloc(pmap_t pmap);
 
 /*
+ * Isolate the global pv list lock from data and other locks to prevent false
+ * sharing within the cache.
+ */
+static struct {
+	struct rwlock	lock;
+	char		padding[CACHE_LINE_SIZE - sizeof(struct rwlock)];
+} pvh_global __aligned(CACHE_LINE_SIZE);
+
+#define	pvh_global_lock	pvh_global.lock
+
+/*
  * Data for the pv entry allocation mechanism
  */
 static TAILQ_HEAD(pch, pv_chunk) pv_chunks = TAILQ_HEAD_INITIALIZER(pv_chunks);
@@ -187,7 +196,7 @@
 static vm_page_t pmap_allocpte(pmap_t pmap, vm_offset_t va, int flags);
 static vm_page_t _pmap_allocpte(pmap_t pmap, unsigned ptepindex, int flags);
 static int pmap_unuse_pt(pmap_t, vm_offset_t, pd_entry_t);
-static pt_entry_t init_pte_prot(vm_offset_t va, vm_page_t m, vm_prot_t prot);
+static pt_entry_t init_pte_prot(vm_page_t m, vm_prot_t prot);
 
 #ifdef SMP
 static void pmap_invalidate_page_action(void *arg);
@@ -590,6 +599,11 @@
 	pmap_max_asid = VMNUM_PIDS;
 	mips_wr_entryhi(0);
 	mips_wr_pagemask(0);
+
+ 	/*
+	 * Initialize the global pv list lock.
+	 */
+	rw_init(&pvh_global_lock, "pmap pv global");
 }
 
 /*
@@ -1091,9 +1105,9 @@
 	if ((m = pmap_alloc_direct_page(ptepindex, VM_ALLOC_NORMAL)) == NULL) {
 		if (flags & M_WAITOK) {
 			PMAP_UNLOCK(pmap);
-			vm_page_unlock_queues();
+			rw_wunlock(&pvh_global_lock);
 			pmap_grow_direct_page_cache();
-			vm_page_lock_queues();
+			rw_wlock(&pvh_global_lock);
 			PMAP_LOCK(pmap);
 		}
 
@@ -1187,19 +1201,8 @@
 
 
 /***************************************************
-* Pmap allocation/deallocation routines.
+ * Pmap allocation/deallocation routines.
  ***************************************************/
-/*
- *  Revision 1.397
- *  - Merged pmap_release and pmap_release_free_page.  When pmap_release is
- *    called only the page directory page(s) can be left in the pmap pte
- *    object, since all page table pages will have been freed by
- *    pmap_remove_pages and pmap_remove.  In addition, there can only be one
- *    reference to the pmap and the page directory is wired, so the page(s)
- *    can never be busy.  So all there is to do is clear the magic mappings
- *    from the page directory and free the page(s).
- */
-
 
 /*
  * Release any resources held by the given physical map.
@@ -1493,7 +1496,7 @@
 	struct pv_chunk *pc;
 	int bit, field, idx;
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
 	PV_STAT(pv_entry_frees++);
 	PV_STAT(pv_entry_spare++);
@@ -1548,7 +1551,7 @@
 	vm_page_t m;
 	int bit, field, idx;
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
 	PV_STAT(pv_entry_allocs++);
 	pv_entry_count++;
@@ -1616,7 +1619,7 @@
 {
 	pv_entry_t pv;
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	TAILQ_FOREACH(pv, &pvh->pv_list, pv_list) {
 		if (pmap == PV_PMAP(pv) && va == pv->pv_va) {
 			TAILQ_REMOVE(&pvh->pv_list, pv, pv_list);
@@ -1642,7 +1645,7 @@
 pmap_remove_entry(pmap_t pmap, vm_page_t m, vm_offset_t va)
 {
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	pmap_pvh_free(&m->md, pmap, va);
 	if (TAILQ_EMPTY(&m->md.pv_list))
 		vm_page_aflag_clear(m, PGA_WRITEABLE);
@@ -1657,8 +1660,8 @@
 {
 	pv_entry_t pv;
 
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
 	if ((pv = get_pv_entry(pmap, TRUE)) != NULL) {
 		pv->pv_va = va;
 		TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list);
@@ -1678,7 +1681,7 @@
 	vm_page_t m;
 	vm_paddr_t pa;
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
 
 	oldpte = *ptq;
@@ -1719,7 +1722,7 @@
 	pd_entry_t *pde;
 	pt_entry_t *ptq;
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
 	pde = pmap_pde(pmap, va);
 	if (pde == NULL || *pde == 0)
@@ -1763,7 +1766,7 @@
 	if (pmap->pm_stats.resident_count == 0)
 		return;
 
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	PMAP_LOCK(pmap);
 
 	/*
@@ -1799,7 +1802,7 @@
 		}
 	}
 out:
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	PMAP_UNLOCK(pmap);
 }
 
@@ -1826,7 +1829,7 @@
 
 	KASSERT((m->oflags & VPO_UNMANAGED) == 0,
 	    ("pmap_remove_all: page %p is not managed", m));
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 
 	if (m->md.pv_flags & PV_TABLE_REF)
 		vm_page_aflag_set(m, PGA_REFERENCED);
@@ -1876,7 +1879,7 @@
 
 	vm_page_aflag_clear(m, PGA_WRITEABLE);
 	m->md.pv_flags &= ~(PV_TABLE_REF | PV_TABLE_MOD);
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 }
 
 /*
@@ -1897,7 +1900,7 @@
 	if (prot & VM_PROT_WRITE)
 		return;
 
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	PMAP_LOCK(pmap);
 	for (; sva < eva; sva = va_next) {
 		pt_entry_t pbits;
@@ -1945,7 +1948,7 @@
 			}
 		}
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	PMAP_UNLOCK(pmap);
 }
 
@@ -1970,7 +1973,7 @@
 	pt_entry_t origpte, newpte;
 	pv_entry_t pv;
 	vm_page_t mpte, om;
-	pt_entry_t rw = 0;
+	pt_entry_t rw;
 
 	va &= ~PAGE_MASK;
  	KASSERT(va <= VM_MAX_KERNEL_ADDRESS, ("pmap_enter: toobig"));
@@ -1979,7 +1982,7 @@
 
 	mpte = NULL;
 
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	PMAP_LOCK(pmap);
 
 	/*
@@ -2081,7 +2084,7 @@
 validate:
 	if ((access & VM_PROT_WRITE) != 0)
 		m->md.pv_flags |= PV_TABLE_MOD | PV_TABLE_REF;
-	rw = init_pte_prot(va, m, prot);
+	rw = init_pte_prot(m, prot);
 
 #ifdef PMAP_DEBUG
 	printf("pmap_enter:  va: %p -> pa: %p\n", (void *)va, (void *)pa);
@@ -2141,7 +2144,7 @@
 		mips_icache_sync_range(va, PAGE_SIZE);
 		mips_dcache_wbinv_range(va, PAGE_SIZE);
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	PMAP_UNLOCK(pmap);
 }
 
@@ -2158,10 +2161,10 @@
 pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot)
 {
 
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	PMAP_LOCK(pmap);
 	(void)pmap_enter_quick_locked(pmap, va, m, prot, NULL);
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	PMAP_UNLOCK(pmap);
 }
 
@@ -2175,7 +2178,7 @@
 	KASSERT(va < kmi.clean_sva || va >= kmi.clean_eva ||
 	    (m->oflags & VPO_UNMANAGED) != 0,
 	    ("pmap_enter_quick_locked: managed mapping within the clean submap"));
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	PMAP_LOCK_ASSERT(pmap, MA_OWNED);
 
 	/*
@@ -2347,11 +2350,6 @@
 }
 
 /*
- * Moved the code to Machine Independent
- *	 vm_map_pmap_enter()
- */
-
-/*
  * Maps a sequence of resident pages belonging to the same object.
  * The sequence begins with the given page m_start.  This page is
  * mapped at the given virtual address start.  Each subsequent page is
@@ -2374,14 +2372,14 @@
 	psize = atop(end - start);
 	mpte = NULL;
 	m = m_start;
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	PMAP_LOCK(pmap);
 	while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) {
 		mpte = pmap_enter_quick_locked(pmap, start + ptoa(diff), m,
 		    prot, mpte);
 		m = TAILQ_NEXT(m, listq);
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
  	PMAP_UNLOCK(pmap);
 }
 
@@ -2564,7 +2562,7 @@
 	KASSERT((m->oflags & VPO_UNMANAGED) == 0,
 	    ("pmap_page_exists_quick: page %p is not managed", m));
 	rv = FALSE;
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
 		if (PV_PMAP(pv) == pmap) {
 			rv = TRUE;
@@ -2574,7 +2572,7 @@
 		if (loops >= 16)
 			break;
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	return (rv);
 }
 
@@ -2601,7 +2599,7 @@
 		printf("warning: pmap_remove_pages called with non-current pmap\n");
 		return;
 	}
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	PMAP_LOCK(pmap);
 	TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) {
 		allfree = 1;
@@ -2661,7 +2659,7 @@
 	}
 	pmap_invalidate_all(pmap);
 	PMAP_UNLOCK(pmap);
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 }
 
 /*
@@ -2680,7 +2678,7 @@
 	if (m->oflags & VPO_UNMANAGED)
 		return (rv);
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
 		pmap = PV_PMAP(pv);
 		PMAP_LOCK(pmap);
@@ -2706,7 +2704,7 @@
 	if (m->oflags & VPO_UNMANAGED)
 		return;
 
-	mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+	rw_assert(&pvh_global_lock, RA_WLOCKED);
 	/*
 	 * Loop over all current mappings setting/clearing as appropos If
 	 * setting RO do we need to clear the VAC?
@@ -2755,7 +2753,7 @@
 	count = 0;
 	if ((m->oflags & VPO_UNMANAGED) != 0)
 		return (count);
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
 		pmap = PV_PMAP(pv);
 		PMAP_LOCK(pmap);
@@ -2764,7 +2762,7 @@
 			count++;
 		PMAP_UNLOCK(pmap);
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	return (count);
 }
 
@@ -2790,7 +2788,7 @@
 	if ((m->oflags & VPO_BUSY) == 0 &&
 	    (m->aflags & PGA_WRITEABLE) == 0)
 		return;
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
 		pmap = PV_PMAP(pv);
 		PMAP_LOCK(pmap);
@@ -2811,7 +2809,7 @@
 		PMAP_UNLOCK(pmap);
 	}
 	vm_page_aflag_clear(m, PGA_WRITEABLE);
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 }
 
 /*
@@ -2826,9 +2824,9 @@
 	KASSERT((m->oflags & VPO_UNMANAGED) == 0,
 	    ("pmap_ts_referenced: page %p is not managed", m));
 	if (m->md.pv_flags & PV_TABLE_REF) {
-		vm_page_lock_queues();
+		rw_wlock(&pvh_global_lock);
 		m->md.pv_flags &= ~PV_TABLE_REF;
-		vm_page_unlock_queues();
+		rw_wunlock(&pvh_global_lock);
 		return (1);
 	}
 	return (0);
@@ -2857,12 +2855,12 @@
 	if ((m->oflags & VPO_BUSY) == 0 &&
 	    (m->aflags & PGA_WRITEABLE) == 0)
 		return (FALSE);
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	if (m->md.pv_flags & PV_TABLE_MOD)
 		rv = TRUE;
 	else
 		rv = pmap_testbit(m, PTE_D);
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 	return (rv);
 }
 
@@ -2912,12 +2910,12 @@
 	 */
 	if ((m->aflags & PGA_WRITEABLE) == 0)
 		return;
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	if (m->md.pv_flags & PV_TABLE_MOD) {
 		pmap_changebit(m, PTE_D, FALSE);
 		m->md.pv_flags &= ~PV_TABLE_MOD;
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 }
 
 /*
@@ -2946,11 +2944,11 @@
 
 	KASSERT((m->oflags & VPO_UNMANAGED) == 0,
 	    ("pmap_clear_reference: page %p is not managed", m));
-	vm_page_lock_queues();
+	rw_wlock(&pvh_global_lock);
 	if (m->md.pv_flags & PV_TABLE_REF) {
 		m->md.pv_flags &= ~PV_TABLE_REF;
 	}
-	vm_page_unlock_queues();
+	rw_wunlock(&pvh_global_lock);
 }
 
 /*
@@ -3299,21 +3297,21 @@
 }
 
 static pt_entry_t
-init_pte_prot(vm_offset_t va, vm_page_t m, vm_prot_t prot)
+init_pte_prot(vm_page_t m, vm_prot_t prot)
 {
 	pt_entry_t rw;
 
 	if (!(prot & VM_PROT_WRITE))
-		rw =  PTE_V | PTE_RO;
+		rw = PTE_V | PTE_RO;
 	else if ((m->oflags & VPO_UNMANAGED) == 0) {
 		if ((m->md.pv_flags & PV_TABLE_MOD) != 0)
-			rw =  PTE_V | PTE_D;
+			rw = PTE_V | PTE_D;
 		else
 			rw = PTE_V;
 		vm_page_aflag_set(m, PGA_WRITEABLE);
 	} else
 		/* Needn't emulate a modified bit for unmanaged pages. */
-		rw =  PTE_V | PTE_D;
+		rw = PTE_V | PTE_D;
 	return (rw);
 }
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/net80211/ieee80211_node.c
--- a/head/sys/net80211/ieee80211_node.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/net80211/ieee80211_node.c	Thu Aug 16 21:15:49 2012 +0300
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 233452 2012-03-25 03:11:57Z adrian $");
+__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 239319 2012-08-16 00:53:23Z adrian $");
 
 #include "opt_wlan.h"
 
@@ -2156,30 +2156,123 @@
 		ieee80211_node_timeout, ic);
 }
 
+/*
+ * Iterate over the node table and return an array of ref'ed nodes.
+ *
+ * This is separated out from calling the actual node function so that
+ * no LORs will occur.
+ *
+ * If there are too many nodes (ie, the number of nodes doesn't fit
+ * within 'max_aid' entries) then the node references will be freed
+ * and an error will be returned.
+ *
+ * The responsibility of allocating and freeing "ni_arr" is up to
+ * the caller.
+ */
+int
+ieee80211_iterate_nt(struct ieee80211_node_table *nt,
+    struct ieee80211_node **ni_arr, uint16_t max_aid)
+{
+	u_int gen;
+	int i, j, ret;
+	struct ieee80211_node *ni;
+
+	IEEE80211_NODE_ITERATE_LOCK(nt);
+	IEEE80211_NODE_LOCK(nt);
+
+	gen = ++nt->nt_scangen;
+	i = ret = 0;
+
+	/*
+	 * We simply assume here that since the node
+	 * scan generation doesn't change (as
+	 * we are holding both the node table and
+	 * node table iteration locks), we can simply
+	 * assign it to the node here.
+	 */
+	TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
+		if (i >= max_aid) {
+			ret = E2BIG;
+			if_printf(nt->nt_ic->ic_ifp,
+			    "Node array overflow: max=%u", max_aid);
+			break;
+		}
+		ni_arr[i] = ieee80211_ref_node(ni);
+		ni_arr[i]->ni_scangen = gen;
+		i++;
+	}
+
+	/*
+	 * It's safe to unlock here.
+	 *
+	 * If we're successful, the list is returned.
+	 * If we're unsuccessful, the list is ignored
+	 * and we remove our references.
+	 *
+	 * This avoids any potential LOR with
+	 * ieee80211_free_node().
+	 */
+	IEEE80211_NODE_UNLOCK(nt);
+	IEEE80211_NODE_ITERATE_UNLOCK(nt);
+
+	/*
+	 * If ret is non-zero, we hit some kind of error.
+	 * Rather than walking some nodes, we'll walk none
+	 * of them.
+	 */
+	if (ret) {
+		for (j = 0; j < i; j++) {
+			/* ieee80211_free_node() locks by itself */
+			ieee80211_free_node(ni_arr[j]);
+		}
+	}
+
+	return (ret);
+}
+
+/*
+ * Just a wrapper, so we don't have to change every ieee80211_iterate_nodes()
+ * reference in the source.
+ *
+ * Note that this fetches 'max_aid' from the first VAP, rather than finding
+ * the largest max_aid from all VAPs.
+ */
 void
 ieee80211_iterate_nodes(struct ieee80211_node_table *nt,
 	ieee80211_iter_func *f, void *arg)
 {
-	struct ieee80211_node *ni;
-	u_int gen;
+	struct ieee80211_node **ni_arr;
+	size_t size;
+	int i;
+	uint16_t max_aid;
 
-	IEEE80211_NODE_ITERATE_LOCK(nt);
-	gen = ++nt->nt_scangen;
-restart:
-	IEEE80211_NODE_LOCK(nt);
-	TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
-		if (ni->ni_scangen != gen) {
-			ni->ni_scangen = gen;
-			(void) ieee80211_ref_node(ni);
-			IEEE80211_NODE_UNLOCK(nt);
-			(*f)(arg, ni);
-			ieee80211_free_node(ni);
-			goto restart;
-		}
+	max_aid = TAILQ_FIRST(&nt->nt_ic->ic_vaps)->iv_max_aid;
+	size = max_aid * sizeof(struct ieee80211_node *);
+	ni_arr = (struct ieee80211_node **) malloc(size, M_80211_NODE,
+	    M_NOWAIT | M_ZERO);
+	if (ni_arr == NULL)
+		return;
+
+	/*
+	 * If this fails, the node table won't have any
+	 * valid entries - ieee80211_iterate_nt() frees
+	 * the references to them.  So don't try walking
+	 * the table; just skip to the end and free the
+	 * temporary memory.
+	 */
+	if (ieee80211_iterate_nt(nt, ni_arr, max_aid) != 0)
+		goto done;
+
+	for (i = 0; i < max_aid; i++) {
+		if (ni_arr[i] == NULL)	/* end of the list */
+			break;
+		(*f)(arg, ni_arr[i]);
+		/* ieee80211_free_node() locks by itself */
+		ieee80211_free_node(ni_arr[i]);
 	}
-	IEEE80211_NODE_UNLOCK(nt);
 
-	IEEE80211_NODE_ITERATE_UNLOCK(nt);
+done:
+	free(ni_arr, M_80211_NODE);
 }
 
 void
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/net80211/ieee80211_node.h
--- a/head/sys/net80211/ieee80211_node.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/net80211/ieee80211_node.h	Thu Aug 16 21:15:49 2012 +0300
@@ -23,7 +23,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: head/sys/net80211/ieee80211_node.h 234324 2012-04-15 20:29:39Z adrian $
+ * $FreeBSD: head/sys/net80211/ieee80211_node.h 239312 2012-08-15 20:01:28Z adrian $
  */
 #ifndef _NET80211_IEEE80211_NODE_H_
 #define _NET80211_IEEE80211_NODE_H_
@@ -438,6 +438,8 @@
 void	ieee80211_node_timeout(void *arg);
 
 typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
+int	ieee80211_iterate_nt(struct ieee80211_node_table *,
+		struct ieee80211_node **, uint16_t);
 void	ieee80211_iterate_nodes(struct ieee80211_node_table *,
 		ieee80211_iter_func *, void *);
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/nfs/bootp_subr.c
--- a/head/sys/nfs/bootp_subr.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/nfs/bootp_subr.c	Thu Aug 16 21:15:49 2012 +0300
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/nfs/bootp_subr.c 231852 2012-02-17 02:39:58Z bz $");
+__FBSDID("$FreeBSD: head/sys/nfs/bootp_subr.c 239318 2012-08-16 00:51:50Z gonzo $");
 
 #include "opt_bootp.h"
 #include "opt_nfs.h"
@@ -82,6 +82,14 @@
 #define BOOTP_SETTLE_DELAY 3
 #endif
 
+/* 
+ * Wait 10 seconds for interface appearance
+ * USB ethernet adapters might reqquire some time to pop up
+ */
+#ifndef	BOOTP_IFACE_WAIT_TIMEOUT
+#define	BOOTP_IFACE_WAIT_TIMEOUT	10
+#endif
+
 /*
  * What is the longest we will wait before re-sending a request?
  * Note this is also the frequency of "RPC timeout" messages.
@@ -1515,6 +1523,8 @@
 #endif
 	struct nfsv3_diskless *nd;
 	struct thread *td;
+	int timeout = BOOTP_IFACE_WAIT_TIMEOUT * hz;
+	int delay = hz / 10;
 
 	nd = &nfsv3_diskless;
 	td = curthread;
@@ -1567,6 +1577,7 @@
 		allocifctx(gctx);
 #endif
 
+retry:
 	ifctx = STAILQ_FIRST(&gctx->interfaces);
 	IFNET_RLOCK();
 	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
@@ -1613,6 +1624,11 @@
 
 	if (STAILQ_EMPTY(&gctx->interfaces) ||
 	    STAILQ_FIRST(&gctx->interfaces)->ifp == NULL) {
+		if (timeout > 0) {
+			pause("bootpc", delay);
+			timeout -= delay;
+			goto retry;
+		}
 #ifdef BOOTP_WIRED_TO
 		panic("%s: Could not find interface specified "
 		      "by BOOTP_WIRED_TO: "
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/nlm/nlm_advlock.c
--- a/head/sys/nlm/nlm_advlock.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/nlm/nlm_advlock.c	Thu Aug 16 21:15:49 2012 +0300
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/nlm/nlm_advlock.c 239328 2012-08-16 13:01:56Z kib $");
 
 #include <sys/param.h>
 #include <sys/fcntl.h>
@@ -98,6 +98,7 @@
 	int i;
 
 	mtx_init(&nlm_svid_lock, "NLM svid lock", NULL, MTX_DEF);
+	/* pid_max cannot be greater than PID_MAX */
 	nlm_svid_allocator = new_unrhdr(PID_MAX + 2, INT_MAX, &nlm_svid_lock);
 	for (i = 0; i < NLM_SVID_HASH_SIZE; i++)
 		LIST_INIT(&nlm_file_svids[i]);
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/ofed/include/linux/linux_compat.c
--- a/head/sys/ofed/include/linux/linux_compat.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/ofed/include/linux/linux_compat.c	Thu Aug 16 21:15:49 2012 +0300
@@ -263,7 +263,6 @@
 	if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
 		return (error);
 	filp->f_flags = file->f_flag;
-	devfs_clear_cdevpriv();
 
 	return (0);
 }
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/sys/buf.h
--- a/head/sys/sys/buf.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/sys/buf.h	Thu Aug 16 21:15:49 2012 +0300
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)buf.h	8.9 (Berkeley) 3/30/95
- * $FreeBSD: head/sys/sys/buf.h 236487 2012-06-02 19:39:12Z kib $
+ * $FreeBSD: head/sys/sys/buf.h 239316 2012-08-15 22:25:57Z alc $
  */
 
 #ifndef _SYS_BUF_H_
@@ -466,10 +466,7 @@
 extern int	bdwriteskip;
 extern int	dirtybufferflushes;
 extern int	altbufferflushes;
-extern int      buf_maxio;              /* nominal maximum I/O for buffer */
 extern struct	buf *buf;		/* The buffer headers. */
-extern char	*buffers;		/* The buffer contents. */
-extern int	bufpages;		/* Number of memory pages in the buffer pool. */
 extern struct	buf *swbuf;		/* Swap I/O buffer headers. */
 extern int	nswbuf;			/* Number of swap I/O buffer headers. */
 extern int	cluster_pbuf_freecnt;	/* Number of pbufs for clusters */
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/sys/bus.h
--- a/head/sys/sys/bus.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/sys/bus.h	Thu Aug 16 21:15:49 2012 +0300
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sys/sys/bus.h 239178 2012-08-10 15:02:49Z hselasky $
+ * $FreeBSD: head/sys/sys/bus.h 239299 2012-08-15 15:42:57Z hselasky $
  */
 
 #ifndef _SYS_BUS_H_
@@ -488,11 +488,12 @@
 int	device_set_driver(device_t dev, driver_t *driver);
 void	device_set_flags(device_t dev, u_int32_t flags);
 void	device_set_softc(device_t dev, void *softc);
+void	device_free_softc(void *softc);
+void	device_claim_softc(device_t dev);
 int	device_set_unit(device_t dev, int unit);	/* XXX DONT USE XXX */
 int	device_shutdown(device_t dev);
 void	device_unbusy(device_t dev);
 void	device_verbose(device_t dev);
-void	device_free_softc(device_t dev, void *softc);
 
 /*
  * Access functions for devclass.
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/sys/proc.h
--- a/head/sys/sys/proc.h	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/sys/proc.h	Thu Aug 16 21:15:49 2012 +0300
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)proc.h	8.15 (Berkeley) 5/19/95
- * $FreeBSD: head/sys/sys/proc.h 237848 2012-06-30 17:01:28Z kib $
+ * $FreeBSD: head/sys/sys/proc.h 239301 2012-08-15 15:56:21Z kib $
  */
 
 #ifndef _SYS_PROC_H_
@@ -696,11 +696,12 @@
 #define	FIRST_THREAD_IN_PROC(p)	TAILQ_FIRST(&(p)->p_threads)
 
 /*
- * We use process IDs <= PID_MAX; PID_MAX + 1 must also fit in a pid_t,
- * as it is used to represent "no process group".
+ * We use process IDs <= pid_max <= PID_MAX; PID_MAX + 1 must also fit
+ * in a pid_t, as it is used to represent "no process group".
  */
 #define	PID_MAX		99999
 #define	NO_PID		100000
+extern pid_t pid_max;
 
 #define	SESS_LEADER(p)	((p)->p_session->s_leader == (p))
 
diff -r 02b2b55f6449 -r 00e5fe011396 head/sys/vm/swap_pager.c
--- a/head/sys/vm/swap_pager.c	Thu Aug 16 11:35:40 2012 +0300
+++ b/head/sys/vm/swap_pager.c	Thu Aug 16 21:15:49 2012 +0300
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 237168 2012-06-16 18:56:19Z alc $");
+__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 239327 2012-08-16 08:29:49Z des $");
 
 #include "opt_swap.h"
 #include "opt_vm.h"
@@ -1804,6 +1804,7 @@
 static void
 swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk)
 {
+	static volatile int exhausted;
 	struct swblock *swap;
 	struct swblock **pswap;
 	int idx;
@@ -1847,7 +1848,9 @@
 			mtx_unlock(&swhash_mtx);
 			VM_OBJECT_UNLOCK(object);
 			if (uma_zone_exhausted(swap_zone)) {
-				printf("swap zone exhausted, increase kern.maxswzone\n");
+				if (atomic_cmpset_rel_int(&exhausted, 0, 1))
+					printf("swap zone exhausted, "
+					    "increase kern.maxswzone\n");
 				vm_pageout_oom(VM_OOM_SWAPZ);
 				pause("swzonex", 10);
 			} else
@@ -1856,6 +1859,9 @@
 			goto retry;
 		}
 
+		if (atomic_cmpset_rel_int(&exhausted, 1, 0))
+			printf("swap zone ok\n");
+
 		swap->swb_hnext = NULL;
 		swap->swb_object = object;
 		swap->swb_index = pindex & ~(vm_pindex_t)SWAP_META_MASK;
@@ -2112,6 +2118,31 @@
 	return (error);
 }
 
+/*
+ * Check that the total amount of swap currently configured does not
+ * exceed half the theoretical maximum.  If it does, print a warning
+ * message and return -1; otherwise, return 0.
+ */
+static int
+swapon_check_swzone(unsigned long npages)
+{
+	unsigned long maxpages;
+
+	/* absolute maximum we can handle assuming 100% efficiency */
+	maxpages = uma_zone_get_max(swap_zone) * SWAP_META_PAGES;
+
+	/* recommend using no more than half that amount */
+	if (npages > maxpages / 2) {
+		printf("warning: total configured swap (%lu pages) "
+		    "exceeds maximum recommended amount (%lu pages).\n",
+		    npages, maxpages);
+		printf("warning: increase kern.maxswzone "
+		    "or reduce amount of swap.\n");
+		return (-1);
+	}
+	return (0);
+}
+
 static void
 swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, dev_t dev)
 {
@@ -2175,6 +2206,7 @@
 	nswapdev++;
 	swap_pager_avail += nblks;
 	swap_total += (vm_ooffset_t)nblks * PAGE_SIZE;
+	swapon_check_swzone(swap_total / PAGE_SIZE);
 	swp_sizecheck();
 	mtx_unlock(&sw_dev_mtx);
 }



More information about the Zrouter-src-freebsd mailing list