Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Oct 2007 13:21:37 -0600
From:      Scott Long <scottl@samsco.org>
To:        Steven Brown <freebsd-questions@stellablue.org>, Ed Maste <emaste@freebsd.org>
Cc:        "Leubner, Achim" <Achim_Leubner@adaptec.com>, freebsd-current@freebsd.org
Subject:   Re: Panic: mutex Giant not owned cam_xpt.c :4799
Message-ID:  <471F9B41.5080100@samsco.org>
In-Reply-To: <47091FDE.4060808@stellablue.org>
References:  <47091FDE.4060808@stellablue.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------080705090103080101060807
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Please try the attached patch.  I'm having a hard time reproducing the
problem to validate that it's fixed, but it should be.

Scott


Steven Brown wrote:
> Just decided to try out the 0907 snapshot of -CURRENT (amd64) and it 
> won't boot off the install CD
> 
> Thought I would post as much info as I could for interested parties. I 
> have to copy by hand, so I will try to include as much as I can.
> 
> panic: mutex Giant not owned at /usr/src/sys/cam/cam_xpt.c :4799
> 
> This error occurs right after "md0: Preloaded image </boot/mfsroot> ....
> 
> The motherboard is an Asus P5M2-R, with dual bge ethernets (on mb), a 
> Adaptec 3405 SATA/SAS RAID PCI-e  card (aac driver), and has an Intel 
> Q6600 quad core. 4GB of RAM. You will soon see why I included the 
> information on the Adaptec card.
> 
> This hardware works fine using 6.2-RELEASE p8 -- well, at least i386 
> does. This system has a modified src/sys/dev/aac which includes the 
> vendor ID info for the 3405/3805 cards and has no problems booting (and 
> running), detecting Adaptec card, etc.
> 
> I also have a CD with the same snapshot (CURRENT, 0907) in an i386 
> version (not AMD64) which appears to produce the same error.
> 
> Upon the panic, the system entered the debugger and I typed "trace" to 
> get the following from AMD64 snapshot:
> 
> Tracing pid 26 tid 100026 td 0xffffff0002245680
> kdb_enter() at kdb_enter+0x31
> panic() at panic+0x173
> _mtx_assert() at _mtx_assert+0xd6
> xpt_release_simq() at xpt_release_simq()+0x27
> aac_alloc_commands() at aac_alloc_commands()+0x156
> aac_command_thread() at aac_command_thread()+0xe5
> fork_exit() at fork_exit+0x12a
> fork_trampoline() at fork_trampoline()+0xe
> --- trap 0, rip = 0, rsp = 0xffffffffac6fdd30, rbp = 0 ---
> 
> 
> Hope this helps someone,
> 
> Steve
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"


--------------080705090103080101060807
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
	name="aacp_mpsafe.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="aacp_mpsafe.diff"

Index: aac_cam.c
===================================================================
RCS file: /usr/ncvs/src/sys/dev/aac/aac_cam.c,v
retrieving revision 1.28
diff -u -r1.28 aac_cam.c
--- aac_cam.c	17 Jun 2007 05:55:45 -0000	1.28
+++ aac_cam.c	24 Oct 2007 19:20:13 -0000
@@ -131,19 +131,19 @@
 static int
 aac_cam_detach(device_t dev)
 {
+	struct aac_softc *sc;
 	struct aac_cam *camsc;
 	debug_called(2);
 
 	camsc = (struct aac_cam *)device_get_softc(dev);
+	sc = camsc->inf->aac_sc;
 
-	mtx_lock(&Giant);
-
+	mtx_lock(&sc->aac_io_lock);
 	xpt_async(AC_LOST_DEVICE, camsc->path, NULL);
 	xpt_free_path(camsc->path);
 	xpt_bus_deregister(cam_sim_path(camsc->sim));
 	cam_sim_free(camsc->sim, /*free_devq*/TRUE);
-
-	mtx_unlock(&Giant);
+	mtx_unlock(&sc->aac_io_lock);
 
 	return (0);
 }
@@ -171,15 +171,17 @@
 		return (EIO);
 
 	sim = cam_sim_alloc(aac_cam_action, aac_cam_poll, "aacp", camsc,
-	    device_get_unit(dev), &Giant, 1, 1, devq);
+	    device_get_unit(dev), &inf->aac_sc->aac_io_lock, 1, 1, devq);
 	if (sim == NULL) {
 		cam_simq_free(devq);
 		return (EIO);
 	}
 
 	/* Since every bus has it's own sim, every bus 'appears' as bus 0 */
+	mtx_lock(&inf->aac_sc->aac_io_lock);
 	if (xpt_bus_register(sim, dev, 0) != CAM_SUCCESS) {
 		cam_sim_free(sim, TRUE);
+		mtx_unlock(&inf->aac_sc->aac_io_lock);
 		return (EIO);
 	}
 
@@ -187,11 +189,14 @@
 	    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 		xpt_bus_deregister(cam_sim_path(sim));
 		cam_sim_free(sim, TRUE);
+		mtx_unlock(&inf->aac_sc->aac_io_lock);
 		return (EIO);
 	}
+	mtx_unlock(&inf->aac_sc->aac_io_lock);
 
 	camsc->sim = sim;
 	camsc->path = path;
+	camsc->devq = devq;
 
 	return (0);
 }
@@ -321,7 +326,6 @@
 
 	/* Async ops that require communcation with the controller */
 
-	mtx_lock(&sc->aac_io_lock);
 	if (aac_alloc_command(sc, &cm)) {
 		struct aac_event *event;
 
@@ -333,15 +337,12 @@
 		if (event == NULL) {
 			device_printf(sc->aac_dev,
 			    "Warning, out of memory for event\n");
-			/* XXX Yuck, what to do here? */
-			mtx_unlock(&sc->aac_io_lock);
 			return;
 		}
 		event->ev_callback = aac_cam_event;
 		event->ev_arg = camsc;
 		event->ev_type = AAC_EVENT_CMFREE;
 		aac_add_event(sc, event);
-		mtx_unlock(&sc->aac_io_lock);
 		return;
 	}
 
@@ -429,7 +430,6 @@
 		} else {
 			ccb->ccb_h.status = CAM_REQ_CMP;
 			xpt_done(ccb);
-			mtx_unlock(&sc->aac_io_lock);
 			return;
 		}
 	default:
@@ -460,8 +460,6 @@
 	aac_enqueue_ready(cm);
 	aac_startio(cm->cm_sc);
 
-	mtx_unlock(&sc->aac_io_lock);
-
 	return;
 }
 
@@ -565,7 +563,6 @@
 		return (CAM_REQ_ABORTED);
 	}
 
-	mtx_lock(&sc->aac_io_lock);
 	aac_alloc_sync_fib(sc, &fib);
 
 	vmi = (struct aac_vmioctl *)&fib->data[0];
@@ -586,12 +583,10 @@
 		device_printf(sc->aac_dev,"Error %d sending ResetBus command\n",
 		    e);
 		aac_release_sync_fib(sc);
-		mtx_unlock(&sc->aac_io_lock);
 		return (CAM_REQ_ABORTED);
 	}
 
 	aac_release_sync_fib(sc);
-	mtx_unlock(&sc->aac_io_lock);
 	return (CAM_REQ_CMP);
 }
 

--------------080705090103080101060807--



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