Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 May 2014 03:52:10 +0000 (UTC)
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r265729 - in stable/9: share/man/man4 sys/amd64/conf sys/conf sys/dev/mpr sys/i386/conf sys/ia64/conf sys/mips/conf sys/modules sys/modules/mpr sys/sparc64/conf
Message-ID:  <201405090352.s493qAFm058978@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ken
Date: Fri May  9 03:52:10 2014
New Revision: 265729
URL: http://svnweb.freebsd.org/changeset/base/265729

Log:
  MFC the mpr(4) driver for LSI's 12Gb SAS cards.
  
  This includes r265236, r265237, r265241, r265261, r265386, r265424, and
  r265473.
  
    ------------------------------------------------------------------------
    r265236 | ken | 2014-05-02 14:25:09 -0600 (Fri, 02 May 2014) | 51 lines
  
    Bring in the mpr(4) driver for LSI's MPT3 12Gb SAS controllers.
  
    This is derived from the mps(4) driver, but it supports only the 12Gb
    IT and IR hardware including the SAS 3004, SAS 3008 and SAS 3108.
  
    Some notes about this driver:
     o The 12Gb hardware can do "FastPath" I/O, and that capability is included in
       this driver.
  
     o WarpDrive functionality has been removed, since it isn't supported in
       the 12Gb driver interface.
  
     o The Scatter/Gather list handling code is significantly different between
       the 6Gb and 12Gb hardware.  The 12Gb boards support IEEE Scatter/Gather
       lists.
  
    Thanks to LSI for developing and testing this driver for FreeBSD.
  
    share/man/man4/mpr.4:
    	mpr(4) man page.
  
    sys/dev/mpr/*:
    	mpr(4) driver files.
  
    sys/modules/Makefile,
    sys/modules/mpr/Makefile:
    	Add a module Makefile for the mpr(4) driver.
  
    sys/conf/files:
    	Add the mpr(4) driver.
  
    sys/amd64/conf/GENERIC,
    sys/i386/conf/GENERIC,
    sys/mips/conf/OCTEON1,
    sys/sparc64/conf/GENERIC:
    	Add the mpr(4) driver to all config files that currently
    	have the mps(4) driver.
  
    sys/ia64/conf/GENERIC:
    	Add the mps(4) and mpr(4) drivers to the ia64 GENERIC
    	config file.
  
    sys/i386/conf/XEN:
    	Exclude the mpr module from building here.
  
    Submitted by:	Steve McConnell <Stephen.McConnell@avagotech.com>
    Tested by:	Chris Reeves <chrisr@spectralogic.com>
    Sponsored by:	LSI, Spectra Logic
    Relnotes:	LSI 12Gb SAS driver mpr(4) added
  
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    r265237 | ken | 2014-05-02 14:36:20 -0600 (Fri, 02 May 2014) | 8 lines
  
    Add the mpr(4) man page to the man4 Makefile.
  
    This should have been included in r265236.
  
    Submitted by:	Steve McConnell <Stephen.McConnell@avagotech.com>
    Sponsored by:	LSI, Spectra Logic
  
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    r265241 | brueffer | 2014-05-02 15:14:28 -0600 (Fri, 02 May 2014) | 2 lines
  
    Use our standard SYNOPSIS wording; perform some cleanup while here.
  
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    r265261 | brueffer | 2014-05-03 05:15:28 -0600 (Sat, 03 May 2014) | 2 lines
  
    Add a missing colon.
  
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    r265386 | ken | 2014-05-05 13:53:03 -0600 (Mon, 05 May 2014) | 15 lines
  
    Adjust #if statements inside mprsas_send_smpcmd() to more accurately
    reflect when unmapped I/O support was added.
  
    For FreeBSD 10, it arrived just prior to __FreeBSD_version 1000028.
    For FreeBSD 9, it arrived just prior to __FreeBSD_version 902001.
  
    Also, fix compiler warnings in mprsas_send_smpcmd() that happen in the
    i386 PAE build for non-unmapped I/O builds.  These were fixed in mps(4)
    in revision 241145, but didn't make it into the mpr(4) driver.  This
    change should only affect FreeBSD versions outside the above revisions,
    and thus doesn't affect head.
  
    Sponsored by:	Spectra Logic Corporation
  
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    r265424 | ken | 2014-05-06 00:18:43 -0600 (Tue, 06 May 2014) | 33 lines
  
    Fix a problem with async notifications in the mpr(4) driver.
  
    This problem only occurs on versions of FreeBSD prior to the recent CAM
    locking changes.  (i.e. stable/9 and older versions of stable/10)  This
    change should be a no-op for head and stable/10.
  
    If a path isn't specified, xpt_register_async() will create a fully
    wildcarded path and acquire a lock (the XPT lock in older versions,
    and via xpt_path_lock() in newer versions) to call xpt_action() for the
    XPT_SASYNC_CB CCB.  It will then drop the lock and if the requested event
    includes AC_FOUND_DEVICE or AC_PATH_REGISTERED, it will get the caller up
    to date with any device arrivals or path registrations.
  
    The issue is that before the locking changes, each SIM lock would get
    acquired in turn during the EDT tree traversal process.  If a path is
    specified for xpt_register_async(), it won't acquire and drop its own lock,
    but instead expects the caller to hold its own SIM lock.  That works for
    the first part of xpt_register_async(), but causes a recursive lock
    acquisition once the EDT traversal happens and it comes to the SIM in
    question.  And it isn't possible to call xpt_action() without holding a SIM
    lock.
  
    The locking changes fix this by using the XPT topology lock for EDT
    traversal, so it is no longer an issue to hold the SIM lock while calling
    xpt_register_async().
  
    The solution for FreeBSD versions before the locking changes is to request
    notification of all device arrivals (so we pass a NULL path into
    xpt_register_async()) and then filter out the arrivals that are not ours.
  
    Sponsored by:	Spectra Logic Corporation
  
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    r265473 | ken | 2014-05-06 16:13:38 -0600 (Tue, 06 May 2014) | 7 lines
  
    Change the device name for mpr(4) from /dev/mpr_N to /dev/mprN.
  
    This is more consistent with the existing mps(4) behavior.
  
    Reviewed by:	Steve McConnell <stephen.mcconnell@avagotech.com>
  
    ------------------------------------------------------------------------
  
  Submitted by:	Steve McConnell <Stephen.McConnell@avagotech.com>
  Tested by:	Chris Reeves <chrisr@spectralogic.com>
  Sponsored by:	LSI, Spectra Logic
  Relnotes:	LSI 12Gb SAS driver mpr(4) added

Added:
  stable/9/share/man/man4/mpr.4
     - copied, changed from r265236, head/share/man/man4/mpr.4
  stable/9/sys/dev/mpr/
     - copied from r265236, head/sys/dev/mpr/
  stable/9/sys/modules/mpr/
     - copied from r265236, head/sys/modules/mpr/
Modified:
  stable/9/share/man/man4/Makefile
  stable/9/sys/amd64/conf/GENERIC
  stable/9/sys/conf/files
  stable/9/sys/dev/mpr/mpr_sas.c
  stable/9/sys/dev/mpr/mpr_user.c
  stable/9/sys/i386/conf/GENERIC
  stable/9/sys/i386/conf/XEN
  stable/9/sys/ia64/conf/GENERIC
  stable/9/sys/mips/conf/OCTEON1
  stable/9/sys/modules/Makefile
  stable/9/sys/sparc64/conf/GENERIC
Directory Properties:
  stable/9/   (props changed)
  stable/9/share/   (props changed)
  stable/9/share/man/   (props changed)
  stable/9/share/man/man4/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/modules/   (props changed)

Modified: stable/9/share/man/man4/Makefile
==============================================================================
--- stable/9/share/man/man4/Makefile	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/share/man/man4/Makefile	Fri May  9 03:52:10 2014	(r265729)
@@ -246,6 +246,7 @@ MAN=	aac.4 \
 	mod_cc.4 \
 	mos.4 \
 	mouse.4 \
+	mpr.4 \
 	mps.4 \
 	mpt.4 \
 	msk.4 \

Copied and modified: stable/9/share/man/man4/mpr.4 (from r265236, head/share/man/man4/mpr.4)
==============================================================================
--- head/share/man/man4/mpr.4	Fri May  2 20:25:09 2014	(r265236, copy source)
+++ stable/9/share/man/man4/mpr.4	Fri May  9 03:52:10 2014	(r265729)
@@ -36,7 +36,7 @@
 .\" $Id$
 .\" $FreeBSD$
 .\"
-.Dd Apr 28, 2014
+.Dd May 2, 2014
 .Dt MPR 4
 .Os
 .Sh NAME
@@ -51,7 +51,8 @@ kernel configuration file:
 .Cd "device mpr"
 .Ed
 .Pp
-Or, to load the driver as a module at boot, place the following line in
+Alternatively, to load the driver as a
+module at boot time, place the following line in
 .Xr loader.conf 5 :
 .Bd -literal -offset indent
 mpr_load="YES"
@@ -65,7 +66,7 @@ controllers.
 .Sh HARDWARE
 The following controllers are supported by the
 .Nm
-driver
+driver:
 .Pp
 .Bl -bullet -compact
 .It
@@ -156,7 +157,8 @@ control for all adapters by setting the 
 hw.mpr.exclude_ids=Y
 .Ed
 .Pp
-where Y is the target ID of the device.  If more than one device is to be
+where Y is the target ID of the device.
+If more than one device is to be
 excluded, target ID's are separated by commas.
 .Pp
 Devices can be excluded from
@@ -167,7 +169,8 @@ control for a specific adapter by settin
 dev.mpr.X.exclude_ids=Y
 .Ed
 .Pp
-where X is the adapter number and Y is the target ID of the device.  If more
+where X is the adapter number and Y is the target ID of the device.
+If more
 than one device is to be excluded, target ID's are separated by commas.
 .Sh DEBUGGING
 To enable debugging prints from the
@@ -200,8 +203,8 @@ The following bits have the described ef
 .Xr cd 4 ,
 .Xr ch 4 ,
 .Xr da 4 ,
-.Xr mpt 4 ,
 .Xr mps 4 ,
+.Xr mpt 4 ,
 .Xr pci 4 ,
 .Xr sa 4 ,
 .Xr scsi 4 ,

Modified: stable/9/sys/amd64/conf/GENERIC
==============================================================================
--- stable/9/sys/amd64/conf/GENERIC	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/amd64/conf/GENERIC	Fri May  9 03:52:10 2014	(r265729)
@@ -106,6 +106,7 @@ device		isp		# Qlogic family
 #device		ispfw		# Firmware for QLogic HBAs- normally a module
 device		mpt		# LSI-Logic MPT-Fusion
 device		mps		# LSI-Logic MPT-Fusion 2
+device		mpr		# LSI-Logic MPT-Fusion 3
 #device		ncr		# NCR/Symbios Logic
 device		sym		# NCR/Symbios Logic (newer chipsets + those of `ncr')
 device		trm		# Tekram DC395U/UW/F DC315U adapters

Modified: stable/9/sys/conf/files
==============================================================================
--- stable/9/sys/conf/files	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/conf/files	Fri May  9 03:52:10 2014	(r265729)
@@ -1543,6 +1543,17 @@ dev/mmc/mmcbr_if.m		standard
 dev/mmc/mmcbus_if.m		standard
 dev/mmc/mmcsd.c			optional mmcsd
 dev/mn/if_mn.c			optional mn pci
+dev/mpr/mpr.c			optional mpr
+dev/mpr/mpr_config.c		optional mpr
+# XXX Work around clang warning, until maintainer approves fix.
+dev/mpr/mpr_mapping.c		optional mpr \
+	compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
+dev/mpr/mpr_pci.c		optional mpr pci
+dev/mpr/mpr_sas.c		optional mpr \
+	compile-with "${NORMAL_C} ${NO_WUNNEEDED_INTERNAL_DECL}"
+dev/mpr/mpr_sas_lsi.c		optional mpr
+dev/mpr/mpr_table.c		optional mpr
+dev/mpr/mpr_user.c		optional mpr
 dev/mps/mps.c			optional mps
 dev/mps/mps_config.c		optional mps
 # XXX Work around clang warning, until maintainer approves fix.

Modified: stable/9/sys/dev/mpr/mpr_sas.c
==============================================================================
--- head/sys/dev/mpr/mpr_sas.c	Fri May  2 20:25:09 2014	(r265236)
+++ stable/9/sys/dev/mpr/mpr_sas.c	Fri May  9 03:52:10 2014	(r265729)
@@ -813,8 +813,49 @@ mpr_attach_sas(struct mpr_softc *sc)
 #else
 		event = AC_FOUND_DEVICE;
 #endif
+
+		/*
+		 * Prior to the CAM locking improvements, we can't call
+		 * xpt_register_async() with a particular path specified.
+		 *
+		 * If a path isn't specified, xpt_register_async() will
+		 * generate a wildcard path and acquire the XPT lock while
+		 * it calls xpt_action() to execute the XPT_SASYNC_CB CCB.
+		 * It will then drop the XPT lock once that is done.
+		 * 
+		 * If a path is specified for xpt_register_async(), it will
+		 * not acquire and drop the XPT lock around the call to
+		 * xpt_action().  xpt_action() asserts that the caller
+		 * holds the SIM lock, so the SIM lock has to be held when
+		 * calling xpt_register_async() when the path is specified.
+		 * 
+		 * But xpt_register_async calls xpt_for_all_devices(),
+		 * which calls xptbustraverse(), which will acquire each
+		 * SIM lock.  When it traverses our particular bus, it will
+		 * necessarily acquire the SIM lock, which will lead to a
+		 * recursive lock acquisition.
+		 * 
+		 * The CAM locking changes fix this problem by acquiring
+		 * the XPT topology lock around bus traversal in
+		 * xptbustraverse(), so the caller can hold the SIM lock
+		 * and it does not cause a recursive lock acquisition.
+		 *
+		 * These __FreeBSD_version values are approximate, especially
+		 * for stable/10, which is two months later than the actual
+		 * change.
+		 */
+
+#if (__FreeBSD_version < 1000703) || \
+    ((__FreeBSD_version >= 1100000) && (__FreeBSD_version < 1100002))
+		mpr_unlock(sc);
+		status = xpt_register_async(event, mprsas_async, sc,
+					    NULL);
+		mpr_lock(sc);
+#else
 		status = xpt_register_async(event, mprsas_async, sc,
 					    sassc->path);
