On Sun, Nov 29, 2015 at 02:52:15PM +0100, Adam Wolk wrote: > Now to be precise. I can use this dongle quite fine. It sometimes goes > up to 1 hour of usage without any timeouts. When it does timeout it's > usually in rapid succession (like 2-3 times in next 10 minutes). Each > time after a timeout I can restart the connection with netstart > *without* unplugging the device.
If transmission of a frame times out (e.g. because of environmental reasons like distortion or like parts moving out of radio range), the hardware doesn't signal "transfer complete" and a watchdog handler is triggered to handle the situation. Usually, this watchdog will reset the hardware (down/up the interface) and hope that things will work afterwards. However, this is currently not implemented for most USB drivers where you'll find an XXX comment in the watchdog code: if (--sc->sc_tx_timer == 0) { printf("%s: device timeout\n", sc->sc_dev.dv_xname); /* urtwn_init(ifp); XXX needs a process context! */ ifp->if_oerrors++; return; } So... USB drivers don't recover from transmit errors :( This needs to be fixed to solve your issue. Most drivers for PCI devices already do the right thing here. Note that the watchdog runs in interrupt context and filesystem access (ie. loading firmware) is impossible in this context. One PCI driver which has the same problem is iwm(4). Look there for an approach that should also work for USB drivers: Using the task API (task_add(9), task_del(9), etc.) to reset the hardware from process context. All other people in this thread had attachment problems which are not related to the watchdog at all.