Skip to contentSkip to conversation

MIPS: Unify low-level debugging functionalities

PATCH Superseded Jiaxun Yang 2 participants 16 messages Mar 26, 2024 – Apr 8, 2024 MIPS

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover MIPS: Unify low-level debugging functionalities

Hi all,

This is a attempt to bring all low-level debugging print functions together and provide a arm-like low-level debugging interface and a further capability to debug early exceptions.

This patch elimiate platform specific early_printk, zboot printing functions and cps-vec-ns16550 by newly introduced debug_ll.

Hope you'll find them handy :-)

Happy hacking!

Thanks

---
Jiaxun Yang (9):
MIPS: asm: Move strings to .rodata.str section
MIPS: debug: Implement low-level debugging functions
MIPS: debug: Hook up DEBUG_LL with early printk
MIPS: debug: Provide an early exception vector for low-level debugging
MIPS: debug_ll: Add Kconfig symbols for some 8250 uarts
MIPS: debug_ll: Implement support for Alchemy uarts
MIPS: debug_ll: Implement support for AR933X uarts
MIPS: zboot: Convert to use debug_ll facilities
MIPS: CPS: Convert to use debug_ll facilities

 arch/mips/Kconfig                        |  12 +-
 arch/mips/Kconfig.debug                  | 240 +++++++++++++++++++++++--------
 arch/mips/boot/compressed/Makefile       |   9 +-
 arch/mips/boot/compressed/dbg.c          |  39 -----
 arch/mips/boot/compressed/debug-vec.S    |   3 +
 arch/mips/boot/compressed/debug.S        |   3 +
 arch/mips/boot/compressed/decompress.h   |   8 +-
 arch/mips/boot/compressed/head.S         |   6 +
 arch/mips/boot/compressed/uart-16550.c   |  49 -------
 arch/mips/boot/compressed/uart-alchemy.c |   9 --
 arch/mips/boot/compressed/uart-ath79.c   |   2 -
 arch/mips/boot/compressed/uart-prom.c    |   9 --
 arch/mips/include/asm/asm.h              |   2 +-
 arch/mips/include/debug/8250.S           |  60 ++++++++
 arch/mips/include/debug/alchemy.S        |  46 ++++++
 arch/mips/include/debug/ar933x.S         |  41 ++++++
 arch/mips/include/debug/uhi.S            |  48 +++++++
 arch/mips/kernel/Makefile                |   4 +-
 arch/mips/kernel/cps-vec.S               |  16 +--
 arch/mips/kernel/debug-vec.S             | 194 +++++++++++++++++++++++++
 arch/mips/kernel/debug.S                 | 130 +++++++++++++++++
 arch/mips/kernel/early_printk.c          |  19 +++
 arch/mips/kernel/head.S                  |   4 +
 23 files changed, 756 insertions(+), 197 deletions(-)

---
base-commit: 084c8e315db34b59d38d06e684b1a0dd07d30287
change-id: 20240326-mips_debug_ll-ce72fee1b6a2

Best regards,

Signature · 1 line
Jiaxun Yang <[email protected]>
#1 lore raw

PATCH v2 1/9 MIPS: asm: Move strings to .rodata.str section

Well, they are read only.

---
 arch/mips/include/asm/asm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/asm.h +1 -1
index 2e99450f4228..05a158a8920c 100644
@@ -94,7 +94,7 @@ symbol:		.insn
 symbol		=	value
 
 #define TEXT(msg)					\
-		.pushsection .data;			\
+		.pushsection .rodata.str;			\
 8:		.asciiz msg;				\
 		.popsection;
 
Signature · 1 line
2.34.1
Reviewed-by on v2 1/9
#2 lore raw

Re: [PATCH v2 1/9] MIPS: asm: Move strings to .rodata.str section

Quoted 12 lines · Jiaxun Yang

Well, they are read only.

---
  arch/mips/include/asm/asm.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/asm.h +0 -0
index 2e99450f4228..05a158a8920c 100644

arch/mips/include/asm/asm.h symbol: .insn · line 97

Quoted 5 lines
arch/mips/include/asm/asm.h +1 -1
@@ -94,7 +94,7 @@ symbol:		.insn
  symbol		=	value
 
  #define TEXT(msg)					\
-		.pushsection .data;			\
+		.pushsection .rodata.str;			\

Nitpicking, \ is now misaligned.

Quoted 4 lines
arch/mips/include/asm/asm.h +0 -0
  8:		.asciiz msg;				\
  		.popsection;
 
#3 lore raw

PATCH v2 2/9 MIPS: debug: Implement low-level debugging functions

In reply to Jiaxun Yang

Currently we have three sets of early debugging functions for MIPS: zboot putc/puts, cps-vec-ns16550, and prom_putc.

