Skip to content

Commit

Permalink
powerpc/xmon: Fallback to printk() in xmon_printf() if udbg is not setup
Browse files Browse the repository at this point in the history
It is possible to configure a kernel which has xmon enabled, but has no
udbg backend to provide IO. This can make xmon rather confusing, as it
produces no output, blocks for two seconds, and then returns.

As a last resort we can instead try to printk(), which may deadlock or
otherwise crash, but tries quite hard not to.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Michael Ellerman authored and Benjamin Herrenschmidt committed Nov 15, 2012
1 parent 0104cd6 commit b2bb65f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arch/powerpc/xmon/nonstdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,19 @@ char *xmon_gets(char *str, int nb)
void xmon_printf(const char *format, ...)
{
va_list args;
int n;
static char xmon_outbuf[1024];
int rc, n;

va_start(args, format);
n = vsnprintf(xmon_outbuf, sizeof(xmon_outbuf), format, args);
va_end(args);
xmon_write(xmon_outbuf, n);

rc = xmon_write(xmon_outbuf, n);

if (n && rc == 0) {
/* No udbg hooks, fallback to printk() - dangerous */
printk(xmon_outbuf);
}
}

void xmon_puts(const char *str)
Expand Down

0 comments on commit b2bb65f

Please sign in to comment.