Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756136AbbGTRZ4 (ORCPT ); Mon, 20 Jul 2015 13:25:56 -0400 Received: from mail-lb0-f175.google.com ([209.85.217.175]:36119 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752319AbbGTRZx (ORCPT ); Mon, 20 Jul 2015 13:25:53 -0400 Date: Mon, 20 Jul 2015 19:25:46 +0200 From: Johan Hovold To: Sven Brauch Cc: Linux Kernel Mailing List , One Thousand Gnomes , Oliver Neukum , Peter Hurley , Toby Gray , linux-usb@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH] Fix data loss in cdc-acm Message-ID: <20150720172546.GF20628@localhost> References: <55AC1883.4050605@svenbrauch.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55AC1883.4050605@svenbrauch.de> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1762 Lines: 40 [ +CC: Alan, Oliver, Peter, Toby, linux-serial, linux-usb ] On Sun, Jul 19, 2015 at 11:37:07PM +0200, Sven Brauch wrote: > Since acm_process_read_urb does not check the return value > of tty_insert_flip_string, it can happen that not all data > is copied from the urb to the tty if the tty buffer > is full and throttling does not set in quickly enough. This > problem is very evident for devices with high data throughput; > for a device with ~12 MB/s of data transfer, I get a few > missing kB of data every few MB transferred randomly. What kernel version are you using? > To solve this problem, a check is introduced which verifies > that indeed all data was copied from the urb to the tty buffer. > If that is not the case, the urb is held in a queue instead > of resubmitting it to the USB subsystem right away. When new > data arrives or the tty is unthrottled, the queue is emptied > again (as far as possible). > > Effectively, this change will force the transmitting USB device > to wait until the tty buffer can accept new data again, instead > of discarding the data in this case. The idea of adding another layer of buffering in the cdc-acm driver has been suggested in the past but was rejected (or at least questioned). See for example this thread: https://lkml.kernel.org/r/20110608164626.22bc893c@lxorguk.ukuu.org.uk The tty buffers are quite large these days, but could possibly be bumped further if needed to give the ldisc some more time to throttle the device at very high speeds. Johan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/