[PATCH v3 0/6] console: Implement flush() function

Heinrich Schuchardt xypron.glpk at gmx.de
Thu Sep 22 15:13:37 CEST 2022


On 9/22/22 13:27, Simon Glass wrote:
> Hi,
>
> On Wed, 21 Sept 2022 at 15:56, Tom Rini <trini at konsulko.com> wrote:
>>
>> On Wed, Sep 21, 2022 at 03:54:13PM +0200, Pali Rohár wrote:
>>> On Wednesday 21 September 2022 09:49:24 Tom Rini wrote:
>>>> On Mon, Sep 05, 2022 at 11:31:15AM +0200, Pali Rohár 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 ..."
>>>>>
>>>>> Changes in v3:
>>>>> * add macro STDIO_DEV_ASSIGN_FLUSH()
>>>>> * fix commit messages
>>>>> * remove changes from serial.c
>>>>>
>>>>> Changes in v2:
>>>>> * split one big patch into smaller 6 patches
>>>>> * add config option to allow disabling this new function
>>>>>
>>>>> Pali Rohár (6):
>>>>>    sandbox: Add function os_flush()
>>>>>    console: Implement flush() function
>>>>>    serial: Implement flush callback
>>>>>    serial: Implement serial_flush() function for console flush() fallback
>>>>>    serial: Call flush() before changing baudrate
>>>>>    boot: Call flush() before booting
>>>>
>>>> Including the change you suggested to 4/6 to fix that build issue,
>>>> there's at least one more large issue that prevents CI from getting too
>>>> far:
>>>> https://source.denx.de/u-boot/u-boot/-/pipelines/13534
>>>> and they all have a failure similar to:
>>>> https://source.denx.de/u-boot/u-boot/-/jobs/500794#L51
>>>
>>> It looks like that some efi stuff overloads u-boot functions, in this
>>> case newly added flush() function.
>>>
>>> Any idea how to handle this issue?
>
> I think you should rename the EFI flush() function to something like
> efi_flush().

lib/efi_selftest/efi_selftest_loadimage.c has a static function flush()
which will override any global flush() function in the context of the
unit test. The unit test does not access the console so it is not really
problematic. But I have no objections to renaming it to efi_st_flush().

Using flush() as name for a global function that only flushes the
console seems a bit generic. Why not use flush_console() as name to
clearly indicate what the function does?

Best regards

Heinrich

>
>>>
>>> The only option which I see how to address it is to revert those changes
>>> in source files which always calls flush() function and replace them by
>>> my first attempt which use guard #ifdef to ensure that flush() call is
>>> completely eliminated at preprocessor stage when efi is enabled.
>>
>> Adding in Heinrich.
>>
>> --
>> Tom
>
> Regards,
> Simon



More information about the U-Boot mailing list