Re: [PATCH v5 12/14] serial: 8250: allow UART drivers to override rx_trig_bytes handling

From: Andy Shevchenko

Date: Sun Aug 02 2026 - 05:21:14 EST


On Fri, Jul 31, 2026 at 10:49 AM Crescent Hsieh
<crescentcy.hsieh@xxxxxxxx> wrote:
>
> The rx_trig_bytes sysfs attribute currently relies on 8250-internal
> helper functions and assumes a fixed mapping between trigger levels and
> FIFO behavior.
>
> Some UARTs provide hardware-specific RX trigger mechanisms that do not
> fit this model. Add optional uart_port callbacks for setting and getting
> the RX trigger level, and use them when provided, while preserving the
> existing 8250 helpers as the default fallback.

...

> struct tty_port *port = dev_get_drvdata(dev);
> + struct uart_state *state = container_of(port, struct uart_state, port);
> + struct uart_port *uport = state->uart_port;
> int rxtrig_bytes;

Hmm... do_set_rxtrig() and do_get_rxtrig() do the same, but under the
mutex lock. Hence there are questions:
- is it correct to have without mutex?
- if so, why not to propagate these (if you really need it), to the callees?
- or should these callbacks be integrated in the lower level?

> - rxtrig_bytes = do_serial8250_get_rxtrig(port);
> + if (uport->get_rxtrig)
> + rxtrig_bytes = uport->get_rxtrig(uport);
> + else
> + rxtrig_bytes = do_serial8250_get_rxtrig(port);

--
With Best Regards,
Andy Shevchenko