This is a attempt to bring them all to one by providing a interface similar to arm's debug_ll, which is very portable and allows you to support new platforms easily.

Two examples of output interfaces are provided, including 8250 uart and MIPS UHI semihosting, which already covered most of the platforms.

---
 arch/mips/Kconfig.debug        |  80 +++++++++++++++++++++++++
 arch/mips/include/debug/8250.S |  60 +++++++++++++++++++
 arch/mips/include/debug/uhi.S  |  48 +++++++++++++++
 arch/mips/kernel/Makefile      |   2 +
 arch/mips/kernel/debug.S       | 130 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 320 insertions(+)
arch/mips/Kconfig.debug +80 -0
index f4ae7900fcd3..892e31804982 100644
@@ -164,3 +164,83 @@ config MIPS_CPS_NS16550_WIDTH
 	  lb/sb instructions.
 
 endif # MIPS_CPS_NS16550_BOOL
+
+# These options are only for real kernel hackers who want to get their hands dirty.
+config DEBUG_LL
+	bool "Kernel low-level debugging functions (read help!)"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here to include definitions of printascii, printch, printhex
+	  in the kernel.  This is helpful if you are debugging code that
+	  executes before the console is initialized.
+
+	  Note that selecting this option will limit the kernel to a single
+	  UART or semihosting definition, as specified below. Attempting to
+	  boot the kernel image on a different platform *will not work*, so
+	  this option should not be enabled for kernels that are intended to
+	  be portable.
+
+choice
+	prompt "Kernel low-level debugging port"
+	depends on DEBUG_LL
+
+	config DEBUG_MIPS_UHI
+		bool "Kernel low-level debugging via UHI semihosting"
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  via MIPS UHI semihosting.
+
+	config DEBUG_LL_UART_8250
+		bool "Kernel low-level debugging via 8250 UART"
+		select DEBUG_LL_UART
+		help
+		  Say Y here if you wish the debug print routes to direct
+		  their output to an 8250 UART.  You can use this option
+		  to provide the parameters for the 8250 UART rather than
+		  selecting one of the platform specific options below if
+		  you know the parameters for the port.
+
+endchoice
+
+config DEBUG_LL_INCLUDE
+	string
+	default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
+	default "debug/uhi.S" if DEBUG_MIPS_UHI
+	default "debug-macro.S"
+
+# Compatibility options for 8250
+config DEBUG_UART_8250
+	bool
+	select DEBUG_LL_UART
+
+config DEBUG_LL_UART
+	bool
+
+config DEBUG_UART_FLOW_CONTROL
+	bool "Enable flow control (CTS) for the debug UART"
+	depends on DEBUG_LL_UART
+	default n
+	help
+	  Some UART ports are connected to terminals that will use modem
+	  control signals to indicate whether they are ready to receive text.
+	  In practice this means that the terminal is asserting the special
+	  control signal CTS (Clear To Send). If your debug UART supports
+	  this and your debug terminal will require it, enable this option.
+
+config DEBUG_UART_PHYS
+	hex "Physical base address of debug UART"
+	depends on DEBUG_LL_UART
+	help
+	  This is the physical base address of the debug UART. It must be
+	  accessible from unmapped kernel space (i.e. KSEG1 for 32bit kernels
+	  or XKPHYS for 64bit kernels).
+
+config DEBUG_UART_8250_SHIFT
+	int "Register offset shift for the 8250 debug UART"
+	depends on DEBUG_LL_UART_8250 || DEBUG_UART_8250
+	default 2
+
+config DEBUG_UART_8250_WIDTH
+	int "Register width for the 8250 debug UART"
+	depends on DEBUG_LL_UART_8250 || DEBUG_UART_8250
+	default 1
arch/mips/include/debug/8250.S new file +60 -0

60 lines not on this page · raw message

arch/mips/include/debug/uhi.S new file +48 -0

48 lines not on this page · raw message

arch/mips/kernel/Makefile +2 -0
index ecf3278a32f7..bfac35a64ae5 100644
@@ -78,6 +78,8 @@ obj-$(CONFIG_MIPS32_COMPAT)	+= linux32.o ptrace32.o signal32.o
 obj-$(CONFIG_MIPS32_N32)	+= scall64-n32.o signal_n32.o
 obj-$(CONFIG_MIPS32_O32)	+= scall64-o32.o signal_o32.o
 
+obj-$(CONFIG_DEBUG_LL)		+= debug.o
+
 obj-$(CONFIG_KGDB)		+= kgdb.o
 obj-$(CONFIG_PROC_FS)		+= proc.o
 obj-$(CONFIG_MAGIC_SYSRQ)	+= sysrq.o
arch/mips/kernel/debug.S new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v2 2/9
#4 lore raw

