git: 176fd23c88e8 - main - iwm: ensure NIC is alive during txq enable

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Sat, 17 Oct 2026 21:38:07 UTC
The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=176fd23c88e8f7e3736389547c4a2990736911e7

commit 176fd23c88e8f7e3736389547c4a2990736911e7
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2026-10-17 21:32:01 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-10-17 21:32:01 +0000

    iwm: ensure NIC is alive during txq enable
    
    I broke this in a previous commit.  OpenBSD already has the NIC
    nailed alive but FreeBSD's codebase currently does not.
    
    Locally tested:
    
    * 7260, 9260, STA mode
    
    Fixes: 0a12ff65b9647a6e31471e5d27a8692b4adb6803
    
    Differential Revision:  https://reviews.freebsd.org/D60823
---
 sys/dev/iwm/if_iwm.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index 94963c17312c..1bd07fa07102 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -1706,9 +1706,10 @@ iwm_enable_ac_txq(struct iwm_softc *sc, int qid, int fifo)
 {
 	int err;
 
-	if (!sc->cmd_hold_nic_awake) {
-		device_printf(sc->sc_dev, "%s: NIC not awake\n", __func__);
-		return (ENXIO);
+	if (!iwm_nic_lock(sc)) {
+		device_printf(sc->sc_dev, "%s: cannot enable txq %d\n",
+		    __func__, qid);
+		return EBUSY;
 	}
 
 	IWM_WRITE(sc, IWM_HBUS_TARG_WRPTR, qid << 8 | 0);
@@ -1719,6 +1720,10 @@ iwm_enable_ac_txq(struct iwm_softc *sc, int qid, int fifo)
 
 	err = iwm_clear_bits_prph(sc, IWM_SCD_AGGR_SEL, (1 << qid));
 	if (err) {
+		iwm_nic_unlock(sc);
+		device_printf(sc->sc_dev,
+		    "%s: cannot clear aggr_sel for txq %d\n",
+		    __func__, qid);
 		return err;
 	}
 
@@ -1747,6 +1752,8 @@ iwm_enable_ac_txq(struct iwm_softc *sc, int qid, int fifo)
 		iwm_write_prph(sc, IWM_SCD_EN_CTRL,
 		    iwm_read_prph(sc, IWM_SCD_EN_CTRL) | (1 << qid));
 
+	iwm_nic_unlock(sc);
+
 	return 0;
 }