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

From: John Williams
Date: Mon May 05 2008 - 19:23:41 EST



On Sun, 2008-05-04 at 13:41 +0200, monstr@xxxxxxxxx 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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/