Skip to content

Commit

Permalink
Enable pstore/ramoops dump for kernel panics.
Browse files Browse the repository at this point in the history
Updated to include options for proper last_kmsg generation
CONFIG_SEC_DEBUG_NOCACHE_LOG_IN_LEVEL_LOW=y
CONFIG_PRINTK_PROCESS=y
CONFIG_SEC_DEBUG_LOW_LOG=y

Squashed commit of the following:

commit cf46f03896a2010cd291607e143638aea86cf5bd
Author: Tony Layher <layhertony@gmail.com>
Date:   Sun Jan 25 23:34:40 2015 -0500

    trlte: enable panic dumps in defconfig and carve out mem region

    Change-Id: Ifee3321b13a2fbd908a62f442b1a3656f793373d

commit 683306b316e6296084fbe6d53dcad9824dd525ad
Author: Yi-wei Zhao <gbjc64@motorola.com>
Date:   Thu Aug 7 13:59:41 2014 -0500

    fs/pstore: handle panic kmsg dump

    There are two changes:

    1. read 'record size' and 'dump oops' from device tree.
    2. only write for KMSG_DUMP_PANIC. When oops happens (panic_on_oops = 1),
    both oops_exit() and panic() will dump kmsg. Skip KMSG_DUMP_OOPS
    to avoid dump kmsg twice.

    Signed-off-by: Yi-wei Zhao <gbjc64@motorola.com>
    Reviewed-by: Hong-Mei Li <a21834@motorola.com>

commit 74305f95eccb13b0658817b0cd5c08b1fb18008d
Author: Arve Hjønnevåg <arve@android.com>
Date:   Fri May 2 20:23:21 2014 -0700

    pstore/ram: Add ramoops_console_write_buf api

    Allow writing into the ramoops console buffer.

    Change-Id: Iff0d69b562e4dae33ea7f8d19412227bebb17e47
    Signed-off-by: Arve Hjønnevåg <arve@android.com>
    Signed-off-by: Patrick Tjin <pattjin@google.com>

    Conflicts:
    fs/pstore/ram.c

commit 0e9158f4623586c10050471ce20298f99b4063f9
Author: Yuanyuan Zhong <zyy@motorola.com>
Date:   Tue Jun 10 16:20:27 2014 -0500

    pstore/ram: export map/unmap functions

    Export persistent_ram_map() and persistent_ram_unmap() as
    general purpose functions for mapping and unmapping reserved
    memory buffer.

    Signed-off-by: Yuanyuan Zhong <zyy@motorola.com>
    Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>

commit 5a7438174d61d26b6d7e321eedabb0801b5b660d
Author: Yuanyuan Zhong <zyy@motorola.com>
Date:   Tue Jun 10 14:23:07 2014 -0500

    pstore/ram: allow annotation appending

    Existing pstore ram annotation stores messages and exports them
    after reset. Add function which can be used to append messages
    to the annotation after reset and before they are exported to
    annotation-ramoops file.

    Signed-off-by: Yuanyuan Zhong <zyy@motorola.com>
    Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>

commit a950f7ff89cae0a0d4bced57fc94bff218a25e16
Author: Dmitry Ornatsky <cdo021c@motorola.com>
Date:   Tue Apr 8 08:11:06 2014 -0500

    fs: pstore: add annotation support

    Add annotation type prz support to pstore. Publish
    annotate function for kernel modules. On warm power
    up pstore will make annotation information found in
    new ramprz available in annotation-ramoops file.

    Signed-off-by: Dmitry Ornatsky <cdo021c@motorola.com>
    Reviewed-by: Russell Knize <rknize@motorola.com>

commit 7bbbdcacd7b11d02c7e70e875f04d24c6a423b86
Author: Yi-wei Zhao <gbjc64@motorola.com>
Date:   Mon Mar 31 19:28:35 2014 -0500

    fs:pstore:ramoops: config mem from dt

    configure the start & size of ramoops memory using device tree.

    the 'dummy' device is no harm as long as initial mem_size is zero.

    Signed-off-by: Yi-wei Zhao <gbjc64@motorola.com>
    Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>

Change-Id: I371bfdcfc0bb4dca76c40ed03705ad32fd8b97ab
  • Loading branch information
slayher authored and javilonas committed May 14, 2015
1 parent 7e705f9 commit 6c16390
Show file tree
Hide file tree
Showing 9 changed files with 394 additions and 14 deletions.
15 changes: 15 additions & 0 deletions arch/arm/boot/dts/qcom/apq8084.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@
#size-cells = <1>;
ranges = <0 0 0 0xffffffff>;

ramoops {
compatible = "ramoops";
status = "ok";
android,ramoops-buffer-start = <0x3e9e0000>;
android,ramoops-buffer-size = <0x100000>;
android,ramoops-console-size = <0x80000>;
android,ramoops-record-size = <0x7F800>;
android,ramoops-annotate-size = <0x800>;
android,ramoops-dump-oops = <0x1>;
android,ramoops-hole {
compatible = "qcom,msm-contig-mem";
qcom,memblock-reserve = <0x3e9e0000 0x100000>;
};
};

