linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Karthik Manamcheri <karthik.manamcheri@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: Buffer overflow concerns when TTY_THRESHOLD_THROTTLE <= Uart FIFO size of the sending side
Date: Mon, 12 Aug 2013 07:30:01 -0400	[thread overview]
Message-ID: <5208C739.1020801@hurleysoftware.com> (raw)
In-Reply-To: <CAES2cWzqgKmCT7Uy-4dqrgNeq1W0LeBH5A=y7D+OX8cnBuM-rw@mail.gmail.com>

On 08/09/2013 05:08 PM, Karthik Manamcheri wrote:
> When using software-level RTS/CTS flow control (or Xon/Xoff), we could
> leak at most the UART FIFO size of bytes after getting the flow
> control signal. This is because the bytes might be loaded in the FIFO
> when the flow control signal comes through and the UART will send them
> out the wire.
>
> Consider a case where I have a UART with a 128 byte FIFO. The
> TTY_THRESHOLD_THROTTLE is set at 128 bytes in n_tty.c. So, isn't it
> possible that potentially we lose bytes when moving data to the TTY
> line discipline buffer? If the line discipline buffer is almost full
> (say the receiving room is 120 bytes), it calls throttle and even if
> the other end gets the throttle in time, it could potentially send 128
> bytes (but there is only 120 bytes of space in the buffer). So when we
> are flushing to ldisc, we will transfer only the receive_room amount
> of data and discard the rest? Is there any way of avoiding this?

Up to 64Kb of received data is buffered, so even if there is significant
delay throttling the sender, an overflow should not occur unless the bit
rate is in excess of 20Mbits/sec or so.

The receive buffer code is in drivers/tty/tty_buffer.c
The commonly used driver-side interface is tty_insert_flip_string() and
tty_flip_buffer_push(). flush_to_ldisc() is the work thread routine
which pushes this received data to the line discipline.

As far as I'm aware, only the synclink* drivers use the line discipline
interface directly (rather than the tty buffer interface) but perform
their own rx buffering.

Regards,
Peter Hurley

      reply	other threads:[~2013-08-12 11:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 21:08 Buffer overflow concerns when TTY_THRESHOLD_THROTTLE <= Uart FIFO size of the sending side Karthik Manamcheri
2013-08-12 11:30 ` Peter Hurley [this message]

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=5208C739.1020801@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=karthik.manamcheri@gmail.com \
    --cc=linux-serial@vger.kernel.org \
    /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).