fs: pstore: import vangogh-r-oss support to get last_kmsg
This commit is contained in:
parent
6b146db8c9
commit
4e007d173f
@ -490,7 +490,7 @@ static void msm_restart_prepare(const char *cmd)
|
||||
pr_info("Forcing a warm reset of the system\n");
|
||||
|
||||
/* Hard reset the PMIC unless memory contents must be maintained. */
|
||||
if (force_warm_reboot || need_warm_reset)
|
||||
if (force_warm_reboot || need_warm_reset || in_panic)
|
||||
qpnp_pon_system_pwr_off(PON_POWER_OFF_WARM_RESET);
|
||||
else
|
||||
qpnp_pon_system_pwr_off(PON_POWER_OFF_HARD_RESET);
|
||||
|
@ -153,3 +153,11 @@ config PSTORE_RAM
|
||||
"ramoops.ko".
|
||||
|
||||
For more information, see Documentation/admin-guide/ramoops.rst.
|
||||
|
||||
config PSTORE_LAST_KMSG
|
||||
bool "export /proc/last_kmsg"
|
||||
default y
|
||||
depends on PSTORE
|
||||
help
|
||||
When the option is enabled, pstore will export a proc filesystem
|
||||
interface /proc/last_kmsg.
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Persistent Storage - ramfs parts.
|
||||
*
|
||||
* Copyright (C) 2010 Intel Corporation <tony.luck@intel.com>
|
||||
* Copyright (C) 2021 XiaoMi, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@ -36,6 +37,9 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/uaccess.h>
|
||||
#ifdef CONFIG_PSTORE_LAST_KMSG
|
||||
#include <linux/proc_fs.h>
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -297,6 +301,25 @@ bool pstore_is_mounted(void)
|
||||
return pstore_sb != NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PSTORE_LAST_KMSG
|
||||
|
||||
static char *console_buffer;
|
||||
static ssize_t console_bufsize;
|
||||
|
||||
static ssize_t last_kmsg_read(struct file *file, char __user *buf,
|
||||
size_t len, loff_t *offset)
|
||||
{
|
||||
return simple_read_from_buffer(buf, len, offset,
|
||||
console_buffer, console_bufsize);
|
||||
}
|
||||
|
||||
static const struct file_operations last_kmsg_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = last_kmsg_read,
|
||||
.llseek = default_llseek,
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make a regular file in the root directory of our file system.
|
||||
* Load it up with "size" bytes of data from "buf".
|
||||
@ -403,6 +426,13 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
|
||||
list_add(&private->list, &allpstore);
|
||||
spin_unlock_irqrestore(&allpstore_lock, flags);
|
||||
|
||||
#ifdef CONFIG_PSTORE_LAST_KMSG
|
||||
if (record->type == PSTORE_TYPE_CONSOLE) {
|
||||
console_buffer = private->record->buf;
|
||||
console_bufsize = size;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
fail_private:
|
||||
@ -488,6 +518,9 @@ static struct file_system_type pstore_fs_type = {
|
||||
int __init pstore_init_fs(void)
|
||||
{
|
||||
int err;
|
||||
#ifdef CONFIG_PSTORE_LAST_KMSG
|
||||
struct proc_dir_entry *last_kmsg_entry = NULL;
|
||||
#endif
|
||||
|
||||
/* Create a convenient mount point for people to access pstore */
|
||||
err = sysfs_create_mount_point(fs_kobj, "pstore");
|
||||
@ -498,6 +531,14 @@ int __init pstore_init_fs(void)
|
||||
if (err < 0)
|
||||
sysfs_remove_mount_point(fs_kobj, "pstore");
|
||||
|
||||
#ifdef CONFIG_PSTORE_LAST_KMSG
|
||||
last_kmsg_entry = proc_create_data("last_kmsg", S_IFREG | S_IRUGO,
|
||||
NULL, &last_kmsg_fops, NULL);
|
||||
if (!last_kmsg_entry) {
|
||||
pr_err("Failed to create last_kmsg\n");
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
* RAM Oops/Panic logger
|
||||
*
|
||||
* Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
|
||||
* Copyright (C) 2021 XiaoMi, Inc.
|
||||
* Copyright (C) 2011 Kees Cook <keescook@chromium.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@ -35,6 +36,7 @@
|
||||
#include <linux/pstore_ram.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/memblock.h>
|
||||
|
||||
#define RAMOOPS_KERNMSG_HDR "===="
|
||||
#define MIN_MEM_SIZE 4096UL
|
||||
@ -967,6 +969,49 @@ static void __init ramoops_register_dummy(void)
|
||||
}
|
||||
}
|
||||
|
||||
static struct ramoops_platform_data ramoops_data;
|
||||
|
||||
static struct platform_device ramoops_dev = {
|
||||
.name = "ramoops",
|
||||
.dev = {
|
||||
.platform_data = &ramoops_data,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init ramoops_memreserve(char *p)
|
||||
{
|
||||
unsigned long size;
|
||||
|
||||
if (!p)
|
||||
return 1;
|
||||
|
||||
size = memparse(p, &p) & PAGE_MASK;
|
||||
ramoops_data.mem_size = size;
|
||||
ramoops_data.mem_address = 0xB0000000;
|
||||
ramoops_data.console_size = size / 2;
|
||||
ramoops_data.pmsg_size = size / 2;
|
||||
ramoops_data.dump_oops = 1;
|
||||
|
||||
pr_info("msm_reserve_ramoops_memory addr=%llx,size=%lx\n",
|
||||
ramoops_data.mem_address, ramoops_data.mem_size);
|
||||
pr_info("msm_reserve_ramoops_memory record_size=%lx,ftrace_size=%lx\n",
|
||||
ramoops_data.record_size, ramoops_data.ftrace_size);
|
||||
|
||||
memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
early_param("ramoops_memreserve", ramoops_memreserve);
|
||||
|
||||
static int __init msm_register_ramoops_device(void)
|
||||
{
|
||||
pr_info("msm_register_ramoops_device\n");
|
||||
if (platform_device_register(&ramoops_dev))
|
||||
pr_info("Unable to register ramoops platform device\n");
|
||||
return 0;
|
||||
}
|
||||
core_initcall(msm_register_ramoops_device);
|
||||
|
||||
static int __init ramoops_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
Loading…
Reference in New Issue
Block a user