sc_wantresp -1 is special, so give it a proper name.
Also, have all commands wait for completion of active sync commands.
Right now only sync commands wait. We don't use async commands yet,
but if we do in the future they could be sent while a sync command
is still in progress, and I don't think the firmware would like that.
Index: if_iwm.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v
retrieving revision 1.53
diff -u -p -r1.53 if_iwm.c
--- if_iwm.c 6 Oct 2015 09:12:00 -0000 1.53
+++ if_iwm.c 10 Oct 2015 08:45:49 -0000
@@ -3369,11 +3369,13 @@ iwm_send_cmd(struct iwm_softc *sc, struc
paylen += hcmd->len[i];
}
+ /* wait for outstanding sync commands to complete */
+ while (sc->sc_wantresp != IWM_CMD_RESP_IDLE)
+ tsleep(&sc->sc_wantresp, 0, "iwmcmdsl", 0);
+
/* if the command wants an answer, busy sc_cmd_resp */
if (wantresp) {
KASSERT(!async);
- while (sc->sc_wantresp != -1)
- tsleep(&sc->sc_wantresp, 0, "iwmcmdsl", 0);
sc->sc_wantresp = ring->qid << 16 | ring->cur;
DPRINTFN(12, ("wantresp is %x\n", sc->sc_wantresp));
}
@@ -3571,10 +3573,10 @@ iwm_mvm_send_cmd_pdu_status(struct iwm_s
void
iwm_free_resp(struct iwm_softc *sc, struct iwm_host_cmd *hcmd)
{
- KASSERT(sc->sc_wantresp != -1);
+ KASSERT(sc->sc_wantresp != IWM_CMD_RESP_IDLE);
KASSERT((hcmd->flags & (IWM_CMD_WANT_SKB|IWM_CMD_SYNC))
== (IWM_CMD_WANT_SKB|IWM_CMD_SYNC));
- sc->sc_wantresp = -1;
+ sc->sc_wantresp = IWM_CMD_RESP_IDLE;
wakeup(&sc->sc_wantresp);
}
@@ -6450,7 +6452,7 @@ iwm_attach(struct device *parent, struct
}
printf(", %s\n", intrstr);
- sc->sc_wantresp = -1;
+ sc->sc_wantresp = IWM_CMD_RESP_IDLE;
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_INTEL_WL_3160_1:
Index: if_iwmvar.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v
retrieving revision 1.10
diff -u -p -r1.10 if_iwmvar.h
--- if_iwmvar.h 5 Oct 2015 13:05:08 -0000 1.10
+++ if_iwmvar.h 8 Oct 2015 06:29:33 -0000
@@ -301,6 +301,9 @@ struct iwm_ucode_status {
int uc_intr;
};
+/* sc_wantresp */
+#define IWM_CMD_RESP_IDLE -1
+
#define IWM_CMD_RESP_MAX PAGE_SIZE
#define IWM_OTP_LOW_IMAGE_SIZE 2048