Skip to contentSkip to conversation

8250_kgdb driver reworked

PATCH In review Tom Rini 3 participants 7 messages Sep 1, 2005 Library code

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 8250_kgdb driver reworked

Andrew, I'll probably repost the whole series next week in hope you'll grab it for 2.6.13-mm2.

This is the I/O driver for any 8250-compatible UARTs. This also adds some small hooks into the normal serial core so that we can take away the uart and make sure only KGDB is trying to use it. We also make sure that if KGDB_8250 is enabled, SERIAL_8250_NR_UARTS is set to the default of 4. This is so that if we can always depend on that constant in the 8250 driver for giving our table a size. To make it easier (or in some cases, possible) to free up ports on a shared irq system, we add a line member to plat_serial8250_port.

Since the last time this was submitted, I've reworked the commandline param, kgdb8250=, to be of the form <io or mmio>,<address>,<baud rate>,<irq> for all platforms to always work as an override of the compiled in port. To compile in a port you either go by number and baud rate, or compile in the port information the same as you would pass it in on the command line. The config options are pared way down as well now (don't ask me why I forgot 'int' exists, I can't say...).

CC: Russell King <[email protected]>, Bjorn Helgaas <[email protected]> This is the I/O driver for any 8250-compatible UARTs. This also adds some small hooks into the normal serial core so that we can take away the uart and make sure only KGDB is trying to use it. We also make sure that if KGDB_8250 is enabled, SERIAL_8250_NR_UARTS is set to the default of 4. This is so that if we can always depend on that constant in the 8250 driver for giving our table a size. To make it easier (or in some cases, possible) to free up ports on a shared irq system, we add a line member to plat_serial8250_port.

Since the last time this was submitted, I've reworked the commandline param, kgdb8250=, to be of the form <io or mmio>,<address>,<baud rate>,<irq> for all platforms to always work as an override of the compiled in port. To compile in a port you either go by number and baud rate, or compile in the port information the same as you would pass it in on the command line.

---

 linux-2.6.13-trini/drivers/serial/8250.c      |   21 +
 linux-2.6.13-trini/drivers/serial/8250.h      |    1 
 linux-2.6.13-trini/drivers/serial/8250_kgdb.c |  538 ++++++++++++++++++++++++++
 linux-2.6.13-trini/drivers/serial/Kconfig     |    2 
 linux-2.6.13-trini/drivers/serial/Makefile    |    1 
 linux-2.6.13-trini/lib/Kconfig.debug          |   60 ++
 6 files changed, 621 insertions(+), 2 deletions(-)
drivers/serial/8250.c renamed from drivers/serial/8250.c~8250 +21 -0
diff -puN drivers/serial/8250.c~8250 drivers/serial/8250.c
@@ -2516,6 +2516,27 @@ void serial8250_unregister_port(int line
 }
 EXPORT_SYMBOL(serial8250_unregister_port);
 