Re: [PATCH v2 2/9] MIPS: debug: Implement low-level debugging functions

Quoted 11 lines · Jiaxun Yang

Currently we have three sets of early debugging functions for MIPS: zboot putc/puts, cps-vec-ns16550, and prom_putc.

This is a attempt to bring them all to one by providing a interface similar to arm's debug_ll, which is very portable and allows you to support new platforms easily.

Two examples of output interfaces are provided, including 8250 uart and MIPS UHI semihosting, which already covered most of the platforms.

Quoted 8 lines
---
  arch/mips/Kconfig.debug        |  80 +++++++++++++++++++++++++
  arch/mips/include/debug/8250.S |  60 +++++++++++++++++++
  arch/mips/include/debug/uhi.S  |  48 +++++++++++++++
  arch/mips/kernel/Makefile      |   2 +
  arch/mips/kernel/debug.S       | 130 +++++++++++++++++++++++++++++++++++++++++
  5 files changed, 320 insertions(+)
#5 lore raw

PATCH v2 3/9 MIPS: debug: Hook up DEBUG_LL with early printk

In reply to Jiaxun Yang

Output earlyprintk to low-level debug functions when it's available.

DEBUG_LL takes priority over platform earlyprintk because people must know what are they doing when they are trying to enable DEBUG_LL.

---
 arch/mips/Kconfig.debug         |  2 +-
 arch/mips/kernel/early_printk.c | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
arch/mips/Kconfig.debug +1 -1
index 892e31804982..6ef42edc7d67 100644
@@ -2,7 +2,7 @@
 
 config EARLY_PRINTK
 	bool "Early printk" if EXPERT
-	depends on SYS_HAS_EARLY_PRINTK
+	depends on SYS_HAS_EARLY_PRINTK || DEBUG_LL
 	default y
 	help
 	  This option enables special console drivers which allow the kernel
arch/mips/kernel/early_printk.c +19 -0
index 4a1647ddfbd9..c3f3b0a930f0 100644
@@ -14,6 +14,24 @@
 
 #include <asm/setup.h>
 
+#ifdef CONFIG_DEBUG_LL
+extern void printascii(const char *);
+
+static void early_console_write(struct console *con, const char *s, unsigned n)
+{
+	char buf[128];
+
+	while (n) {
+		unsigned int l = min(n, sizeof(buf)-1);
+
+		memcpy(buf, s, l);
+		buf[l] = 0;
+		s += l;
+		n -= l;
+		printascii(buf);
+	}
+}
+#else
 static void early_console_write(struct console *con, const char *s, unsigned n)
 {
 	while (n-- && *s) {
@@ -23,6 +41,7 @@ static void early_console_write(struct console *con, const char *s, unsigned n)
 		s++;
 	}
 }
