Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Oct 2007 08:06:32 GMT
From:      Kevin Lo <kevlo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 127300 for review
Message-ID:  <200710080806.l9886WhV081052@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=127300

Change 127300 by kevlo@kevlo_rtsl on 2007/10/08 08:05:43

	Passed in the MTX_RECURSE argument of mtx_init(). 
	This fixes a potential kernel panic problem after configuring a 
	bwi interface.

Affected files ...

.. //depot/projects/wifi/sys/dev/bwi/bwirf.c#3 edit
.. //depot/projects/wifi/sys/dev/bwi/if_bwi.c#4 edit
.. //depot/projects/wifi/sys/dev/bwi/if_bwi_pci.c#3 edit
.. //depot/projects/wifi/sys/dev/bwi/if_bwivar.h#3 edit

Differences ...

==== //depot/projects/wifi/sys/dev/bwi/bwirf.c#3 (text+ko) ====

@@ -358,6 +358,7 @@
 		0x0810, 0x002b, 0x0015
 	};
 
+	struct bwi_softc *sc = mac->mac_sc;
 	struct bwi_phy *phy = &mac->mac_phy;
 	struct bwi_rf *rf = &mac->mac_rf;
 	uint16_t save_phy[SAVE_PHY_MAX];
@@ -425,7 +426,7 @@
 	PHY_SETBITS(mac, 0x811, 0x100);
 	PHY_CLRBITS(mac, 0x812, 0x3000);
 
-	if ((mac->mac_sc->sc_card_flags & BWI_CARD_F_EXT_LNA) &&
+	if ((sc->sc_card_flags & BWI_CARD_F_EXT_LNA) &&
 	    phy->phy_rev >= 7) {
 		PHY_SETBITS(mac, 0x811, 0x800);
 		PHY_SETBITS(mac, 0x812, 0x8000);

==== //depot/projects/wifi/sys/dev/bwi/if_bwi.c#4 (text+ko) ====

@@ -285,6 +285,8 @@
 	struct bwi_phy *phy;
 	int i, error, bands;
 
+	BWI_LOCK_INIT(sc);
+
 	bwi_power_on(sc, 1);
 
 	error = bwi_bbp_attach(sc);
@@ -459,10 +461,10 @@
 	if (bootverbose)
 		ieee80211_announce(ic);
 
-	return 0;
+	return (0);
 fail:
-	bwi_detach(sc);
-	return error;
+	BWI_LOCK_DESTROY(sc);
+	return (error);
 }
 
 int

==== //depot/projects/wifi/sys/dev/bwi/if_bwi_pci.c#3 (text+ko) ====

@@ -194,13 +194,10 @@
 	sc->sc_pci_subvid = pci_get_subvendor(dev);
 	sc->sc_pci_subdid = pci_get_subdevice(dev);
 
-	BWI_LOCK_INIT(sc);
-
 	error = bwi_attach(sc);
 	if (error == 0)					/* success */
 		return 0;
 
-	BWI_LOCK_DESTROY(sc);
 	bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_irq_handle);
 bad2:
 	bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
@@ -227,8 +224,6 @@
 
 	bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, sc->sc_mem_res);
 
-	BWI_LOCK_DESTROY(sc);
-
 	return (0);
 }
 

==== //depot/projects/wifi/sys/dev/bwi/if_bwivar.h#3 (text+ko) ====

@@ -590,10 +590,9 @@
 #define BWI_F_BUS_INITED	0x1
 #define BWI_F_PROMISC		0x2
 
-#define	BWI_LOCK_INIT(sc) do { \
+#define	BWI_LOCK_INIT(sc) \
 	mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->sc_dev), \
-	    MTX_NETWORK_LOCK, MTX_DEF); \
-} while (0)
+	    MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);
 #define	BWI_LOCK_DESTROY(sc)	mtx_destroy(&(sc)->sc_mtx)
 #define	BWI_LOCK(sc)	mtx_lock(&sc->sc_mtx)
 #define	BWI_UNLOCK(sc)	mtx_unlock(&sc->sc_mtx)



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