Skip to contentSkip to conversation

consoles: polling support, kgdboc

PATCH In review Ingo Molnar 2 participants 3 messages Feb 10, 2008

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

PATCH 4/6 consoles: polling support, kgdboc

From: Jan Kiszka <[email protected]>

polled console handling support, to access a console in an irq-less way while in debug or irq context.

absolutely zero impact as long as CONFIG_CONSOLE_POLL is disabled. (which is the default)

kgdb over consoles support from:

Jason Wessel <[email protected]>

[ [email protected]: redesign, splitups, cleanups. ]

---
 drivers/char/tty_io.c        |   47 ++++++++++++
 drivers/serial/8250.c        |   62 ++++++++++++++++
 drivers/serial/Kconfig       |    3 
 drivers/serial/Makefile      |    1 
 drivers/serial/kgdboc.c      |  164 +++++++++++++++++++++++++++++++++++++++++++
 drivers/serial/serial_core.c |   67 +++++++++++++++++
 include/linux/serial_core.h  |    4 +
 include/linux/tty_driver.h   |   12 +++
 8 files changed, 359 insertions(+), 1 deletion(-)
drivers/char/tty_io.c +47 -0
Index: linux-kgdb.q/drivers/char/tty_io.c
===================================================================
@@ -1155,6 +1155,48 @@ static struct tty_driver *get_tty_driver
 	return NULL;
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+/**
+ *	tty_find_polling_driver	-	find device of a polled tty
+ *	@name: name string to match
+ *	@line: pointer to resulting tty line nr
+ *
+ *	This routine returns a tty driver structure, given a name
+ *	and the condition that the tty driver is capable of polled
+ *	operation.
+ */
+struct tty_driver *tty_find_polling_driver(char *name, int *line)
+{
+	struct tty_driver *p, *res = NULL;
+	int tty_line = 0;
+	char *str;
+
+	mutex_lock(&tty_mutex);
+	/* Search through the tty devices to look for a match */
+	list_for_each_entry(p, &tty_drivers, tty_drivers) {
+		str = name + strlen(p->name);
+		tty_line = simple_strtoul(str, &str, 10);
+		if (*str == ',')
+			str++;
+		if (*str == '\0')
+			str = 0;
+
+		if (tty_line >= 0 && tty_line <= p->num && p->poll_init &&
+				!p->poll_init(p, tty_line, str)) {
+
+			res = p;
+			*line = tty_line;
+			break;
+		}
+	}
+	mutex_unlock(&tty_mutex);
+
+	return res;
+}
+EXPORT_SYMBOL_GPL(tty_find_polling_driver);
+#endif
+
 /**
  *	tty_check_change	-	check for POSIX terminal changes
  *	@tty: tty to check
@@ -3850,6 +3892,11 @@ void tty_set_operations(struct tty_drive
 	driver->write_proc = op->write_proc;
 	driver->tiocmget = op->tiocmget;
 	driver->tiocmset = op->tiocmset;
+#ifdef CONFIG_CONSOLE_POLL
+	driver->poll_init = op->poll_init;
+	driver->poll_get_char = op->poll_get_char;
+	driver->poll_put_char = op->poll_put_char;
+#endif
 }
 
 
drivers/serial/8250.c +62 -0

74 lines not on this page · raw message

drivers/serial/Kconfig +3 -0
Index: linux-kgdb.q/drivers/serial/Kconfig
===================================================================
@@ -961,6 +961,9 @@ config SERIAL_CORE
 config SERIAL_CORE_CONSOLE
 	bool
 
+config CONSOLE_POLL
+	bool
+
 config SERIAL_68328
 	bool "68328 serial support"
 	depends on M68328 || M68EZ328 || M68VZ328
drivers/serial/Makefile +1 -0
Index: linux-kgdb.q/drivers/serial/Makefile
===================================================================
@@ -66,4 +66,5 @@ obj-$(CONFIG_SERIAL_UARTLITE) += uartlit
 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
+obj-$(CONFIG_KGDBOC) += kgdboc.o
 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
drivers/serial/kgdboc.c new file +164 -0

164 lines not on this page · raw message

drivers/serial/serial_core.c +66 -1

85 lines not on this page · raw message

include/linux/serial_core.h +4 -0
Index: linux-kgdb.q/include/linux/serial_core.h
===================================================================
@@ -211,6 +211,10 @@ struct uart_ops {
 	void		(*config_port)(struct uart_port *, int);
 	int		(*verify_port)(struct uart_port *, struct serial_struct *);
 	int		(*ioctl)(struct uart_port *, unsigned int, unsigned long);
+#ifdef CONFIG_CONSOLE_POLL
+	void	(*poll_put_char)(struct uart_port *, unsigned char);
+	int		(*poll_get_char)(struct uart_port *);
+#endif
 };
 
 #define UART_CONFIG_TYPE	(1 << 0)
include/linux/tty_driver.h +12 -0
Index: linux-kgdb.q/include/linux/tty_driver.h
===================================================================
@@ -125,6 +125,7 @@
 #include <linux/cdev.h>
 
 struct tty_struct;
+struct tty_driver;
 
 struct tty_operations {
 	int  (*open)(struct tty_struct * tty, struct file * filp);
@@ -157,6 +158,11 @@ struct tty_operations {
 	int (*tiocmget)(struct tty_struct *tty, struct file *file);
 	int (*tiocmset)(struct tty_struct *tty, struct file *file,
 			unsigned int set, unsigned int clear);
+#ifdef CONFIG_CONSOLE_POLL
+	int (*poll_init)(struct tty_driver *driver, int line, char *options);
+	int (*poll_get_char)(struct tty_driver *driver, int line);
+	void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
+#endif
 };
 
 struct tty_driver {
@@ -220,6 +226,11 @@ struct tty_driver {
 	int (*tiocmget)(struct tty_struct *tty, struct file *file);
 	int (*tiocmset)(struct tty_struct *tty, struct file *file,
 			unsigned int set, unsigned int clear);
+#ifdef CONFIG_CONSOLE_POLL
+	int (*poll_init)(struct tty_driver *driver, int line, char *options);
+	int (*poll_get_char)(struct tty_driver *driver, int line);
+	void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
+#endif
 
 	struct list_head tty_drivers;
 };
@@ -230,6 +241,7 @@ struct tty_driver *alloc_tty_driver(int 
 void put_tty_driver(struct tty_driver *driver);
 void tty_set_operations(struct tty_driver *driver,
 			const struct tty_operations *op);
+extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
 
 /* tty driver magic number */
 #define TTY_DRIVER_MAGIC		0x5402
