diff options
author | Jean-Marc Eurin <jmeurin@google.com> | 2022-04-25 19:09:27 +0300 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2022-04-26 10:27:12 +0300 |
commit | aa641a22bb5b1971a459b37746b845e3f5f084ca (patch) | |
tree | 58caabf89212631cb689eaaaf3c5d5c6f5f57268 /drivers/mtd | |
parent | 0bd359ee712d9d3e757971ded4094c8ba006acd4 (diff) | |
download | linux-aa641a22bb5b1971a459b37746b845e3f5f084ca.tar.xz |
mtd: mtdoops: Add a timestamp to the mtdoops header.
On some systems, the oops only has relative time from boot.
Signed-off-by: Jean-Marc Eurin <jmeurin@google.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220425160927.3823016-1-jmeurin@google.com
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdoops.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 186eeb01bee1..3d4a2ffb5b01 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -16,6 +16,7 @@ #include <linux/wait.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include <linux/timekeeping.h> #include <linux/mtd/mtd.h> #include <linux/kmsg_dump.h> @@ -37,11 +38,13 @@ module_param(dump_oops, int, 0600); MODULE_PARM_DESC(dump_oops, "set to 1 to dump oopses, 0 to only dump panics (default 1)"); -#define MTDOOPS_KERNMSG_MAGIC 0x5d005d00 +#define MTDOOPS_KERNMSG_MAGIC_v1 0x5d005d00 /* Original */ +#define MTDOOPS_KERNMSG_MAGIC_v2 0x5d005e00 /* Adds the timestamp */ struct mtdoops_hdr { u32 seq; u32 magic; + ktime_t timestamp; } __packed; static struct mtdoops_context { @@ -191,7 +194,8 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) /* Add mtdoops header to the buffer */ hdr = (struct mtdoops_hdr *)cxt->oops_buf; hdr->seq = cxt->nextcount; - hdr->magic = MTDOOPS_KERNMSG_MAGIC; + hdr->magic = MTDOOPS_KERNMSG_MAGIC_v2; + hdr->timestamp = ktime_get_real(); if (panic) { ret = mtd_panic_write(mtd, cxt->nextpage * record_size, @@ -247,7 +251,9 @@ static void find_next_position(struct mtdoops_context *cxt) if (hdr.seq == 0xffffffff && hdr.magic == 0xffffffff) mark_page_unused(cxt, page); - if (hdr.seq == 0xffffffff || hdr.magic != MTDOOPS_KERNMSG_MAGIC) + if (hdr.seq == 0xffffffff || + (hdr.magic != MTDOOPS_KERNMSG_MAGIC_v1 && + hdr.magic != MTDOOPS_KERNMSG_MAGIC_v2)) continue; if (maxcount == 0xffffffff) { maxcount = hdr.seq; |