soc: qcom: memory_dump: Restore memory_dump table during hibernation

Add hibernation callback to restore memory_dump table in IMEM
during hibernation restore. Use syscore callbacks in this
case to restore the value as soon as possible.

Change-Id: I243a354ce6ccb9f349684eb9b649d43d5b3ed519
Signed-off-by: Arun KS <arunks@codeaurora.org>
This commit is contained in:
Arun KS 2020-04-08 20:19:51 +05:30
parent e6f30f66af
commit 03c0e41a74

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, 2020 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -23,6 +23,7 @@
#include <linux/of_device.h>
#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/syscore_ops.h>
#define MSM_DUMP_TABLE_VERSION MSM_DUMP_MAKE_VERSION(2, 0)
@ -168,12 +169,23 @@ struct dump_vaddr_entry *get_msm_dump_ptr(enum msm_dump_data_ids id)
}
EXPORT_SYMBOL(get_msm_dump_ptr);
static void __iomem *imem_base;
#ifdef CONFIG_HIBERNATION
static void memory_dump_syscore_resume(void)
{
memcpy_toio(imem_base, &memdump.table_phys, sizeof(memdump.table_phys));
}
static struct syscore_ops memory_dump_syscore_ops = {
.resume = memory_dump_syscore_resume,
};
#endif
static int __init init_memory_dump(void)
{
struct msm_dump_table *table;
struct msm_dump_entry entry;
struct device_node *np;
void __iomem *imem_base;
int ret;
np = of_find_compatible_node(NULL, NULL,
@ -201,8 +213,9 @@ static int __init init_memory_dump(void)
mb();
pr_info("MSM Memory Dump base table set up\n");
#ifndef CONFIG_HIBERNATION
iounmap(imem_base);
#endif
table = kzalloc(sizeof(struct msm_dump_table), GFP_KERNEL);
if (!table) {
ret = -ENOMEM;
@ -219,6 +232,9 @@ static int __init init_memory_dump(void)
}
pr_info("MSM Memory Dump apps data table set up\n");
#ifdef CONFIG_HIBERNATION
register_syscore_ops(&memory_dump_syscore_ops);
#endif
return 0;
err2:
kfree(table);