#1 lore raw
Quoted 2 lines · Ingo Molnar

From: Jan Kiszka <[email protected]>

Well, actually not from me but from Jason. I think I just touched it last for the configuration cleanups.

However, this fragment is additionally required to avoid crashes when doing runtime reconfigurations. To avoid the ifdef'ery of the original version, I just killed the __init - tiny-linux people may cry now...

---
 serial_core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/serial/serial_core.c +2 -2
index 8e6dce3..a72116a 100644
@@ -1827,7 +1827,7 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co)
  *	options.  The format of the string is <baud><parity><bits><flow>,
  *	eg: 115200n8r
  */
-void __init
+void
 uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow)
 {
 	char *s = options;
@@ -1872,7 +1872,7 @@ static const struct baud_rates baud_rates[] = {
  *	@bits: number of data bits
  *	@flow: flow control character - 'r' (rts)
  */
-int __init
+int
 uart_set_options(struct uart_port *port, struct console *co,
 		 int baud, int parity, int bits, int flow)
 {
#2 lore raw
Quoted 6 lines · Jan Kiszka
Quoted 2 lines · Ingo Molnar

From: Jan Kiszka <[email protected]>

Well, actually not from me but from Jason. I think I just touched it last for the configuration cleanups.

i restructured it in some major ways but wanted to keep the original author - thanks for pointing out that it was Jason not you - i've fixed that.

Quoted 3 lines

However, this fragment is additionally required to avoid crashes when doing runtime reconfigurations. To avoid the ifdef'ery of the original version, I just killed the __init - tiny-linux people may cry now...

i wondered about that - indeed - applied.

Ingo