Re: [PATCH] serial: 8250_dwlib: Restore NOTEMT for em485

From: Ilpo Järvinen

Date: Fri Dec 04 2026 - 07:56:45 EST


On Fri, 4 Dec 2026, Andy Shevchenko wrote:

> On Sat, Nov 21, 2026 at 02:35:15PM +0800, Fuyao Kashizuku wrote:
> >
> > A DesignWare UART using software RS485 can transmit one byte and then
> > leave the next write queued indefinitely.
> >
> > dw8250_setup_port() sets UART_CAP_NOTEMT because the UART does not
> > interrupt when the shift register becomes empty. If neither hardware
> > nor platform data supplies a component parameter register (CPR) value,
> > the driver leaves UPF_FIXED_TYPE clear. When autoconfig() identifies
> > a 16550A, it replaces the capabilities with the type defaults and drops
> > UART_CAP_NOTEMT.
> >
> > If the TX FIFO empties while the shift register is still busy, __stop_tx()
> > then returns without arming the stop timer or clearing THRI. With no
> > further interrupt when the last bit leaves the wire, em485 can stay in
> > transmit mode and a subsequent write can remain queued.
> >
> > Restore UART_CAP_NOTEMT in the DW software RS485 configuration callback.
> > This lets the existing em485 timer finish the transmission and release
> > RTS after the last character.
>
> ...
>
> > +static int dw8250_em485_config(struct uart_port *p, struct ktermios *termios,
> > + struct serial_rs485 *rs485)
> > +{
> > +
> > + struct uart_8250_port *up = up_to_u8250p(p);
> > +
> > + /*
> > + * Without CPR, 8250 autoconfiguration can overwrite capabilities.
> > + * Restore NOTEMT before enabling emulation: DW has no TEMT interrupt.
>
> Hmm... The end of the phrase raises a Q: Is it true for *all* versions of
> the DW 8250 IP (there are differences between 4.x and older once which might
> be related)?

My impression there's no TEMT interrupt in DW UART.

But if I understand the comment correctly, this problem seem to relate
CPRless HW falling back to autoconfig which overwrites what capabilities
dwlib set (autoconfig is really annoying as it respects nothing?).

> > + */
> > + up->capabilities |= UART_CAP_NOTEMT;
> > +
> > + return serial8250_em485_config(p, termios, rs485);
> > +}
>
>

--
i.