From patchwork Thu May 17 08:40:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8706 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4C61A23E1B for ; Thu, 17 May 2012 08:42:04 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id EC523A18103 for ; Thu, 17 May 2012 08:42:03 +0000 (UTC) Received: by yenq6 with SMTP id q6so1869871yen.11 for ; Thu, 17 May 2012 01:42:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=03ipC39WMcN7UJ98l8SN5vRw3tshNWK5QuvuKFCKywU=; b=EhxKvS15wFBVJIng0Qrzz5aM0LzXF9BIXUfsB4tiwmryR+APObRb13L7lcgoyaH2YE GV9w3lh7Wb4f3MSnjqyqh6eBYtDvcdLKyujd0fhGyqnpV9XIhaEmuRw20cXPTT5hYLjP jHPC0mehaCG3KGkthmSzpSTHrG13TfPBoFMab3iHjfLxiq/FHFTlgxUt3CEUEFbQG9ZE q4YDvm24Zb5BFckEQ8P9FbxXfVH+eUVdlHC23mh6eB47RbcS+xcjabAnf23fx354cRAC lswy2AVpGA4Zv72XmuQFnSCn5xVB5nLLxq9wmlVQR6xqJVOoN12A1Ihu3Z+27TlcHoVl 17Yw== Received: by 10.50.185.233 with SMTP id ff9mr12376389igc.57.1337244123154; Thu, 17 May 2012 01:42:03 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.35.72 with SMTP id o8csp12004ibd; Thu, 17 May 2012 01:42:02 -0700 (PDT) Received: by 10.68.223.138 with SMTP id qu10mr11960932pbc.124.1337244122206; Thu, 17 May 2012 01:42:02 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id qb6si2517932pbb.107.2012.05.17.01.42.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 01:42:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by pbbrr4 with SMTP id rr4so2728948pbb.37 for ; Thu, 17 May 2012 01:42:01 -0700 (PDT) Received: by 10.68.242.226 with SMTP id wt2mr7754315pbc.89.1337244121829; Thu, 17 May 2012 01:42:01 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id ka5sm8416635pbb.37.2012.05.17.01.41.59 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 01:42:00 -0700 (PDT) Date: Thu, 17 May 2012 01:40:31 -0700 From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 1/6] pstore: Add console log messages support Message-ID: <20120517084031.GA31753@lizard> References: <20120517083740.GA25627@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120517083740.GA25627@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQnchbCxFbE6Wi0wgq9hXMDxsf3V2Tw8PuF9sMxz3OFKaeE8UfRIFyVsRGzsvbxkiTL59Jhm Pstore doesn't support logging kernel messages in run-time, it only dumps dmesg when kernel oopses/panics. This makes pstore useless for debugging hangs caused by HW issues or improper use of HW (e.g. weird device inserted -> driver tried to write a reserved bits -> SoC hanged. In that case we don't get any messages in the pstore. Therefore, let's add a runtime logging support: PSTORE_TYPE_CONSOLE. Signed-off-by: Anton Vorontsov Acked-by: Kees Cook --- fs/pstore/Kconfig | 7 +++++++ fs/pstore/inode.c | 3 +++ fs/pstore/platform.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pstore.h | 1 + 4 files changed, 44 insertions(+) diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 23ade26..d044de6 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -12,6 +12,13 @@ config PSTORE If you don't have a platform persistent store driver, say N. +config PSTORE_CONSOLE + bool "Log kernel console messages" + depends on PSTORE + help + When the option is enabled, pstore will log all kernel + messages, even if no oops or panic happened. + config PSTORE_RAM tristate "Log panic/oops to a RAM buffer" depends on PSTORE diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 1950788..97d35ee 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -212,6 +212,9 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, case PSTORE_TYPE_DMESG: sprintf(name, "dmesg-%s-%lld", psname, id); break; + case PSTORE_TYPE_CONSOLE: + sprintf(name, "console-%s", psname); + break; case PSTORE_TYPE_MCE: sprintf(name, "mce-%s-%lld", psname, id); break; diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 82c585f..a3f6d96 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -1,6 +1,7 @@ /* * Persistent Storage - platform driver interface parts. * + * Copyright (C) 2007-2008 Google, Inc. * Copyright (C) 2010 Intel Corporation * * This program is free software; you can redistribute it and/or modify @@ -22,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +158,36 @@ static struct kmsg_dumper pstore_dumper = { .dump = pstore_dump, }; +#ifdef CONFIG_PSTORE_CONSOLE +static void pstore_console_write(struct console *con, const char *s, unsigned c) +{ + const char *e = s + c; + + while (s < e) { + if (c > psinfo->bufsize) + c = psinfo->bufsize; + memcpy(psinfo->buf, s, c); + psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo); + s += c; + c = e - s; + } +} + +static struct console pstore_console = { + .name = "pstore", + .write = pstore_console_write, + .flags = CON_PRINTBUFFER | CON_ENABLED | CON_ANYTIME, + .index = -1, +}; + +static void pstore_register_console(void) +{ + register_console(&pstore_console); +} +#else +static void pstore_register_console(void) {} +#endif + /* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform @@ -193,6 +225,7 @@ int pstore_register(struct pstore_info *psi) pstore_get_records(0); kmsg_dump_register(&pstore_dumper); + pstore_register_console(); pstore_timer.expires = jiffies + PSTORE_INTERVAL; add_timer(&pstore_timer); diff --git a/include/linux/pstore.h b/include/linux/pstore.h index e1461e1..1bd014b 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -29,6 +29,7 @@ enum pstore_type_id { PSTORE_TYPE_DMESG = 0, PSTORE_TYPE_MCE = 1, + PSTORE_TYPE_CONSOLE = 2, PSTORE_TYPE_UNKNOWN = 255 };