From: Hosung Kim Date: Tue, 17 Jul 2018 04:13:24 +0000 (+0900) Subject: [RAMEN9610-9963][COMMON] lib: dss: add DEBUG_SNAPSHOT_USER_MODE and debug level X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f12356ff5f7f39f9090ceb5c1392b0d72ee3fc30;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [RAMEN9610-9963][COMMON] lib: dss: add DEBUG_SNAPSHOT_USER_MODE and debug level This commit adds DEBUG_SNAPSHOT_USER_MODE and debug level. If DEBUG_SNAPSHOT_USER_MODE is enabled, DEBUG_SNAPSHOT_MINIMIZED_MODE is enabled too and debug_level is set by low. It means that DEBUG_SNAPSHOT_USER_MODE is static level(build time) debugging, debug level is runtime debugging. debug level is able to conrol in bootloader. Change-Id: Idedb764b82d7bfcfd313774827b71517d92e6fae Signed-off-by: Hosung Kim --- diff --git a/include/linux/debug-snapshot.h b/include/linux/debug-snapshot.h index f684855d4b5f..bfac0d3ba537 100644 --- a/include/linux/debug-snapshot.h +++ b/include/linux/debug-snapshot.h @@ -38,6 +38,8 @@ extern int dbg_snapshot_post_panic(void); extern int dbg_snapshot_post_reboot(char *cmd); extern int dbg_snapshot_set_hardlockup(int); extern int dbg_snapshot_get_hardlockup(void); +extern int dbg_snapshot_set_debug_level(const char *); +extern int dbg_snapshot_get_debug_level(void); extern unsigned int dbg_snapshot_get_item_size(char *); extern unsigned int dbg_snapshot_get_item_paddr(char *); extern unsigned long dbg_snapshot_get_item_vaddr(char *); @@ -218,6 +220,8 @@ extern void dbg_snapshot_binder(struct trace_binder_transaction_base *base, #define dbg_snapshot_post_reboot(a) do { } while(0) #define dbg_snapshot_set_hardlockup(a) do { } while(0) #define dbg_snapshot_get_hardlockup() do { } while(0) +#define dbg_snapshot_set_debug_level(a) do { } while(0) +#define dbg_snapshot_get_debug_level() do { } while(0) #define dbg_snapshot_check_crash_key(a,b) do { } while(0) #define dbg_snapshot_dm(a,b,c,d,e) do { } while(0) #define dbg_snapshot_panic_handler_safe() do { } while(0) @@ -227,7 +231,6 @@ extern void dbg_snapshot_binder(struct trace_binder_transaction_base *base, #define dbg_snapshot_hook_hardlockup_exit() do { } while(0) #define dbg_snapshot_binder(a,b,c) do { } while(0) - static inline unsigned int dbg_snapshot_get_item_size(char *name) { return 0; diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 0b02437920f8..3648fc933d01 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2000,10 +2000,15 @@ menuconfig DEBUG_SNAPSHOT default n config DEBUG_SNAPSHOT_LINUX_BUILD - bool + bool "May be built in LINUX environment" depends on DEBUG_SNAPSHOT default y +config DEBUG_SNAPSHOT_USER_MODE + bool "Enable User Mode, Most of debug feature are disabled" + depends on DEBUG_SNAPSHOT + default n + config DEBUG_SNAPSHOT_CALLSTACK int "shown callstack level" depends on DEBUG_SNAPSHOT @@ -2108,5 +2113,5 @@ config DEBUG_SNAPSHOT_CRASH_KEY config DEBUG_SNAPSHOT_MINIMIZED_MODE bool "Support minimized feature configuration" - depends on DEBUG_SNAPSHOT + depends on DEBUG_SNAPSHOT_USER_MODE default n diff --git a/lib/debug-snapshot-local.h b/lib/debug-snapshot-local.h index 4683bf721539..47c6938c2f88 100644 --- a/lib/debug-snapshot-local.h +++ b/lib/debug-snapshot-local.h @@ -40,13 +40,16 @@ extern void dbg_snapshot_recall_hardlockup_core(void); extern struct dbg_snapshot_helper_ops *dss_soc_ops; - /* SoC Specific define, This will be removed */ #define DSS_REG_MCT_ADDR (0) #define DSS_REG_MCT_SIZE (0) #define DSS_REG_UART_ADDR (0) #define DSS_REG_UART_SIZE (0) +#define DSS_DEBUG_LEVEL_NONE (-1) +#define DSS_DEBUG_LEVEL_LOW (0) +#define DSS_DEBUG_LEVEL_MID (1) + typedef int (*dss_initcall_t)(const struct device_node *); struct dbg_snapshot_base { @@ -96,6 +99,7 @@ struct dbg_snapshot_desc { int hardlockup_detected; int allcorelockup_detected; int no_wdt_dev; + int debug_level; }; diff --git a/lib/debug-snapshot.c b/lib/debug-snapshot.c index 195d2a692d03..a2862ceaf6f9 100644 --- a/lib/debug-snapshot.c +++ b/lib/debug-snapshot.c @@ -52,6 +52,11 @@ struct dbg_snapshot_ops dss_ops = { }; #endif +const char *debug_level_val[] = { + "low", + "mid", +}; + 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, }, @@ -77,6 +82,35 @@ struct dbg_snapshot_desc dss_desc; /* Variable for assigning virtual address base */ static size_t g_dbg_snapshot_vaddr_base = DSS_FIXED_VIRT_BASE; +int dbg_snapshot_set_debug_level(const char *level) +{ + int i; + + if (!level) + goto out; + + for (i = 0; i < ARRAY_SIZE(debug_level_val); i++) { + if (!strncmp(level, debug_level_val[i], + strlen(debug_level_val[i]))) { + dss_desc.debug_level = i; + goto out; + } + } +#if !IS_ENABLED(CONFIG_DEBUG_SNAPSHOT_USER_MODE) + dss_desc.debug_level = DSS_DEBUG_LEVEL_MID; +#else + dss_desc.debug_level = DSS_DEBUG_LEVEL_LOW; +#endif + +out: + return 0; +} + +int dbg_snapshot_get_debug_level(void) +{ + return dss_desc.debug_level; +} + int dbg_snapshot_set_enable(const char *name, int en) { struct dbg_snapshot_item *item = NULL; @@ -598,8 +632,32 @@ static void __init dbg_snapshot_fixmap(void) static int dbg_snapshot_init_dt_parse(struct device_node *np) { int ret = 0; - struct device_node *sfr_dump_np = of_get_child_by_name(np, "dump-info"); + struct device_node *sfr_dump_np; + const char *debug_level; + if (of_property_read_u32(np, "use_multistage_wdt_irq", + &dss_desc.multistage_wdt_irq)) { + dss_desc.multistage_wdt_irq = 0; + pr_err("debug-snapshot: no support multistage_wdt\n"); + } + + if (of_property_read_string(np, "debug_level", &debug_level)) { + /* + * if failed to get debug_level in device tree + * debug_level should be followed kernel configuration policy + */ +#if !IS_ENABLED(CONFIG_DEBUG_SNAPSHOT_USER_MODE) + dss_desc.debug_level = DSS_DEBUG_LEVEL_MID; +#else + dss_desc.debug_level = DSS_DEBUG_LEVEL_LOW; +#endif + } else { + dbg_snapshot_set_debug_level(debug_level); + } + pr_info("debug-snapshot: debug_level [%s]\n", + debug_level_val[dss_desc.debug_level]); + + sfr_dump_np = of_get_child_by_name(np, "dump-info"); if (!sfr_dump_np) { pr_err("debug-snapshot: failed to get dump-info node\n"); ret = -ENODEV; @@ -616,13 +674,6 @@ static int dbg_snapshot_init_dt_parse(struct device_node *np) if (ret < 0) dbg_snapshot_set_enable("log_sfr", false); - if (of_property_read_u32(np, "use_multistage_wdt_irq", - &dss_desc.multistage_wdt_irq)) { - dss_desc.multistage_wdt_irq = 0; - pr_err("debug-snapshot: no support multistage_wdt\n"); - ret = -EINVAL; - } - of_node_put(np); return ret; }