Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Feb 2014 21:48:34 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262575 - head/sys/dev/mps
Message-ID:  <201402272148.s1RLmYVS094638@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Feb 27 21:48:34 2014
New Revision: 262575
URL: http://svnweb.freebsd.org/changeset/base/262575

Log:
  Restore SIM freeze/release match, broken at r253549.
  
  This fixes problem with SIM left in frozen state after reinit, for example,
  after firmware update.
  
  MFC after:	1 week

Modified:
  head/sys/dev/mps/mps_sas.c

Modified: head/sys/dev/mps/mps_sas.c
==============================================================================
--- head/sys/dev/mps/mps_sas.c	Thu Feb 27 21:47:20 2014	(r262574)
+++ head/sys/dev/mps/mps_sas.c	Thu Feb 27 21:48:34 2014	(r262575)
@@ -180,6 +180,9 @@ mpssas_startup_increment(struct mpssas_s
 			/* just starting, freeze the simq */
 			mps_dprint(sassc->sc, MPS_INIT,
 			    "%s freezing simq\n", __func__);
+#if __FreeBSD_version >= 1000039
+			xpt_hold_boot();
+#endif
 			xpt_freeze_simq(sassc->sim, 1);
 		}
 		mps_dprint(sassc->sc, MPS_INIT, "%s refcount %u\n", __func__,
@@ -200,10 +203,10 @@ mpssas_startup_decrement(struct mpssas_s
 			mps_dprint(sassc->sc, MPS_INIT,
 			    "%s releasing simq\n", __func__);
 			sassc->flags &= ~MPSSAS_IN_STARTUP;
+			xpt_release_simq(sassc->sim, 1);
 #if __FreeBSD_version >= 1000039
 			xpt_release_boot();
 #else
-			xpt_release_simq(sassc->sim, 1);
 			mpssas_rescan_target(sassc->sc, NULL);
 #endif
 		}
@@ -763,12 +766,8 @@ mps_attach_sas(struct mps_softc *sc)
 	 * Hold off boot until discovery is complete.
 	 */
 	sassc->flags |= MPSSAS_IN_STARTUP | MPSSAS_IN_DISCOVERY;
-#if __FreeBSD_version >= 1000039
-	xpt_hold_boot();
-#else
-	xpt_freeze_simq(sassc->sim, 1);
-#endif
 	sc->sassc->startup_refcount = 0;
+	mpssas_startup_increment(sassc);
 
 	callout_init(&sassc->discovery_callout, 1 /*mpsafe*/);
 	sassc->discovery_timeouts = 0;
@@ -1139,7 +1138,7 @@ mpssas_handle_reinit(struct mps_softc *s
 	mps_dprint(sc, MPS_INIT, "%s startup\n", __func__);
 	sc->sassc->flags |= MPSSAS_IN_STARTUP;
 	sc->sassc->flags |= MPSSAS_IN_DISCOVERY;
-	xpt_freeze_simq(sc->sassc->sim, 1);
+	mpssas_startup_increment(sc->sassc);
 
 	/* notify CAM of a bus reset */
 	mpssas_announce_reset(sc, AC_BUS_RESET, CAM_TARGET_WILDCARD, 
@@ -1152,12 +1151,6 @@ mpssas_handle_reinit(struct mps_softc *s
 	    "%s startup %u tm %u after command completion\n",
 	    __func__, sc->sassc->startup_refcount, sc->sassc->tm_count);
 
-	/*
-	 * The simq was explicitly frozen above, so set the refcount to 0.
-	 * The simq will be explicitly released after port enable completes.
-	 */
-	sc->sassc->startup_refcount = 0;
-
 	/* zero all the target handles, since they may change after the
 	 * reset, and we have to rediscover all the targets and use the new
 	 * handles.  
@@ -3461,15 +3454,12 @@ mpssas_read_cap_done(struct cam_periph *
 int
 mpssas_startup(struct mps_softc *sc)
 {
-	struct mpssas_softc *sassc;
 
 	/*
 	 * Send the port enable message and set the wait_for_port_enable flag.
 	 * This flag helps to keep the simq frozen until all discovery events
 	 * are processed.
 	 */
-	sassc = sc->sassc;
-	mpssas_startup_increment(sassc);
 	sc->wait_for_port_enable = 1;
 	mpssas_send_portenable(sc);
 	return (0);
@@ -3554,7 +3544,6 @@ mpssas_portenable_complete(struct mps_so
 	sc->port_enable_complete = 1;
 	wakeup(&sc->port_enable_complete);
 	mpssas_startup_decrement(sassc);
-	xpt_release_simq(sassc->sim, 1);
 }
 
 int



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