diff options
-rw-r--r-- | sys/dev/pci/if_ipw.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/if_ipwvar.h | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_iwi.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/if_iwivar.h | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_iwn.c | 28 | ||||
-rw-r--r-- | sys/dev/pci/if_iwnvar.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/if_wpi.c | 28 | ||||
-rw-r--r-- | sys/dev/pci/if_wpivar.h | 4 |
8 files changed, 44 insertions, 94 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index f47b220afb5..c9a0ed2c144 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipw.c,v 1.115 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.116 2016/09/05 08:17:29 tedu Exp $ */ /*- * Copyright (c) 2004-2008 @@ -28,6 +28,7 @@ #include <sys/task.h> #include <sys/mbuf.h> #include <sys/kernel.h> +#include <sys/rwlock.h> #include <sys/socket.h> #include <sys/systm.h> #include <sys/conf.h> @@ -203,6 +204,7 @@ ipw_attach(struct device *parent, struct device *self, void *aux) } printf(": %s", intrstr); + rw_init(&sc->sc_rwlock, "ipwlock"); task_set(&sc->sc_scantask, ipw_scan, sc); task_set(&sc->sc_authandassoctask, ipw_auth_and_assoc, sc); @@ -318,17 +320,14 @@ ipw_wakeup(struct ipw_softc *sc) data &= ~0x0000ff00; pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); + rw_enter_write(&sc->sc_rwlock); s = splnet(); - while (sc->sc_flags & IPW_FLAG_BUSY) - tsleep(&sc->sc_flags, PZERO, "ipwpwr", 0); - sc->sc_flags |= IPW_FLAG_BUSY; if (ifp->if_flags & IFF_UP) ipw_init(ifp); - sc->sc_flags &= ~IPW_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); } int @@ -1359,18 +1358,10 @@ ipw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr; int s, error = 0; - s = splnet(); - /* - * Prevent processes from entering this function while another - * process is tsleep'ing in it. - */ - while ((sc->sc_flags & IPW_FLAG_BUSY) && error == 0) - error = tsleep(&sc->sc_flags, PCATCH, "ipwioc", 0); - if (error != 0) { - splx(s); + error = rw_enter(&sc->sc_rwlock, RW_ENTER | RW_INTR); + if (error) return error; - } - sc->sc_flags |= IPW_FLAG_BUSY; + s = splnet(); switch (cmd) { case SIOCSIFADDR: @@ -1419,9 +1410,8 @@ ipw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = 0; } - sc->sc_flags &= ~IPW_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); return error; } @@ -1483,8 +1473,6 @@ ipw_stop_master(struct ipw_softc *sc) tmp = CSR_READ_4(sc, IPW_CSR_RST); CSR_WRITE_4(sc, IPW_CSR_RST, tmp | IPW_RST_PRINCETON_RESET); - - sc->sc_flags &= ~IPW_FLAG_FW_INITED; } int @@ -2004,7 +1992,6 @@ ipw_init(struct ifnet *ifp) printf("%s: could not load firmware\n", sc->sc_dev.dv_xname); goto fail2; } - sc->sc_flags |= IPW_FLAG_FW_INITED; free(fw.data, M_DEVBUF, fw.size); fw.data = NULL; diff --git a/sys/dev/pci/if_ipwvar.h b/sys/dev/pci/if_ipwvar.h index 8d01e4dab89..bef0fff5f23 100644 --- a/sys/dev/pci/if_ipwvar.h +++ b/sys/dev/pci/if_ipwvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipwvar.h,v 1.25 2015/09/01 07:09:55 deraadt Exp $ */ +/* $OpenBSD: if_ipwvar.h,v 1.26 2016/09/05 08:17:29 tedu Exp $ */ /*- * Copyright (c) 2004-2006 @@ -82,9 +82,7 @@ struct ipw_softc { int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int); - uint32_t sc_flags; -#define IPW_FLAG_FW_INITED (1 << 0) -#define IPW_FLAG_BUSY (1 << 1) + struct rwlock sc_rwlock; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index 4b81e4bf964..a2c2d24d76c 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwi.c,v 1.132 2016/04/13 10:34:32 mpi Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.133 2016/09/05 08:17:48 tedu Exp $ */ /*- * Copyright (c) 2004-2008 @@ -27,6 +27,7 @@ #include <sys/sockio.h> #include <sys/mbuf.h> #include <sys/kernel.h> +#include <sys/rwlock.h> #include <sys/socket.h> #include <sys/systm.h> #include <sys/conf.h> @@ -317,6 +318,7 @@ iwi_attach(struct device *parent, struct device *self, void *aux) sc->sc_txtap.wt_ihdr.it_present = htole32(IWI_TX_RADIOTAP_PRESENT); #endif + rw_init(&sc->sc_rwlock, "iwilock"); task_set(&sc->init_task, iwi_init_task, sc); return; @@ -364,17 +366,14 @@ iwi_init_task(void *arg1) struct ifnet *ifp = &sc->sc_ic.ic_if; int s; + rw_enter_write(&sc->sc_rwlock); s = splnet(); - while (sc->sc_flags & IWI_FLAG_BUSY) - tsleep(&sc->sc_flags, 0, "iwipwr", 0); - sc->sc_flags |= IWI_FLAG_BUSY; if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_UP) iwi_init(ifp); - sc->sc_flags &= ~IWI_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); } int @@ -1451,18 +1450,10 @@ iwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr; int s, error = 0; - s = splnet(); - /* - * Prevent processes from entering this function while another - * process is tsleep'ing in it. - */ - while ((sc->sc_flags & IWI_FLAG_BUSY) && error == 0) - error = tsleep(&sc->sc_flags, PCATCH, "iwiioc", 0); - if (error != 0) { - splx(s); + error = rw_enter(&sc->sc_rwlock, RW_WRITE | RW_INTR); + if (error) return error; - } - sc->sc_flags |= IWI_FLAG_BUSY; + s = splnet(); switch (cmd) { case SIOCSIFADDR: @@ -1511,9 +1502,8 @@ iwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = 0; } - sc->sc_flags &= ~IWI_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); return error; } @@ -1539,8 +1529,6 @@ iwi_stop_master(struct iwi_softc *sc) tmp = CSR_READ_4(sc, IWI_CSR_RST); CSR_WRITE_4(sc, IWI_CSR_RST, tmp | IWI_RST_PRINCETON_RESET); - - sc->sc_flags &= ~IWI_FLAG_FW_INITED; } int @@ -2282,7 +2270,6 @@ iwi_init(struct ifnet *ifp) } free(data, M_DEVBUF, size); - sc->sc_flags |= IWI_FLAG_FW_INITED; if ((error = iwi_config(sc)) != 0) { printf("%s: device configuration failed\n", diff --git a/sys/dev/pci/if_iwivar.h b/sys/dev/pci/if_iwivar.h index 1ca82c0c444..610014854c8 100644 --- a/sys/dev/pci/if_iwivar.h +++ b/sys/dev/pci/if_iwivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwivar.h,v 1.25 2013/12/03 22:37:24 kettenis Exp $ */ +/* $OpenBSD: if_iwivar.h,v 1.26 2016/09/05 08:17:48 tedu Exp $ */ /*- * Copyright (c) 2004-2006 @@ -91,9 +91,7 @@ struct iwi_softc { int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int); - uint32_t sc_flags; -#define IWI_FLAG_FW_INITED (1 << 0) -#define IWI_FLAG_BUSY (1 << 1) + struct rwlock sc_rwlock; bus_dma_tag_t sc_dmat; diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index 2cf24b227db..2603661f19d 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.171 2016/09/02 17:10:48 stsp Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.172 2016/09/05 08:18:18 tedu Exp $ */ /*- * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -27,6 +27,7 @@ #include <sys/sockio.h> #include <sys/mbuf.h> #include <sys/kernel.h> +#include <sys/rwlock.h> #include <sys/socket.h> #include <sys/systm.h> #include <sys/malloc.h> @@ -537,6 +538,7 @@ iwn_attach(struct device *parent, struct device *self, void *aux) iwn_radiotap_attach(sc); #endif timeout_set(&sc->calib_to, iwn_calib_timeout, sc); + rw_init(&sc->sc_rwlock, "iwnlock"); task_set(&sc->init_task, iwn_init_task, sc); return; @@ -776,17 +778,14 @@ iwn_init_task(void *arg1) struct ifnet *ifp = &sc->sc_ic.ic_if; int s; + rw_enter_write(&sc->sc_rwlock); s = splnet(); - while (sc->sc_flags & IWN_FLAG_BUSY) - tsleep(&sc->sc_flags, 0, "iwnpwr", 0); - sc->sc_flags |= IWN_FLAG_BUSY; if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_UP) iwn_init(ifp); - sc->sc_flags &= ~IWN_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); } int @@ -3212,18 +3211,10 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr; int s, error = 0; - s = splnet(); - /* - * Prevent processes from entering this function while another - * process is tsleep'ing in it. - */ - while ((sc->sc_flags & IWN_FLAG_BUSY) && error == 0) - error = tsleep(&sc->sc_flags, PCATCH, "iwnioc", 0); - if (error != 0) { - splx(s); + error = rw_enter(&sc->sc_rwlock, RW_WRITE | RW_INTR); + if (error) return error; - } - sc->sc_flags |= IWN_FLAG_BUSY; + s = splnet(); switch (cmd) { case SIOCSIFADDR: @@ -3279,9 +3270,8 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } } - sc->sc_flags &= ~IWN_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); return error; } diff --git a/sys/dev/pci/if_iwnvar.h b/sys/dev/pci/if_iwnvar.h index 55f5fcb1dc6..fe8b325300e 100644 --- a/sys/dev/pci/if_iwnvar.h +++ b/sys/dev/pci/if_iwnvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwnvar.h,v 1.30 2016/01/05 18:41:15 stsp Exp $ */ +/* $OpenBSD: if_iwnvar.h,v 1.31 2016/09/05 08:18:18 tedu Exp $ */ /*- * Copyright (c) 2007, 2008 @@ -190,13 +190,13 @@ struct iwn_softc { bus_dma_tag_t sc_dmat; + struct rwlock sc_rwlock; u_int sc_flags; #define IWN_FLAG_HAS_5GHZ (1 << 0) #define IWN_FLAG_HAS_OTPROM (1 << 1) #define IWN_FLAG_CALIB_DONE (1 << 2) #define IWN_FLAG_USE_ICT (1 << 3) #define IWN_FLAG_INTERNAL_PA (1 << 4) -#define IWN_FLAG_BUSY (1 << 5) #define IWN_FLAG_HAS_11N (1 << 6) #define IWN_FLAG_ENH_SENS (1 << 7) #define IWN_FLAG_ADV_BT_COEX (1 << 8) diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 712b69fff9c..6d8337da438 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.134 2016/08/17 11:08:08 stsp Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.135 2016/09/05 08:18:40 tedu Exp $ */ /*- * Copyright (c) 2006-2008 @@ -27,6 +27,7 @@ #include <sys/sockio.h> #include <sys/mbuf.h> #include <sys/kernel.h> +#include <sys/rwlock.h> #include <sys/socket.h> #include <sys/systm.h> #include <sys/malloc.h> @@ -323,6 +324,7 @@ wpi_attach(struct device *parent, struct device *self, void *aux) wpi_radiotap_attach(sc); #endif timeout_set(&sc->calib_to, wpi_calib_timeout, sc); + rw_init(&sc->sc_rwlock, "wpilock"); task_set(&sc->init_task, wpi_init_task, sc); return; @@ -421,17 +423,14 @@ wpi_init_task(void *arg1) struct ifnet *ifp = &sc->sc_ic.ic_if; int s; + rw_enter_write(&sc->sc_rwlock); s = splnet(); - while (sc->sc_flags & WPI_FLAG_BUSY) - tsleep(&sc->sc_flags, 0, "wpipwr", 0); - sc->sc_flags |= WPI_FLAG_BUSY; if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_UP) wpi_init(ifp); - sc->sc_flags &= ~WPI_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); } int @@ -1968,18 +1967,10 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ifreq *ifr; int s, error = 0; - s = splnet(); - /* - * Prevent processes from entering this function while another - * process is tsleep'ing in it. - */ - while ((sc->sc_flags & WPI_FLAG_BUSY) && error == 0) - error = tsleep(&sc->sc_flags, PCATCH, "wpiioc", 0); - if (error != 0) { - splx(s); + error = rw_enter(&sc->sc_rwlock, RW_WRITE | RW_INTR); + if (error) return error; - } - sc->sc_flags |= WPI_FLAG_BUSY; + s = splnet(); switch (cmd) { case SIOCSIFADDR: @@ -2034,9 +2025,8 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } } - sc->sc_flags &= ~WPI_FLAG_BUSY; - wakeup(&sc->sc_flags); splx(s); + rw_exit_write(&sc->sc_rwlock); return error; } diff --git a/sys/dev/pci/if_wpivar.h b/sys/dev/pci/if_wpivar.h index 22a0f4f6126..755f2c16ac9 100644 --- a/sys/dev/pci/if_wpivar.h +++ b/sys/dev/pci/if_wpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpivar.h,v 1.25 2013/11/28 20:07:32 kettenis Exp $ */ +/* $OpenBSD: if_wpivar.h,v 1.26 2016/09/05 08:18:40 tedu Exp $ */ /*- * Copyright (c) 2006-2008 @@ -140,9 +140,9 @@ struct wpi_softc { bus_dma_tag_t sc_dmat; + struct rwlock sc_rwlock; u_int sc_flags; #define WPI_FLAG_HAS_5GHZ (1 << 0) -#define WPI_FLAG_BUSY (1 << 1) /* Shared area. */ struct wpi_dma_info shared_dma; |