intc: interrupt-controller@f9000000 {
compatible = "qcom,msm-qgic2";
interrupt-controller;
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/configs/apq8084_sec_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ CONFIG_CRYPTO_LZO=y
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_RAM=y
CONFIG_PSTORE_RAM_ANNOTATION_APPEND=y
CONFIG_PRINTK_PROCESS=y
CONFIG_SEC_DEBUG_NOCACHE_LOG_IN_LEVEL_LOW=y
CONFIG_SEC_DEBUG_LOW_LOG=y
CONFIG_F2FS_FS=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ASCII=y
Expand Down
14 changes: 14 additions & 0 deletions fs/pstore/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,17 @@ config PSTORE_RAM
"ramoops.ko".

For more information, see Documentation/ramoops.txt.

config PSTORE_RAM_ANNOTATION_APPEND
bool "Allow appending messages to pstore ram annotation"
default n
depends on PSTORE_RAM
help
Existing pstore ram annotation stores messages and exports them
after reset. Sometimes only after reset can we do some postmortem
analysis. This adds function which can be used to append the
analysis info to pstore ram annotation. The function should only
be used before pstore ram annotation is exported. It's safe to use
the function before pstore is initialized. Content will be buffered
and merged to annotation-ramoops file.
If unsure, say N.
16 changes: 10 additions & 6 deletions fs/pstore/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,26 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,

switch (type) {
case PSTORE_TYPE_DMESG:
sprintf(name, "dmesg-%s-%lld", psname, id);
snprintf(name, PSTORE_NAMELEN, "dmesg-%s-%lld", psname, id);
break;
case PSTORE_TYPE_CONSOLE:
sprintf(name, "console-%s", psname);
snprintf(name, PSTORE_NAMELEN, "console-%s", psname);
break;
case PSTORE_TYPE_FTRACE:
sprintf(name, "ftrace-%s", psname);
snprintf(name, PSTORE_NAMELEN, "ftrace-%s", psname);
break;
case PSTORE_TYPE_MCE:
sprintf(name, "mce-%s-%lld", psname, id);
snprintf(name, PSTORE_NAMELEN, "mce-%s-%lld", psname, id);
break;
case PSTORE_TYPE_ANNOTATE:
snprintf(name, PSTORE_NAMELEN, "annotate-%s", psname);
break;
case PSTORE_TYPE_UNKNOWN:
sprintf(name, "unknown-%s-%lld", psname, id);
snprintf(name, PSTORE_NAMELEN, "unknown-%s-%lld", psname, id);
break;
default:
sprintf(name, "type%d-%s-%lld", type, psname, id);
snprintf(name, PSTORE_NAMELEN, "type%d-%s-%lld",
type, psname, id);
break;
}

Expand Down
46 changes: 46 additions & 0 deletions fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/atomic.h>
#include <linux/types.h>
#include <linux/errno.h>
Expand Down Expand Up @@ -177,6 +179,48 @@ static struct kmsg_dumper pstore_dumper = {
.dump = pstore_dump,
};



/* Export function to save device specific power up
* data
*
*/

int pstore_annotate(const char *buf)
{
unsigned cnt = strlen(buf);
const char *end = buf + cnt;

while (buf < end) {
unsigned long flags;
int ret;
u64 id;

if (cnt > psinfo->bufsize)
cnt = psinfo->bufsize;

if (oops_in_progress) {
if (!spin_trylock_irqsave(&psinfo->buf_lock, flags))
break;
} else {
spin_lock_irqsave(&psinfo->buf_lock, flags);
}
memcpy(psinfo->buf, buf, cnt);
ret = psinfo->write(PSTORE_TYPE_ANNOTATE, 0, &id, 0, 0,
cnt, psinfo);
spin_unlock_irqrestore(&psinfo->buf_lock, flags);

pr_debug("ret %d wrote bytes %d\n", ret, cnt);
buf += cnt;
cnt = end - buf;
}

return 0;

}
EXPORT_SYMBOL_GPL(pstore_annotate);


#ifdef CONFIG_PSTORE_CONSOLE
static void pstore_console_write(struct console *con, const char *s, unsigned c)
{
Expand Down Expand Up @@ -273,6 +317,7 @@ int pstore_register(struct pstore_info *psi)
msecs_to_jiffies(pstore_update_ms);
add_timer(&pstore_timer);
}
pr_info("psi registered\n");

return 0;
}
Expand Down Expand Up @@ -309,6 +354,7 @@ void pstore_get_records(int quiet)
buf = NULL;
if (rc && (rc != -EEXIST || !quiet))
failed++;
pr_info("Found record type %d, psi name %s\n", type, psi->name);
}
if (psi->close)
psi->close(psi);
Expand Down
Loading

0 comments on commit 6c16390

Please sign in to comment.