+/**
+ *	serial8250_unregister_by_port - remove a 16x50 serial port
+ *	at runtime.
+ *	@port: A &struct uart_port that describes the port to remove.
+ *
+ *	Remove one serial port.  This may not be called from interrupt
+ *	context.  We hand the port back to the our control.
+ */
+void serial8250_unregister_by_port(struct uart_port *port)
+{
+	struct uart_8250_port *uart;
+
+	down(&serial_sem);
+	uart = serial8250_find_match_or_unused(port);
+	up(&serial_sem);
+
+	if (uart)
+		serial8250_unregister_port(uart->port.line);
+}
+EXPORT_SYMBOL(serial8250_unregister_by_port);
+
 static int __init serial8250_init(void)
 {
 	int ret, i;
drivers/serial/8250.h renamed from drivers/serial/8250.h~8250 +1 -0
diff -puN drivers/serial/8250.h~8250 drivers/serial/8250.h
@@ -19,6 +19,7 @@
 
 int serial8250_register_port(struct uart_port *);
 void serial8250_unregister_port(int line);
+void serial8250_unregister_by_port(struct uart_port *port);
 void serial8250_suspend_port(int line);
 void serial8250_resume_port(int line);
 
drivers/serial/Kconfig renamed from drivers/serial/Kconfig~8250 +1 -1
diff -puN drivers/serial/Kconfig~8250 drivers/serial/Kconfig
@@ -87,7 +87,7 @@ config SERIAL_8250_ACPI
 
 config SERIAL_8250_NR_UARTS
 	int "Maximum number of 8250/16550 serial ports"
-	depends on SERIAL_8250
+	depends on SERIAL_8250 || KGDB_8250
 	default "4"
 	help
 	  Set this to the number of serial ports you want the driver

diff -L drivers/serial/kgdb_8250.c -puN /dev/null /dev/null

drivers/serial/Makefile renamed from drivers/serial/Makefile~8250 +1 -0
diff -puN drivers/serial/Makefile~8250 drivers/serial/Makefile
@@ -57,3 +57,4 @@ obj-$(CONFIG_SERIAL_JSM) += jsm/
 obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o
 obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
 obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
+obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o

diff -puN include/linux/kgdb.h~8250 include/linux/kgdb.h diff -puN include/linux/serial_8250.h~8250 include/linux/serial_8250.h

lib/Kconfig.debug renamed from lib/Kconfig.debug~8250 +59 -1

76 lines not on this page · raw message

drivers/serial/8250_kgdb.c new file +538 -0

538 lines not on this page · raw message

_

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#1 lore raw
Quoted 3 lines · Tom Rini

Andrew, I'll probably repost the whole series next week in hope you'll grab it for 2.6.13-mm2.

Well. Am sitting on >1,100 patches at present and the bugs just keep on rolling in..

Let's have another go at this in two weeks time, after I've shed some stuff, OK?

#2 lore raw
In reply to Tom Rini

drivers/serial/8250_kgdb.c line 154

Quoted 7 lines
drivers/serial/8250_kgdb.c new file +7 -0
+static irqreturn_t
+kgdb8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	char iir;
+
+	if (irq != KGDB8250_IRQ)
+		return IRQ_NONE;

How can this occur - you gave the IRQ number in the register_irq. WHy test for it, and if it occurs why not BUG()

drivers/serial/8250_kgdb.c line 161

Quoted 7 lines
drivers/serial/8250_kgdb.c new file +7 -0
+	/*
+	 * If  there is some other CPU in KGDB then this is a
+	 * spurious interrupt. so return without even checking a byte
+	 */
+	if (atomic_read(&debugger_active))
+		return IRQ_NONE;
+

Shared IRQ -> hung box.

Also lose the ugly confusing macros like CURRENTPORT please to follow kernel style better. In fact why not keep a pointer to the 'current' uart to get tighter code too ?

author
#3 lore raw
Quoted 10 lines · Alan Cox

drivers/serial/8250_kgdb.c line 154

Quoted 7 lines
drivers/serial/8250_kgdb.c new file +7 -0
+static irqreturn_t
+kgdb8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	char iir;
+
+	if (irq != KGDB8250_IRQ)
+		return IRQ_NONE;

How can this occur - you gave the IRQ number in the register_irq. WHy test for it, and if it occurs why not BUG()

Early sanity tests, dropped.

Quoted 9 lines

drivers/serial/8250_kgdb.c line 161

Quoted 7 lines
drivers/serial/8250_kgdb.c new file +7 -0
+	/*
+	 * If  there is some other CPU in KGDB then this is a
+	 * spurious interrupt. so return without even checking a byte
+	 */
+	if (atomic_read(&debugger_active))
+		return IRQ_NONE;
+

Shared IRQ -> hung box.

Can you elaborate a bit more please? When we're actually in KGDB and working on stuff we're polling so it's really just the GDB-is-interrupting case.

Quoted 3 lines

Also lose the ugly confusing macros like CURRENTPORT please to follow kernel style better. In fact why not keep a pointer to the 'current' uart to get tighter code too ?

Sure, why not.

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#4 lore raw
Quoted 9 lines · Tom Rini
Quoted 8 lines

drivers/serial/8250_kgdb.c line 161

Quoted 6 lines
drivers/serial/8250_kgdb.c new file +6 -0
+	 * If  there is some other CPU in KGDB then this is a
+	 * spurious interrupt. so return without even checking a byte
+	 */
+	if (atomic_read(&debugger_active))
+		return IRQ_NONE;
+

Shared IRQ -> hung box.

Quoted 3 lines

Can you elaborate a bit more please? When we're actually in KGDB and working on stuff we're polling so it's really just the GDB-is-interrupting case.

If the IRQ source is level triggered and the device is the cause then as soon as you exit the IRQ handler, you'll be called again and again and again until the IRQ is cleared or 10,000 tries or so occur when the IRQ is disabled

Does this only occur if there is a stray IRQ under delivery as kgdb is entered ? (ie you do something like

write irq off to port
read back if mmio (to avoid posting) atomic_inc(&debugger_active)

??

)

author
#5 lore raw
Quoted 10 lines · Alan Cox
Quoted 9 lines · Tom Rini
Quoted 8 lines

drivers/serial/8250_kgdb.c line 161

Quoted 6 lines
drivers/serial/8250_kgdb.c new file +6 -0
+	 * If  there is some other CPU in KGDB then this is a
+	 * spurious interrupt. so return without even checking a byte
+	 */
+	if (atomic_read(&debugger_active))
+		return IRQ_NONE;
+

Shared IRQ -> hung box.

Quoted 8 lines
Quoted 3 lines

Can you elaborate a bit more please? When we're actually in KGDB and working on stuff we're polling so it's really just the GDB-is-interrupting case.

If the IRQ source is level triggered and the device is the cause then as soon as you exit the IRQ handler, you'll be called again and again and again until the IRQ is cleared or 10,000 tries or so occur when the IRQ is disabled

But in the shared IRQ and other source is the other uart still registered to the real 8250 driver, we'd luck out. I know this has been tested on a shared serial irq box, so it's not immediate and always death at least...

Quoted 2 lines

Does this only occur if there is a stray IRQ under delivery as kgdb is entered ? (ie you do something like

So digging back in CVS it seems this was added to fix a spurious interrupt that occured on an (probably) an x86_64 box when NMI support didn't work correctly. I think it's safe enough to just drop this.

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
author
#6 lore raw

On Thu, Sep 01, 2005 at 03:45:09PM -0700, Tom Rini wrote:

[snip]

Quoted 3 lines

So digging back in CVS it seems this was added to fix a spurious interrupt that occured on an (probably) an x86_64 box when NMI support didn't work correctly. I think it's safe enough to just drop this.

Since reposting seems to be getting more and more helpful feedback, here's things again:

drivers/serial/8250.c +21 -0
Index: linux-2.6.13/drivers/serial/8250.c
===================================================================
@@ -2516,6 +2516,27 @@ void serial8250_unregister_port(int line
 }
 EXPORT_SYMBOL(serial8250_unregister_port);
 
+/**
+ *	serial8250_unregister_by_port - remove a 16x50 serial port
+ *	at runtime.
+ *	@port: A &struct uart_port that describes the port to remove.
+ *
+ *	Remove one serial port.  This may not be called from interrupt
+ *	context.  We hand the port back to the our control.
+ */
+void serial8250_unregister_by_port(struct uart_port *port)
+{
+	struct uart_8250_port *uart;
+
+	down(&serial_sem);
+	uart = serial8250_find_match_or_unused(port);
+	up(&serial_sem);
+
+	if (uart)
+		serial8250_unregister_port(uart->port.line);
+}
+EXPORT_SYMBOL(serial8250_unregister_by_port);
+
 static int __init serial8250_init(void)
 {
 	int ret, i;
drivers/serial/8250.h +1 -0
Index: linux-2.6.13/drivers/serial/8250.h
===================================================================
@@ -19,6 +19,7 @@
 
 int serial8250_register_port(struct uart_port *);
 void serial8250_unregister_port(int line);
+void serial8250_unregister_by_port(struct uart_port *port);
 void serial8250_suspend_port(int line);
 void serial8250_resume_port(int line);
 
drivers/serial/Kconfig +1 -1
Index: linux-2.6.13/drivers/serial/Kconfig
===================================================================
@@ -87,7 +87,7 @@ config SERIAL_8250_ACPI
 
 config SERIAL_8250_NR_UARTS
 	int "Maximum number of 8250/16550 serial ports"
-	depends on SERIAL_8250
+	depends on SERIAL_8250 || KGDB_8250
 	default "4"
 	help
 	  Set this to the number of serial ports you want the driver
drivers/serial/Makefile +1 -0
Index: linux-2.6.13/drivers/serial/Makefile
===================================================================
@@ -57,3 +57,4 @@ obj-$(CONFIG_SERIAL_JSM) += jsm/
 obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o
 obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
 obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
+obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o
lib/Kconfig.debug +59 -1

76 lines not on this page · raw message

drivers/serial/8250_kgdb.c new file +515 -0

515 lines not on this page · raw message

Quoted 4 lines
Signature · 3 lines
-- 
Tom Rini
http://gate.crashing.org/~trini/
Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/