[PATCH] console: Implement flush() function
sjg at chromium.org
Sat Mar 12 03:25:03 CET 2022
On Wed, 23 Feb 2022 at 06:34, Pali Rohár <pali at kernel.org> wrote:
> On certain places it is required to flush output print buffers to ensure
> that text strings were sent to console or serial devices. For example when
> printing message that U-Boot is going to boot kernel or when U-Boot is
> going to change baudrate of terminal device.
> Some console devices, like UART, have putc/puts functions which just put
> characters into HW transmit queue and do not wait until all data are
> transmitted. Doing some sensitive operations (like changing baudrate or
> starting kernel which resets UART HW) cause that U-Boot messages are lost.
> Therefore introduce a new flush() function, implement it for all serial
> devices via pending(false) callback and use this new flush() function on
> sensitive places after which output device may go into reset state.
> This change fixes printing of U-Boot messages:
> "## Starting application at ..."
> "## Switch baudrate to ..."
> Signed-off-by: Pali Rohár <pali at kernel.org>
> arch/sandbox/cpu/os.c | 5 +++
> boot/bootm_os.c | 1 +
> cmd/boot.c | 1 +
> cmd/elf.c | 2 ++
> cmd/load.c | 5 +++
> common/console.c | 56 ++++++++++++++++++++++++++++++++++
> common/stdio.c | 6 ++++
> drivers/serial/serial-uclass.c | 25 +++++++++++++++
> drivers/serial/serial.c | 1 +
> include/_exports.h | 1 +
> include/os.h | 8 +++++
> include/serial.h | 2 ++
> include/stdio.h | 7 +++++
> include/stdio_dev.h | 2 ++
> 14 files changed, 122 insertions(+)
There is a lot going on in this patch and I think it should be split
into a small series, something like:
- driver model changes (don't forget to update test/dm/serial.c)
- stdio changes
- sandbox changes
- plumbing into certain commands
You must not implement new features in the non-DM code as we are
migrating away from that. So just implement it for driver model.
Also, given the code-size impact I think this should have a Kconfig option.
More information about the U-Boot