+#endif
 
 static struct console early_console_prom = {
 	.name	= "early",
Signature · 1 line
2.34.1
Reviewed-by on v2 3/9
#6 lore raw

Re: [PATCH v2 3/9] MIPS: debug: Hook up DEBUG_LL with early printk

Quoted 7 lines · Jiaxun Yang

Output earlyprintk to low-level debug functions when it's available.

DEBUG_LL takes priority over platform earlyprintk because people must know what are they doing when they are trying to enable DEBUG_LL.

Quoted 5 lines
---
  arch/mips/Kconfig.debug         |  2 +-
  arch/mips/kernel/early_printk.c | 19 +++++++++++++++++++
  2 files changed, 20 insertions(+), 1 deletion(-)
#7 lore raw

PATCH v2 4/9 MIPS: debug: Provide an early exception vector for low-level debugging

In reply to Jiaxun Yang

This is helpful for debugging of early boot crash when exceptions happens before trap_init(), or for debugging SMP bringup code.

It will install exception handler very early on kernel_entry by setting ebase or copy itself to start of CKSEG0, and print off exception vectors and other status registers like:

Low level exception: ffffffff8011e180

GlobalNumber: 0x00000000
EBase:    0xffffffff8011e000
Xcontext: 0x0000000000000000
Cause:    0x0000000c
Status:   0x14000082
EPC:      0xffffffff80d324e0
BadVAddr: 0x0000000000000000
BadInstr: 0xac000000
---
 arch/mips/Kconfig.debug      |   9 ++
 arch/mips/kernel/Makefile    |   1 +
 arch/mips/kernel/debug-vec.S | 194 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/kernel/head.S      |   4 +
 4 files changed, 208 insertions(+)
arch/mips/Kconfig.debug +9 -0
index 6ef42edc7d67..323ad3ec643b 100644
@@ -180,6 +180,15 @@ config DEBUG_LL
 	  this option should not be enabled for kernels that are intended to
 	  be portable.
 
+config DEBUG_LL_EXCEPT
+	bool "Kernel low-level debugging of exceptions"
+	depends on DEBUG_LL
+	help
+	  Say Y here to enable debugging prints for low-level exceptions.
+	  This is helpful if you are debugging a early boot crash when
+	  exceptions happens before trap_init(), or if you are debugging
+	  SMP bringup code.
+
 choice
 	prompt "Kernel low-level debugging port"
 	depends on DEBUG_LL
arch/mips/kernel/Makefile +1 -0
index bfac35a64ae5..6641c3370e68 100644
@@ -79,6 +79,7 @@ obj-$(CONFIG_MIPS32_N32)	+= scall64-n32.o signal_n32.o
 obj-$(CONFIG_MIPS32_O32)	+= scall64-o32.o signal_o32.o
 
 obj-$(CONFIG_DEBUG_LL)		+= debug.o
+obj-$(CONFIG_DEBUG_LL_EXCEPT)	+= debug-vec.o
 
 obj-$(CONFIG_KGDB)		+= kgdb.o
 obj-$(CONFIG_PROC_FS)		+= proc.o
arch/mips/kernel/debug-vec.S new file +194 -0

194 lines not on this page · raw message

arch/mips/kernel/head.S +4 -0
index b825ed4476c7..9be1c4ce6324 100644
@@ -106,6 +106,10 @@ NESTED(kernel_entry, 16, sp)			# kernel entry point
 	LONG_S		a2, fw_arg2
 	LONG_S		a3, fw_arg3
 
+#ifdef CONFIG_DEBUG_LL_EXCEPT
+	jal		setup_debug_ll_exception
+#endif
+
 	MTC0		zero, CP0_CONTEXT	# clear context register
 #ifdef CONFIG_64BIT
 	MTC0		zero, CP0_XCONTEXT
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 5/9 MIPS: debug_ll: Add Kconfig symbols for some 8250 uarts

In reply to Jiaxun Yang

Define platform symbols for all 8250 style uart type supported by zboot, plus Loongson-2K and boston.

---
 arch/mips/Kconfig.debug | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
arch/mips/Kconfig.debug +56 -0
index 323ad3ec643b..3609d298a9eb 100644
@@ -209,6 +209,54 @@ choice
 		  selecting one of the platform specific options below if
 		  you know the parameters for the port.
 
+	config DEBUG_BOSTON_UART
+		bool "Kernel low-level debugging messages via Boston UART"
+		depends on MIPS_GENERIC_KERNEL
+		select DEBUG_UART_8250
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on IMG Boston board.
+
+	config DEBUG_MALTA_UART
+		bool "Kernel low-level debugging messages via malta UART"
+		depends on MIPS_MALTA
+		select DEBUG_UART_8250
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on MTI malta board.
+
+	config DEBUG_AR71XX_UART
+		bool "Kernel low-level debugging messages via AR71XX UART"
+		depends on ATH79
+		select DEBUG_UART_8250
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on AR71xx based platforms.
+
+	config DEBUG_LOONGSON3_UART
+		bool "Kernel low-level debugging messages via Loongson-3 UART"
+		depends on MACH_LOONGSON64
+		select DEBUG_UART_8250
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Loongson-3 systems.
+
+	config DEBUG_LOONGSON2K_UART
+		bool "Kernel low-level debugging messages via Loongson 2K UART"
+		depends on MACH_LOONGSON64
+		select DEBUG_UART_8250
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Loongson-2K SoCs.
+
+	config DEBUG_INGENIC_UART
+		bool "Kernel low-level debugging messages via Ingenic UART"
+		depends on MACH_INGENIC_SOC
+		select DEBUG_UART_8250
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on uart0 of Ingenic SoCs.
+
 endchoice
 
 config DEBUG_LL_INCLUDE
@@ -239,6 +287,12 @@ config DEBUG_UART_FLOW_CONTROL
 config DEBUG_UART_PHYS
 	hex "Physical base address of debug UART"
 	depends on DEBUG_LL_UART
+	default 0x17ffe000 if DEBUG_BOSTON_UART
+	default 0x1fd003f8 if DEBUG_MALTA_UART
+	default 0x18020000 if DEBUG_AR71XX_UART
+	default 0x1fd003f8 if DEBUG_LOONGSON3_UART
+	default 0x1fe00000 if DEBUG_LOONGSON2K_UART
+	default 0x10030000 if DEBUG_INGENIC_UART
 	help
 	  This is the physical base address of the debug UART. It must be
 	  accessible from unmapped kernel space (i.e. KSEG1 for 32bit kernels
@@ -247,6 +301,8 @@ config DEBUG_UART_PHYS
 config DEBUG_UART_8250_SHIFT
 	int "Register offset shift for the 8250 debug UART"
 	depends on DEBUG_LL_UART_8250 || DEBUG_UART_8250
+	default 1 if DEBUG_MALTA_UART || DEBUG_LOONGSON3_UART || \
+		DEBUG_LOONGSON2K_UART
 	default 2
 
 config DEBUG_UART_8250_WIDTH
Signature · 1 line
2.34.1
Reviewed-by on v2 5/9
#9 lore raw

Re: [PATCH v2 5/9] MIPS: debug_ll: Add Kconfig symbols for some 8250 uarts

Quoted 7 lines · Jiaxun Yang

Define platform symbols for all 8250 style uart type supported by zboot, plus Loongson-2K and boston.

---
  arch/mips/Kconfig.debug | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 56 insertions(+)
#10 lore raw

PATCH v2 6/9 MIPS: debug_ll: Implement support for Alchemy uarts

In reply to Jiaxun Yang

Alchemy uart is a 8250 derivative that requires some special care on barriers and readys, also they have a wired register layout.

Implement it as a special include.

---
 arch/mips/Kconfig.debug           | 10 +++++++++
 arch/mips/include/debug/alchemy.S | 46 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
arch/mips/Kconfig.debug +10 -0
index 3609d298a9eb..aef116058654 100644
@@ -257,11 +257,20 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on uart0 of Ingenic SoCs.
 
+	config DEBUG_ALCHEMY_UART
+		bool "Kernel low-level debugging messages via Alchemy UART"
+		depends on MIPS_ALCHEMY
+		select DEBUG_LL_UART
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on uart of alchemy SoCs.
+
 endchoice
 
 config DEBUG_LL_INCLUDE
 	string
 	default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
+	default "debug/alchemy.S" if DEBUG_ALCHEMY_UART
 	default "debug/uhi.S" if DEBUG_MIPS_UHI
 	default "debug-macro.S"
 
@@ -293,6 +302,7 @@ config DEBUG_UART_PHYS
 	default 0x1fd003f8 if DEBUG_LOONGSON3_UART
 	default 0x1fe00000 if DEBUG_LOONGSON2K_UART
 	default 0x10030000 if DEBUG_INGENIC_UART
+	default 0x11100000 if DEBUG_ALCHEMY_UART
 	help
 	  This is the physical base address of the debug UART. It must be
 	  accessible from unmapped kernel space (i.e. KSEG1 for 32bit kernels
arch/mips/include/debug/alchemy.S new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.34.1
#11 lore raw

PATCH v2 7/9 MIPS: debug_ll: Implement support for AR933X uarts

In reply to Jiaxun Yang

Implement support for AR933X uarts which has it's own register definition.

---
 arch/mips/Kconfig.debug          |  9 +++++++++
 arch/mips/include/debug/ar933x.S | 41 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
arch/mips/Kconfig.debug +9 -0
index aef116058654..a6687c503c34 100644
@@ -265,6 +265,14 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on uart of alchemy SoCs.
 
+	config DEBUG_AR933X_UART
+		bool "Kernel low-level debugging messages via Alchemy UART"
+		depends on MIPS_ALCHEMY
+		select DEBUG_LL_UART
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on uart of AR933X SoCs.
+
 endchoice
 
 config DEBUG_LL_INCLUDE
@@ -303,6 +311,7 @@ config DEBUG_UART_PHYS
 	default 0x1fe00000 if DEBUG_LOONGSON2K_UART
 	default 0x10030000 if DEBUG_INGENIC_UART
 	default 0x11100000 if DEBUG_ALCHEMY_UART
+	default 0x18020000 if DEBUG_AR933X_UART
 	help
 	  This is the physical base address of the debug UART. It must be
 	  accessible from unmapped kernel space (i.e. KSEG1 for 32bit kernels
arch/mips/include/debug/ar933x.S new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 8/9 MIPS: zboot: Convert to use debug_ll facilities

In reply to Jiaxun Yang

Since now debug_ll facilities can cover all platforms supported by zboot debug print, and it provides extra capability on debugging exceptions, switch zboot to use those facilities.

---
 arch/mips/Kconfig                        | 12 ++------
 arch/mips/Kconfig.debug                  | 46 +++++++++++++-----------------
 arch/mips/boot/compressed/Makefile       |  9 ++----
 arch/mips/boot/compressed/dbg.c          | 39 -------------------------
 arch/mips/boot/compressed/debug-vec.S    |  3 ++
 arch/mips/boot/compressed/debug.S        |  3 ++
 arch/mips/boot/compressed/decompress.h   |  8 +++---
 arch/mips/boot/compressed/head.S         |  6 ++++
 arch/mips/boot/compressed/uart-16550.c   | 49 --------------------------------
 arch/mips/boot/compressed/uart-alchemy.c |  9 ------
 arch/mips/boot/compressed/uart-ath79.c   |  2 --
 arch/mips/boot/compressed/uart-prom.c    |  9 ------
 12 files changed, 39 insertions(+), 156 deletions(-)
arch/mips/Kconfig +2 -10
index 06ef440d16ce..6729bf1d158d 100644
@@ -240,7 +240,7 @@ config ATH79
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
 	select SYS_SUPPORTS_MIPS16
-	select SYS_SUPPORTS_ZBOOT_UART_PROM
+	select SYS_SUPPORTS_ZBOOT
 	select USE_OF
 	select USB_EHCI_ROOT_HUB_TT if USB_EHCI_HCD_PLATFORM
 	help
@@ -422,7 +422,7 @@ config MACH_INGENIC_SOC
 	select MIPS_GENERIC
 	select MACH_INGENIC
 	select MACH_GENERIC_CORE
-	select SYS_SUPPORTS_ZBOOT_UART16550
+	select SYS_SUPPORTS_ZBOOT
 	select CPU_SUPPORTS_CPUFREQ
 	select MIPS_EXTERNAL_TIMER
 
@@ -1792,14 +1792,6 @@ config SYS_SUPPORTS_ZBOOT
 	select HAVE_KERNEL_XZ
 	select HAVE_KERNEL_ZSTD
 
-config SYS_SUPPORTS_ZBOOT_UART16550
-	bool
-	select SYS_SUPPORTS_ZBOOT
-
-config SYS_SUPPORTS_ZBOOT_UART_PROM
-	bool
-	select SYS_SUPPORTS_ZBOOT
-
 config CPU_LOONGSON2EF
 	bool
 	select CPU_SUPPORTS_32BIT_KERNEL
arch/mips/Kconfig.debug +19 -27

55 lines not on this page · raw message

arch/mips/boot/compressed/Makefile +2 -7
index 6cc28173bee8..78c65db8dd04 100644
@@ -43,13 +43,8 @@ KCSAN_SANITIZE			:= n
 # decompressor objects (linked with vmlinuz)
 vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
 
-ifdef CONFIG_DEBUG_ZBOOT
-vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT)		   += $(obj)/dbg.o
-vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
-vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
-vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY)		   += $(obj)/uart-alchemy.o
-vmlinuzobjs-$(CONFIG_ATH79)			   += $(obj)/uart-ath79.o
-endif
+vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT)		+= $(obj)/debug.o
+vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT_EXCEPT)	+= $(obj)/debug-vec.o
 
 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
 
