linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Brauch <mail@svenbrauch.de>
To: Oliver Neukum <oneukum@suse.com>
Cc: Johan Hovold <johan@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
	Peter Hurley <peter@hurleysoftware.com>,
	Toby Gray <toby.gray@realvnc.com>,
	linux-usb@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH] Fix data loss in cdc-acm
Date: Tue, 21 Jul 2015 23:43:34 +0200	[thread overview]
Message-ID: <55AEBD06.6020402@svenbrauch.de> (raw)
In-Reply-To: <1437486195.3823.13.camel@suse.com>

[-- Attachment #1: Type: text/plain, Size: 2394 bytes --]

Hi,

Thank you for your comments.

On 21/07/15 15:43, Oliver Neukum wrote:
> But others won't and we'd preserve stale data in preference over fresh
> data.
If that is important for your device, you should be using an isochronous
endpoint, not bulk, no?
Also note that the driver currently does this anyways. It loses a few kB
of data, and _then_ it throttles the producer and forces it to wait.

On 21/07/15 11:18, Johan Hovold wrote:
> In general if data isn't being consumed fast enough we eventually need
> to drop it (unless we can throttle the producer).
Yes, maybe this is the first thing which should be cleared up: Is
"throttle the producer" always preferable over "lose data"? I'd say yes
for bulk transfers, no for isochronous. It is in principle easy enough
to throttle the producer, that is what e.g. my patch does. Whether a
different approach may be more appropriate than the "don't resubmit the
urbs" thing is then of course open to debate.

As far as I can see, throttling the producer is the only way to
guarantee data delivery. So if we want that (and I certainly want it for
my application, I don't know about the general case), I think all
changes to the tty buffers or throttling mechanisms are "just"
performance optimization, since no such modification will ever guarantee
delivery if the producer is not throttled in time.
And, this I want to mention again, if your producer is timing-sensitive
you would not be using bulk anyways. The USB controller could just
decide that your device cannot send data for the next five seconds, and
it will have to handle that case as well. Thus I see no reason to not
throttle the producer if necessary.

On 21/07/15 18:45, Peter Hurley wrote:
> 1. Instrument acm_read_bulk_callback with tty_buffer_space_avail()
> to track the (approx) fill level of the tty buffers. I would
> use ftrace/trace_printk() to record this.
I already did this while debugging. For a while, the buffer is almost
empty (fluctuates by a few kB), then it rapidly drops to zero bytes
free. Only after a few urbs where submitted (or rather, not submitted)
into the full buffer, the throttle flag gets set.

Thank you for your offer to help figuring out what exactly goes wrong
with the throttling mechanism. If it turns out we should actually look
for a fix there, I'll be happy to make use of it.

Best,
Sven


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-07-21 21:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-19 21:37 [PATCH] Fix data loss in cdc-acm Sven Brauch
2015-07-20 17:25 ` Johan Hovold
2015-07-20 18:07   ` Sven Brauch
2015-07-21  9:18     ` Johan Hovold
2015-07-21 16:45       ` Peter Hurley
2015-07-22  8:40         ` Oliver Neukum
2015-07-22 14:30           ` Peter Hurley
2015-07-22 15:01             ` Oliver Neukum
2015-08-05  0:26               ` Peter Hurley
2015-07-21 13:43     ` Oliver Neukum
2015-07-21 21:43       ` Sven Brauch [this message]
2015-07-21 23:34         ` Peter Hurley
2015-07-22  0:47           ` Sven Brauch
2015-07-22 22:12             ` Peter Hurley
2015-07-22 22:53               ` Sven Brauch
2015-07-27 10:00                 ` Peter Stuge
2015-08-05 17:36                 ` Peter Hurley
2015-10-20 18:16                   ` Peter Hurley
2015-10-21 10:12                     ` Oliver Neukum
2015-10-21 12:09                       ` Peter Hurley
2015-10-21 14:58                         ` Peter Hurley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55AEBD06.6020402@svenbrauch.de \
    --to=mail@svenbrauch.de \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=peter@hurleysoftware.com \
    --cc=toby.gray@realvnc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).