All of lore.kernel.org
 help / color / mirror / Atom feed
From: Crescent Hsieh <crescentcy.hsieh@moxa.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	FangpingFP.Cheng@moxa.com, Epson.Chiang@moxa.com,
	EddieSY.Lin@moxa.com, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH v5 12/14] serial: 8250: allow UART drivers to override rx_trig_bytes handling
Date: Tue, 4 Aug 2026 11:52:54 +0800	[thread overview]
Message-ID: <anFiFtp5vP0CtDVO@moxa-KabyLake-H> (raw)
In-Reply-To: <CAHp75VcRkgsBOYWwk9pUxDvc4-YmSvVn0fkrhPSHHerwykVvWQ@mail.gmail.com>

On Sun, Aug 02, 2026 at 12:20:18PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 31, 2026 at 10:49 AM Crescent Hsieh
> <crescentcy.hsieh@moxa.com> 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);

Yes, the callback path should be protected by the same mutex.

I agree that the callback dispatch should be moved into the lower-level
helpers rather than handled directly in rx_trig_bytes_show() and
rx_trig_bytes_store().

I also think the function names should be aligned with the naming
convention used by the other generic 8250 helpers for consistency.

So the resulting call  flow would be like:

		      rx_trig_bytes_store/show()
				  |
				  v
		     serial8250_set/get_rxtrig()
	                          |
	  +-----------------------+-----------------------+
	  |						  |
	  v						  v
uport->set/get_rxtrig()                  serial8250_do_set/get_rxtrig()

--
Thanks,
Crescent Hsieh

  reply	other threads:[~2026-08-04  3:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  7:48 [PATCH v5 00/14] serial: 8250: add Moxa MUEx50 PCIe board support Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 01/14] serial: 8250: split Moxa PCIe serial board support out of 8250_pci Crescent Hsieh
2026-08-02  8:35   ` Andy Shevchenko
2026-07-31  7:48 ` [PATCH v5 02/14] serial: 8250: add Moxa MUEx50 UART port type Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 03/14] serial: 8250_mxpcie: enable enhanced mode and program FIFO trigger levels Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 04/14] serial: 8250_mxpcie: enable automatic RTS/CTS flow control Crescent Hsieh
2026-08-02  8:58   ` Andy Shevchenko
2026-07-31  7:48 ` [PATCH v5 05/14] serial: 8250_mxpcie: offload XON/XOFF flow control to MUEx50 hardware Crescent Hsieh
2026-08-02  9:00   ` Andy Shevchenko
2026-07-31  7:48 ` [PATCH v5 06/14] serial: 8250_mxpcie: add custom handle_irq callback Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 07/14] serial: 8250_mxpcie: speed up RX using memory-mapped FIFO window Crescent Hsieh
2026-08-02  9:03   ` Andy Shevchenko
2026-07-31  7:48 ` [PATCH v5 08/14] serial: 8250_mxpcie: speed up TX " Crescent Hsieh
2026-08-02  9:10   ` Andy Shevchenko
2026-08-03  4:46     ` Jiri Slaby
2026-08-03  7:26       ` Andy Shevchenko
2026-08-03  7:28         ` Andy Shevchenko
2026-07-31  7:48 ` [PATCH v5 09/14] serial: 8250_mxpcie: support serial interface mode switching Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 10/14] serial: 8250: allow low-level drivers to override break control Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 11/14] serial: 8250_mxpcie: add break support for RS485 using MUEx50 features Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 12/14] serial: 8250: allow UART drivers to override rx_trig_bytes handling Crescent Hsieh
2026-08-02  9:20   ` Andy Shevchenko
2026-08-04  3:52     ` Crescent Hsieh [this message]
2026-07-31  7:48 ` [PATCH v5 13/14] serial: 8250_mxpcie: introduce per-port private data structure Crescent Hsieh
2026-07-31  7:48 ` [PATCH v5 14/14] serial: 8250_mxpcie: implement rx_trig_bytes callbacks via MUEx50 RTL Crescent Hsieh
2026-08-03 14:52 ` [PATCH v5 00/14] serial: 8250: add Moxa MUEx50 PCIe board support Greg Kroah-Hartman

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=anFiFtp5vP0CtDVO@moxa-KabyLake-H \
    --to=crescentcy.hsieh@moxa.com \
    --cc=EddieSY.Lin@moxa.com \
    --cc=Epson.Chiang@moxa.com \
    --cc=FangpingFP.Cheng@moxa.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.