Re: Problem with firewire disks with recent -CURRENT.

From: Richard Todd <rmtodd_at_servalan.servalan.com>
Date: Tue, 07 May 2013 19:21:02 -0500
rmtodd_at_servalan.servalan.com writes:

> Tried upgrading one of my machines to -CURRENT yesterday and got the 
> following panic when the sbp code did its probing of all the firewire 
> devices:

> panic: mutex sbp not owned at /usr/src/sys/cam/cam_xpt.c:4549
> cpuid = 0
> KDB: stack backtrace:
> db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffff81fe6837f0
> kdb_backtrace() at kdb_backtrace+0x39/frame 0xffffff81fe6838a0
> vpanic() at vpanic+0x126/frame 0xffffff81fe6838e0
> panic() at panic+0x43/frame 0xffffff81fe683940
> __mtx_assert() at __mtx_assert+0xc2/frame 0xffffff81fe683950
> xpt_compile_path() at xpt_compile_path+0xa1/frame 0xffffff81fe6839a0
> xpt_create_path() at xpt_create_path+0x5b/frame 0xffffff81fe6839f0
> sbp_do_attach() at sbp_do_attach+0xe8/frame 0xffffff81fe683a30

I did some further poking around in the source code trying to figure out what
went on here.  Looks to me like in the current version of xpt_find_target()
(called by xpt_compile_path() and hence, indirectly, by xpt_create_path() )
the code expects the SIM's mutex to be owned, but apparently the call from
the sbp_do_attach happens without the SIM mutex being locked.  I tried hacking
together the following patch and the resulting kernel comes up and lets the
system properly detect the drives and do I/O to them.  I don't know enough
about the CAM system and its locking to know if this patch is the Right 
Thing to do here, though.

diff -r 96ce948dd944 sys/dev/firewire/sbp.c
--- a/sys/dev/firewire/sbp.c	Sat May 04 17:23:33 2013 -0500
+++ b/sys/dev/firewire/sbp.c	Tue May 07 19:17:28 2013 -0500
_at__at_ -1085,10 +1085,13 _at__at_
 END_DEBUG
 	sbp_xfer_free(xfer);
 
-	if (sdev->path == NULL)
+        if (sdev->path == NULL) {
+	        CAM_SIM_LOCK(target->sbp->sim);
 		xpt_create_path(&sdev->path, NULL,
 			cam_sim_path(target->sbp->sim),
 			target->target_id, sdev->lun_id);
+                CAM_SIM_UNLOCK(target->sbp->sim);
+	}
 
 	/*
 	 * Let CAM scan the bus if we are in the boot process.
Received on Tue May 07 2013 - 22:30:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:37 UTC