mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2)
@ 2008-08-15  8:23 Bryan Wu
  2008-08-15  8:23 ` [PATCH 1/2] Blackfin Serial Driver: fix bug - Avoid null point exception in kgdb over UART Bryan Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bryan Wu @ 2008-08-15  8:23 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel


Hi Alan,

Sorry for sending out a patch (Blackfin Serial Driver: Fix bug -
request UART2/3 peripheral mapped interrupts in PIO mode) you acked
before. This time is the 2 bug fixing patches in my queue.

Thanks
-Bryan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Blackfin Serial Driver: fix bug - Avoid null point exception in kgdb over UART
  2008-08-15  8:23 [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Bryan Wu
@ 2008-08-15  8:23 ` Bryan Wu
  2008-08-15  8:23 ` [PATCH 2/2] Blackfin Serial Driver: Add a debug function to serial driver Bryan Wu
  2008-08-15  9:03 ` [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Alan Cox
  2 siblings, 0 replies; 5+ messages in thread
From: Bryan Wu @ 2008-08-15  8:23 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel, Sonic Zhang, Bryan Wu

From: Sonic Zhang <sonic.zhang@analog.com>

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
 drivers/serial/bfin_5xx.c |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 487a562..a5ff54e 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -124,8 +124,6 @@ static void bfin_serial_enable_ms(struct uart_port *port)
 }
 
 #ifdef CONFIG_KGDB_UART
