From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Esben Haabendal" <esben@geanix.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Sunil V L" <sunilvl@ventanamicro.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Lino Sanfilippo" <l.sanfilippo@kunbus.com>,
"Rengarajan S" <rengarajan.s@microchip.com>,
"Serge Semin" <fancer.lancer@gmail.com>
Subject: Re: [PATCH next v2 1/4] serial: 8250: Split out IER from rs485_start_tx()
Date: Thu, 19 Sep 2024 17:01:49 +0200 [thread overview]
Message-ID: <Zuw83ZyzeKxA6RmE@pathway.suse.cz> (raw)
In-Reply-To: <84ldzproiy.fsf@jogness.linutronix.de>
On Wed 2024-09-18 17:10:53, John Ogness wrote:
> On 2024-09-17, Petr Mladek <pmladek@suse.com> wrote:
> > Sigh, I am trying to review this patch but I am not familiar with the
> > code. Feel free to ignore me when the questions are completely off.
>
> I appreciate you researching where the code came from. I made my changes
> based on what I see the code doing now.
>
> >> --- a/drivers/tty/serial/8250/8250_port.c
> >> +++ b/drivers/tty/serial/8250/8250_port.c
> >> void serial8250_em485_start_tx(struct uart_8250_port *up)
> >> {
> >> unsigned char mcr = serial8250_in_MCR(up);
> >>
> >> + /*
> >> + * Some chips set the UART_LSR_DR bit even when UART_IER_RDI is
> >> + * disabled, so explicitly mask it.
> >> + */
> >> if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX))
> >> - serial8250_stop_rx(&up->port);
> >> + up->port.read_status_mask &= ~UART_LSR_DR;
> >
> > This change is related to disabling UART_IER_RDI but we do not longer
> > disable it in this code path.
>
> Correct. It will be disabled in the new wrapper
> serial8250_em485_start_tx(). For the console write() callback, RDI is
> already being disabled (IER is cleared). It will not use the wrapper.
>
> > Why do we need to do it here, please?
>
> Because the console write() callback also needs to clear LSR_DR. That
> part of the callback needs to stay.
>
> > Why is it needed only in the em485-specific path, please?
>
> Only RS485 deals with controlling TX/RX directions.
>
> > On one hand, the comment talks about UART_LSR_DR and UART_IER_RDI
> > so seems to be relater.
>
> I do not know if the LSR_DR modify is strictly necessary. I am just
> preserving the existing behavior (and related comment). The disabling of
> IER_RDI will still happen (via wrapper or explicitly as in the console
> write() callback).
>
> >> static bool start_tx_rs485(struct uart_port *port)
> >> {
> >> @@ -1585,7 +1600,7 @@ static bool start_tx_rs485(struct uart_port *port)
> >> if (em485->tx_stopped) {
> >> em485->tx_stopped = false;
> >>
> >> - up->rs485_start_tx(up);
> >> + serial8250_rs485_start_tx(up);
> >
> > If I get this correctly then this keeps the existing behavior when
> >
> > up->rs485_start_tx == serial8250_em485_start_tx
>
> Correct.
>
> > Is this always the case, please?
>
> Yes.
>
> > Can start_tx_rs485() be called for the 8250_bcm2835aux.c driver?
>
> Yes.
IMHO, the answer "Yes" to both last questions can't be valid.
The 8250_bcm2835aux driver does:
static int bcm2835aux_serial_probe(struct platform_device *pdev)
{
[...]
up.rs485_start_tx = bcm2835aux_rs485_start_tx;
[...]
}
As a result, the 1st "Yes" was not correct:
up->rs485_start_tx != serial8250_em485_start_tx
and this patch would change the behavior for the 8250_bcm2835aux driver.
Before, start_tx_rs485() called directly:
up->rs485_start_tx(up);
Newly, it would call:
void serial8250_rs485_start_tx(struct uart_8250_port *up)
{
if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX))
serial8250_stop_rx(&up->port);
up->rs485_start_tx(up);
}
It means that it could call serial8250_stop_rx() even when it was not
called by the original code.
And SER_RS485_RX_DURING_TX seems to be checked even in
drivers/tty/serial/8250/8250_bcm2835aux.c. So, it looks like it
might be (un)set even for this driver.
Or is this code path prevented in start_tx_rs485()? I mean that
em485->tx_stopped could never be true for the 8250_bcm2835aux
driver?
But I see
static int bcm2835aux_serial_probe(struct platform_device *pdev)
{
[...]
up.port.rs485_config = serial8250_em485_config;
up.port.rs485_supported = serial8250_em485_supported;
[...]
}
=> It looks like even bcm2835aux driver could have the em485 thing.
But it obviously wanted to something special in
up->rs485_start_tx().
It looks to me that the change might either cause regression.
Or it would deserve a comment unless the validity is obvious for people
familiar with the code.
Best Regards,
Petr
next prev parent reply other threads:[~2024-09-19 15:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-13 14:05 [PATCH next v2 0/4] convert 8250 to nbcon John Ogness
2024-09-13 14:05 ` [PATCH next v2 1/4] serial: 8250: Split out IER from rs485_start_tx() John Ogness
2024-09-17 14:48 ` Petr Mladek
2024-09-18 15:04 ` John Ogness
2024-09-19 15:01 ` Petr Mladek [this message]
2024-09-13 14:05 ` [PATCH next v2 2/4] serial: 8250: Split out IER from rs485_stop_tx() John Ogness
2024-09-14 10:18 ` kernel test robot
2024-09-18 9:53 ` Petr Mladek
2024-09-13 14:05 ` [PATCH next v2 3/4] serial: 8250: Switch to nbcon console John Ogness
2024-09-18 12:26 ` Petr Mladek
2024-09-18 14:01 ` Andy Shevchenko
2024-09-18 14:35 ` Petr Mladek
2024-09-18 17:03 ` Andy Shevchenko
2024-09-18 15:19 ` John Ogness
2024-09-18 14:47 ` John Ogness
2024-09-13 14:05 ` [PATCH next v2 4/4] serial: 8250: Revert "drop lockdep annotation from serial8250_clear_IER()" John Ogness
2024-09-18 12:52 ` Petr Mladek
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=Zuw83ZyzeKxA6RmE@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=esben@geanix.com \
--cc=f.fainelli@gmail.com \
--cc=fancer.lancer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=l.sanfilippo@kunbus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=rengarajan.s@microchip.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=sunilvl@ventanamicro.com \
--cc=tglx@linutronix.de \
/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®