The otus(4) USB driver supports dual-band and uses the same broken pattern
as run(4). See http://marc.info/?l=openbsd-tech&m=143660130627359&w=2
Untested since I don't have hardware.
Index: if_otus.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_otus.c,v
retrieving revision 1.46
diff -u -p -r1.46 if_otus.c
--- if_otus.c 14 Mar 2015 03:38:49 -0000 1.46
+++ if_otus.c 11 Jul 2015 08:17:56 -0000
@@ -718,16 +718,20 @@ otus_task(void *arg)
struct otus_softc *sc = arg;
struct otus_host_cmd_ring *ring = &sc->cmdq;
struct otus_host_cmd *cmd;
- int s;
+ int s, generation;
/* Process host commands. */
s = splusb();
+ generation = ring->generation;
while (ring->next != ring->cur) {
cmd = &ring->cmd[ring->next];
splx(s);
/* Callback. */
cmd->cb(sc, cmd->data);
s = splusb();
+ /* Abort this task if interface was stopped meanwhile. */
+ if (generation != ring->generation)
+ break;
ring->queued--;
ring->next = (ring->next + 1) % OTUS_HOST_CMD_RING_COUNT;
}
@@ -743,6 +747,11 @@ otus_do_async(struct otus_softc *sc, voi
int s;
s = splusb();
+ if (ring->queued == OTUS_HOST_CMD_RING_COUNT) {
+ printf("%s: host command ring overflow\n", sc->sc_dev.dv_xname);
+ splx(s);
+ return;
+ }
cmd = &ring->cmd[ring->cur];
cmd->cb = cb;
KASSERT(len <= sizeof (cmd->data));
@@ -914,9 +923,11 @@ otus_media_change(struct ifnet *ifp)
sc->fixed_ridx = ridx;
}
- if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
+ if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
+ (IFF_UP | IFF_RUNNING)) {
+ otus_stop(ifp);
error = otus_init(ifp);
-
+ }
return error;
}
@@ -1531,8 +1542,10 @@ otus_ioctl(struct ifnet *ifp, u_long cmd
if (error == ENETRESET) {
if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
- (IFF_UP | IFF_RUNNING))
+ (IFF_UP | IFF_RUNNING)) {
+ otus_stop(ifp);
otus_init(ifp);
+ }
error = 0;
}
@@ -2318,6 +2331,10 @@ otus_stop(struct ifnet *ifp)
timeout_del(&sc->calib_to);
s = splusb();
+
+ /* Abort otus_task thread. */
+ sc->cmdq.generation++;
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* Wait for all queued asynchronous commands to complete. */
usb_wait_task(sc->sc_udev, &sc->sc_task);
Index: if_otusreg.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_otusreg.h,v
retrieving revision 1.9
diff -u -p -r1.9 if_otusreg.h
--- if_otusreg.h 26 Nov 2013 20:33:18 -0000 1.9
+++ if_otusreg.h 11 Jul 2015 08:13:16 -0000
@@ -899,6 +899,7 @@ struct otus_host_cmd_ring {
int cur;
int next;
int queued;
+ int generation;
};
struct otus_node {