From patchwork Fri May 18 22:25:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8821 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 5643F23EB5 for ; Fri, 18 May 2012 22:26:32 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 10D0AA18340 for ; Fri, 18 May 2012 22:26:31 +0000 (UTC) Received: by yhpp61 with SMTP id p61so4113203yhp.11 for ; Fri, 18 May 2012 15:26:31 -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=ledJ+aPj7V0O+KTMvYtk3z3DoXcj57jmTk40ZhiIX18=; b=daajLmZ8z8usYBSamT5QP2EuxRDeM0WxKBjoCV6cWBEu9nfSlYQiu7IIfIWrzgw57K WsSX3koT6nAz64zt5VxiZDUZfiOpVohj2c21c7sCShRrJzT630KXlIM1CbUCYKqtKbQE D1wB+T5hQGyq1XwGRZ3G1YrHKGtAQ50k1Ca1+r1797K7Ilksh1cMpX7BBRMfqu6xN1LS Tp9Htp7zbDDTiwmyryn1CR4rztF+zFn7Llo7teEJ41wS2WM+SYB9sWJtDvMdXCde3Slh Y2tS/pzK+wkY9MAJX2+kWfM26IycnITZUVepJol7Re75cU0nadcyEK/T0J3ahSex8DYn ljRg== Received: by 10.50.46.232 with SMTP id y8mr1619787igm.57.1337379991188; Fri, 18 May 2012 15:26:31 -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 o8csp135264ibd; Fri, 18 May 2012 15:26:30 -0700 (PDT) Received: by 10.68.197.99 with SMTP id it3mr11676937pbc.148.1337379990489; Fri, 18 May 2012 15:26:30 -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 t9si17694348pbj.72.2012.05.18.15.26.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 15:26:30 -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 rr4so5393933pbb.37 for ; Fri, 18 May 2012 15:26:30 -0700 (PDT) Received: by 10.68.226.228 with SMTP id rv4mr15654063pbc.167.1337379990192; Fri, 18 May 2012 15:26:30 -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 pz3sm14141144pbc.16.2012.05.18.15.26.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 15:26:29 -0700 (PDT) Date: Fri, 18 May 2012 15:25:00 -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 05/14] pstore: Add console log messages support Message-ID: <20120518222500.GE23089@lizard> References: <20120518222314.GA9425@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120518222314.GA9425@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlYOuGNxtFy1KtEQJScYHM/CG5ChCPy8mv5SDfdlPPxWDuM30+Z0ROEVZ+8fUjpsXmSkLNa 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 Acked-by: Colin Cross --- 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 49b40ea..fda1331 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 };