Module Name:    src
Committed By:   nat
Date:           Fri Sep 17 12:58:31 UTC 2021

Modified Files:
        src/sys/dev/usb: if_urtwn.c

Log Message:
Serialize sending of firmware commands to device.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/usb/if_urtwn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.97 src/sys/dev/usb/if_urtwn.c:1.98
--- src/sys/dev/usb/if_urtwn.c:1.97	Fri Sep 17 12:55:10 2021
+++ src/sys/dev/usb/if_urtwn.c	Fri Sep 17 12:58:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.97 2021/09/17 12:55:10 nat Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.98 2021/09/17 12:58:31 nat Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.97 2021/09/17 12:55:10 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.98 2021/09/17 12:58:31 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1106,7 +1106,6 @@ urtwn_fw_cmd(struct urtwn_softc *sc, uin
 	mutex_enter(&sc->sc_fwcmd_mtx);
 	fwcur = sc->fwcur;
 	sc->fwcur = (sc->fwcur + 1) % R92C_H2C_NBOX;
-	mutex_exit(&sc->sc_fwcmd_mtx);
 
 	/* Wait for current FW box to be empty. */
 	for (ntries = 0; ntries < 100; ntries++) {
@@ -1117,6 +1116,7 @@ urtwn_fw_cmd(struct urtwn_softc *sc, uin
 	if (ntries == 100) {
 		aprint_error_dev(sc->sc_dev,
 		    "could not send firmware command %d\n", id);
+		mutex_exit(&sc->sc_fwcmd_mtx);
 		return ETIMEDOUT;
 	}
 
@@ -1145,6 +1145,7 @@ urtwn_fw_cmd(struct urtwn_softc *sc, uin
 	} else {
 		urtwn_write_region(sc, R92C_HMEBOX(fwcur), cp, len);
 	}
+	mutex_exit(&sc->sc_fwcmd_mtx);
 
 	return 0;
 }

Reply via email to