Skip to contentSkip to conversation

KGDB: This adds basic support to the MIPS architecture

PATCH In review Jason Wessel 2 participants 2 messages Oct 15, 2007 – Oct 16, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 9/21 KGDB: This adds basic support to the MIPS architecture

mips-lite.patch

From: Jason Wessel <[email protected]>
CC: [email protected]
Subject: [PATCH] This adds basic support to the MIPS architecture

This patch also adds support for the rs232 early kgdb access for MIPS Malta (via 8250), SiByte 1250-SWARM (32 and 64bit, custom UART), all from Manish Lachwani, and Toshiba TX493x platforms from Sergei Shtylyov.

---
 arch/mips/Kconfig                                          |    8 
 arch/mips/Kconfig.debug                                    |   22 
 arch/mips/au1000/common/Makefile                           |    1 
 arch/mips/au1000/common/dbg_io.c                           |  121 -
 arch/mips/basler/excite/Makefile                           |    1 
 arch/mips/basler/excite/excite_dbg_io.c                    |  121 -
 arch/mips/basler/excite/excite_irq.c                       |    7 
 arch/mips/basler/excite/excite_setup.c                     |    4 
 arch/mips/jmr3927/rbhma3100/Makefile                       |    1 
 arch/mips/jmr3927/rbhma3100/kgdb_io.c                      |  105 -
 arch/mips/kernel/Makefile                                  |    3 
 arch/mips/kernel/gdb-low.S                                 |  394 ----
 arch/mips/kernel/gdb-stub.c                                | 1154 -------------
 arch/mips/kernel/irq.c                                     |   33 
 arch/mips/kernel/kgdb-jmp.c                                |  112 +
 arch/mips/kernel/kgdb-setjmp.S                             |   28 
 arch/mips/kernel/kgdb.c                                    |  293 +++
 arch/mips/kernel/kgdb_handler.S                            |  339 +++
 arch/mips/kernel/traps.c                                   |   13 
 arch/mips/mips-boards/atlas/Makefile                       |    1 
 arch/mips/mips-boards/atlas/atlas_gdb.c                    |   97 -
 arch/mips/mips-boards/atlas/atlas_setup.c                  |    7 
 arch/mips/mips-boards/generic/Makefile                     |    1 
 arch/mips/mips-boards/generic/gdb_hook.c                   |  133 -
 arch/mips/mips-boards/generic/init.c                       |   62 
 arch/mips/mips-boards/malta/malta_setup.c                  |    8 
 arch/mips/mm/extable.c                                     |    7 
 arch/mips/pci/fixup-atlas.c                                |   21 
 arch/mips/philips/pnx8550/common/Makefile                  |    1 
 arch/mips/philips/pnx8550/common/gdb_hook.c                |  109 -
 arch/mips/philips/pnx8550/common/setup.c                   |   11 
 arch/mips/pmc-sierra/yosemite/Makefile                     |    1 
 arch/mips/pmc-sierra/yosemite/dbg_io.c                     |  180 --
 arch/mips/pmc-sierra/yosemite/irq.c                        |    9 
 arch/mips/sgi-ip22/ip22-setup.c                            |   24 
 arch/mips/sgi-ip27/Makefile                                |    1 
 arch/mips/sgi-ip27/ip27-dbgio.c                            |   60 
 arch/mips/sibyte/bcm1480/irq.c                             |   81 
 arch/mips/sibyte/cfe/setup.c                               |   14 
 arch/mips/sibyte/sb1250/irq.c                              |   64 
 arch/mips/sibyte/sb1250/kgdb_sibyte.c                      |  145 +
 arch/mips/sibyte/swarm/Makefile                            |    2 
 arch/mips/sibyte/swarm/dbg_io.c                            |   76 
 arch/mips/tx4927/common/Makefile                           |    1 
 arch/mips/tx4927/common/tx4927_dbgio.c                     |   46 
 arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c |   12 
 arch/mips/tx4938/common/Makefile                           |    1 
 arch/mips/tx4938/common/dbgio.c                            |   50 
 arch/mips/tx4938/toshiba_rbtx4938/setup.c                  |   10 
 drivers/serial/Makefile                                    |    1 
 drivers/serial/serial_txx9.c                               |   13 
 drivers/serial/serial_txx9_kgdb.c                          |  152 +
 include/asm-mips/asmmacro-32.h                             |   43 
 include/asm-mips/asmmacro-64.h                             |   99 +
 include/asm-mips/kdebug.h                                  |   30 
 include/asm-mips/kgdb.h                                    |   48 
 lib/Kconfig.kgdb                                           |   19 
 57 files changed, 1384 insertions(+), 3016 deletions(-)
