[U-Boot] [PATCH 5/6] serial: ns16550: fix debug uart putc called before init
sjg at google.com
sjg at google.com
Wed Oct 24 17:32:14 UTC 2018
On Tue, Oct 23, 2018 at 11:01 AM Marek Vasut <marex at denx.de> wrote:
>
> On 10/19/2018 05:25 AM, Simon Glass wrote:
> > On 9 August 2018 at 13:04, Simon Goldschmidt
> > <simon.k.r.goldschmidt at gmail.com> wrote:
> >> If _debug_uart_putc() is called before _debug_uart_init(), the
> >> ns16550 debug uart driver hangs in a tight loop waiting for the
> >> tx FIFO to get empty.
> >>
> >> As this can happen via a printf sneaking in before the port calls
> >> debug_uart_init(), let's rather ignore characters before the debug
> >> uart is initialized.
> >>
> >> This is done by reading the baudrate divisor and aborting if is zero.
> >>
> >> Tested on socfpga_cyclone5_socrates.
> >>
> >> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
> >> ---
> >> v2:
> >> - this patch is new in v2 of the series. It replaces the printf/debug
> >> change in reset_manager_gen5.c from v1
> >>
> >> drivers/serial/ns16550.c | 18 ++++++++++++++++--
> >> 1 file changed, 16 insertions(+), 2 deletions(-)
> >
> > We cannot use global_data before it is set up, so I think this is the
> > best solution.
> >
> > Acked-by: Simon Glass <sjg at chromium.org>
>
> So there's no GD available when using debug uart ? Hum.
>
> btw. Does the NS16550_read_baud_divisor() need to be called within the
> while loop ?
No. I just decided to put it there so that it is not executed unless
we wait in a tight loop anyway.
So if the transmit buffer is empty, code flow is unchanged by this
patch. Only if it is not empty, the baud divisor is read. But in this
case, we would cycle the while loop a few hundred times, anyway, I
guess...
Simon
Applied to u-boot-dm/next, thanks!
More information about the U-Boot
mailing list