Re: [PATCH v6 5/9] serial: max310x: wait for TX to drain before powering down in shutdown

From: Tapio Reijonen

Date: Mon Oct 05 2026 - 06:52:10 EST




On 10/5/26 13:12, Maarten Brock wrote:
> Would it not be better to retrieve the fifo level and multiply that
> by char_time_us to wait first? Yes, the (MAX3109) datasheet mentions
> its value may sometimes be inaccurate, but the worst that can happen
> is waiting too long. And after that use this max310x_tx_empty().

That would tighten the loop, but v7 drops the drain altogether - see
my reply to the review bot elsewhere in this thread. Draining turned
out to be wrong twice over: the wait is an uninterruptible sleep of
up to fifosize+1 character times per close() (~26 s at 50 baud, and
unbounded when CTS flow control holds the FIFO), and a close() with
data still queued on the auto-RTS path powers the port down
mid-transmission, where the stopped UART clock freezes RTS at its
asserted level until the next open - reproduced on the wire.

In v7, shutdown() stops the transmitter instead: MODE1 TxDisabl lets
the character in flight complete, data beyond it is abandoned (it is
only still queued when the tty layer was told not to wait for it),
the FIFOs are reset so the auto-RTS engine sees the transmitter empty
and releases RTS, and the power-off waits the configured after-send
hold plus one bit time. With the transmitter stopped the fill level
no longer matters; the remaining one-character wait covers the shift
register, which no level register reports.

Tapio