arch/mips/Kconfig.debug +0 -22
@@ -46,28 +46,6 @@ config SMTC_IDLE_HOOK_DEBUG
 	  arch/mips/kernel/smtc.c.  This debugging option result in significant
 	  overhead so should be disabled in production kernels.
 
-config KGDB
-	bool "Remote GDB kernel debugging"
-	depends on DEBUG_KERNEL && SYS_SUPPORTS_KGDB
-	select DEBUG_INFO
-	help
-	  If you say Y here, it will be possible to remotely debug the MIPS
-	  kernel using gdb. This enlarges your kernel image disk size by
-	  several megabytes and requires a machine with more than 16 MB,
-	  better 32 MB RAM to avoid excessive linking time. This is only
-	  useful for kernel hackers. If unsure, say N.
-
-config SYS_SUPPORTS_KGDB
-	bool
-
-config GDB_CONSOLE
-	bool "Console output to GDB"
-	depends on KGDB
-	help
-	  If you are using GDB for remote debugging over a serial port and
-	  would like kernel messages to be formatted into GDB $O packets so
-	  that GDB prints them as program output, say 'Y'.
-
 config SB1XXX_CORELIS
 	bool "Corelis Debugger"
 	depends on SIBYTE_SB1xxx_SOC
arch/mips/kernel/Makefile +2 -1
@@ -60,7 +60,8 @@ obj-$(CONFIG_MIPS32_COMPAT)	+= linux32.o
 obj-$(CONFIG_MIPS32_N32)	+= binfmt_elfn32.o scall64-n32.o signal_n32.o
 obj-$(CONFIG_MIPS32_O32)	+= binfmt_elfo32.o scall64-o32.o
 
-obj-$(CONFIG_KGDB)		+= gdb-low.o gdb-stub.o
+obj-$(CONFIG_KGDB)		+= kgdb_handler.o kgdb.o kgdb-jmp.o	\
+					kgdb-setjmp.o
 obj-$(CONFIG_PROC_FS)		+= proc.o
 
 obj-$(CONFIG_64BIT)		+= cpu-bugs64.o
arch/mips/kernel/gdb-stub.c deleted +0 -1154

1,154 lines not on this page · raw message

arch/mips/kernel/irq.c +16 -17
@@ -21,11 +21,15 @@
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/kallsyms.h>
+#include <linux/kgdb.h>
 
 #include <asm/atomic.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
+/* Keep track of if we've done certain initialization already or not. */
+int kgdb_early_setup;
+
 static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];
 
 int allocate_irqno(void)
@@ -130,28 +134,23 @@ asmlinkage void spurious_interrupt(void)
 	atomic_inc(&irq_err_count);
 }
 
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-extern void set_debug_traps(void);
-
-static int kgdb_flag = 1;
-static int __init nokgdb(char *str)
+void __init init_IRQ(void)
 {
-	kgdb_flag = 0;
-	return 1;
-}
-__setup("nokgdb", nokgdb);
+
+#ifdef CONFIG_KGDB
+	if (kgdb_early_setup)
+		return;
 #endif
 
-void __init init_IRQ(void)
-{
 	arch_init_irq();
 
+
 #ifdef CONFIG_KGDB
-	if (kgdb_flag) {
-		printk("Wait for gdb client connection ...\n");
-		set_debug_traps();
-		breakpoint();
-	}
+	/*
+	 * We have been called before kgdb_arch_init(). Hence,
+	 * we dont want the traps to be reinitialized
+	 */
+	if (kgdb_early_setup == 0)
+		kgdb_early_setup = 1;
 #endif
 }
arch/mips/kernel/kgdb-jmp.c new file +112 -0

112 lines not on this page · raw message

arch/mips/kernel/kgdb-setjmp.S new file +28 -0
@@ -0,0 +1,28 @@
+/*
+ * arch/mips/kernel/kgdb-jmp.c
+ *
+ * Save and restore system registers so that within a limited frame we
+ * may have a fault and "jump back" to a known safe location.
+ *
+ * Copyright (C) 2005 by MontaVista Software.
+ * Author: Manish Lachwani ([email protected])
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program as licensed "as is" without any warranty of
+ * any kind, whether express or implied.
+ */
+
+#include <asm/asm.h>
+#include <asm/mipsregs.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+	.ent	kgdb_fault_setjmp,0
+ENTRY (kgdb_fault_setjmp)
+	move    a1, sp
+	move	a2, fp
+#ifdef CONFIG_64BIT
+	nop
+#endif
+	j	kgdb_fault_setjmp_aux
+	.end	kgdb_fault_setjmp
arch/mips/kernel/kgdb.c new file +293 -0

293 lines not on this page · raw message

arch/mips/kernel/kgdb_handler.S new file +339 -0

339 lines not on this page · raw message

arch/mips/kernel/traps.c +13 -0
@@ -10,6 +10,8 @@
  * Kevin D. Kissell, [email protected] and Carsten Langgaard, [email protected]
  * Copyright (C) 2000, 01 MIPS Technologies, Inc.
  * Copyright (C) 2002, 2003, 2004, 2005  Maciej W. Rozycki
+ *
+ * KGDB specific changes - Manish Lachwani ([email protected])
  */
 #include <linux/bug.h>
 #include <linux/init.h>
@@ -21,6 +23,8 @@
 #include <linux/kallsyms.h>
 #include <linux/bootmem.h>
 #include <linux/interrupt.h>
+#include <linux/kgdb.h>
+#include <linux/kdebug.h>
 
 #include <asm/bootinfo.h>
 #include <asm/branch.h>
@@ -319,6 +323,10 @@ void __noreturn die(const char * str, st
 	unsigned long dvpret = dvpe();
 #endif /* CONFIG_MIPS_MT_SMTC */
 
+#ifdef CONFIG_KGDB
+	if (kgdb_may_fault)
+		kgdb_fault_longjmp(kgdb_fault_jmp_regs);
+#endif
 	console_verbose();
 	spin_lock_irq(&die_lock);
 	bust_spinlocks(1);
@@ -1470,6 +1478,11 @@ void __init trap_init(void)
 	extern char except_vec4;
 	unsigned long i;
 
+#if defined(CONFIG_KGDB)
+	if (kgdb_early_setup)
+		return;	/* Already done */
+#endif
+
 	if (cpu_has_veic || cpu_has_vint)
 		ebase = (unsigned long) alloc_bootmem_low_pages(0x200 + VECTORSPACING*64);
 	else
arch/mips/mips-boards/generic/Makefile +0 -1
@@ -23,6 +23,5 @@ obj-y				:= reset.o display.o init.o mem
 
 obj-$(CONFIG_EARLY_PRINTK)	+= console.o
 obj-$(CONFIG_PCI)		+= pci.o
-obj-$(CONFIG_KGDB)		+= gdb_hook.o
 
 EXTRA_CFLAGS += -Werror
arch/mips/mips-boards/generic/init.c +0 -62

74 lines not on this page · raw message

arch/mips/mips-boards/malta/malta_setup.c +0 -8
@@ -38,10 +38,6 @@
 extern void mips_reboot_setup(void);
 extern unsigned long mips_rtc_get_time(void);
 
-#ifdef CONFIG_KGDB
-extern void kgdb_config(void);
-#endif
-
 struct resource standard_io_resources[] = {
 	{ .name = "dma1", .start = 0x00, .end = 0x1f, .flags = IORESOURCE_BUSY },
 	{ .name = "timer", .start = 0x40, .end = 0x5f, .flags = IORESOURCE_BUSY },
@@ -98,10 +94,6 @@ void __init plat_mem_setup(void)
 	 */
 	enable_dma(4);
 
-#ifdef CONFIG_KGDB
-	kgdb_config();
-#endif
-
 	if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO) {
 		char *argptr;
 
arch/mips/mm/extable.c +7 -0
@@ -3,6 +3,7 @@
  */
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/kgdb.h>
 #include <asm/branch.h>
 #include <asm/uaccess.h>
 
@@ -16,6 +17,12 @@ int fixup_exception(struct pt_regs *regs
 
 		return 1;
 	}
+#ifdef CONFIG_KGDB
+	if (atomic_read(&debugger_active) && kgdb_may_fault)
+		/* Restore our previous state. */
+		kgdb_fault_longjmp(kgdb_fault_jmp_regs);
+		/* Not reached. */
+#endif
 
 	return 0;
 }
arch/mips/sibyte/cfe/setup.c +0 -14
@@ -58,10 +58,6 @@ int cfe_cons_handle;
 extern unsigned long initrd_start, initrd_end;
 #endif
 
-#ifdef CONFIG_KGDB
-extern int kgdb_port;
-#endif
-
 static void __noreturn cfe_linux_exit(void *arg)
 {
 	int warm = *(int *)arg;
@@ -242,9 +238,6 @@ void __init prom_init(void)
 	int argc = fw_arg0;
 	char **envp = (char **) fw_arg2;
 	int *prom_vec = (int *) fw_arg3;
-#ifdef CONFIG_KGDB
-	char *arg;
-#endif
 
 	_machine_restart   = cfe_linux_restart;
 	_machine_halt      = cfe_linux_halt;
@@ -308,13 +301,6 @@ void __init prom_init(void)
 		}
 	}
 
