Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (C) 2007-2009 PetaLogix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (C) 2006 Atmark Techno, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kallsyms.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sched/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/debug_locks.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/exceptions.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/unwind.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void trap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	__enable_hw_exceptions();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static unsigned long kstack_depth_to_print;	/* 0 == entire stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static int __init kstack_setup(char *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	return !kstrtoul(s, 0, &kstack_depth_to_print);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) __setup("kstack=", kstack_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	unsigned long words_to_show;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	u32 fp = (u32) sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	if (fp == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		if (task) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			fp = ((struct thread_info *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 				(task->stack))->cpu_context.r1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 			/* Pick up caller of dump_stack() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			fp = (u32)&sp - 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	words_to_show = (THREAD_SIZE - (fp & (THREAD_SIZE - 1))) >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	if (kstack_depth_to_print && (words_to_show > kstack_depth_to_print))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		words_to_show = kstack_depth_to_print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	printk("%sKernel Stack:\n", loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	 * Make the first line an 'odd' size if necessary to get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	 * remaining lines to start at an address multiple of 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	if (fp & 0xF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		unsigned long line1_words = (0x10 - (fp & 0xF)) >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		if (line1_words < words_to_show) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 			print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 				       4, (void *)fp, line1_words << 2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 			fp += line1_words << 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 			words_to_show -= line1_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	print_hex_dump(loglvl, "", DUMP_PREFIX_ADDRESS, 32, 4, (void *)fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		       words_to_show << 2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	printk("%s\n\nCall Trace:\n", loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	microblaze_unwind(task, NULL, loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	printk("%s\n", loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	if (!task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 		task = current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	debug_show_held_locks(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }