PERFORCE change 173891 for review
Alexander Motin
mav at FreeBSD.org
Fri Jan 29 09:15:27 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=173891
Change 173891 by mav at mav_mavbook on 2010/01/29 09:14:27
IFC
Affected files ...
.. //depot/projects/scottl-camlock/src/lib/libusb/libusb20.3#4 integrate
.. //depot/projects/scottl-camlock/src/lib/libusb/libusb20.c#6 integrate
.. //depot/projects/scottl-camlock/src/lib/libusb/libusb20.h#4 integrate
.. //depot/projects/scottl-camlock/src/lib/libusb/libusb20_int.h#4 integrate
.. //depot/projects/scottl-camlock/src/lib/libusb/libusb20_ugen20.c#6 integrate
.. //depot/projects/scottl-camlock/src/share/man/man4/Makefile#21 integrate
.. //depot/projects/scottl-camlock/src/share/man/man4/ahci.4#8 integrate
.. //depot/projects/scottl-camlock/src/share/man/man4/gpib.4#2 integrate
.. //depot/projects/scottl-camlock/src/share/man/man4/run.4#1 branch
.. //depot/projects/scottl-camlock/src/share/man/man9/locking.9#3 integrate
.. //depot/projects/scottl-camlock/src/share/misc/committers-src.dot#9 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#36 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#48 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#31 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#74 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam.c#16 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam.h#13 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_ccb.h#38 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#52 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#27 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_queue.h#9 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.c#14 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#146 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#23 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_internal.h#17 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_periph.h#14 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_sim.h#7 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.c#15 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#38 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#22 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#53 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_low.c#20 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#31 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_xpt.c#29 integrate
.. //depot/projects/scottl-camlock/src/sys/conf/NOTES#49 integrate
.. //depot/projects/scottl-camlock/src/sys/conf/files#63 integrate
.. //depot/projects/scottl-camlock/src/sys/contrib/dev/run/LICENSE#1 branch
.. //depot/projects/scottl-camlock/src/sys/contrib/dev/run/rt2870.fw.uu#1 branch
.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#99 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.h#34 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/asr/asr.c#17 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/ata/ata-all.c#49 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/ata/atapi-cam.c#23 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/ciss/ciss.c#26 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/hptiop/hptiop.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/hptrr/hptrr_osm_bsd.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/hptrr/os_bsd.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mly/mly.c#16 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_cam.h#8 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_raid.c#20 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/ppbus/vpo.c#13 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/siis/siis.c#37 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/trm/trm.c#16 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/twa/tw_osl_cam.c#12 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/controller/ehci.c#12 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/quirk/usb_quirk.c#10 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/storage/umass.c#18 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdevs#42 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/wlan/if_rum.c#10 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/wlan/if_run.c#1 branch
.. //depot/projects/scottl-camlock/src/sys/dev/usb/wlan/if_runreg.h#1 branch
.. //depot/projects/scottl-camlock/src/sys/dev/usb/wlan/if_runvar.h#1 branch
.. //depot/projects/scottl-camlock/src/sys/dev/usb/wlan/if_uath.c#9 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/wlan/if_zyd.c#11 integrate
.. //depot/projects/scottl-camlock/src/sys/fs/nfsclient/nfs.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/fs/nfsclient/nfs_clbio.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/fs/nfsclient/nfs_clnfsiod.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/fs/nfsclient/nfs_clsubs.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/fs/nfsclient/nfsmount.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/atheros/ar71xx_pci.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/asm_octeon.S#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_fau.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_fau.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_fpa.c#3 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_fpa.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_ipd.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_ipd.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_pip.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_pko.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_pko.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_rgmx.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/dev/rgmii/octeon_rgmx.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/driveid.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/obiovar.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/octeon_ebt3000_cf.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/octeon_ebt3000_cf.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/octeon_machdep.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/cavium/octeon_pcmap_regs.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/conf/ALCHEMY#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/mips/locore.S#4 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/mips/pmap.c#9 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/rmi/on_chip.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/rmi/pic.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/mips/rmi/xlr_machdep.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/modules/Makefile#43 integrate
.. //depot/projects/scottl-camlock/src/sys/modules/runfw/Makefile#1 branch
.. //depot/projects/scottl-camlock/src/sys/modules/usb/Makefile#14 integrate
.. //depot/projects/scottl-camlock/src/sys/modules/usb/run/Makefile#1 branch
Differences ...
==== //depot/projects/scottl-camlock/src/lib/libusb/libusb20.3#4 (text+ko) ====
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libusb/libusb20.3,v 1.5 2009/11/20 08:57:25 thompsa Exp $
+.\" $FreeBSD: src/lib/libusb/libusb20.3,v 1.6 2010/01/29 02:44:06 thompsa Exp $
.\"
.Dd November 18, 2009
.Dt LIBUSB20 3
@@ -143,6 +143,8 @@
.Ft int
.Fn libusb20_dev_reset "struct libusb20_device *pdev"
.Ft int
+.Fn libusb20_dev_check_connected "struct libusb20_device *pdev"
+.Ft int
.Fn libusb20_dev_set_power_mode "struct libusb20_device *pdev" "uint8_t power_mode"
.Ft uint8_t
.Fn libusb20_dev_get_power_mode "struct libusb20_device *pdev"
@@ -677,6 +679,15 @@
This function returns zero on success else a LIBUSB20_ERROR value is
returned.
.
+.
+.Pp
+.
+.Fn libusb20_dev_check_connected
+will check if an opened USB device is still connected.
+.
+This function returns zero if the device is still connected else a LIBUSB20_ERROR value is returned.
+.
+.
.Pp
.
.Fn libusb20_dev_set_power_mode
==== //depot/projects/scottl-camlock/src/lib/libusb/libusb20.c#6 (text+ko) ====
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/lib/libusb/libusb20.c,v 1.7 2010/01/10 19:18:49 thompsa Exp $ */
+/* $FreeBSD: src/lib/libusb/libusb20.c,v 1.8 2010/01/29 02:44:06 thompsa Exp $ */
/*-
* Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved.
*
@@ -67,6 +67,7 @@
#define dummy_set_config_index (void *)dummy_int
#define dummy_set_alt_index (void *)dummy_int
#define dummy_reset_device (void *)dummy_int
+#define dummy_check_connected (void *)dummy_int
#define dummy_set_power_mode (void *)dummy_int
#define dummy_get_power_mode (void *)dummy_int
#define dummy_kernel_driver_active (void *)dummy_int
@@ -673,6 +674,15 @@
}
int
+libusb20_dev_check_connected(struct libusb20_device *pdev)
+{
+ int error;
+
+ error = pdev->methods->check_connected(pdev);
+ return (error);
+}
+
+int
libusb20_dev_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode)
{
int error;
==== //depot/projects/scottl-camlock/src/lib/libusb/libusb20.h#4 (text+ko) ====
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/lib/libusb/libusb20.h,v 1.6 2009/11/20 08:57:25 thompsa Exp $ */
+/* $FreeBSD: src/lib/libusb/libusb20.h,v 1.7 2010/01/29 02:44:06 thompsa Exp $ */
/*-
* Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved.
* Copyright (c) 2007-2008 Daniel Drake. All rights reserved.
@@ -250,6 +250,7 @@
int libusb20_dev_req_string_sync(struct libusb20_device *pdev, uint8_t index, uint16_t langid, void *ptr, uint16_t len);
int libusb20_dev_req_string_simple_sync(struct libusb20_device *pdev, uint8_t index, void *ptr, uint16_t len);
int libusb20_dev_reset(struct libusb20_device *pdev);
+int libusb20_dev_check_connected(struct libusb20_device *pdev);
int libusb20_dev_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode);
uint8_t libusb20_dev_get_power_mode(struct libusb20_device *pdev);
int libusb20_dev_set_alt_index(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
==== //depot/projects/scottl-camlock/src/lib/libusb/libusb20_int.h#4 (text+ko) ====
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/lib/libusb/libusb20_int.h,v 1.4 2009/07/30 00:11:41 alfred Exp $ */
+/* $FreeBSD: src/lib/libusb/libusb20_int.h,v 1.5 2010/01/29 02:44:06 thompsa Exp $ */
/*-
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
*
@@ -101,6 +101,7 @@
typedef int (libusb20_get_power_mode_t)(struct libusb20_device *pdev, uint8_t *power_mode);
typedef int (libusb20_set_alt_index_t)(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index);
typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t index);
+typedef int (libusb20_check_connected_t)(struct libusb20_device *pdev);
/* USB transfer specific */
typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no);
@@ -117,6 +118,7 @@
m(n, kernel_driver_active) \
m(n, process) \
m(n, reset_device) \
+ m(n, check_connected) \
m(n, set_power_mode) \
m(n, get_power_mode) \
m(n, set_alt_index) \
==== //depot/projects/scottl-camlock/src/lib/libusb/libusb20_ugen20.c#6 (text+ko) ====
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/lib/libusb/libusb20_ugen20.c,v 1.6 2009/11/08 20:03:52 thompsa Exp $ */
+/* $FreeBSD: src/lib/libusb/libusb20_ugen20.c,v 1.7 2010/01/29 02:44:06 thompsa Exp $ */
/*-
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
*
@@ -67,6 +67,7 @@
static libusb20_set_config_index_t ugen20_set_config_index;
static libusb20_set_alt_index_t ugen20_set_alt_index;
static libusb20_reset_device_t ugen20_reset_device;
+static libusb20_check_connected_t ugen20_check_connected;
static libusb20_set_power_mode_t ugen20_set_power_mode;
static libusb20_get_power_mode_t ugen20_get_power_mode;
static libusb20_kernel_driver_active_t ugen20_kernel_driver_active;
@@ -553,6 +554,25 @@
}
static int
+ugen20_check_connected(struct libusb20_device *pdev)
+{
+ uint32_t plugtime;
+ int error = 0;
+
+ if (ioctl(pdev->file_ctrl, USB_GET_PLUGTIME, &plugtime)) {
+ error = LIBUSB20_ERROR_NO_DEVICE;
+ goto done;
+ }
+
+ if (pdev->session_data.plugtime != plugtime) {
+ error = LIBUSB20_ERROR_NO_DEVICE;
+ goto done;
+ }
+done:
+ return (error);
+}
+
+static int
ugen20_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode)
{
int temp;
==== //depot/projects/scottl-camlock/src/share/man/man4/Makefile#21 (text+ko) ====
@@ -1,5 +1,5 @@
# @(#)Makefile 8.1 (Berkeley) 6/18/93
-# $FreeBSD: src/share/man/man4/Makefile,v 1.472 2010/01/27 00:34:52 delphij Exp $
+# $FreeBSD: src/share/man/man4/Makefile,v 1.473 2010/01/28 22:28:01 thompsa Exp $
MAN= aac.4 \
acpi.4 \
@@ -328,6 +328,7 @@
rp.4 \
rue.4 \
rum.4 \
+ run.4 \
sa.4 \
safe.4 \
sbp.4 \
==== //depot/projects/scottl-camlock/src/share/man/man4/ahci.4#8 (text+ko) ====
@@ -23,9 +23,9 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/share/man/man4/ahci.4,v 1.3 2009/08/30 15:20:13 mav Exp $
+.\" $FreeBSD: src/share/man/man4/ahci.4,v 1.4 2010/01/28 18:15:19 mav Exp $
.\"
-.Dd August 24, 2009
+.Dd January 28, 2010
.Dt AHCI 4
.Os
.Sh NAME
@@ -114,14 +114,11 @@
etc.
.Pp
Driver features include support for Serial ATA and ATAPI devices,
-Port Multipliers, hardware command queues (up to 32 commands per port),
+Port Multipliers (including FIS-based switching, when supported),
+hardware command queues (up to 32 commands per port),
Native Command Queuing, SATA interface Power Management, device hot-plug
and Message Signaled Interrupts.
.Pp
-The Port Multiplier FIS Based Switching feature added in the AHCI 1.2
-specification, which is required for effective parallel operation of devices
-behind Port Multipliers, is not yet supported.
-.Pp
AHCI hardware is also supported by ataahci driver from
.Xr ata 4
subsystem. If both drivers are loaded at the same time, this one will be
@@ -131,6 +128,10 @@
.Nm
driver supports AHCI compatible controllers having PCI class 1 (mass storage),
subclass 6 (SATA) and programming interface 1 (AHCI).
+.Pp
+Also, in cooperation with atamarvell and atajmicron drivers of ata(4),
+it supports AHCI part of legacy-PATA + AHCI-SATA combined controllers,
+such as JMicron JMB36x and Marvell 88SX61xx.
.Sh SEE ALSO
.Xr ada 4 ,
.Xr cd 4 ,
==== //depot/projects/scottl-camlock/src/share/man/man4/gpib.4#2 (text+ko) ====
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/share/man/man4/gpib.4,v 1.2 2010/01/25 06:37:44 joerg Exp $
+.\" $FreeBSD: src/share/man/man4/gpib.4,v 1.3 2010/01/28 19:12:40 joerg Exp $
.\"
.Dd January 24, 2010
.Dt GPIB 4
@@ -88,7 +88,7 @@
.El
.Sh SEE ALSO
.\" .Xr libgpib 3 ,
-.Xr gpib 4 ,
+.Xr pcii 4 ,
.Xr tnt4882 4
.Sh HISTORY
The
==== //depot/projects/scottl-camlock/src/share/man/man9/locking.9#3 (text+ko) ====
@@ -22,17 +22,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/share/man/man9/locking.9,v 1.12 2007/11/08 14:47:54 ups Exp $
+.\" $FreeBSD: src/share/man/man9/locking.9,v 1.15 2010/01/28 21:14:12 trasz Exp $
.\"
-.Dd March 14, 2007
+.Dd January 29, 2010
.Dt LOCKING 9
.Os
.Sh NAME
.Nm locking
.Nd kernel synchronization primitives
-.Sh SYNOPSIS
-All sorts of stuff to go here.
-.Pp
.Sh DESCRIPTION
The
.Em FreeBSD
@@ -43,21 +40,19 @@
These include:
.Bl -enum
.It
-Spin Mutexes
+Mutexes
.It
-Sleep Mutexes
+Spin mutexes
.It
-pool Mutexes
+Pool mutexes
.It
-Shared-Exclusive locks
+Shared/exclusive locks
.It
-Reader-Writer locks
+Reader/writer locks
.It
-Read-Mostly locks
+Read-mostly locks
.It
-Turnstiles
-.It
-Semaphores
+Counting semaphores
.It
Condition variables
.It
@@ -70,62 +65,45 @@
.Pp
The primitives interact and have a number of rules regarding how
they can and can not be combined.
-There are too many for the average
-human mind and they keep changing.
-(if you disagree, please write replacement text) :-)
-.Pp
-Some of these primitives may be used at the low (interrupt) level and
-some may not.
-.Pp
-There are strict ordering requirements and for some of the types this
-is checked using the
+Many of these rules are checked using the
.Xr witness 4
code.
.Pp
-.Ss SPIN Mutexes
-Mutexes are the basic primitive.
-You either hold it or you don't.
-If you don't own it then you just spin, waiting for the holder (on
-another CPU) to release it.
-Hopefully they are doing something fast.
+.Ss Mutexes
+Mutexes are the most commonly used synchronization primitive in the kernel.
+Thread acquires (locks) a mutex before accessing data shared with other
+threads (including interrupt threads), and releases (unlocks) it afterwards.
+If the mutex cannot be acquired, the thread requesting it will sleep.
+Mutexes fully support priority propagation.
+.Pp
+See
+.Xr mutex 9
+for details.
+.Ss Spin mutexes
+Spin mutexes are variation of basic mutexes; the main difference between
+the two is that spin mutexes never sleep - instead, they spin, waiting
+for the thread holding the lock, which runs on another CPU, to release it.
+Differently from ordinary mutex, spin mutexes disable interrupts when acquired.
+Since disabling interrupts is expensive, they are also generally slower.
+Spin mutexes should only be used to protect data shared with primary
+(INTR_FILTER) interrupt code.
You
.Em must not
do anything that deschedules the thread while you
-are holding a SPIN mutex.
-.Ss Mutexes
-Basically (regular) mutexes will deschedule the thread if the
-mutex can not be acquired.
-A non-spin mutex can be considered to be equivalent
-to getting a write lock on an
-.Em rw_lock
-(see below), and in fact non-spin mutexes and rw_locks may soon become the same thing.
-As in spin mutexes, you either get it or you don't.
-You may only call the
-.Xr sleep 9
-call via
-.Fn msleep
-or the new
-.Fn mtx_sleep
-variant.
-These will atomically drop the mutex and reacquire it
-as part of waking up.
-This is often however a
-.Em BAD
-idea because it generally relies on you having
-such a good knowledge of all the call graph above you
-and what assumptions it is making that there are a lot
-of ways to make hard-to-find mistakes.
-For example you MUST re-test all the assumptions you made before,
-all the way up the call graph to where you got the lock.
-You can not just assume that mtx_sleep can be inserted anywhere.
-If any caller above you has any mutex or
-rwlock, your sleep, will cause a panic.
-If the sleep only happens rarely it may be years before the
-bad code path is found.
-.Ss Pool Mutexes
-A variant of regular mutexes where the allocation of the mutex is handled
-more by the system.
-.Ss Rw_locks
+are holding a spin mutex.
+.Ss Pool mutexes
+With most synchronisaton primitives, such as mutexes, programmer must
+provide a piece of allocated memory to hold the primitive.
+For example, a mutex may be embedded inside the structure it protects.
+Pool mutex is a variant of mutex without this requirement - to lock or unlock
+a pool mutex, one uses address of the structure being protected with it,
+not the mutex itself.
+Pool mutexes are seldom used.
+.Pp
+See
+.Xr mtx_pool 9
+for details.
+.Ss Reader/writer locks
Reader/writer locks allow shared access to protected data by multiple threads,
or exclusive access by a single thread.
The threads with shared access are known as
@@ -135,23 +113,12 @@
.Em writer
since it may modify protected data.
.Pp
-Although reader/writer locks look very similar to
-.Xr sx 9
-(see below) locks, their usage pattern is different.
Reader/writer locks can be treated as mutexes (see above and
.Xr mutex 9 )
with shared/exclusive semantics.
More specifically, regular mutexes can be
considered to be equivalent to a write-lock on an
.Em rw_lock.
-In the future this may in fact
-become literally the fact.
-An
-.Em rw_lock
-can be locked while holding a regular mutex, but
-can
-.Em not
-be held while sleeping.
The
.Em rw_lock
locks have priority propagation like mutexes, but priority
@@ -163,54 +130,48 @@
can recurse, but exclusive locks are not allowed to recurse.
This ability should not be used lightly and
.Em may go away.
-Users of recursion in any locks should be prepared to
-defend their decision against vigorous criticism.
-.Ss Rm_locks
+.Pp
+See
+.Xr rwlock 9
+for details.
+.Ss Read-mostly locks
Mostly reader locks are similar to
-.Em Reader/write
-locks but optimized for very infrequent
-.Em writer
-locking.
-.Em rm_lock
+.Em reader/writer
+locks but optimized for very infrequent write locking.
+.Em Read-mostly
locks implement full priority propagation by tracking shared owners
using a lock user supplied
.Em tracker
data structure.
-.Ss Sx_locks
-Shared/exclusive locks are used to protect data that are read far more often
-than they are written.
-Mutexes are inherently more efficient than shared/exclusive locks, so
-shared/exclusive locks should be used prudently.
-The main reason for using an
-.Em sx_lock
-is that a thread may hold a shared or exclusive lock on an
-.Em sx_lock
-lock while sleeping.
-As a consequence of this however, an
-.Em sx_lock
-lock may not be acquired while holding a mutex.
-The reason for this is that, if one thread slept while holding an
-.Em sx_lock
-lock while another thread blocked on the same
-.Em sx_lock
-lock after acquiring a mutex, then the second thread would effectively
-end up sleeping while holding a mutex, which is not allowed.
-The
-.Em sx_lock
-should be considered to be closely related to
+.Pp
+See
+.Xr rmlock 9
+for details.
+.Ss Shared/exclusive locks
+Shared/exclusive locks are similar to reader/writer locks; the main difference
+between them is that shared/exclusive locks may be held during unbounded sleep
+(and may thus perform an unbounded sleep).
+They are inherently less efficient than mutexes, reader/writer locks
+and read-mostly locks. They don't support priority propagation.
+They should be considered to be closely related to
.Xr sleep 9 .
In fact it could in some cases be
considered a conditional sleep.
-.Ss Turnstiles
-Turnstiles are used to hold a queue of threads blocked on
-non-sleepable locks.
-Sleepable locks use condition variables to implement their queues.
-Turnstiles differ from a sleep queue in that turnstile queue's
-are assigned to a lock held by an owning thread.
-Thus, when one thread is enqueued onto a turnstile, it can lend its
-priority to the owning thread.
-If this sounds confusing, we need to describe it better.
-.Ss Semaphores
+.Pp
+See
+.Xr sx 9
+for details.
+.Ss Counting semaphores
+Counting semaphores provide a mechanism for synchronizing access
+to a pool of resources.
+Unlike mutexes, semaphores do not have the concept of an owner,
+so they can be useful in situations where one thread needs
+to acquire a resource, and another thread needs to release it.
+They are largely deprecated.
+.Pp
+See
+.Xr sema 9
+for details.
.Ss Condition variables
Condition variables are used in conjunction with mutexes to wait for
conditions to occur.
@@ -220,9 +181,12 @@
When a thread waits on a condition, the mutex
is atomically released before the thread is blocked, then reacquired
before the function call returns.
+.Pp
+See
+.Xr condvar 9
+for details.
.Ss Giant
-Giant is a special instance of a sleep lock.
-It has several special characteristics.
+Giant is an instance of a mutex, with some special characteristics:
.Bl -enum
.It
It is recursive.
@@ -237,7 +201,7 @@
There are places in the kernel that drop Giant and pick it back up
again.
Sleep locks will do this before sleeping.
-Parts of the Network or VM code may do this as well, depending on the
+Parts of the network or VM code may do this as well, depending on the
setting of a sysctl.
This means that you cannot count on Giant keeping other code from
running if your code sleeps, even if you want it to.
@@ -298,26 +262,72 @@
.Va Giant
mutex before the function returns.
.Pp
-.Ss lockmanager locks
-Largely deprecated.
-See the
+See
+.Xr sleep 9
+for details.
+.Pp
+.Ss Lockmanager locks
+Shared/exclusive locks, used mostly in
+.Xr VFS 9 ,
+in particular as a
+.Xr vnode 9
+lock.
+They have features other lock types don't have, such as sleep timeout,
+writer starvation avoidance, draining, and interlock mutex, but this makes them
+complicated to implement; for this reason, they are deprecated.
+.Pp
+See
.Xr lock 9
-page for more information.
-I don't know what the downsides are but I'm sure someone will fill in this part.
-.Sh Usage tables.
-.Ss Interaction table.
+for details.
+.Sh INTERACTIONS
+.Ss Bounded vs. unbounded sleep
+The following primitives perform bounded sleep: mutexes, pool mutexes,
+reader/writer locks and read-mostly locks.
+.Pp
+The following primitives block (perform unbounded sleep): shared/exclusive locks,
+counting semaphores, condition variables, sleep/wakeup and lockmanager locks.
+.Pp
+It is an error to do any operation that could result in any kind of sleep while
+holding spin mutex.
+.Pp
+As a general rule, it is an error to do any operation that could result
+in unbounded sleep while holding any primitive from the 'bounded sleep' group.
+For example, it is an error to try to acquire shared/exclusive lock while
+holding mutex, or to try to allocate memory with M_WAITOK while holding
+read-write lock.
+.Pp
+As a special case, it is possible to call
+.Fn sleep 9
+or
+.Fn mtx_sleep 9
+while holding a mutex.
+It will atomically drop the mutex and reacquire it
+as part of waking up.
+This is often however a bad
+idea because it generally relies on you having
+such a good knowledge of all the call graph above you
+and what assumptions it is making that there are a lot
+of ways to make hard-to-find mistakes.
+For example you must re-test all the assumptions you made before,
+all the way up the call graph to where you got the lock.
+You can not just assume that mtx_sleep can be inserted anywhere.
+If any caller above you has any mutex or
+rwlock, your sleep, will cause a panic.
+If the sleep only happens rarely it may be years before the
+bad code path is found.
+.Ss Interaction table
The following table shows what you can and can not do if you hold
one of the synchronization primitives discussed here:
(someone who knows what they are talking about should write this table)
-.Bl -column ".Ic xxxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXX" -offset indent
+.Bl -column ".Ic xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXX" -offset indent
.It Xo
-.Em "You have: You want:" Ta Spin_mtx Ta Slp_mtx Ta sx_lock Ta rw_lock Ta rm_lock Ta sleep
+.Em "You have: You want:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep
.Xc
-.It Ic SPIN mutex Ta \&ok-1 Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no-3
-.It Ic Sleep mutex Ta \&ok Ta \&ok-1 Ta \&no Ta \&ok Ta \&ok Ta \&no-3
-.It Ic sx_lock Ta \&ok Ta \&ok Ta \&ok-2 Ta \&ok Ta \&ok Ta \&ok-4
-.It Ic rw_lock Ta \&ok Ta \&ok Ta \&no Ta \&ok-2 Ta \&ok Ta \&no-3
-.It Ic rm_lock Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok-2 Ta \&no
+.It Ic spin mtx Ta \&ok-1 Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no-3
+.It Ic mutex Ta \&ok Ta \&ok-1 Ta \&no Ta \&ok Ta \&ok Ta \&no-3
+.It Ic sx Ta \&ok Ta \&ok Ta \&ok-2 Ta \&ok Ta \&ok Ta \&ok-4
+.It Ic rwlock Ta \&ok Ta \&ok Ta \&no Ta \&ok-2 Ta \&ok Ta \&no-3
+.It Ic rmlock Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok-2 Ta \&no
.El
.Pp
.Em *1
@@ -342,12 +352,12 @@
.Fn sx_sleep
which atomically release this primitive when going to sleep and
reacquire it on wakeup.
-.Ss Context mode table.
+.Ss Context mode table
The next table shows what can be used in different contexts.
At this time this is a rather easy to remember table.
-.Bl -column ".Ic Xxxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXX" -offset indent
+.Bl -column ".Ic Xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXX" -offset indent
.It Xo
-.Em "Context:" Ta Spin_mtx Ta Slp_mtx Ta sx_lock Ta rw_lock Ta rm_lock Ta sleep
+.Em "Context:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep
.Xc
.It interrupt: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no
.It idle: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no
@@ -362,11 +372,13 @@
.Xr sema 9 ,
.Xr sleep 9 ,
.Xr sx 9 ,
-.Xr LOCK_PROFILING 9 ,
-.Xr WITNESS 9
+.Xr witness 9 ,
+.Xr LOCK_PROFILING 9
.Sh HISTORY
These
functions appeared in
.Bsx 4.1
through
.Fx 7.0
+.Sh BUGS
+There are too many locking primitives to choose from.
==== //depot/projects/scottl-camlock/src/share/misc/committers-src.dot#9 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/misc/committers-src.dot,v 1.103 2009/12/10 14:41:47 kib Exp $
+# $FreeBSD: src/share/misc/committers-src.dot,v 1.104 2010/01/28 19:41:26 uqs Exp $
# This file is meant to list all FreeBSD src committers and describe the
# mentor-mentee relationships between them.
@@ -187,6 +187,7 @@
trhodes [label="Tom Rhodes\ntrhodes at FreeBSD.org\n2002/05/28"]
tuexen [label="Michael Tuexen\ntuexen at FreeBSD.org\n2009/06/06"]
ume [label="Hajimu UMEMOTO\nume at FreeBSD.org\n2000/02/26"]
+uqs [label="Ulrich Spoerlein\nuqs at FreeBSD.org\n2010/01/28"]
vanhu [label="Yvan Vanhullebus\nvanhu at FreeBSD.org\n2008/07/21"]
versus [label="Konrad Jankowski\nversus at FreeBSD.org\n2008/10/27"]
weongyo [label="Weongyo Jeong\nweongyo at FreeBSD.org\n2007/12/21"]
@@ -398,6 +399,7 @@
philip -> ed
philip -> jls
philip -> matteo
+philip -> uqs
pjd -> kib
pjd -> lulf
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#36 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/ata/ata_all.c,v 1.12 2009/12/28 20:08:01 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/ata/ata_all.c,v 1.13 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#48 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/ata/ata_da.c,v 1.14 2009/12/28 20:08:01 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/ata/ata_da.c,v 1.15 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#31 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/ata/ata_pmp.c,v 1.5 2009/12/07 16:23:25 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/ata/ata_pmp.c,v 1.6 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#74 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/ata/ata_xpt.c,v 1.19 2010/01/10 09:20:56 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/ata/ata_xpt.c,v 1.20 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
#include <sys/bus.h>
==== //depot/projects/scottl-camlock/src/sys/cam/cam.c#16 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/cam.c,v 1.15 2009/11/11 11:10:36 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/cam.c,v 1.16 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
#ifdef _KERNEL
==== //depot/projects/scottl-camlock/src/sys/cam/cam.h#13 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam.h,v 1.16 2009/11/03 11:19:05 mav Exp $
+ * $FreeBSD: src/sys/cam/cam.h,v 1.17 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_ccb.h#38 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_ccb.h,v 1.42 2009/11/26 08:49:46 mav Exp $
+ * $FreeBSD: src/sys/cam/cam_ccb.h,v 1.43 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_CCB_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#52 (text+ko) ====
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/cam_periph.c,v 1.87 2009/11/14 20:30:42 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/cam_periph.c,v 1.88 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
#include <sys/systm.h>
==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#27 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_periph.h,v 1.23 2009/12/06 11:48:53 mav Exp $
+ * $FreeBSD: src/sys/cam/cam_periph.h,v 1.24 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_PERIPH_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_queue.h#9 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_queue.h,v 1.12 2009/11/14 20:30:42 mav Exp $
+ * $FreeBSD: src/sys/cam/cam_queue.h,v 1.13 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_QUEUE_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_sim.c#14 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/cam_sim.c,v 1.13 2008/12/19 14:33:29 trasz Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/cam_sim.c,v 1.14 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
#include <sys/systm.h>
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#146 (text+ko) ====
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.236 2009/11/24 12:47:58 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.237 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
#include <sys/bus.h>
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#23 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_xpt.h,v 1.10 2009/07/10 08:18:08 scottl Exp $
+ * $FreeBSD: src/sys/cam/cam_xpt.h,v 1.11 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_XPT_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_internal.h#17 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_xpt_internal.h,v 1.5 2009/11/11 11:10:36 mav Exp $
+ * $FreeBSD: src/sys/cam/cam_xpt_internal.h,v 1.6 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_XPT_INTERNAL_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_periph.h#14 (text+ko) ====
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_xpt_periph.h,v 1.8 2009/07/10 08:18:08 scottl Exp $
+ * $FreeBSD: src/sys/cam/cam_xpt_periph.h,v 1.9 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_XPT_PERIPH_H
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_sim.h#7 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/cam_xpt_sim.h,v 1.10 2009/01/08 17:26:51 trasz Exp $
+ * $FreeBSD: src/sys/cam/cam_xpt_sim.h,v 1.11 2010/01/28 08:41:30 mav Exp $
*/
#ifndef _CAM_CAM_XPT_SIM_H
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.c#15 (text+ko) ====
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.56 2009/10/23 08:27:55 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.57 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#38 (text+ko) ====
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.116 2009/12/18 14:41:30 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.117 2010/01/28 08:41:30 mav Exp $");
#include "opt_cd.h"
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#22 (text+ko) ====
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_ch.c,v 1.50 2009/11/14 20:13:38 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_ch.c,v 1.51 2010/01/28 08:41:30 mav Exp $");
#include <sys/param.h>
#include <sys/queue.h>
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list