arch/mips/boot/compressed/dbg.c deleted +0 -39
deleted file mode 100644
index 95405292accd..000000000000
@@ -1,39 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * MIPS-specific debug support for pre-boot environment
- *
- * NOTE: putc() is board specific, if your board have a 16550 compatible uart,
- * please select SYS_SUPPORTS_ZBOOT_UART16550 for your machine. otherwise, you
- * need to implement your own putc().
- */
-#include <linux/compiler.h>
-#include <linux/types.h>
-
-#include "decompress.h"
-
-void __weak putc(char c)
-{
-}
-
-void puts(const char *s)
-{
-	char c;
-	while ((c = *s++) != '\0') {
-		putc(c);
-		if (c == '\n')
-			putc('\r');
-	}
-}
-
-void puthex(unsigned long long val)
-{
-
-	unsigned char buf[10];
-	int i;
-	for (i = 7; i >= 0; i--) {
-		buf[i] = "0123456789ABCDEF"[val & 0x0F];
-		val >>= 4;
-	}
-	buf[8] = '\0';
-	puts(buf);
-}
arch/mips/boot/compressed/debug-vec.S new file +3 -0
new file mode 100644
index 000000000000..e7bedb183da8
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include "../../kernel/debug-vec.S"
arch/mips/boot/compressed/debug.S new file +3 -0
new file mode 100644
index 000000000000..0cf3da958f7e
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include "../../kernel/debug.S"
arch/mips/boot/compressed/decompress.h +4 -4
index 073b64593b3d..e375d50c71a0 100644
@@ -7,11 +7,11 @@ extern unsigned char __image_begin[], __image_end[];
 
 /* debug interfaces  */
 #ifdef CONFIG_DEBUG_ZBOOT
