Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37486875 authored by Wu Jin's avatar Wu Jin Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: common_log: Support for memory dump v2



Add common_log to register with the memory dump v2 driver to
take advantage of the new enhanced memory dump format.

Change-Id: Idb4e70cc0c96c9621ae394b606ca3f6d9e32e32d
Signed-off-by: default avatarJin Wu <jinw@codeaurora.org>
parent 62e43848
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -279,7 +279,6 @@ config MSM_MEMORY_DUMP_V2

config MSM_COMMON_LOG
	bool "MSM Common Log Support"
	depends on MSM_MEMORY_DUMP
	help
	 Use this to export symbols of some log address and variables
	 that need to parse crash dump files to a memory dump table. This
+53 −14
Original line number Diff line number Diff line
@@ -10,35 +10,74 @@
 * GNU General Public License for more details.
 *
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/kallsyms.h>
#include <linux/slab.h>
#include <soc/qcom/memory_dump.h>

static void __init common_log_register(void)
static void __init common_log_register(char *addr, uint32_t length,
						unsigned long *reserved)
{
	struct msm_client_dump dump;
	char **log_bufp;
	uint32_t *log_buf_lenp;
	struct msm_dump_entry dump_entry;
	struct msm_dump_data *dump_data;
	int ret;
	static int count;

	log_bufp = (char **)kallsyms_lookup_name("log_buf");
	log_buf_lenp = (uint32_t *)kallsyms_lookup_name("log_buf_len");
	if (!log_bufp || !log_buf_lenp) {
		pr_err("%s: Symbol log_buf not found!\n", __func__);
	if (MSM_DUMP_MAJOR(msm_dump_table_version()) == 1) {
		dump.id = MSM_COMMON_LOG + count;
		dump.start_addr = virt_to_phys(addr);
		dump.end_addr = virt_to_phys(addr + length);
		if (msm_dump_tbl_register(&dump))
			pr_err("Unable to register %d.\n", dump.id);
	} else {
		dump_data = kzalloc(sizeof(struct msm_dump_data), GFP_KERNEL);
		if (!dump_data) {
			pr_err("Unable to alloc data space.\n");
			return;
		}
	dump.id = MSM_LOG_BUF;
	dump.start_addr = virt_to_phys(*log_bufp);
	dump.end_addr = virt_to_phys(*log_bufp + *log_buf_lenp);
	if (msm_dump_tbl_register(&dump))
		pr_err("%s: Could not register log_buf.\n", __func__);
		if (reserved != 0)
			dump_data->len = virt_to_phys(reserved);
		else
			dump_data->len = 0;
		dump_data->reserved = length;
		dump_data->addr = virt_to_phys(addr);
		dump_entry.id = MSM_DUMP_DATA_COMMON_LOG + count;
		dump_entry.addr = virt_to_phys(dump_data);
		ret = msm_dump_data_register(MSM_DUMP_TABLE_APPS, &dump_entry);
		if (ret) {
			kfree(dump_data);
			pr_err("Unable to register %d.\n", dump_entry.id);
		}
	}
	count++;
}

static void __init register_symbols(char *name, char *len)
{
	char **addr;
	uint32_t *length;
	unsigned long *reserved = 0;

	addr = (char **)kallsyms_lookup_name(name);
	length = (uint32_t *)kallsyms_lookup_name(len);
	if (!addr || !length) {
		pr_err("Unable to find %s by kallsyms!\n", name);
		return;
	}
	/* If item is log_buf, register first index to locate
	* the start address of kmsg in ring buffer. */
	if (strcmp(name, "log_buf") == 0)
		reserved = (unsigned long *)kallsyms_lookup_name(
							"log_first_idx");
	common_log_register(*addr, *length, reserved);
}

static int __init msm_common_log_init(void)
{
	common_log_register();
	register_symbols("log_buf", "log_buf_len");
	return 0;
}
late_initcall(msm_common_log_init);
+3 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ enum dump_client_type {
	MSM_ETM3_REG,
	MSM_TMC0_REG, /* TMC_ETR */
	MSM_TMC1_REG, /* TMC_ETF */
	MSM_LOG_BUF,
	MSM_COMMON_LOG,
	MAX_NUM_CLIENTS,
};

@@ -61,7 +61,7 @@ static inline uint32_t msm_dump_table_version(void)
#define MSM_DUMP_MINOR(val)		(val & 0xFFFFF)


#define MAX_NUM_ENTRIES		0x110
#define MAX_NUM_ENTRIES		0x120

enum msm_dump_data_ids {
	MSM_DUMP_DATA_CPU_CTX = 0x00,
@@ -73,6 +73,7 @@ enum msm_dump_data_ids {
	MSM_DUMP_DATA_OCMEM = 0xE0,
	MSM_DUMP_DATA_TMC_ETF = 0xF0,
	MSM_DUMP_DATA_TMC_REG = 0x100,
	MSM_DUMP_DATA_COMMON_LOG = 0x110,
	MSM_DUMP_DATA_MAX = MAX_NUM_ENTRIES,
};