From: Greg KH <gregkh@linuxfoundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jiri Slaby <jslaby@suse.com>,
Peter Hurley <peter@hurleysoftware.com>,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Expected behavior of set_termios() w.r.t. TX FIFO?
Date: Sat, 18 Mar 2017 18:57:54 +0800 [thread overview]
Message-ID: <20170318105754.GA19937@kroah.com> (raw)
In-Reply-To: <CAMuHMdWVOFVxb4bfexg5ZPOdC6Yig4g5Rd+5rRAOfrhH3W83GQ@mail.gmail.com>
On Fri, Mar 17, 2017 at 01:28:39PM +0100, Geert Uytterhoeven wrote:
> Hi Greg, Jiri, Peter,
>
> I'm wondering what is the expected behavior of calling
> uart_ops.set_termios() w.r.t. characters that are already queued in the
> UART's TX FIFO.
>
> - Should it wait (block) until all queued characters have been
> transmitted, before changing the UART's settings?
> - Should it apply the new settings immediately, affecting the already
> queued characters?
> - Should it apply the new settings, dropping the already queued
> characters?
> - Is calling uart_ops.set_termios() while the TX FIFO isn't empty
> allowed (this can be triggered easily from userspace)?
>
> uart_ops.set_termios() returns void, so there's no way to return an error.
>
> Currently the sh-sci driver blocks until the TX FIFO has been emptied,
> which may never happen if hardware flow control is enabled, and the remote
> side never asserts CTS, leading to:
>
> NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s!
>
> See also "[PATCH 2/2] serial: sh-sci: Fix hang in sci_reset()",
> https://lkml.org/lkml/2016/12/2/225).
>
> Thanks for your answer!
I think this has come up in the past, and due to the problem you have
found (could be waiting forever due to flow control), the answer was
just to set the new settings and not wait for anything to be flushed out
of the uart.
If a user sends a bunch of data, and then changes settings, without
first waiting for the data to be sent, then I feel they deserve the
uncertainty they will get :)
Hope this helps,
greg k-h
prev parent reply other threads:[~2017-03-18 11:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 12:28 Expected behavior of set_termios() w.r.t. TX FIFO? Geert Uytterhoeven
2017-03-18 10:57 ` Greg KH [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=20170318105754.GA19937@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=geert@linux-m68k.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=peter@hurleysoftware.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