-extern void putc(char c);
-extern void puts(const char *s);
-extern void puthex(unsigned long long val);
+extern void printascii(const char *s);
+extern void printhexl(unsigned long val);
+#define puts(s) printascii(s)
+#define puthex(val) printhexl(val)
 #else
-#define putc(s) do {} while (0)
 #define puts(s) do {} while (0)
 #define puthex(val) do {} while (0)
 #endif
arch/mips/boot/compressed/head.S +6 -0
index d237a834b85e..b05e9591d3af 100644
@@ -22,6 +22,12 @@
 	move	s2, a2
 	move	s3, a3
 
+#ifdef CONFIG_DEBUG_ZBOOT_EXCEP
+	/* Set up the exception vector */
+	PTR_LA	t9, setup_debug_ll_exception
+	jalr	t9
+#endif
+
 	/* Clear BSS */
 	PTR_LA	a0, _edata
 	PTR_LA	a2, _end
arch/mips/boot/compressed/uart-16550.c deleted +0 -49

49 lines not on this page · raw message

arch/mips/boot/compressed/uart-alchemy.c deleted +0 -9
deleted file mode 100644
index 003967c084b3..000000000000
@@ -1,9 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <asm/mach-au1x00/au1000.h>
-
-#include "decompress.h"
-
-void putc(char c)
-{
-	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
-}
arch/mips/boot/compressed/uart-ath79.c deleted +0 -2
deleted file mode 100644
index d686820921be..000000000000
@@ -1,2 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include "../../ath79/early_printk.c"
arch/mips/boot/compressed/uart-prom.c deleted +0 -9
deleted file mode 100644
index 5fa3b9945333..000000000000
@@ -1,9 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <asm/setup.h>
-
-#include "decompress.h"
-
-void putc(char c)
-{
-	prom_putchar(c);
-}
Signature · 1 line
2.34.1
Reviewed-by on v2 8/9
#13 lore raw

Re: [PATCH v2 8/9] MIPS: zboot: Convert to use debug_ll facilities

Quoted 5 lines · Jiaxun Yang

Since now debug_ll facilities can cover all platforms supported by zboot debug print, and it provides extra capability on debugging exceptions, switch zboot to use those facilities.

Quoted 14 lines
---
  arch/mips/Kconfig                        | 12 ++------
  arch/mips/Kconfig.debug                  | 46 +++++++++++++-----------------
  arch/mips/boot/compressed/Makefile       |  9 ++----
  arch/mips/boot/compressed/dbg.c          | 39 -------------------------
  arch/mips/boot/compressed/debug-vec.S    |  3 ++
  arch/mips/boot/compressed/debug.S        |  3 ++
  arch/mips/boot/compressed/decompress.h   |  8 +++---
  arch/mips/boot/compressed/head.S         |  6 ++++
  arch/mips/boot/compressed/uart-16550.c   | 49 --------------------------------
  arch/mips/boot/compressed/uart-alchemy.c |  9 ------
  arch/mips/boot/compressed/uart-ath79.c   |  2 --
  arch/mips/boot/compressed/uart-prom.c    |  9 ------
  12 files changed, 39 insertions(+), 156 deletions(-)
#14 lore raw

PATCH v2 9/9 MIPS: CPS: Convert to use debug_ll facilities

In reply to Jiaxun Yang

debug_ll replaced CPS's custom NS16550 printing functions for dump early SMP bring-up exceptions.

This will enable CPS debugging on more platforms and also reduce code duplication.

All exception name strings are prefixed with CPS to help identification with regular low-level interrupts.

---
 arch/mips/Kconfig.debug    | 52 +++++++++-------------------------------------
 arch/mips/kernel/Makefile  |  1 -
 arch/mips/kernel/cps-vec.S | 16 +++++++-------
 3 files changed, 18 insertions(+), 51 deletions(-)
arch/mips/Kconfig.debug +10 -42
index 0ce6d24d05b3..caba00cd8a33 100644
@@ -96,48 +96,6 @@ config SCACHE_DEBUGFS
 
 	  If unsure, say N.
 
-menuconfig MIPS_CPS_NS16550_BOOL
-	bool "CPS SMP NS16550 UART output"
-	depends on MIPS_CPS
-	help
-	  Output debug information via an ns16550 compatible UART if exceptions
-	  occur early in the boot process of a secondary core.
-
-if MIPS_CPS_NS16550_BOOL
-
-config MIPS_CPS_NS16550
-	def_bool MIPS_CPS_NS16550_BASE != 0
-
-config MIPS_CPS_NS16550_BASE
-	hex "UART Base Address"
-	default 0x1b0003f8 if MIPS_MALTA
-	default 0
-	help
-	  The base address of the ns16550 compatible UART on which to output
-	  debug information from the early stages of core startup.
-
-	  This is only used if non-zero.
-
-config MIPS_CPS_NS16550_SHIFT
-	int "UART Register Shift"
-	default 0
-	help
-	  The number of bits to shift ns16550 register indices by in order to
-	  form their addresses. That is, log base 2 of the span between
-	  adjacent ns16550 registers in the system.
-
-config MIPS_CPS_NS16550_WIDTH
-	int "UART Register Width"
-	default 1
-	help
-	  ns16550 registers width. UART registers IO access methods will be
-	  selected in accordance with this parameter. By setting it to 1, 2 or
-	  4 UART registers will be accessed by means of lb/sb, lh/sh or lw/sw
-	  instructions respectively. Any value not from that set activates
-	  lb/sb instructions.
-
-endif # MIPS_CPS_NS16550_BOOL
-
 # These options are only for real kernel hackers who want to get their hands dirty.
 config DEBUG_LL
 	bool "Kernel low-level debugging functions (read help!)"
