From patchwork Tue Oct 9 14:20:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 190333 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 77BAC2C1825 for ; Wed, 10 Oct 2012 01:33:53 +1100 (EST) Received: by ozlabs.org (Postfix) id 83F682C0269; Wed, 10 Oct 2012 01:20:53 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: by ozlabs.org (Postfix, from userid 1034) id 716332C0348; Wed, 10 Oct 2012 01:20:53 +1100 (EST) From: Michael Ellerman To: Subject: [PATCH 20/20] powerpc/xmon: Fallback to printk() in xmon_printf() if udbg is not setup Date: Wed, 10 Oct 2012 01:20:47 +1100 Message-Id: <1349792447-15714-20-git-send-email-michael@ellerman.id.au> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au> References: <1349792447-15714-1-git-send-email-michael@ellerman.id.au> Cc: Paul Mackerras , Anton Blanchard X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/powerpc/xmon/nonstdio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c index 942d0f6..bce3dcf 100644 --- a/arch/powerpc/xmon/nonstdio.c +++ b/arch/powerpc/xmon/nonstdio.c @@ -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)