From 5134a99ff3a5cff1ebc003e0510a8c8f7e2fc791 Mon Sep 17 00:00:00 2001 From: stsp Date: Wed, 30 Jun 2021 09:47:20 +0000 Subject: [PATCH] Make the iwx(4) mac context task send its command only if we are still in RUN state when the task gets to run. Fixes fatal firmware errors where mac context updates were erroneously sent in states other than RUN state. Additionally, avoid scheduling a mac context task if a pending newstate task is going to move us out of RUN state anyway. Issue debugged by zxystd in OpenIntelWireless itlwm; patch by me. --- sys/dev/pci/if_iwx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index 8761374945f..6d8c82c6129 100644 --- a/sys/dev/pci/if_iwx.c +++ b/sys/dev/pci/if_iwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwx.c,v 1.60 2021/06/30 09:46:46 stsp Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.61 2021/06/30 09:47:20 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -2947,7 +2947,8 @@ iwx_mac_ctxt_task(void *arg) struct iwx_node *in = (void *)ic->ic_bss; int err, s = splnet(); - if (sc->sc_flags & IWX_FLAG_SHUTDOWN) { + if ((sc->sc_flags & IWX_FLAG_SHUTDOWN) || + ic->ic_state != IEEE80211_S_RUN) { refcnt_rele_wake(&sc->task_refs); splx(s); return; @@ -2966,7 +2967,8 @@ iwx_updateprot(struct ieee80211com *ic) { struct iwx_softc *sc = ic->ic_softc; - if (ic->ic_state == IEEE80211_S_RUN) + if (ic->ic_state == IEEE80211_S_RUN && + !task_pending(&sc->newstate_task)) iwx_add_task(sc, systq, &sc->mac_ctxt_task); } @@ -2975,7 +2977,8 @@ iwx_updateslot(struct ieee80211com *ic) { struct iwx_softc *sc = ic->ic_softc; - if (ic->ic_state == IEEE80211_S_RUN) + if (ic->ic_state == IEEE80211_S_RUN && + !task_pending(&sc->newstate_task)) iwx_add_task(sc, systq, &sc->mac_ctxt_task); } @@ -2984,7 +2987,8 @@ iwx_updateedca(struct ieee80211com *ic) { struct iwx_softc *sc = ic->ic_softc; - if (ic->ic_state == IEEE80211_S_RUN) + if (ic->ic_state == IEEE80211_S_RUN && + !task_pending(&sc->newstate_task)) iwx_add_task(sc, systq, &sc->mac_ctxt_task); } -- 2.20.1