Re: [PATCH 18/56] microblaze_v2: early_printk support

Michal Simek
2008-05-06T08:13:50Z

Make sense.
I'll add it.

Thanks,
M
> On Sun, 2008-05-04 at 13:41 +0200, monstr@seznam.cz wrote:
>
>> +++ b/arch/microblaze/kernel/early_printk.c
>
>> +static void early_printk_putc(char c)
>> +{
>> + while (ioread32(STATUS) & (1<<3));
>> + iowrite32((c & 0xff), TX_FIFO);
>> +}
>
> The while() loop needs a retry counter - if you configure
> EARLY_PRINTK_BASE_ADDRESS wrongly and it points to memory or anything
> that is not a uartlite, the loop spins forever and you get silent
> lockup. Not nice behaviour from debug code :)
>
> Here's my current implementation:
>
> static void early_printk_putc(char c)
> {
> /* Limit how many times we'll spin waiting for TX FIFO status.
> This will prevent lockups if the base address is incorrectly
> set, or
> any other issue on the UARTLITE.
>
> This limit is pretty arbitrary, unless we are at about 10
> baud
> we'll never timeout on a working UART. */
>
> unsigned retries=10000;
> while (retries-- && (ioread32(STATUS) & (1<<3)))
> ;
>
> /* Only attempt the iowrite if we didn't timeout */
> if(retries)
> iowrite32((c & 0xff), TX_FIFO);
> }
>
> Cheers
>
> John
>
>
>
>