linux/drivers/usb/class
Bjørn Mork 833415a3e7 cdc-wdm: fix "out-of-sync" due to missing notifications
The driver enforces a strict one-to-one relationship between the
received RESPONSE_AVAILABLE notifications and messages read from
the device. At the same time, it will cancel the interrupt URB
when there is no client holding the character device open.

Many devices do not cope well with this behaviour.  They maintain
a FIFO queue of messages, and send notifications on a best effort
basis.  Messages are queued regardless of whether the notification
is successful or not. So if the driver loses a single notification,
which can easily happen when the interrupt URB is cancelled, then
the device and driver becomes out-of-sync. New messages end up
at the end of the queue, while the associated notification makes
the driver read only the first message from the queue.

This state is permanent from a user point of view. There is no
no way to flush the device queue without resetting the device or
using another driver.

The problem is easy to hit with current QMI and MBIM command line
tools, which typically close the character device after seeing
the reply they expect. Any pending unsolicited messages from the
device will then trigger the driver bug.

Fix by always reading all queued messages from the device when
the notification URB is first submitted.  This is expected to
end with an -EPIPE status when there are no more pending
messages, so demote the printk associated with -EPIPE to debug
level.

The workaround has been tested on a large number of different MBIM
and QMI devices, as well as the Ericsson F5521gw and H5321gw modems
with real Device Management functions.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-09 15:50:17 +02:00
..
cdc-acm.c cdc-acm: beautify probe() 2016-07-18 08:46:57 -07:00
cdc-acm.h cdc-acm: implement put_char() and flush_chars() 2016-02-14 17:06:43 -08:00
cdc-wdm.c cdc-wdm: fix "out-of-sync" due to missing notifications 2016-08-09 15:50:17 +02:00
Kconfig USB: regroup all depends on USB within an if USB block 2013-04-09 16:49:07 -07:00
Makefile
usblp.c usblp: do not set TASK_INTERRUPTIBLE before lock 2015-11-19 16:31:42 -08:00
usbtmc.c usb: usbtmc: Fix disconnect/poll interaction 2016-02-20 20:21:53 -08:00