From: Fang Lijun fanglijun3@huawei.com
Signed-off-by: Fang Lijun fanglijun3@huawei.com --- arch/arm64/Kconfig | 8 ++++++++ arch/arm64/mm/init.c | 3 +++ include/linux/init.h | 1 + kernel/panic.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 28b4e754e856..c6aa794901e1 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2052,6 +2052,14 @@ config ASCEND_CLEAN_CDM the management structures for hbm nodes to the ddr nodes of the same partion to reduce the probability of kernel crashes.
+config ASCEND_FDM + bool "Enable support for fdm" + default n + help + Fdm write an interrupt to the register to activate HBM ECC check in panic + + This option only enabled in ascend910 now. + config ASCEND_OOM bool "Enable support for disable oom killer" default y diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index ddce006b1b22..5c6da9ec499c 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -717,6 +717,9 @@ void ascend_enable_all_features(void) cgroup_memory_nokmem = false; }
+ if (IS_ENABLED(CONFIG_ASCEND_FDM)) + ascend_fdm_enable = true; + #ifdef CONFIG_ARM64_PSEUDO_NMI extern bool enable_pseudo_nmi; enable_pseudo_nmi = true; diff --git a/include/linux/init.h b/include/linux/init.h index 7b53cb3092ee..885e9b2e7951 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -162,6 +162,7 @@ extern void (*late_time_init)(void);
extern bool initcall_debug;
+extern int ascend_fdm_enable; #endif
#ifndef MODULE diff --git a/kernel/panic.c b/kernel/panic.c index d991c3b1b559..e6c47ab9c4a6 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -58,6 +58,11 @@ bool panic_on_taint_nousertaint = false; int panic_timeout = CONFIG_PANIC_TIMEOUT; EXPORT_SYMBOL_GPL(panic_timeout);
+int ascend_fdm_enable; +char *fdm_base_reg; +#define FDM_BASE_ADDR 0x202010000 +#define FDM_SIZE 0x1000 + #define PANIC_PRINT_TASK_INFO 0x00000001 #define PANIC_PRINT_MEM_INFO 0x00000002 #define PANIC_PRINT_TIMER_INFO 0x00000004 @@ -166,6 +171,28 @@ static void panic_print_sys_info(void) ftrace_dump(DUMP_ALL); }
+static int remap_fdm_base(void) +{ + fdm_base_reg = ioremap(FDM_BASE_ADDR, FDM_SIZE); + if (!fdm_base_reg) + return -ENOMEM; + return 0; +} + +static void enable_fdm(void) +{ + u32 val; + + if (fdm_base_reg == NULL) + return; + val = readl(fdm_base_reg + 0x20); + writel(val, fdm_base_reg + 0x2C); + writel(0xFFFFFF00, fdm_base_reg + 0x04); + writel(0xFFFFFF00, fdm_base_reg + 0x24); + writel(0xFFFFFF00, fdm_base_reg + 0x14); + writel(0x1, fdm_base_reg + 0x18); +} + /** * panic - halt the system * @fmt: The text string to print @@ -183,6 +210,8 @@ void panic(const char *fmt, ...) int old_cpu, this_cpu; bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
+ if (ascend_fdm_enable) + enable_fdm(); /* * Disable local interrupts. This will prevent panic_smp_self_stop * from deadlocking the first cpu that invokes the panic, since @@ -693,6 +722,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, NULL, clear_warn_once_set,
static __init int register_warn_debugfs(void) { + if (remap_fdm_base()) + pr_err("remap fdm base failed!\n"); /* Don't care about failure */ debugfs_create_file_unsafe("clear_warn_once", 0200, NULL, NULL, &clear_warn_once_fops);