[PATCH] nve(4) locking cleanup

John Baldwin jhb at freebsd.org
Thu Nov 17 08:04:49 PST 2005


On Thursday 17 November 2005 08:46 am, David Xu wrote:
> John Baldwin wrote:
> >I have a patch for nve(4) which fixes at least one known LOR in the driver
> > and generally fixes up the locking.  If you have an nve(4) card that
> > currently works, please test this patch to make sure it doesn't break
> > anything.  If you have an nve(4) card that doesn't work, this patch
> > probably won't help.
> >
> >http://www.FreeBSD.org/~jhb/patches/nve_locking.patch
>
> After this patch is applied, I got:
> nve0: <NVIDIA nForce MCP7 Networking Adapter> port 0xb400-0xb407 mem
> 0xec000000-0xec000fff irq 20 at device 5.0 on pci0
> nve0: nve_oslockacquire: normal mutex not held
> nve0: nve_oslockrelease: normal mutex not held

Ah, I think I messsed up the conditional for this when I added the sc->dead 
checks.  I'll update the patch in a second.  These warnings aren't a problem 
during attach before ether_ifattach() and bus_setup_intr() or after 
ether_ifdetach() in detach.  Here's the relevant diff to the old patch:

--- //depot/user/jhb/acpipci/dev/nve/if_nve.c
+++ /home/john/work/p4/acpipci/dev/nve/if_nve.c
@@ -1726,7 +1726,7 @@
 
 	DEBUGOUT(NVE_DEBUG_LOCK, "nve: nve_oslockacquire\n");
 
-	if (!mtx_owned(&sc->mtx) && !device_is_attached(sc->dev) && !sc->dead)
+	if (!mtx_owned(&sc->mtx) && device_is_attached(sc->dev) && !sc->dead)
 		device_printf(sc->dev, "%s: normal mutex not held\n", __func__);
 	NVE_OSLOCK((struct nve_softc *)lock);
 
@@ -1742,7 +1742,7 @@
 	DEBUGOUT(NVE_DEBUG_LOCK, "nve: nve_oslockrelease\n");
 
 	NVE_OSUNLOCK((struct nve_softc *)lock);
-	if (!mtx_owned(&sc->mtx) && !device_is_attached(sc->dev) && !sc->dead)
+	if (!mtx_owned(&sc->mtx) && device_is_attached(sc->dev) && !sc->dead)
 		device_printf(sc->dev, "%s: normal mutex not held\n", __func__);
 
 	return (1);

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-current mailing list