@@ -320,3 +278,13 @@ config DEBUG_ZBOOT_EXCEPT
 	  during decompression of a compressed kernel via the DEBUG_LL output.
 
 	  If unsure, say N.
+
+config DEBUG_CPS_EXCEPT
+	bool "Enable kernel debugging of Coherent Processing System exceptions"
+	depends on MIPS_CPS && DEBUG_LL_EXCEPT
+	help
+	  Say Y here if you want to enable debugging of exceptions happen
+	  during SMP bring-up stages on processors witn MIPS Coherent Processing
+	  System support.
+
+	  If unsure, say N.
arch/mips/kernel/Makefile +0 -1
index 6641c3370e68..94325c02cae2 100644
@@ -59,7 +59,6 @@ obj-$(CONFIG_MIPS_MT)		+= mips-mt.o
 obj-$(CONFIG_MIPS_MT_FPAFF)	+= mips-mt-fpaff.o
 obj-$(CONFIG_MIPS_MT_SMP)	+= smp-mt.o
 obj-$(CONFIG_MIPS_CPS)		+= smp-cps.o cps-vec.o
-obj-$(CONFIG_MIPS_CPS_NS16550)	+= cps-vec-ns16550.o
 obj-$(CONFIG_MIPS_SPRAM)	+= spram.o
 
 obj-$(CONFIG_MIPS_VPE_LOADER)	+= vpe.o
arch/mips/kernel/cps-vec.S +8 -8
index f876309130ad..49d682b3b49a 100644
@@ -33,15 +33,15 @@
 # define STATUS_BITDEPS		0
 #endif
 
-#ifdef CONFIG_MIPS_CPS_NS16550
+#ifdef CONFIG_DEBUG_CPS_EXCEPT
 
 #define DUMP_EXCEP(name)		\
 	PTR_LA	a0, 8f;			\
-	jal	mips_cps_bev_dump;	\
+	jal	debug_ll_exception;	\
 	 nop;				\
 	TEXT(name)
 
-#else /* !CONFIG_MIPS_CPS_NS16550 */
+#else /* !CONFIG_DEBUG_CPS_EXCEPT */
 
 #define DUMP_EXCEP(name)
 
@@ -154,31 +154,31 @@ LEAF(mips_cps_core_boot)
 
 	__INIT
 LEAF(excep_tlbfill)
-	DUMP_EXCEP("TLB Fill")
+	DUMP_EXCEP("CPS - TLB Fill")
 	b	.
 	 nop
 	END(excep_tlbfill)
 
 LEAF(excep_xtlbfill)
-	DUMP_EXCEP("XTLB Fill")
+	DUMP_EXCEP("CPS - XTLB Fill")
 	b	.
 	 nop
 	END(excep_xtlbfill)
 
 LEAF(excep_cache)
-	DUMP_EXCEP("Cache")
+	DUMP_EXCEP("CPS - Cache")
 	b	.
 	 nop
 	END(excep_cache)
 
 LEAF(excep_genex)
-	DUMP_EXCEP("General")
+	DUMP_EXCEP("CPS - General")
 	b	.
 	 nop
 	END(excep_genex)
 
 LEAF(excep_intex)
-	DUMP_EXCEP("Interrupt")
+	DUMP_EXCEP("CPS - Interrupt")
 	b	.
 	 nop
 	END(excep_intex)
Signature · 1 line
2.34.1
Reviewed-by on v2 9/9
#15 lore raw

Re: [PATCH v2 9/9] MIPS: CPS: Convert to use debug_ll facilities

Quoted 9 lines · Jiaxun Yang

debug_ll replaced CPS's custom NS16550 printing functions for dump early SMP bring-up exceptions.

This will enable CPS debugging on more platforms and also reduce code duplication.

All exception name strings are prefixed with CPS to help identification with regular low-level interrupts.

Quoted 6 lines
---
  arch/mips/Kconfig.debug    | 52 +++++++++-------------------------------------
  arch/mips/kernel/Makefile  |  1 -
  arch/mips/kernel/cps-vec.S | 16 +++++++-------
  3 files changed, 18 insertions(+), 51 deletions(-)