Baseline update from LYNQ_SDK_ASR_T108_V05.03.01.00(kernel build error.)
Change-Id: I56fc72cd096e82c589920026553170e5cb9692eb
diff --git a/marvell/linux/kernel/panic.c b/marvell/linux/kernel/panic.c
old mode 100644
new mode 100755
index 0a1293b..b0282f7
--- a/marvell/linux/kernel/panic.c
+++ b/marvell/linux/kernel/panic.c
@@ -231,6 +231,10 @@
int old_cpu, this_cpu;
bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
+ //mbtk wyq for reboot reason
+ int ret = MBTK_REBOOT_RESULT_FAIL;
+ //mbtk wyq for reboot reason
+
if (panic_on_warn) {
/*
* This thread may hit another WARN() in the panic path.
@@ -281,6 +285,14 @@
buf[len - 1] = '\0';
pr_emerg("Kernel panic - not syncing: %s\n", buf);
+
+//mbtk wyq for reboot reason
+ ret = mbtk_reboot_reason_save(MBTK_DEV_INFO_NAME, MBTK_REBOOT_FLAG_ABNORMAL);
+ if(ret) {
+ pr_emerg("mbtk_reboot_reason_save err\n");
+ }
+//mbtk wyq for reboot reason
+
#ifdef CONFIG_DEBUG_BUGVERBOSE
/*
* Avoid nested stack-dumping if a panic occurs during oops processing
diff --git a/marvell/linux/kernel/reboot.c b/marvell/linux/kernel/reboot.c
old mode 100644
new mode 100755
index a9b037b..2f5e7b2
--- a/marvell/linux/kernel/reboot.c
+++ b/marvell/linux/kernel/reboot.c
@@ -315,6 +315,103 @@
DEFINE_MUTEX(system_transition_mutex);
+//mbtk wyq for reboot reason
+#include <linux/mtd/mtd.h>
+
+int mbtk_reboot_reason_save(const char *mtd_name, mbtk_device_info_reboot_flag_enum reboot_flag)
+{
+ int err;
+ uint32 ret_err = MBTK_REBOOT_RESULT_FAIL;
+ uint32 read_len = 0;
+ uint32 write_len = 0;
+ uint8 *data_buff = NULL;
+ struct erase_info erase_info = {0};
+ mbtk_device_info_header_t *header = NULL;
+ mbtk_device_info_basic_t *info_basic = NULL;
+ //struct mtd_info *mtd = get_mtd_device(NULL, mtd_num);
+ struct mtd_info *mtd = get_mtd_device_nm(mtd_name);
+ if(IS_ERR(mtd)) {
+ err = PTR_ERR(mtd);
+ pr_emerg("error: Cannot get mtd device[%d]\n", err);
+ return ret_err;
+ }
+
+ /*
+ pr_emerg("device_info:size[0x%08llx] erase_size[0x%08x] write_size[0x%08x] oob_size[0x%08x]\n",
+ mtd->size, mtd->erasesize, mtd->writesize, mtd->oobsize);
+ */
+ data_buff = (uint8 *)vmalloc(mtd->erasesize);
+ if (!data_buff) {
+ pr_emerg("mtd vmalloc err\n");
+ goto fail;
+ }
+
+ if (mtd_read(mtd, (loff_t)0 * mtd->erasesize, mtd->erasesize, &read_len, data_buff)) {
+ pr_emerg("mtd mtd_read err\n");
+ goto fail;
+ }
+
+ if(mtd->erasesize != read_len)
+ {
+ pr_emerg("read_len[0x%x] erasesize[0x%x] inequality\n", read_len, mtd->erasesize);
+ goto fail;
+ }
+
+ header = (mbtk_device_info_header_t*)data_buff;
+ if(header->tag != MBTK_DEVICE_INFO_PARTITION_TAG || header->version != MBTK_DEVICE_INFO_CURR_VERSION)
+ {
+ pr_emerg("tag: 0x%08x verson: %d\n", header->tag, header->version);
+ goto fail;
+ }
+
+ info_basic = (mbtk_device_info_basic_t*)(data_buff + header->item_header[MBTK_DEVICE_INFO_ITEM_BASIC].addr);
+ if(info_basic->reboot_flag == MBTK_REBOOT_FLAG_NORMAL)
+ {
+ info_basic->reboot_flag = reboot_flag;
+ }
+ else
+ {
+ goto success;
+ }
+
+ memset(&erase_info, 0x0, sizeof(struct erase_info));
+ erase_info.addr = 0;
+ erase_info.len = mtd->erasesize;
+
+ err = mtd_erase(mtd, &erase_info);
+ if(err)
+ {
+ pr_emerg("mtd_erase err[%d]\n", err);
+ goto fail;
+ }
+
+ if (mtd_write(mtd, (loff_t)0 * mtd->erasesize, mtd->erasesize, &write_len, data_buff)) {
+ pr_emerg("mtd mtd_write err\n");
+ goto fail;
+ }
+
+ if(mtd->erasesize != write_len)
+ {
+ pr_emerg("write_len[0x%x] erasesize[0x%x] inequality\n", write_len, mtd->erasesize);
+ goto fail;
+ }
+
+success:
+ ret_err = MBTK_REBOOT_RESULT_SUCCESS;
+
+fail:
+ if(data_buff) {
+ vfree(data_buff);
+ data_buff = NULL;
+ }
+ if (mtd) {
+ put_mtd_device(mtd);
+ mtd = NULL;
+ }
+ return ret_err;
+}
+//mbtk wyq for reboot reason
+
/*
* Reboot system call: for obvious reasons only root may call it,
* and even root needs to set up some magic numbers in the registers
@@ -343,6 +440,15 @@
magic2 != LINUX_REBOOT_MAGIC2C))
return -EINVAL;
+//mbtk wyq for reboot reason
+ if(cmd) {
+ ret = mbtk_reboot_reason_save(MBTK_DEV_INFO_NAME, MBTK_REBOOT_FLAG_COMMAND);
+ if(ret) {
+ pr_emerg("mbtk_reboot_reason_save err\n");
+ }
+ }
+//mbtk wyq for reboot reason
+
/*
* If pid namespaces are enabled and the current task is in a child
* pid_namespace, the command is handled by reboot_pid_ns() which will