* [PATCH 1/4] early_printk
2008-01-15 22:28 [PATCH 0/4] implement KGDB on Toshiba RBTX4927, 2.6.24-rc7 Frank Rowand
@ 2008-01-15 22:31 ` Frank Rowand
2008-01-16 15:27 ` Atsushi Nemoto
2008-01-15 22:32 ` [PATCH 2/4] kgdb on not SMP Frank Rowand
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Frank Rowand @ 2008-01-15 22:31 UTC (permalink / raw)
To: ralf, linux-mips
From: Frank Rowand <frank.rowand@am.sony.com>
Implement early printk in the serial_txx9 driver, and enable for the
Toshiba RBTX4927 board. This is needed for the connect to GDB console
message.
Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
---
arch/mips/Kconfig | 1 1 + 0 - 0 !
arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c | 6 6 + 0 - 0 !
drivers/serial/serial_txx9.c | 39 39 + 0 - 0 !
3 files changed, 46 insertions(+)
Index: linux-2.6.24-rc7/arch/mips/Kconfig
===================================================================
--- linux-2.6.24-rc7.orig/arch/mips/Kconfig
+++ linux-2.6.24-rc7/arch/mips/Kconfig
@@ -631,6 +631,7 @@ config TOSHIBA_RBTX4927
select I8259 if TOSHIBA_FPCIB0
select SWAP_IO_SPACE
select SYS_HAS_CPU_TX49XX
+ select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_LITTLE_ENDIAN
Index: linux-2.6.24-rc7/drivers/serial/serial_txx9.c
===================================================================
--- linux-2.6.24-rc7.orig/drivers/serial/serial_txx9.c
+++ linux-2.6.24-rc7/drivers/serial/serial_txx9.c
@@ -1198,6 +1198,45 @@ MODULE_DEVICE_TABLE(pci, serial_txx9_pci
static struct platform_device *serial_txx9_plat_devs;
+#ifdef CONFIG_EARLY_PRINTK
+
+/*
+ * Do NOT request the console resources, allows normal driver to initialize
+ * console later.
+ */
+
+static int prom_putchar_port = -1;
+
+void early_printk_serial_txx9_console_setup(void)
+{
+ prom_putchar_port = 0;
+}
+
+void prom_putchar(char ch)
+{
+ unsigned int status;
+ struct uart_txx9_port *up;
+
+ if (prom_putchar_port == -1)
+ return;
+
+ up = &serial_txx9_ports[prom_putchar_port];
+
+ if (ch == '\n')
+ prom_putchar('\r');
+
+ while (1) {
+ status = sio_in(up, TXX9_SICISR);
+ if (status & TXX9_SICISR_TRDY) {
+ sio_out(up, TXX9_SITFIFO, (u32)ch);
+ break;
+ }
+ }
+}
+
+#endif
+
+
static int __init serial_txx9_init(void)
{
int ret;
Index: linux-2.6.24-rc7/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
===================================================================
--- linux-2.6.24-rc7.orig/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ linux-2.6.24-rc7/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -913,6 +913,12 @@ void __init toshiba_rbtx4927_setup(void)
if (strstr(argptr, "console=") == NULL) {
strcat(argptr, " console=ttyS0,38400");
}
+#ifdef CONFIG_EARLY_PRINTK
+ {
+ extern void early_printk_serial_txx9_console_setup(void);
+ early_printk_serial_txx9_console_setup();
+ }
+#endif
#endif
#endif
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 1/4] early_printk
2008-01-15 22:31 ` [PATCH 1/4] early_printk Frank Rowand
@ 2008-01-16 15:27 ` Atsushi Nemoto
0 siblings, 0 replies; 10+ messages in thread
From: Atsushi Nemoto @ 2008-01-16 15:27 UTC (permalink / raw)
To: frank.rowand; +Cc: ralf, linux-mips
On Tue, 15 Jan 2008 14:31:27 -0800, Frank Rowand <frank.rowand@am.sony.com> wrote:
> Implement early printk in the serial_txx9 driver, and enable for the
> Toshiba RBTX4927 board. This is needed for the connect to GDB console
> message.
>
> Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
> ---
> arch/mips/Kconfig | 1 1 + 0 - 0 !
> arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c | 6 6 + 0 - 0 !
> drivers/serial/serial_txx9.c | 39 39 + 0 - 0 !
> 3 files changed, 46 insertions(+)
Please do not add MIPS local prom_putchar() to the serial_txx9 driver.
This driver is used on some powerpc platform too.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/4] kgdb on not SMP
2008-01-15 22:28 [PATCH 0/4] implement KGDB on Toshiba RBTX4927, 2.6.24-rc7 Frank Rowand
2008-01-15 22:31 ` [PATCH 1/4] early_printk Frank Rowand
@ 2008-01-15 22:32 ` Frank Rowand
2008-01-15 22:33 ` [PATCH 3/4] serial_txx9 driver support Frank Rowand
2008-01-15 22:34 ` [PATCH 4/4] invoke kgdb via magic sysrq Frank Rowand
3 siblings, 0 replies; 10+ messages in thread
From: Frank Rowand @ 2008-01-15 22:32 UTC (permalink / raw)
To: ralf, linux-mips
From: Frank Rowand <frank.rowand@am.sony.com>
Fix gdb-stub.c compile warning for non-SMP systems (which becomes compile
error due to -Werror).
Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
---
arch/mips/kernel/gdb-stub.c | 2 2 + 0 - 0 !
1 files changed, 2 insertions(+)
Index: linux-2.6.24-rc5/arch/mips/kernel/gdb-stub.c
===================================================================
--- linux-2.6.24-rc5.orig/arch/mips/kernel/gdb-stub.c
+++ linux-2.6.24-rc5/arch/mips/kernel/gdb-stub.c
@@ -656,6 +656,7 @@ void set_async_breakpoint(unsigned long
*epc = (unsigned long)async_breakpoint;
}
+#ifdef CONFIG_SMP
static void kgdb_wait(void *arg)
{
unsigned flags;
@@ -668,6 +669,7 @@ static void kgdb_wait(void *arg)
local_irq_restore(flags);
}
+#endif
/*
* GDB stub needs to call kgdb_wait on all processor with interrupts
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 3/4] serial_txx9 driver support
2008-01-15 22:28 [PATCH 0/4] implement KGDB on Toshiba RBTX4927, 2.6.24-rc7 Frank Rowand
2008-01-15 22:31 ` [PATCH 1/4] early_printk Frank Rowand
2008-01-15 22:32 ` [PATCH 2/4] kgdb on not SMP Frank Rowand
@ 2008-01-15 22:33 ` Frank Rowand
2008-01-16 15:47 ` Atsushi Nemoto
2008-01-18 23:44 ` Frank Rowand
2008-01-15 22:34 ` [PATCH 4/4] invoke kgdb via magic sysrq Frank Rowand
3 siblings, 2 replies; 10+ messages in thread
From: Frank Rowand @ 2008-01-15 22:33 UTC (permalink / raw)
To: ralf, linux-mips
From: Frank Rowand <frank.rowand@am.sony.com>
Add polled debug driver support to serial_txx9.c for kgdb, and initialize
the driver for the Toshiba RBTX4927.
Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
---
arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c | 6 6 + 0 - 0 !
drivers/serial/serial_txx9.c | 90 90 + 0 - 0 !
2 files changed, 96 insertions(+)
Index: linux-2.6.24-rc7/drivers/serial/serial_txx9.c
===================================================================
--- linux-2.6.24-rc7.orig/drivers/serial/serial_txx9.c
+++ linux-2.6.24-rc7/drivers/serial/serial_txx9.c
@@ -1237,6 +1237,96 @@ void prom_putchar(char ch)
#endif
+/******************************************************************************/
+/* BEG: KDBG Routines */
+/******************************************************************************/
+
+#ifdef CONFIG_KGDB
+int kgdb_initialized;
+
+void txx9_sio_kgdb_hook(unsigned int port, unsigned int baud_rate)
+{
+ static struct resource kgdb_resource;
+ int ret;
+ struct uart_txx9_port *up = &serial_txx9_ports[port];
+
+ /* prevent initialization by driver */
+ kgdb_resource.name = "serial_txx9(debug)";
+ kgdb_resource.start = (resource_size_t)up->port.membase;
+ kgdb_resource.end = (resource_size_t)up->port.membase + 36 - 1;
+ kgdb_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+
+ ret = request_resource(&iomem_resource, &kgdb_resource);
+ if (ret == -EBUSY)
+ printk(KERN_ERR
+ "txx9_sio_kgdb_hook(): request_resource failed\n");
+
+ return;
+}
+void
+txx9_sio_kdbg_init(unsigned int port_number)
+{
+ if (port_number == 1) {
+ txx9_sio_kgdb_hook(port_number, 38400);
+ kgdb_initialized = 1;
+ } else {
+ printk(KERN_ERR
+ "txx9_sio_kdbg_init(): Bad Port Number [%u] != [1]\n",
+ port_number);
+ }
+
+ return;
+}
+
+u8
+txx9_sio_kdbg_rd(void)
+{
+ unsigned int status, ch;
+ struct uart_txx9_port *up = &serial_txx9_ports[1];
+
+ if (!kgdb_initialized)
+ return 0;
+
+ while (1) {
+ status = sio_in(up, TXX9_SIDISR);
+ if (status & 0x1f) {
+ ch = sio_in(up, TXX9_SIRFIFO);
+ break;
+ }
+ }
+
+ return ch;
+}
+
+int
+txx9_sio_kdbg_wr(u8 ch)
+{
+ unsigned int status;
+ struct uart_txx9_port *up = &serial_txx9_ports[1];
+
+ if (!kgdb_initialized)
+ return 0;
+
+ while (1) {
+ status = sio_in(up, TXX9_SICISR);
+ if (status & TXX9_SICISR_TRDY) {
+ if (ch == '\n')
+ txx9_sio_kdbg_wr('\r');
+ sio_out(up, TXX9_SITFIFO, (u32)ch);
+
+ break;
+ }
+ }
+
+ return 1;
+}
+#endif /* CONFIG_KGDB */
+
+
+/******************************************************************************/
+/* END: KDBG Routines */
+/******************************************************************************/
+
static int __init serial_txx9_init(void)
{
int ret;
Index: linux-2.6.24-rc7/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
===================================================================
--- linux-2.6.24-rc7.orig/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ linux-2.6.24-rc7/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -919,6 +919,12 @@ void __init toshiba_rbtx4927_setup(void)
early_printk_serial_txx9_console_setup();
}
#endif
+#ifdef CONFIG_KGDB
+ {
+ extern void txx9_sio_kdbg_init(unsigned int port_number);
+ txx9_sio_kdbg_init(1);
+ }
+#endif
#endif
#endif
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 3/4] serial_txx9 driver support
2008-01-15 22:33 ` [PATCH 3/4] serial_txx9 driver support Frank Rowand
@ 2008-01-16 15:47 ` Atsushi Nemoto
2008-01-16 23:46 ` Frank Rowand
2008-01-18 23:44 ` Frank Rowand
1 sibling, 1 reply; 10+ messages in thread
From: Atsushi Nemoto @ 2008-01-16 15:47 UTC (permalink / raw)
To: frank.rowand; +Cc: ralf, linux-mips
On Tue, 15 Jan 2008 14:33:52 -0800, Frank Rowand <frank.rowand@am.sony.com> wrote:
> Add polled debug driver support to serial_txx9.c for kgdb, and initialize
> the driver for the Toshiba RBTX4927.
I think Jason Wessel's kgdb patchset is a way to go.
Anyway, some comments below.
> +int kgdb_initialized;
Should be static.
> +void txx9_sio_kgdb_hook(unsigned int port, unsigned int baud_rate)
Should be static. The baud_rate is not used.
> +void
> +txx9_sio_kdbg_init(unsigned int port_number)
> +{
> + if (port_number == 1) {
> + txx9_sio_kgdb_hook(port_number, 38400);
> + kgdb_initialized = 1;
> + } else {
> + printk(KERN_ERR
> + "txx9_sio_kdbg_init(): Bad Port Number [%u] != [1]\n",
> + port_number);
> + }
> +
> + return;
> +}
Why port_number other than 1 is bad?
The "return" at the end of the function is redundant.
> +u8
> +txx9_sio_kdbg_rd(void)
> +{
> + unsigned int status, ch;
> + struct uart_txx9_port *up = &serial_txx9_ports[1];
Oh this assumes port number 1. The gdb port number should be customizable.
> + sio_out(up, TXX9_SITFIFO, (u32)ch);
The cast is not needed.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 3/4] serial_txx9 driver support
2008-01-16 15:47 ` Atsushi Nemoto
@ 2008-01-16 23:46 ` Frank Rowand
2008-01-17 16:57 ` Sergei Shtylyov
0 siblings, 1 reply; 10+ messages in thread
From: Frank Rowand @ 2008-01-16 23:46 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: ralf, linux-mips
On Thu, 2008-01-17 at 00:47 +0900, Atsushi Nemoto wrote:
> On Tue, 15 Jan 2008 14:33:52 -0800, Frank Rowand <frank.rowand@am.sony.com> wrote:
> > Add polled debug driver support to serial_txx9.c for kgdb, and initialize
> > the driver for the Toshiba RBTX4927.
>
> I think Jason Wessel's kgdb patchset is a way to go.
Somehow I overlooked Jason's patchset. Yes, I agree that is the way to go,
so my four patches should not be applied. Thanks for bringing that to my
attention.
-Frank
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] serial_txx9 driver support
2008-01-16 23:46 ` Frank Rowand
@ 2008-01-17 16:57 ` Sergei Shtylyov
0 siblings, 0 replies; 10+ messages in thread
From: Sergei Shtylyov @ 2008-01-17 16:57 UTC (permalink / raw)
To: frank.rowand; +Cc: Atsushi Nemoto, ralf, linux-mips
Hello Frank. :-)
>>>Add polled debug driver support to serial_txx9.c for kgdb, and initialize
>>>the driver for the Toshiba RBTX4927.
>>I think Jason Wessel's kgdb patchset is a way to go.
> Somehow I overlooked Jason's patchset. Yes, I agree that is the way to go,
BTW, that patchset already has TX[34]9xx KGDB serial driver...
> so my four patches should not be applied.
Well, it's not in the mainline yet anyway...
> -Frank
WBR, Sergei
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] serial_txx9 driver support
2008-01-15 22:33 ` [PATCH 3/4] serial_txx9 driver support Frank Rowand
2008-01-16 15:47 ` Atsushi Nemoto
@ 2008-01-18 23:44 ` Frank Rowand
1 sibling, 0 replies; 10+ messages in thread
From: Frank Rowand @ 2008-01-18 23:44 UTC (permalink / raw)
To: ralf; +Cc: linux-mips
On Tue, 2008-01-15 at 14:33 -0800, Frank Rowand wrote:
> From: Frank Rowand <frank.rowand@am.sony.com>
>
> Add polled debug driver support to serial_txx9.c for kgdb, and initialize
> the driver for the Toshiba RBTX4927.
>
> Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
> ---
> arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c | 6 6 + 0 - 0 !
> drivers/serial/serial_txx9.c | 90 90 + 0 - 0 !
> 2 files changed, 96 insertions(+)
Just for the record... original attribution is very important.
I meant to mention in the original email, but I overlooked it, that
the serial_txx9.c code is mostly from the kgdb patch version 2.4 at
http://kgdb.linsyssoft.com/downloads.htm with a few slight changes. The
code is attributed to Ralf in the comments at the head of that patch
file. I suspect that Ralf recognized his code when I first sent it to
him :-).
-Frank
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/4] invoke kgdb via magic sysrq
2008-01-15 22:28 [PATCH 0/4] implement KGDB on Toshiba RBTX4927, 2.6.24-rc7 Frank Rowand
` (2 preceding siblings ...)
2008-01-15 22:33 ` [PATCH 3/4] serial_txx9 driver support Frank Rowand
@ 2008-01-15 22:34 ` Frank Rowand
3 siblings, 0 replies; 10+ messages in thread
From: Frank Rowand @ 2008-01-15 22:34 UTC (permalink / raw)
To: ralf, linux-mips
From: Frank Rowand <frank.rowand@am.sony.com>
Add hooks so that the host can connect to KGDB or asynchronously invoke an
already connected KGDB via a magic sysrq. This should work for most MIPS
targets that support KGDB, though it has only been tested on the Toshiba
RBTX4927. This can be useful to invoke an already connected KGDB for some
types of system hang. It also allows normally booting without connecting
to KGDB, then later connecting to KGDB if kernel debugging is desired.
This functionality exists for PowerPC and sh.
Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
---
arch/mips/kernel/gdb-stub.c | 26 26 + 0 - 0 !
1 files changed, 26 insertions(+)
Index: linux-2.6.24-rc7/arch/mips/kernel/gdb-stub.c
===================================================================
--- linux-2.6.24-rc7.orig/arch/mips/kernel/gdb-stub.c
+++ linux-2.6.24-rc7/arch/mips/kernel/gdb-stub.c
@@ -131,6 +131,7 @@
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/reboot.h>
+#include <linux/sysrq.h>
#include <asm/asm.h>
#include <asm/cacheflush.h>
@@ -1154,3 +1155,28 @@ static int __init register_gdb_console(v
console_initcall(register_gdb_console);
#endif
+
+#ifdef CONFIG_MAGIC_SYSRQ
+static void sysrq_handle_gdb(int key, struct tty_struct *tty)
+{
+ if (!initialized) {
+ printk(KERN_ALERT "Wait for gdb client connection ...\n");
+ set_debug_traps();
+ }
+
+ breakpoint();
+}
+static struct sysrq_key_op sysrq_gdb_op = {
+ .handler = sysrq_handle_gdb,
+ .help_msg = "Gdb",
+ .action_msg = "GDB",
+};
+
+static int gdb_register_sysrq(void)
+{
+ printk(KERN_INFO "Registering GDB sysrq handler\n");
+ register_sysrq_key('g', &sysrq_gdb_op);
+ return 0;
+}
+module_init(gdb_register_sysrq);
+#endif
^ permalink raw reply [flat|nested] 10+ messages in thread