[U-Boot] [PATCH] logbuff: Prevent an infinite loop for console output

Peter Tyser ptyser at xes-inc.com
Fri May 7 19:34:28 CEST 2010


On Fri, 2010-05-07 at 10:23 +0200, Detlev Zundel wrote:
> Hi Peter,
> 
> > When using 'logbuff' as stdout and the console loglevel is greater
> > than a message's loglevel it is supposed to be both logged, and printed
> > to the console.  The logbuff_printk() function is responsible for both
> > logging and displaying the message.  However, logbuff_printk()
> > previously used printf() to print the message to the console.  The
> > printf() call would eventually end up back in logbuff_printk(), and
> > an infinite loop would occur which would hang a board.
> >
> > Using serial_puts() instead of printf() in logbuff_printk() avoids the
> > recursion and resolves the issue.
> >
> > Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
> > Reported-by: Dennis Ruffer <daruffer at gmail.com>
> 
> Hm.  What if a board has "stdout" set to "lcd" or "nc" or any other
> device?  Do we really want the text to be output on the serial console
> then?  Doesn't this break the whole "stdout" concept?

Yes, it does break the stdout concept, but I went with the current patch
for 3 reasons:
1. Most anything is better than the current board lockup that occurs
without the change.

2. For most of the boot process serial_puts() is used to output messages
(ie prior to GD_FLG_DEVINIT is set in gd->flags).  Continuing to use the
same output method after GD_FLG_DEVINIT is set makes some degree of
sense.

3. A proper fix would be more involved.  For example, perhaps allowing
the stdout variable to support multiple devices (eg
"stdout=logbuff,lcd") would be a more elegant solution.  In any case, to
use both the logbuff and non-serial port for output would require much
more extensive changes than this 1-line change.  I don't use the
logbuff, so am not so interested in spending the time to fix it.  The
fact that no one else ran into this bug implies no on else is using it
either.

I agree this fix isn't the best, but its better than the bug in my
opinion.  Ideally someone who uses the logbuff could provide a more
elegant fix.  Any takers?

Best,
Peter



More information about the U-Boot mailing list