u-boot-amlogic.groups.io archive mirror
 help / color / mirror / Atom feed
From: "Neil Armstrong" <neil.armstrong@linaro.org>
To: Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	u-boot-amlogic@groups.io
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH] serial: meson: fix meson_serial_pending() tx logic
Date: Wed, 7 Jun 2023 10:03:19 +0200	[thread overview]
Message-ID: <5699d7cb-0861-a21a-2928-eb2e7e80f63d@linaro.org> (raw)
In-Reply-To: <20230606-fix-meson-serial-pending-v1-1-6a54d4a01f76@baylibre.com>

On 06/06/2023 18:07, Mattijs Korpershoek wrote:
> According to the dm_serial_ops documentation, pending() should:
>> @return number of waiting characters, 0 for none, -ve on error
> 
> And:
>> It is acceptable to return 1 if an indeterminant number
>> of characters is waiting.
> 
> With the current implementation, we have:
> * FIFO is full           -> pending() returns 0
> * FIFO is partially used -> pending() returns 1
> * FIFO is empty          -> pending() returns 1
> 
> This is not the same as what the documentation requires.
> 
> Moreover, since [1], arm reset now flushes all console devices
> (including serial) before the cpu gets reset.
> Because of the flawed logic:
> 
>    => reset # user calls reset
>    flush() is called
>    _serial_flush() is called
>    ops->pending(dev, false) # never returns false
>    # board hangs indefinitely without resetting.
> 
> Fix it by using AML_UART_TX_EMPTY instead of AML_UART_TX_FULL.
> 
> [1] commit c5f4cdb8eb60 ("console: Use flush() before panic and reset"),
> 
> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> Tested with:
> => reset # vim3 board no longer hangs
> ---
>   drivers/serial/serial_meson.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
> index d026f5a7a8e5..934de2ab2358 100644
> --- a/drivers/serial/serial_meson.c
> +++ b/drivers/serial/serial_meson.c
> @@ -201,7 +201,10 @@ static int meson_serial_pending(struct udevice *dev, bool input)
>   
>   		return true;
>   	} else {
> -		return !(status & AML_UART_TX_FULL);
> +		if (status & AML_UART_TX_EMPTY)
> +			return false;
> +
> +		return true;
>   	}
>   }
>   
> 
> ---
> base-commit: a1fd9cb41fb1fda2283a089f9c97e5eed4d4940a
> change-id: 20230606-fix-meson-serial-pending-890e11467215
> 
> Best regards,

Acked-by: Neil Armstrong <neil.armstrong@linaro.org>

      reply	other threads:[~2023-06-07  8:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 16:07 [PATCH] serial: meson: fix meson_serial_pending() tx logic Mattijs Korpershoek
2023-06-07  8:03 ` Neil Armstrong [this message]

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=5699d7cb-0861-a21a-2928-eb2e7e80f63d@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=mkorpershoek@baylibre.com \
    --cc=u-boot-amlogic@groups.io \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).