mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tapio Reijonen <tapio.reijonen@vaisala.com>
To: sashiko-reviews@lists.linux.dev
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	linux-kernel@vger.kernel.org,
	Hugo Villeneuve <hvilleneuve@dimonoff.com>,
	Tapio Reijonen <tapio.reijonen@kolumbus.fi>
Subject: Re: [PATCH v6 5/9] serial: max310x: wait for TX to drain before powering down in shutdown
Date: Mon, 5 Oct 2026 11:19:35 +0300	[thread overview]
Message-ID: <1e1a097b-bc64-4ca8-a499-e6bc3cf4c502@vaisala.com> (raw)
In-Reply-To: <20261004122835.92E741F000FF@smtp.kernel.org>



On 10/4/26 15:28, sashiko-bot@kernel.org wrote:
> [Severity: High]
> Can this loop be used to cause a local Denial of Service via an
> extended D-state hang or Hung Task Panic?
>
> If a user opens the TTY, configures a very low baud rate (e.g.,
> speed 1-50), disables CTS flow control (preventing the TX FIFO from
> draining), and closes the device, max310x_shutdown() could call
> fsleep() up to 129 times in TASK_UNINTERRUPTIBLE.

Agreed, the loop waits on data, so a blocked FIFO makes close() pay
for it. One precision note: the baud rate generator floors at
uartclk / 16 / 0xffff, tens of baud with the usual crystals, so the
1-baud / 20-minute case is not reachable - but ~26 s per close() at
50 baud with CTS blocked is real and bad enough.

v7 will rework shutdown() to stop the transmitter instead of
draining it, following what imx.c does: set MODE1 TxDisabl (the
character in flight completes, the rest of the FIFO is abandoned -
the next startup() resets the FIFOs anyway) and honour only the RTS
timing. On the auto-RTS path the FIFO is also reset, so the engine
sees the transmitter empty and releases RTS before the power-off
freezes the pin. The wait is then bounded by one character plus the
configured after-send delay, independent of how much data was
queued: measured on a MAX14830 board, a close() with a second of
data still in flight at 50 baud takes 0.23 s instead of 2.4, and the
CTS-blocked case no longer waits on data at all. Data the tty layer
explicitly did not wait for is then truncated rather than drained,
which matches how other RS485 drivers close.

Tapio


  parent reply	other threads:[~2026-10-05  8:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 12:16 [PATCH v6 0/9] serial: max310x: RS485 delay and RTS fixes, software-timed delays Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 1/9] serial: max310x: don't clobber the TX break bit in set_termios Tapio Reijonen
2026-10-05 15:45   ` Hugo Villeneuve
2026-10-04 12:16 ` [PATCH v6 2/9] serial: max310x: assert the transceiver during a break Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 3/9] serial: max310x: centralize the RS485 transceiver programming Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 4/9] serial: max310x: convert RS485 delays from milliseconds to bit-times Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 5/9] serial: max310x: wait for TX to drain before powering down in shutdown Tapio Reijonen
     [not found]   ` <20261004122835.92E741F000FF@smtp.kernel.org>
2026-10-05  8:19     ` Tapio Reijonen [this message]
2026-10-05 10:12   ` Maarten Brock
2026-10-05 10:51     ` Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 6/9] serial: max310x: support active-low RTS on the hardware path Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 7/9] serial: max310x: schedule tx_work directly from the IRQ handler Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 8/9] serial: max310x: drive RTS in software when hardware delays are too short Tapio Reijonen
2026-10-04 12:16 ` [PATCH v6 9/9] serial: max310x: don't transmit while an RS485 reconfigure is pending Tapio Reijonen

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=1e1a097b-bc64-4ca8-a499-e6bc3cf4c502@vaisala.com \
    --to=tapio.reijonen@vaisala.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tapio.reijonen@kolumbus.fi \
    /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

all inboxes | Powered by JetHome®