-static int kgdb_entry_state;
-
 void kgdb_put_debug_char(int chr)
 {
 	struct bfin_serial_port *uart;
@@ -178,7 +176,7 @@ int kgdb_get_debug_char(void)
 #ifdef CONFIG_SERIAL_BFIN_PIO
 static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
 {
-	struct tty_struct *tty = uart->port.info->port.tty;
+	struct tty_struct *tty = NULL;
 	unsigned int status, ch, flg;
 	static struct timeval anomaly_start = { .tv_sec = 0 };
 
@@ -191,24 +189,33 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
 #ifdef CONFIG_KGDB_UART
 	if (uart->port.line == CONFIG_KGDB_UART_PORT) {
 		struct pt_regs *regs = get_irq_regs();
-		if (uart->port.cons->index == CONFIG_KGDB_UART_PORT && ch == 0x1) { /* Ctrl + A */
-			kgdb_breakkey_pressed(regs);
-			return;
-		} else if (kgdb_entry_state == 0 && ch == '$') {/* connection from KGDB */
-			kgdb_entry_state = 1;
-		} else if (kgdb_entry_state == 1 && ch == 'q') {
-			kgdb_entry_state = 0;
+		int kgdb_timeout;
+		if (uart->port.cons->index == CONFIG_KGDB_UART_PORT
+			&& ch == 0x1) { /* Ctrl + A */
 			kgdb_breakkey_pressed(regs);
 			return;
+		}
+		if (ch == '$') {
+			/* connection from KGDB */
+			kgdb_timeout = get_cclk()/10000;
+			while (!(UART_GET_LSR(uart) & DR)
+				&& kgdb_timeout > 0) {
+				kgdb_timeout--;
+				cpu_relax();
+			}
+			if (kgdb_timeout && UART_GET_CHAR(uart) == 'q') {
+				kgdb_breakkey_pressed(regs);
+				return;
+			}
 		} else if (ch == 0x3) {/* Ctrl + C */
-			kgdb_entry_state = 0;
 			kgdb_breakkey_pressed(regs);
 			return;
-		} else {
-			kgdb_entry_state = 0;
 		}
+		if (!uart->port.info)
+			return;
 	}
 #endif
+	tty = uart->port.info->tty;
 
 	if (ANOMALY_05000363) {
 		/* The BF533 (and BF561) family of processors have a nice anomaly
@@ -1076,10 +1083,7 @@ static int __init bfin_serial_rs_console_init(void)
 {
 	bfin_serial_init_ports();
 	register_console(&bfin_serial_console);
-#ifdef CONFIG_KGDB_UART
-	kgdb_entry_state = 0;
-	init_kgdb_uart();
-#endif
+
 	return 0;
 }
 console_initcall(bfin_serial_rs_console_init);
@@ -1266,6 +1270,7 @@ static int __init bfin_serial_init(void)
 		t.c_line = CONFIG_KGDB_UART_PORT;
 		bfin_serial_set_termios(&uart->port, &t, &t);
 	}
+	init_kgdb_uart();
 #endif
 	return ret;
 }
@@ -1276,7 +1281,11 @@ static void __exit bfin_serial_exit(void)
 	uart_unregister_driver(&bfin_serial_reg);
 }
 
+#ifdef CONFIG_KGDB_UART
+subsys_initcall(bfin_serial_init);
+#else
 module_init(bfin_serial_init);
+#endif
 module_exit(bfin_serial_exit);
 
 MODULE_AUTHOR("Aubrey.Li <aubrey.li@analog.com>");
-- 
1.5.6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Blackfin Serial Driver: Add a debug function to serial driver.
  2008-08-15  8:23 [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Bryan Wu
  2008-08-15  8:23 ` [PATCH 1/2] Blackfin Serial Driver: fix bug - Avoid null point exception in kgdb over UART Bryan Wu
@ 2008-08-15  8:23 ` Bryan Wu
  2008-08-15 12:47   ` Mike Frysinger
  2008-08-15  9:03 ` [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Alan Cox
  2 siblings, 1 reply; 5+ messages in thread
From: Bryan Wu @ 2008-08-15  8:23 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel, Graf Yang, Bryan Wu

From: Graf Yang <graf.yang@analog.com>

Signed-off-by: Graf Yang <graf.yang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
 drivers/serial/bfin_5xx.c |   53 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index a5ff54e..1917904 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -21,6 +21,7 @@
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/serial_core.h>
+#include <stdarg.h>
 
 #ifdef CONFIG_KGDB_UART
 #include <linux/kgdb.h>
@@ -1101,7 +1102,8 @@ static __init void early_serial_putc(struct uart_port *port, int ch)
 	struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
 
 	while ((!(UART_GET_LSR(uart) & THRE)) && --timeout)
-		cpu_relax();
+		barrier();
+
 	UART_PUT_CHAR(uart, ch);
 }
 
@@ -1150,6 +1152,55 @@ struct console __init *bfin_earlyserial_init(unsigned int port,
 
 #endif /* CONFIG_SERIAL_BFIN_CONSOLE */
 
+#ifdef CONFIG_DEBUG_KERNEL
+void bfin_serial_debug(const char *fmt, ...)
+{
+	struct bfin_serial_port *uart = &bfin_serial_ports[0];
+	unsigned short status, tmp;
+	int flags, i, count;
+	char buf[128];
+	va_list ap;
+
+	if (bfin_serial_console.index < 0)
+		return;		/* Too early. */
+
+	va_start(ap, fmt);
+	vsprintf(buf, fmt, ap);
+	va_end(ap);
+	count = strlen(buf);
+
+	spin_lock_irqsave(&uart->port.lock, flags);
+
+	for (i = 0; i < count; i++) {
+		do {
+			status = UART_GET_LSR(uart);
+		} while (!(status & THRE));
+
+#ifndef CONFIG_BF54x
+		tmp = UART_GET_LCR(uart);
+		tmp &= ~DLAB;
+		UART_PUT_LCR(uart, tmp);
+#endif
+		UART_PUT_CHAR(uart, buf[i]);
+		if (buf[i] == '\n') {
+			do {
+				status = UART_GET_LSR(uart);
+			} while (!(status & THRE));
+			UART_PUT_CHAR(uart, '\r');
+		}
+	}
+
+	spin_unlock_irqrestore(&uart->port.lock, flags);
+}
+EXPORT_SYMBOL(bfin_serial_debug);
+#else
+void bfin_serial_debug(const char *fmt, ...)
+{
+	return;
+}
+EXPORT_SYMBOL(bfin_serial_debug);
+#endif
+
 static struct uart_driver bfin_serial_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "bfin-uart",
-- 
1.5.6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2)
  2008-08-15  8:23 [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Bryan Wu
  2008-08-15  8:23 ` [PATCH 1/2] Blackfin Serial Driver: fix bug - Avoid null point exception in kgdb over UART Bryan Wu
  2008-08-15  8:23 ` [PATCH 2/2] Blackfin Serial Driver: Add a debug function to serial driver Bryan Wu
@ 2008-08-15  9:03 ` Alan Cox
  2 siblings, 0 replies; 5+ messages in thread
From: Alan Cox @ 2008-08-15  9:03 UTC (permalink / raw)
  To: Bryan Wu; +Cc: linux-kernel

On Fri, 15 Aug 2008 16:23:35 +0800
Bryan Wu <cooloney@kernel.org> wrote:

> 
> Hi Alan,
> 
> Sorry for sending out a patch (Blackfin Serial Driver: Fix bug -
> request UART2/3 peripheral mapped interrupts in PIO mode) you acked
> before. This time is the 2 bug fixing patches in my queue.

Look fine to me

Acked-by: Alan Cox <alan@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Blackfin Serial Driver: Add a debug function to serial driver.
  2008-08-15  8:23 ` [PATCH 2/2] Blackfin Serial Driver: Add a debug function to serial driver Bryan Wu
@ 2008-08-15 12:47   ` Mike Frysinger
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2008-08-15 12:47 UTC (permalink / raw)
  To: Bryan Wu; +Cc: alan, linux-kernel, Graf Yang

On Fri, Aug 15, 2008 at 4:23 AM, Bryan Wu wrote:
> +#ifdef CONFIG_DEBUG_KERNEL
> + ...
> +#else
> +void bfin_serial_debug(const char *fmt, ...)
> +{
> +       return;
> +}
> +EXPORT_SYMBOL(bfin_serial_debug);
> +#endif

it doesnt really make sense to export the symbol or make it available
when debugging is not enabled.
-mike

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-15 12:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-15  8:23 [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Bryan Wu
2008-08-15  8:23 ` [PATCH 1/2] Blackfin Serial Driver: fix bug - Avoid null point exception in kgdb over UART Bryan Wu
2008-08-15  8:23 ` [PATCH 2/2] Blackfin Serial Driver: Add a debug function to serial driver Bryan Wu
2008-08-15 12:47   ` Mike Frysinger
2008-08-15  9:03 ` [PATCH 0/2] Blackfin Serial Drivers bug fixing (v2) Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome