From: Valentin CARON <valentin.caron@foss.st.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V3 1/3] serial: stm32: remove infinite loop possibility in putchar function
Date: Tue, 19 Apr 2022 12:33:34 +0200 [thread overview]
Message-ID: <1a3bbcf1-bc03-f3e0-a70b-1e7c47d38b59@foss.st.com> (raw)
In-Reply-To: <CAMuHMdVCeuC5qStugnssWKUeOVWxd_3XyYtS0mrZpqQVaXAP2w@mail.gmail.com>
On 4/19/22 10:59, Geert Uytterhoeven wrote:
> Hi Valentin,
>
> On Tue, Apr 19, 2022 at 10:54 AM Valentin Caron
> <valentin.caron@foss.st.com> wrote:
>> Rework stm32_usart_console_putchar() function in order to anticipate
>> the case where the character can never be sent.
>>
>> Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
> Thanks for your patch!
>
>> --- a/drivers/tty/serial/stm32-usart.c
>> +++ b/drivers/tty/serial/stm32-usart.c
>> @@ -1640,10 +1640,16 @@ static void stm32_usart_console_putchar(struct uart_port *port, unsigned char ch
>> {
>> struct stm32_port *stm32_port = to_stm32_port(port);
>> const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
>> + u32 isr;
>> + int ret;
>>
>> - while (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE))
>> - cpu_relax();
>> -
>> + ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, isr,
>> + (isr & USART_SR_TXE), 100,
>> + STM32_USART_TIMEOUT_USEC);
>> + if (ret != 0) {
>> + dev_err(port->dev, "Error while sending data in UART TX : %d\n", ret);
> Does it make sense to print this message, i.e. will the user ever see it?
> Or is the failure above temporary?
> I assume that you have seen this trigger?
>
>> + return;
>> + }
>> writel_relaxed(ch, port->membase + ofs->tdr);
>> }
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
Hi Geert,
The failure is temporary. It can appears when the uart is too slow to
send data.
I never tested the case, but I prefer to show a message to know if the
console loses a character.
Thanks,
Valentin
next prev parent reply other threads:[~2022-04-19 10:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-19 8:53 [PATCH V3 0/3] serial: stm32: add earlycon and polling mode Valentin Caron
2022-04-19 8:53 ` [PATCH V3 1/3] serial: stm32: remove infinite loop possibility in putchar function Valentin Caron
2022-04-19 8:59 ` Geert Uytterhoeven
2022-04-19 10:33 ` Valentin CARON [this message]
2022-04-19 8:53 ` [PATCH V3 2/3] serial: stm32: add KGDB support Valentin Caron
2022-04-19 8:53 ` [PATCH V3 3/3] serial: stm32: add earlycon support Valentin Caron
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=1a3bbcf1-bc03-f3e0-a70b-1e7c47d38b59@foss.st.com \
--to=valentin.caron@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
/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®