All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Tony Dinh" <mibodhi@gmail.com>, "Simon Glass" <sjg@chromium.org>,
	"Pali Rohár" <pali@kernel.org>
Cc: Tom Rini <trini@konsulko.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>,
	Michael Walle <michael@walle.cc>
Subject: Re: [PATCH] console: Use flush() before panic and reset
Date: Thu, 16 Mar 2023 10:00:09 +0100	[thread overview]
Message-ID: <438618ed-36c0-8694-a8a1-833d4bb93298@denx.de> (raw)
In-Reply-To: <CAJaLiFzqoVyo+LW11-DKzndfN4aYMF_dXEYtm411qJbbN4qFHw@mail.gmail.com>

On 3/15/23 21:29, Tony Dinh wrote:
> Hi Simon,
> 
> On Wed, Mar 15, 2023 at 12:43 PM Simon Glass <sjg@chromium.org> wrote:
>>
>> On Tue, 14 Mar 2023 at 18:24, Tony Dinh <mibodhi@gmail.com> wrote:
>>>
>>> To make sure the panic and the reset messages will go out, console flush() should be used.
>>> Sleep periods do not work in early u-boot phase when timer driver is not initialized yet.
>>>
>>> Reference: https://lists.denx.de/pipermail/u-boot/2023-March/512233.html
>>>
>>> Signed-off-by: Tony Dinh <mibodhi@gmail.com>
>>> ---
>>>
>>>   arch/arm/lib/reset.c | 4 ++--
>>>   lib/panic.c          | 4 +++-
>>>   2 files changed, 5 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/arm/lib/reset.c b/arch/arm/lib/reset.c
>>> index 95169bae1c..3e051e36f1 100644
>>> --- a/arch/arm/lib/reset.c
>>> +++ b/arch/arm/lib/reset.c
>>> @@ -25,6 +25,7 @@
>>>   #include <cpu_func.h>
>>>   #include <irq_func.h>
>>>   #include <linux/delay.h>
>>> +#include <stdio.h>
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> Is flush implemented widely?
> 
> Pali wrote that flush function and here was his comment on the
> referenced thread:
> "Moreover there is already new function named flush() which
> does "wait until stdout message was sent" and can be used instead of
> those sleeps. I have already did it on some places (see git history for
> flush function) but seems that you find some more."
> 
> So I think the answer is not yet widely implemented.

I just checked and it seems it's supported for all platforms using
DM_SERIAL when the serial driver supports the pending() function:

drivers/serial/serial-uclass.c:
#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
static void _serial_flush(struct udevice *dev)
{
	struct dm_serial_ops *ops = serial_get_ops(dev);

	if (!ops->pending)
		return;
	while (ops->pending(dev, false) > 0)
		;
}
#endif

So AFAICT it's implemented widely. Not sure, why
CONFIG_CONSOLE_FLUSH_SUPPORT was introduced. It's enabled by default
and should be available in all cases IMHO.

Thanks,
Stefan

  reply	other threads:[~2023-03-16  9:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15  0:24 [PATCH] console: Use flush() before panic and reset Tony Dinh
2023-03-15 19:43 ` Simon Glass
2023-03-15 20:29   ` Tony Dinh
2023-03-16  9:00     ` Stefan Roese [this message]
2023-03-16  9:02   ` Stefan Roese
2023-03-22 18:05 ` 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=438618ed-36c0-8694-a8a1-833d4bb93298@denx.de \
    --to=sr@denx.de \
    --cc=mibodhi@gmail.com \
    --cc=michael@walle.cc \
    --cc=pali@kernel.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.