Bug #1810
closedconvert iwi(4) to use wlan_token
0%
Description
Hi,
the patch below converts iwi(4) to use the new wlan_token for locking.
This is more or less copied from iwn(4).
I'm not sure if the comment in iwi_var.h still applies and should be
kept.
Johannes
PS: The patch is only tested on an UP system.
diff --git a/sys/dev/netif/iwi/if_iwi.c b/sys/dev/netif/iwi/if_iwi.c
index 88b8437..7617cc6 100644
--- a/sys/dev/netif/iwi/if_iwi.c
+++ b/sys/dev/netif/iwi/if_iwi.c@ -1743,7 +1743,7
@ iwi_cmd(struct iwi_softc *sc, uint8_t type, void *data, uint8_t len)
sc->cmdq.cur = (sc->cmdq.cur + 1) % IWI_CMD_RING_COUNT;
CSR_WRITE_4(sc, IWI_CSR_CMD_WIDX, sc->cmdq.cur);
- return lksleep(sc, &sc->sc_lock, PINTERLOCKED, "iwicmd", hz);
+ return tsleep(sc, 0, "iwicmd", hz);
}
static void
@ -1979,9 +1979,11
@ iwi_start_locked(struct ifnet *ifp)
static void
iwi_start(struct ifnet *ifp)
{
- struct iwi_softc *sc = ifp->if_softc;
+ struct iwi_softc *sc;
IWI_LOCK_DECL;
+ sc = ifp->if_softc;
+
IWI_LOCK(sc);
iwi_start_locked(ifp);
IWI_UNLOCK(sc);@ -2489,7 +2491,7
@ iwi_load_firmware(struct iwi_softc *sc, const struct iwi_fw *fw)
CSR_WRITE_4(sc, IWI_CSR_CTL, tmp | IWI_CTL_ALLOW_STANDBY);
- error = lksleep(sc, &sc->sc_lock, PINTERLOCKED, "iwiinit", hz);
+ error = tsleep(sc, 0, "iwiinit", hz);
if (error != 0) {
device_printf(sc->sc_dev, "timeout waiting for firmware "
"initialization to complete\n");
diff --git a/sys/dev/netif/iwi/if_iwivar.h b/sys/dev/netif/iwi/if_iwivar.h
index 5e78be9..c2184a8 100644
--- a/sys/dev/netif/iwi/if_iwivar.h
+++ b/sys/dev/netif/iwi/if_iwivar.h
@ -243,14 +243,9
@ struct iwi_softc {
- NB.: This models the only instance of async locking in iwi_init_locked
- and must be kept in sync.
*/#define IWI_LOCK_INIT(sc) \lockinit(&(sc)->sc_lock, \
- __DECONST(char *, device_get_nameunit((sc)->sc_dev)), \
- 0, LK_CANRECURSE)#define IWI_LOCK_DESTROY(sc) lockuninit(&(sc)->sc_lock)
#define IWI_LOCK_DECL#define IWI_LOCK_ASSERT(sc) \KKASSERT->sc_lock, curthread) == LK_EXCLUSIVE)#define IWI_LOCK(sc) lockmgr(&(sc)>sc_lock, LK_EXCLUSIVE)#define IWI_UNLOCK(sc) lockmgr(&(sc)>sc_lock, LK_RELEASE)
#define IWI_LOCK_INIT(_sc)
#define IWI_LOCK(_sc) lwkt_gettoken(&wlan_token)
#define IWI_UNLOCK(_sc) lwkt_reltoken(&wlan_token)
#define IWI_LOCK_DESTROY(_sc)
+#define IWI_LOCK_ASSERT(_sc) ASSERT_LWKT_TOKEN_HELD(&wlan_token)
Updated by josepht1 over 14 years ago
committed, 6419676974c9e4dbbd69917646e74afb98d660a8