-#ifdef CONFIG_KGDB
-	if ((arg = strstr(arcs_cmdline, "kgdb=duart")) != NULL)
-		kgdb_port = (arg[10] == '0') ? 0 : 1;
-	else
-		kgdb_port = 1;
-#endif
-
 #ifdef CONFIG_BLK_DEV_INITRD
 	{
 		char *ptr;
arch/mips/sibyte/sb1250/irq.c +9 -55

106 lines not on this page · raw message

arch/mips/sibyte/sb1250/kgdb_sibyte.c new file +145 -0

145 lines not on this page · raw message

arch/mips/sibyte/swarm/Makefile +0 -2
@@ -1,3 +1 @@
 lib-y				= setup.o rtc_xicor1241.o rtc_m41t81.o
-
-lib-$(CONFIG_KGDB)		+= dbg_io.o
arch/mips/sibyte/swarm/dbg_io.c deleted +0 -76

76 lines not on this page · raw message

arch/mips/tx4927/common/Makefile +0 -1
@@ -9,6 +9,5 @@
 obj-y	+= tx4927_prom.o tx4927_setup.o tx4927_irq.o
 
 obj-$(CONFIG_TOSHIBA_FPCIB0)	   += smsc_fdc37m81x.o
-obj-$(CONFIG_KGDB)                 += tx4927_dbgio.o
 
 EXTRA_CFLAGS += -Werror
arch/mips/tx4927/common/tx4927_dbgio.c deleted +0 -46

46 lines not on this page · raw message

arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c +9 -3
@@ -76,7 +76,7 @@
 #include <linux/hdreg.h>
 #include <linux/ide.h>
 #endif
-#ifdef CONFIG_SERIAL_TXX9
+#if defined(CONFIG_SERIAL_TXX9) || defined(CONFIG_KGDB_TXX9)
 #include <linux/tty.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
@@ -891,9 +891,10 @@ void __init toshiba_rbtx4927_setup(void)
 
 #endif /* CONFIG_PCI */
 
-#ifdef CONFIG_SERIAL_TXX9
+#if defined(CONFIG_SERIAL_TXX9) || defined(CONFIG_KGDB_TXX9)
 	{
 		extern int early_serial_txx9_setup(struct uart_port *port);
+		extern int txx9_kgdb_add_port(int n, struct uart_port *port);
 		int i;
 		struct uart_port req;
 		for(i = 0; i < 2; i++) {
@@ -905,7 +906,12 @@ void __init toshiba_rbtx4927_setup(void)
 			req.irq = TX4927_IRQ_PIC_BEG + 8 + i;
 			req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
 			req.uartclk = 50000000;
+#ifdef CONFIG_SERIAL_TXX9
 			early_serial_txx9_setup(&req);
+#endif
+#ifdef CONFIG_KGDB_TXX9
+			txx9_kgdb_add_port(i, &req);
+#endif
 		}
 	}
 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
@@ -914,7 +920,7 @@ void __init toshiba_rbtx4927_setup(void)
                 strcat(argptr, " console=ttyS0,38400");
         }
 #endif
-#endif
+#endif /* defined(CONFIG_SERIAL_TXX9) || defined(CONFIG_KGDB_TXX9) */
 
 #ifdef CONFIG_ROOT_NFS
         argptr = prom_getcmdline();
