From: John Ogness <john.ogness@linutronix.de>
To: Esben Haabendal <esben@geanix.com>, linux-rt-users@vger.kernel.org
Subject: Re: [RFC PATCH v2 2/2] serial: imx: Switch to nbcon console
Date: Mon, 15 Apr 2024 12:34:24 +0206 [thread overview]
Message-ID: <87edb6gbsn.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <2bc0b5d3f99184d8ddbf860666513f9fa7760af8.1712303358.git.esben@geanix.com>
Hi Esben,
You are correct that there is considerable copy/paste from the 8250
driver. Hopefully having another nbcon driver will help us find a way to
cleanly consolidate that logic. Thanks for your work on this.
Comments from me below...
On 2024-04-05, Esben Haabendal <esben@geanix.com> wrote:
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index f7e4f38f08f3..2a49880c2651 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> +static bool imx_uart_console_write_atomic(struct console *co,
> + struct nbcon_write_context *wctxt)
> +{
> + struct imx_port *sport = imx_uart_ports[co->index];
> + struct uart_port *port = &sport->port;
> + struct imx_port_ucrs old_ucr;
> + unsigned int ucr1, usr2;
> +
> + if (!nbcon_enter_unsafe(wctxt))
> + return false;
> +
> + /*
> + * First, save UCR1/2/3 and then disable interrupts
> + */
> + imx_uart_ucrs_save(sport, &old_ucr);
> + ucr1 = old_ucr.ucr1;
> +
> + if (imx_uart_is_imx1(sport))
> + ucr1 |= IMX1_UCR1_UARTCLKEN;
> + ucr1 |= UCR1_UARTEN;
> + ucr1 &= ~(UCR1_TRDYEN | UCR1_RRDYEN | UCR1_RTSDEN);
> +
> + imx_uart_writel(sport, ucr1, UCR1);
> +
> + imx_uart_writel(sport, old_ucr.ucr2 | UCR2_TXEN, UCR2);
> +
> + if (sport->console_newline_needed)
> + uart_console_write(port, "\n", 1, imx_uart_console_putchar);
> + uart_console_write(port, wctxt->outbuf, wctxt->len,
> + imx_uart_console_putchar);
> +
> + /*
> + * Finally, wait for transmitter to become empty
> + * and restore UCR1/2/3
> + */
> + read_poll_timeout_atomic(imx_uart_readl, usr2, usr2 & USR2_TXDC,
> + 0, 1000000, false, sport, USR2);
> + imx_uart_ucrs_restore(sport, &old_ucr);
> +
> + /* Success if no handover/takeover. */
> + return nbcon_exit_unsafe(wctxt);
> +}
In your imx_uart_console_write_atomic() I see lots of register usage:
ucr1, ucr2, ucr3, usr2, uts
It is critical that _all_ usage of these registers throughout the driver
is protected, preferably protected by the port lock. Please go through
and verify that. If imx_uart_console_write_thread() is using even more
registers, you will need to check those as well.
For the 8250 I went through all uses and found several problems [0]. The
imx driver may have similar issues.
John Ogness
[0] https://lore.kernel.org/lkml/20230525093159.223817-1-john.ogness@linutronix.de
next prev parent reply other threads:[~2024-04-15 10:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 7:56 [RFC PATCH v2 0/2] serial: imx: Switch to nbcon console Esben Haabendal
2024-04-05 7:56 ` [RFC PATCH v2 1/2] serial: imx: Introduce timeout when waiting on transmitter empty Esben Haabendal
2024-04-05 8:06 ` Marc Kleine-Budde
2024-04-05 8:32 ` Esben Haabendal
2024-04-05 7:56 ` [RFC PATCH v2 2/2] serial: imx: Switch to nbcon console Esben Haabendal
2024-04-15 10:28 ` John Ogness [this message]
2024-04-05 8:43 ` [RFC PATCH v2 0/2] " Marc Kleine-Budde
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=87edb6gbsn.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=esben@geanix.com \
--cc=linux-rt-users@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).