From f41c5d4b026ef3ce8c761016f104d2de5539beb2 Mon Sep 17 00:00:00 2001 From: Changki Kim Date: Wed, 24 Oct 2018 14:37:12 +0900 Subject: [PATCH] [ERD][NEUS7920-76] [COMMON]lib: dss: Add saving dss item information for bootloader Change-Id: Ie4094df9be7d1a8296dd108667a8d7e6e1e6fde0 Signed-off-by: Changki Kim --- include/linux/debug-snapshot.h | 8 ++++++ lib/debug-snapshot-local.h | 13 +++++++++ lib/debug-snapshot-log.h | 6 +--- lib/debug-snapshot.c | 52 +++++++++++++++++++++++++--------- 4 files changed, 61 insertions(+), 18 deletions(-) diff --git a/include/linux/debug-snapshot.h b/include/linux/debug-snapshot.h index d4136b000357..0ee303467fa7 100644 --- a/include/linux/debug-snapshot.h +++ b/include/linux/debug-snapshot.h @@ -57,6 +57,9 @@ extern void dbg_snapshot_hook_hardlockup_exit(void); extern void dbg_snapshot_dump_sfr(void); extern int dbg_snapshot_hook_pmsg(char *buffer, size_t count); extern void dbg_snapshot_save_log(int cpu, unsigned long where); +extern int dbg_snapshot_add_bl_item_info(const char *name, + unsigned int paddr, unsigned int size); + #define dbg_snapshot_irq_var(v) do { v = cpu_clock(raw_smp_processor_id()); \ } while(0) /* option */ @@ -242,6 +245,11 @@ static inline bool dbg_snapshot_dumper_one(void *v_dumper, { return false; } +static int dbg_snapshot_add_bl_item_info(const char *name, + unsigned int paddr, unsigned int size) +{ + return 0; +} #endif /* CONFIG_DEBUG_SNAPSHOT */ extern void dbg_snapshot_soc_helper_init(void); diff --git a/lib/debug-snapshot-local.h b/lib/debug-snapshot-local.h index 4c9114db612b..47997baa1b8b 100644 --- a/lib/debug-snapshot-local.h +++ b/lib/debug-snapshot-local.h @@ -63,6 +63,19 @@ struct dbg_snapshot_item { struct vm_struct vm; }; +struct dbg_snapshot_bl { + unsigned int magic1; + unsigned int magic2; + unsigned int item_count; + unsigned int reserved; + struct { + char name[SZ_16]; + unsigned int paddr; + unsigned int size; + unsigned int enabled; + } item[SZ_16]; +}; + struct dbg_snapshot_sfrdump { char *name; void __iomem *reg; diff --git a/lib/debug-snapshot-log.h b/lib/debug-snapshot-log.h index 64e066662d41..282276b41a59 100644 --- a/lib/debug-snapshot-log.h +++ b/lib/debug-snapshot-log.h @@ -71,13 +71,9 @@ #define DSS_OFFSET_CORE_POWER_STAT (0x400) #define DSS_OFFSET_PANIC_STAT (0x500) #define DSS_OFFSET_CORE_LAST_PC (0x600) - /* S5P_VA_SS_BASE + 0x700 -- 0x8FF is reserved */ #define DSS_OFFSET_LINUX_BANNER (0x700) - -#define DSS_OFFSET_KERNEL_LOG (0x900) -#define DSS_OFFSET_PLATFORM_LOG (0x904) -#define DSS_OFFSET_KERNEL_EVENT (0x908) +#define DSS_OFFSET_ITEM_INFO (0x900) /* S5P_VA_SS_BASE + 0xC00 -- 0xFFF is reserved */ #define DSS_OFFSET_PANIC_STRING (0xC00) diff --git a/lib/debug-snapshot.c b/lib/debug-snapshot.c index 9027ae5a32b1..201824b8581e 100644 --- a/lib/debug-snapshot.c +++ b/lib/debug-snapshot.c @@ -57,6 +57,7 @@ const char *debug_level_val[] = { "mid", }; +struct dbg_snapshot_bl *dss_bl; struct dbg_snapshot_item dss_items[] = { {"header", {0, 0, 0, false, false}, NULL ,NULL, 0, }, {"log_kernel", {0, 0, 0, false, false}, NULL ,NULL, 0, }, @@ -102,6 +103,20 @@ int dbg_snapshot_get_debug_level(void) return dss_desc.debug_level; } +int dbg_snapshot_add_bl_item_info(const char *name, unsigned int paddr, unsigned int size) +{ + if (dss_bl->item_count >= SZ_16) + return -1; + + memcpy(dss_bl->item[dss_bl->item_count].name, name, strlen(name) + 1); + dss_bl->item[dss_bl->item_count].paddr = paddr; + dss_bl->item[dss_bl->item_count].size = size; + dss_bl->item[dss_bl->item_count].enabled = 1; + dss_bl->item_count++; + + return 0; +} + int dbg_snapshot_set_enable(const char *name, int en) { struct dbg_snapshot_item *item = NULL; @@ -584,6 +599,19 @@ static void __init dbg_snapshot_fixmap_header(void) /* initialize kernel event to 0 except only header */ memset((size_t *)(vaddr + DSS_KEEP_HEADER_SZ), 0, size - DSS_KEEP_HEADER_SZ); + + dss_bl = dbg_snapshot_get_base_vaddr() + DSS_OFFSET_ITEM_INFO; + memset(dss_bl, 0, sizeof(struct dbg_snapshot_bl)); + dss_bl->magic1 = 0x01234567; + dss_bl->magic2 = 0x89ABCDEF; + dss_bl->item_count = ARRAY_SIZE(dss_items); + memcpy(dss_bl->item[dss_desc.header_num].name, + dss_items[dss_desc.header_num].name, + strlen(dss_items[dss_desc.header_num].name) + 1); + dss_bl->item[dss_desc.header_num].paddr = paddr; + dss_bl->item[dss_desc.header_num].size = size; + dss_bl->item[dss_desc.header_num].enabled = + dss_items[dss_desc.header_num].entry.enabled; } static void __init dbg_snapshot_fixmap(void) @@ -596,6 +624,11 @@ static void __init dbg_snapshot_fixmap(void) dbg_snapshot_fixmap_header(); for (i = 1; i < ARRAY_SIZE(dss_items); i++) { + memcpy(dss_bl->item[i].name, + dss_items[i].name, + strlen(dss_items[i].name) + 1); + dss_bl->item[i].enabled = dss_items[i].entry.enabled; + if (!dss_items[i].entry.enabled) continue; @@ -639,6 +672,12 @@ static void __init dbg_snapshot_fixmap(void) dss_info.info_log[i - 1].head_ptr = (unsigned char *)dss_items[i].entry.vaddr; dss_info.info_log[i - 1].curr_ptr = NULL; dss_info.info_log[i - 1].entry.size = size; + + memcpy(dss_bl->item[i].name, + dss_items[i].name, + strlen(dss_items[i].name) + 1); + dss_bl->item[i].paddr = paddr; + dss_bl->item[i].size = size; } dss_log = (struct dbg_snapshot_log *)(dss_items[dss_desc.kevents_num].entry.vaddr); @@ -710,7 +749,6 @@ static int __init dbg_snapshot_init_dt(void) static int __init dbg_snapshot_init_value(void) { int val = dbg_snapshot_get_debug_level_reg(); - struct dbg_snapshot_item *item; dbg_snapshot_set_debug_level(val); @@ -724,18 +762,6 @@ static int __init dbg_snapshot_init_value(void) strncpy(dbg_snapshot_get_base_vaddr() + DSS_OFFSET_LINUX_BANNER, linux_banner, strlen(linux_banner)); - item = &dss_items[dss_desc.log_kernel_num]; - __raw_writel(item->entry.paddr, - dbg_snapshot_get_base_vaddr() + DSS_OFFSET_KERNEL_LOG); - - item = &dss_items[dss_desc.log_platform_num]; - __raw_writel(item->entry.paddr, - dbg_snapshot_get_base_vaddr() + DSS_OFFSET_PLATFORM_LOG); - - item = &dss_items[dss_desc.kevents_num]; - __raw_writel(item->entry.paddr, - dbg_snapshot_get_base_vaddr() + DSS_OFFSET_KERNEL_EVENT); - return 0; } -- 2.20.1