From 7ce5ae7fe003dda26756378e35fa5939c06b5d8f Mon Sep 17 00:00:00 2001 From: thorpej Date: Fri, 22 May 2020 20:27:16 +0000 Subject: [PATCH] This driver sleeps during iwm_media_change(), and thus requires an adaptive mutex for the media lock. --- sys/dev/pci/if_iwm.c | 11 ++++++++--- sys/dev/pci/if_iwmvar.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index ac1dffe8469f..3f83d2777374 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwm.c,v 1.84 2020/01/30 06:03:34 thorpej Exp $ */ +/* $NetBSD: if_iwm.c,v 1.85 2020/05/22 20:27:16 thorpej Exp $ */ /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ #define IEEE80211_NO_HT /* @@ -106,7 +106,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.84 2020/01/30 06:03:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.85 2020/05/22 20:27:16 thorpej Exp $"); #include #include @@ -7774,7 +7774,12 @@ iwm_preinit(struct iwm_softc *sc) /* Override 802.11 state transition machine. */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = iwm_newstate; - ieee80211_media_init(ic, iwm_media_change, ieee80211_media_status); + + /* XXX media locking needs revisiting */ + mutex_init(&sc->sc_media_mtx, MUTEX_DEFAULT, IPL_SOFTNET); + ieee80211_media_init_with_lock(ic, + iwm_media_change, ieee80211_media_status, &sc->sc_media_mtx); + ieee80211_announce(ic); iwm_radiotap_attach(sc); diff --git a/sys/dev/pci/if_iwmvar.h b/sys/dev/pci/if_iwmvar.h index 69d04d76e9df..e51025ae5f5f 100644 --- a/sys/dev/pci/if_iwmvar.h +++ b/sys/dev/pci/if_iwmvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwmvar.h,v 1.19 2019/10/05 23:27:20 mrg Exp $ */ +/* $NetBSD: if_iwmvar.h,v 1.20 2020/05/22 20:27:16 thorpej Exp $ */ /* OpenBSD: if_iwmvar.h,v 1.24 2016/09/21 13:53:18 stsp Exp */ /* @@ -499,6 +499,8 @@ struct iwm_softc { struct bpf_if *sc_drvbpf; + kmutex_t sc_media_mtx; /* XXX */ + union { struct iwm_rx_radiotap_header th; uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];