arch/mips/tx4938/common/Makefile +0 -1
@@ -7,6 +7,5 @@
 #
 
 obj-y	+= prom.o setup.o irq.o
-obj-$(CONFIG_KGDB) += dbgio.o
 
 EXTRA_CFLAGS += -Werror
arch/mips/tx4938/common/dbgio.c deleted +0 -50

50 lines not on this page · raw message

arch/mips/tx4938/toshiba_rbtx4938/setup.c +8 -2
@@ -30,7 +30,7 @@
 #include <asm/io.h>
 #include <asm/bootinfo.h>
 #include <asm/tx4938/rbtx4938.h>
-#ifdef CONFIG_SERIAL_TXX9
+#if defined(CONFIG_SERIAL_TXX9) || defined(CONFIG_KGDB_TXX9)
 #include <linux/tty.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
@@ -878,9 +878,10 @@ void __init toshiba_rbtx4938_setup(void)
 	set_io_port_base(RBTX4938_ETHER_BASE);
 #endif
 
-#ifdef CONFIG_SERIAL_TXX9
+#if defined(CONFIG_SERIAL_TXX9) || defined(CONFIG_KGDB_TXX9)
 	{
 		extern int early_serial_txx9_setup(struct uart_port *port);
+		extern int txx9_kgdb_add_port(int n, struct uart_port *port);
 		int i;
 		struct uart_port req;
 		for(i = 0; i < 2; i++) {
@@ -892,7 +893,12 @@ void __init toshiba_rbtx4938_setup(void)
 			req.irq = RBTX4938_IRQ_IRC_SIO(i);
 			req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
 			req.uartclk = 50000000;
+#ifdef CONFIG_SERIAL_TXX9
 			early_serial_txx9_setup(&req);
+#endif
+#ifdef CONFIG_KGDB_TXX9
+			txx9_kgdb_add_port(i, &req);
+#endif
 		}
 	}
 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
drivers/serial/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_SERIAL_SB1250_DUART) += sb1
 obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
 obj-$(CONFIG_SERIAL_JSM) += jsm/
 obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o
+obj-$(CONFIG_KGDB_TXX9) += serial_txx9_kgdb.o
 obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
 obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
 obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
drivers/serial/serial_txx9.c +13 -0
@@ -40,6 +40,10 @@
 static char *serial_version = "1.10";
 static char *serial_name = "TX39/49 Serial driver";
 
+#ifndef CONFIG_KGDB_TXX9
+#define CONFIG_KGDB_PORT_NUM -1
+#endif
+
 #define PASS_LIMIT	256
 
 #if !defined(CONFIG_SERIAL_TXX9_STDSERIAL)