+#endif
+
 		if (status != CAM_REQ_CMP) {
 			mpr_dprint(sc, MPR_ERROR,
 			    "Error %#x registering async handler for "
@@ -2501,7 +2542,8 @@ mprsas_send_smpcmd(struct mprsas_softc *
 	sg = NULL;
 	error = 0;
 
-#if __FreeBSD_version >= 1000029
+#if (__FreeBSD_version >= 1000028) || \
+    ((__FreeBSD_version >= 902001) && (__FreeBSD_version < 1000000))
 	switch (ccb->ccb_h.flags & CAM_DATA_MASK) {
 	case CAM_DATA_PADDR:
 	case CAM_DATA_SG_PADDR:
@@ -2561,7 +2603,7 @@ mprsas_send_smpcmd(struct mprsas_softc *
 		xpt_done(ccb);
 		return;
 	}
-#else //__FreeBSD_version < 1000029
+#else /* __FreeBSD_version < 1000028 */
 	/*
 	 * XXX We don't yet support physical addresses here.
 	 */
@@ -2604,7 +2646,7 @@ mprsas_send_smpcmd(struct mprsas_softc *
 			bus_dma_segment_t *req_sg;
 
 			req_sg = (bus_dma_segment_t *)ccb->smpio.smp_request;
-			request = (uint8_t *)req_sg[0].ds_addr;
+			request = (uint8_t *)(uintptr_t)req_sg[0].ds_addr;
 		} else
 			request = ccb->smpio.smp_request;
 
@@ -2612,14 +2654,14 @@ mprsas_send_smpcmd(struct mprsas_softc *
 			bus_dma_segment_t *rsp_sg;
 
 			rsp_sg = (bus_dma_segment_t *)ccb->smpio.smp_response;
-			response = (uint8_t *)rsp_sg[0].ds_addr;
+			response = (uint8_t *)(uintptr_t)rsp_sg[0].ds_addr;
 		} else
 			response = ccb->smpio.smp_response;
 	} else {
 		request = ccb->smpio.smp_request;
 		response = ccb->smpio.smp_response;
 	}
-#endif //__FreeBSD_version >= 1000029
+#endif /* __FreeBSD_version < 1000028 */
 
 	cm = mpr_alloc_command(sc);
 	if (cm == NULL) {
@@ -2987,6 +3029,18 @@ mprsas_async(void *callback_arg, uint32_
 			break;
 
 		/*
+		 * See the comment in mpr_attach_sas() for a detailed
+		 * explanation.  In these versions of FreeBSD we register
+		 * for all events and filter out the events that don't
+		 * apply to us.
+		 */
+#if (__FreeBSD_version < 1000703) || \
+    ((__FreeBSD_version >= 1100000) && (__FreeBSD_version < 1100002))
+		if (xpt_path_path_id(path) != sassc->sim->path_id)
+			break;
+#endif
+
+		/*
 		 * We should have a handle for this, but check to make sure.
 		 */
 		KASSERT(xpt_path_target_id(path) < sassc->maxtargets,
@@ -3043,8 +3097,21 @@ mprsas_async(void *callback_arg, uint32_
 	case AC_FOUND_DEVICE: {
 		struct ccb_getdev *cgd;
 
+		/*
+		 * See the comment in mpr_attach_sas() for a detailed
+		 * explanation.  In these versions of FreeBSD we register
+		 * for all events and filter out the events that don't
+		 * apply to us.
+		 */
+#if (__FreeBSD_version < 1000703) || \
+    ((__FreeBSD_version >= 1100000) && (__FreeBSD_version < 1100002))
+		if (xpt_path_path_id(path) != sc->sassc->sim->path_id)
+			break;
+#endif
+
 		cgd = arg;
 		mprsas_prepare_ssu(sc, path, cgd);
+
 #if (__FreeBSD_version < 901503) || \
     ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006))
 		mprsas_check_eedp(sc, path, cgd);

Modified: stable/9/sys/dev/mpr/mpr_user.c
==============================================================================
--- head/sys/dev/mpr/mpr_user.c	Fri May  2 20:25:09 2014	(r265236)
+++ stable/9/sys/dev/mpr/mpr_user.c	Fri May  9 03:52:10 2014	(r265729)
@@ -212,7 +212,7 @@ mpr_attach_user(struct mpr_softc *sc)
 
 	unit = device_get_unit(sc->mpr_dev);
 	sc->mpr_cdev = make_dev(&mpr_cdevsw, unit, UID_ROOT, GID_OPERATOR,
-	    0640, "mpr_%d", unit);
+	    0640, "mpr%d", unit);
 	if (sc->mpr_cdev == NULL) {
 		return (ENOMEM);
 	}

Modified: stable/9/sys/i386/conf/GENERIC
==============================================================================
--- stable/9/sys/i386/conf/GENERIC	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/i386/conf/GENERIC	Fri May  9 03:52:10 2014	(r265729)
@@ -108,6 +108,8 @@ device		hptiop		# Highpoint RocketRaid 3
 device		isp		# Qlogic family
 #device		ispfw		# Firmware for QLogic HBAs- normally a module
 device		mpt		# LSI-Logic MPT-Fusion
+device		mps			# LSI-Logic MPT-Fusion 2
+device		mpr			# LSI-Logic MPT-Fusion 3
 #device		ncr		# NCR/Symbios Logic
 device		sym		# NCR/Symbios Logic (newer chipsets + those of `ncr')
 device		trm		# Tekram DC395U/UW/F DC315U adapters

Modified: stable/9/sys/i386/conf/XEN
==============================================================================
--- stable/9/sys/i386/conf/XEN	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/i386/conf/XEN	Fri May  9 03:52:10 2014	(r265729)
@@ -7,7 +7,7 @@ cpu		I686_CPU
 ident		XEN
 
 makeoptions	DEBUG=-gdwarf-2		# Build kernel with gdb(1) debug symbols
-makeoptions	WITHOUT_MODULES="aha ahb amd ctl cxgb dpt drm drm2 hptnr hptmv ida malo mps mwl nve rdma sound sym trm xfs"
+makeoptions	WITHOUT_MODULES="aha ahb amd ctl cxgb dpt drm drm2 hptnr hptmv ida malo mpr mps mwl nve rdma sound sym trm xfs"
 
 options 	SCHED_ULE		# ULE scheduler
 options 	PREEMPTION		# Enable kernel thread preemption

Modified: stable/9/sys/ia64/conf/GENERIC
==============================================================================
--- stable/9/sys/ia64/conf/GENERIC	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/ia64/conf/GENERIC	Fri May  9 03:52:10 2014	(r265729)
@@ -82,6 +82,8 @@ device		ahd		# AHA39320/29320 and AIC79x
 device		hptiop		# Highpoint RocketRaid 3xxx series
 device		isp		# Qlogic family
 device		mpt		# LSI-Logic MPT-Fusion
+device		mps		# LSI-Logic MPT-Fusion 2
+device		mpr		# LSI-Logic MPT-Fusion 3
 device		sym		# NCR/Symbios Logic
 
 # RAID controllers interfaced to the SCSI subsystem

Modified: stable/9/sys/mips/conf/OCTEON1
==============================================================================
--- stable/9/sys/mips/conf/OCTEON1	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/mips/conf/OCTEON1	Fri May  9 03:52:10 2014	(r265729)
@@ -120,6 +120,7 @@ device		isp		# Qlogic family
 #device		ispfw		# Firmware for QLogic HBAs- normally a module
 device		mpt		# LSI-Logic MPT-Fusion
 device		mps		# LSI-Logic MPT-Fusion 2
+device		mpr		# LSI-Logic MPT-Fusion 3
 #device		ncr		# NCR/Symbios Logic
 device		trm		# Tekram DC395U/UW/F DC315U adapters
 

Modified: stable/9/sys/modules/Makefile
==============================================================================
--- stable/9/sys/modules/Makefile	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/modules/Makefile	Fri May  9 03:52:10 2014	(r265729)
@@ -209,6 +209,7 @@ SUBDIR=	\
 	${_mly} \
 	mmc \
 	mmcsd \
+	mpr \
 	mps \
 	mpt \
 	mqueue \

Modified: stable/9/sys/sparc64/conf/GENERIC
==============================================================================
--- stable/9/sys/sparc64/conf/GENERIC	Fri May  9 01:30:15 2014	(r265728)
+++ stable/9/sys/sparc64/conf/GENERIC	Fri May  9 03:52:10 2014	(r265729)
@@ -97,6 +97,7 @@ device		isp		# Qlogic family
 device		ispfw		# Firmware module for Qlogic host adapters
 device		mpt		# LSI-Logic MPT-Fusion
 device		mps		# LSI-Logic MPT-Fusion 2
+device		mpr		# LSI-Logic MPT-Fusion 3
 device		sym		# NCR/Symbios/LSI Logic 53C8XX/53C1010/53C1510D
 
 # ATA/SCSI peripherals



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