From: Tom Rini <trini@konsulko.com>
To: "Pali Rohár" <pali@kernel.org>
Cc: Stefan Roese <sr@denx.de>,
u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH] serial: Use -EAGAIN in getc and putc
Date: Thu, 8 Dec 2022 10:45:49 -0500 [thread overview]
Message-ID: <20221208154549.GA551143@bill-the-cat> (raw)
In-Reply-To: <20221204123655.29939-1-pali@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]
On Sun, Dec 04, 2022 at 01:36:55PM +0100, Pali Rohár wrote:
> U-Boot serial code already handles -EAGAIN value from getc and putc
> callbacks. So change drivers code to return -EAGAIN when HW is busy instead
> of doing its own busy loop and waiting until HW is ready.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Stefan Roese <sr@denx.de>
[snip]
> diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
> index ff576da516d4..d7259d531b55 100644
> --- a/drivers/serial/serial_lpuart.c
> +++ b/drivers/serial/serial_lpuart.c
> @@ -168,8 +168,8 @@ static void _lpuart_serial_setbrg(struct udevice *dev,
> static int _lpuart_serial_getc(struct lpuart_serial_plat *plat)
> {
> struct lpuart_fsl *base = plat->reg;
> - while (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR)))
> - schedule();
> + if (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR)))
> + return -EAGAIN;
>
> barrier();
>
> @@ -181,8 +181,8 @@ static void _lpuart_serial_putc(struct lpuart_serial_plat *plat,
> {
> struct lpuart_fsl *base = plat->reg;
>
> - while (!(__raw_readb(&base->us1) & US1_TDRE))
> - schedule();
> + if (!(__raw_readb(&base->us1) & US1_TDRE))
> + return -EAGAIN;
>
> __raw_writeb(c, &base->ud);
> }
This is non-trivially not right for this driver. ->putc here is set to
lpuart_serial_putc which calls _lpuart_serial_putc OR
_lpuart32_serial_putc, so there's the lpuart32 cases to address, and
then lpuart_serial_putc needs to just return whatever one it called
rather than always returning 0.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2022-12-08 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-04 12:36 [PATCH] serial: Use -EAGAIN in getc and putc Pali Rohár
2022-12-04 21:16 ` Simon Glass
2022-12-05 6:20 ` Stefan Roese
2022-12-08 15:45 ` Tom Rini [this message]
2022-12-10 23:08 ` Pali Rohár
2022-12-10 23:31 ` [PATCH v2] " Pali Rohár
2023-01-03 15:42 ` Tom Rini
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=20221208154549.GA551143@bill-the-cat \
--to=trini@konsulko.com \
--cc=pali@kernel.org \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.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