@@ -473,6 +477,9 @@ static int serial_txx9_startup(struct ua
 	unsigned long flags;
 	int retval;
 
+	if (up->port.line == CONFIG_KGDB_PORT_NUM)
+		return -EBUSY;
+
 	/*
 	 * Clear the FIFO buffers and disable them.
 	 * (they will be reenabled in set_termios())
@@ -807,6 +814,9 @@ static void __init serial_txx9_register_
 	for (i = 0; i < UART_NR; i++) {
 		struct uart_txx9_port *up = &serial_txx9_ports[i];
 
+		if (up->port.line == CONFIG_KGDB_PORT_NUM)
+			continue;
+
 		up->port.line = i;
 		up->port.ops = &serial_txx9_pops;
 		up->port.dev = dev;
@@ -975,6 +985,9 @@ static int __devinit serial_txx9_registe
 
 	mutex_lock(&serial_txx9_mutex);
 	for (i = 0; i < UART_NR; i++) {
+		if (i == CONFIG_KGDB_PORT_NUM)
+			continue;
+
 		uart = &serial_txx9_ports[i];
 		if (uart_match_port(&uart->port, port)) {
 			uart_remove_one_port(&serial_txx9_reg, &uart->port);
include/asm-mips/kdebug.h +29 -1
@@ -1 +1,29 @@
-#include <asm-generic/kdebug.h>
+/*
+ *
+ * Copyright (C) 2004  MontaVista Software Inc.
+ * Author: Manish Lachwani, [email protected] or [email protected]
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+#ifndef _MIPS_KDEBUG_H
+#define _MIPS_KDEBUG_H
+
+#include <linux/notifier.h>
+
+struct pt_regs;
+
+extern struct atomic_notifier_head mips_die_head;
+
+enum die_val {
+	DIE_OOPS = 1,
+	DIE_PANIC,
+	DIE_DIE,
+	DIE_KERNELDEBUG,
+	DIE_TRAP,
+};
+
+#endif /* _MIPS_KDEBUG_H */
include/asm-mips/kgdb.h new file +48 -0

48 lines not on this page · raw message

lib/Kconfig.kgdb +16 -3
@@ -13,7 +13,7 @@ config UNWIND_INFO
 config KGDB
 	bool "KGDB: kernel debugging with remote gdb"
 	select WANT_EXTRA_DEBUG_INFORMATION
-	depends on DEBUG_KERNEL && (X86 || PPC)
+	depends on DEBUG_KERNEL && (X86 || MIPS || PPC)
 	help
 	  If you say Y here, it will be possible to remotely debug the
 	  kernel using gdb.  Documentation of kernel debugger is available
@@ -41,6 +41,8 @@ choice
 	depends on KGDB
 	default KGDB_MPSC if SERIAL_MPSC
 	default KGDB_CPM_UART if (CPM2 || 8xx)
+	default KGDB_SIBYTE if SIBYTE_SB1xxx_SOC
+ 	default KGDB_TXX9 if CPU_TX49XX
 	default KGDB_8250_NOMODULE
 	help
 	  There are a number of different ways in which you can communicate
@@ -91,6 +93,16 @@ config KGDB_CPM_UART
 	depends on PPC && (CPM2 || 8xx)
  	help
  	  Uses CPM UART to communicate with the host GDB.
+
+config KGDB_SIBYTE
+	bool "KGDB: On Broadcom SB1xxx serial port"
+	depends on MIPS && SIBYTE_SB1xxx_SOC
+
+config KGDB_TXX9
+	bool "KGDB: On TX49xx serial port"
+	depends on MIPS && CPU_TX49XX
+	help
+	  Uses TX49xx serial port to communicate with the host GDB.
 endchoice
 
 choice
@@ -158,7 +170,8 @@ config KGDB_SIMPLE_SERIAL
 config KGDB_BAUDRATE
 	int "Debug serial port baud rate"
 	depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || \
-		KGDB_MPSC || KGDB_CPM_UART
+		KGDB_MPSC || KGDB_CPM_UART || \
+		KGDB_TXX9
 	default "115200"
 	help
 	  gdb and the kernel stub need to agree on the baud rate to be
@@ -169,7 +182,7 @@ config KGDB_PORT_NUM
 	int "Serial port number for KGDB"
 	range 0 1 if KGDB_MPSC
 	range 0 3
-	depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC
+	depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC || KGDB_TXX9
 	default "1"
 	help
 	  Pick the port number (0 based) for KGDB to use.
arch/mips/Kconfig +0 -8
@@ -30,7 +30,6 @@ config BASLER_EXCITE
 	select SYS_HAS_CPU_RM9000
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
-	select SYS_SUPPORTS_KGDB
 	help
 	  The eXcite is a smart camera platform manufactured by
 	  Basler Vision Technologies AG.
@@ -302,7 +301,6 @@ config PMC_MSP
 	select SYS_HAS_CPU_MIPS32_R2
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
-	select SYS_SUPPORTS_KGDB
 	select IRQ_CPU
 	select SERIAL_8250
 	select SERIAL_8250_CONSOLE
@@ -326,7 +324,6 @@ config PMC_YOSEMITE
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
 	select SYS_SUPPORTS_HIGHMEM
-	select SYS_SUPPORTS_KGDB
 	select SYS_SUPPORTS_SMP
 	help
 	  Yosemite is an evaluation board for the RM9000x2 processor
@@ -394,7 +391,6 @@ config SGI_IP27
 	select SYS_HAS_CPU_R10000
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
-	select SYS_SUPPORTS_KGDB
 	select SYS_SUPPORTS_NUMA
 	select SYS_SUPPORTS_SMP
 	select GENERIC_HARDIRQS_NO__DO_IRQ
@@ -476,7 +472,6 @@ config SIBYTE_SWARM
 	select SYS_HAS_CPU_SB1
 	select SYS_SUPPORTS_BIG_ENDIAN
 	select SYS_SUPPORTS_HIGHMEM
-	select SYS_SUPPORTS_KGDB
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 
 config SIBYTE_LITTLESUR
@@ -587,7 +582,6 @@ config TOSHIBA_RBTX4927
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select SYS_SUPPORTS_BIG_ENDIAN
-	select SYS_SUPPORTS_KGDB
 	select GENERIC_HARDIRQS_NO__DO_IRQ
 	help
 	  This Toshiba board is based on the TX4927 processor. Say Y here to
@@ -605,7 +599,6 @@ config TOSHIBA_RBTX4938
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select SYS_SUPPORTS_BIG_ENDIAN
-	select SYS_SUPPORTS_KGDB
 	select GENERIC_HARDIRQS_NO__DO_IRQ
 	select GENERIC_GPIO
 	help
@@ -860,7 +853,6 @@ config SOC_PNX8550
 	select SYS_HAS_EARLY_PRINTK
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select GENERIC_HARDIRQS_NO__DO_IRQ
-	select SYS_SUPPORTS_KGDB
 	select GENERIC_GPIO
 
 config SWAP_IO_SPACE
arch/mips/au1000/common/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-y += prom.o irq.o puts.o time.o rese
 	au1xxx_irqmap.o clocks.o platform.o power.o setup.o \
 	sleeper.o cputable.o dma.o dbdma.o gpio.o
 
-obj-$(CONFIG_KGDB)		+= dbg_io.o
 obj-$(CONFIG_PCI)		+= pci.o
 
 EXTRA_CFLAGS += -Werror
arch/mips/au1000/common/dbg_io.c deleted +0 -121

52 lines not on this page · raw message

arch/mips/basler/excite/Makefile +0 -1

Lines of this file are not shown. View the raw message.

arch/mips/basler/excite/excite_dbg_io.c deleted +0 -121

121 lines not on this page · raw message

arch/mips/basler/excite/excite_irq.c +0 -7

Lines of this file are not shown. View the raw message.

arch/mips/basler/excite/excite_setup.c +2 -2

Lines of this file are not shown. View the raw message.

arch/mips/jmr3927/rbhma3100/Makefile +0 -1

Lines of this file are not shown. View the raw message.

arch/mips/jmr3927/rbhma3100/kgdb_io.c deleted +0 -105

105 lines not on this page · raw message

arch/mips/kernel/gdb-low.S deleted +0 -394

394 lines not on this page · raw message

arch/mips/mips-boards/atlas/Makefile +0 -1

Lines of this file are not shown. View the raw message.

arch/mips/mips-boards/atlas/atlas_gdb.c deleted +0 -97

97 lines not on this page · raw message

arch/mips/mips-boards/atlas/atlas_setup.c +0 -7

Lines of this file are not shown. View the raw message.

arch/mips/mips-boards/generic/gdb_hook.c deleted +0 -133

133 lines not on this page · raw message

arch/mips/pci/fixup-atlas.c +0 -21

Lines of this file are not shown. View the raw message.

arch/mips/philips/pnx8550/common/Makefile +0 -1

Lines of this file are not shown. View the raw message.

arch/mips/philips/pnx8550/common/gdb_hook.c deleted +0 -109

109 lines not on this page · raw message

arch/mips/philips/pnx8550/common/setup.c +0 -11

Lines of this file are not shown. View the raw message.

arch/mips/pmc-sierra/yosemite/Makefile +0 -1

Lines of this file are not shown. View the raw message.

arch/mips/pmc-sierra/yosemite/dbg_io.c deleted +0 -180

180 lines not on this page · raw message

arch/mips/pmc-sierra/yosemite/irq.c +0 -9

Lines of this file are not shown. View the raw message.

arch/mips/sgi-ip22/ip22-setup.c +0 -24

Lines of this file are not shown. View the raw message.

arch/mips/sgi-ip27/Makefile +0 -1

Lines of this file are not shown. View the raw message.

arch/mips/sgi-ip27/ip27-dbgio.c deleted +0 -60

60 lines not on this page · raw message

arch/mips/sibyte/bcm1480/irq.c +0 -81

81 lines not on this page · raw message

drivers/serial/serial_txx9_kgdb.c new file +152 -0

152 lines not on this page · raw message

include/asm-mips/asmmacro-32.h +43 -0

43 lines not on this page · raw message

include/asm-mips/asmmacro-64.h +99 -0

99 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw

drivers/serial/serial_txx9_kgdb.c

Quoted 3 lines · Jason Wessel
drivers/serial/serial_txx9_kgdb.c new file +0 -0
@@ -0,0 +1,152 @@

Thank you for attempting to mainline it. I have some cosmetic comments.

drivers/serial/serial_txx9_kgdb.c line 70

Quoted 10 lines
drivers/serial/serial_txx9_kgdb.c new file +10 -0
+static inline unsigned int sio_in(struct uart_port *port, int offset)
+{
+	return *(volatile u32 *)(port->membase + offset);
+}
+
+static inline void sio_out(struct uart_port *port, int offset,
+	unsigned int value)
+{
+	*(volatile u32 *)(port->membase + offset) = value;
+}

It would be better to avoid volatile.

static inline unsigned int sio_in(struct uart_port *port, int offset)

{
	return __raw_readl(port->membase + offset);
}

static inline void sio_out(struct uart_port *port, int offset,
unsigned int value)

{
	__raw_writel(value, port->membase + offset);
}

drivers/serial/serial_txx9_kgdb.c line 98

Quoted 12 lines
drivers/serial/serial_txx9_kgdb.c new file +12 -0
+	/* Reset the UART. */
+	sio_out(kgdb_port, TXX9_SIFCR, TXX9_SIFCR_SWRST);
+#ifdef CONFIG_CPU_TX49XX
+	/*
+	 * TX4925 BUG WORKAROUND.  Accessing SIOC register
+	 * immediately after soft reset causes bus error.
+	 */
+	iob();
+	udelay(1);
+#endif
+	/* Wait until reset is complete. */
+	while (sio_in(kgdb_port, TXX9_SIFCR) & TXX9_SIFCR_SWRST);

A while ago, this part of serial_txx9.c was changed a bit (no ifdefs, avoid endless loop). Could you change it to:

	unsigned int tmout = 10000;

	sio_out(kgdb_port, TXX9_SIFCR, TXX9_SIFCR_SWRST);
	/* TX4925 BUG WORKAROUND.  Accessing SIOC register
	 * immediately after soft reset causes bus error. */
	mmiowb();
	udelay(1);
	while ((sio_in(kgdb_port, TXX9_SIFCR) & TXX9_SIFCR_SWRST) && --tmout)
		udelay(1);

drivers/serial/serial_txx9_kgdb.c line 108

Quoted 3 lines
drivers/serial/serial_txx9_kgdb.c new file +3 -0
+	/* Select the input clock prescaler that fits the baud rate. */
+	quot = (kgdb_port->uartclk + 8 * kgdb_txx9_baud) /
+		(16 * kgdb_txx9_baud);

uart_get_divisor() can be used here:

	quot = uart_get_divisor(kgdb_port, kgdb_txx9_baud);

drivers/serial/serial_txx9_kgdb.c line 118

Quoted 10 lines
drivers/serial/serial_txx9_kgdb.c new file +10 -0
+	if (quot < (256 << 1))
+		sibgr = (quot >> 1) | TXX9_SIBGR_BCLK_T0;
+	else if (quot < ( 256 << 3))
+		sibgr = (quot >> 3) | TXX9_SIBGR_BCLK_T2;
+	else if (quot < ( 256 << 5))
+		sibgr = (quot >> 5) | TXX9_SIBGR_BCLK_T4;
+	else if (quot < ( 256 << 7))
+		sibgr = (quot >> 7) | TXX9_SIBGR_BCLK_T6;
+	else
+		sibgr = 0xff | TXX9_SIBGR_BCLK_T6;

It would be better to do it more similar to serial_txx9.c:

	quot >>= 1;
	if (quot < 256)
		sibgr = quot | TXX9_SIBGR_BCLK_T0;
	else if (quot < (256 << 2))
		sibgr = (quot >> 2) | TXX9_SIBGR_BCLK_T2;
	else if (quot < (256 << 4))
		sibgr = (quot >> 4) | TXX9_SIBGR_BCLK_T4;
	else if (quot < (256 << 6))
		sibgr = (quot >> 6) | TXX9_SIBGR_BCLK_T6;
	else
		sibgr = 0xff | TXX9_SIBGR_BCLK_T6;

---
Atsushi Nemoto