Use kthread_worker instead of workqueues. For now there is only a single workqueue, but the intention is to bring back the "low_latency" tty option, along with a second high-priority kthread worker. Signed-off-by: Steven Walter <stevenrwalter@xxxxxxxxx> --- drivers/tty/tty_buffer.c | 17 +++++++++++------ drivers/tty/tty_io.c | 3 ++- drivers/tty/tty_port.c | 2 +- include/linux/tty.h | 5 +++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index ed7b5c8..4564202 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -3,6 +3,7 @@ */ #include <linux/types.h> +#include <linux/kthread.h> #include <linux/errno.h> #include <linux/tty.h> #include <linux/tty_driver.h> @@ -431,7 +432,7 @@ receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) * 'consumer' */ -static void flush_to_ldisc(struct work_struct *work) +static void flush_to_ldisc(struct kthread_work *work) { struct tty_port *port = container_of(work, struct tty_port, buf.work); struct tty_bufhead *buf = &port->buf; @@ -520,17 +521,21 @@ EXPORT_SYMBOL(tty_flip_buffer_push); * Must be called before the other tty buffer functions are used. */ +static DEFINE_KTHREAD_WORKER(tty_buffer_worker); void tty_buffer_queue_work(struct tty_port *port) { - struct tty_bufhead *buf = &port->buf; - schedule_work(&buf->work); + queue_kthread_work(&tty_buffer_worker, &port->buf.work); } void tty_buffer_flush_work(struct tty_port *port) { - struct tty_bufhead *buf = &port->buf; - flush_work(&buf->work); + flush_kthread_work(&port->buf.work); +} + +void tty_buffer_init_kthread() +{ + kthread_run(kthread_worker_fn, &tty_buffer_worker, "tty"); } void tty_buffer_init(struct tty_port *port) @@ -544,7 +549,7 @@ void tty_buffer_init(struct tty_port *port) init_llist_head(&buf->free); atomic_set(&buf->mem_used, 0); atomic_set(&buf->priority, 0); - INIT_WORK(&buf->work, flush_to_ldisc); + init_kthread_work(&buf->work, flush_to_ldisc); buf->mem_limit = TTYB_DEFAULT_MEM_LIMIT; } diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 0508a1d..abcd9a5 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1633,7 +1633,7 @@ static void release_tty(struct tty_struct *tty, int idx) tty->port->itty = NULL; if (tty->link) tty->link->port->itty = NULL; - cancel_work_sync(&tty->port->buf.work); + tty_buffer_flush_work(tty->port); if (tty->link) tty_kref_put(tty->link); @@ -3602,6 +3602,7 @@ void console_sysfs_notify(void) */ int __init tty_init(void) { + tty_buffer_init_kthread(); cdev_init(&tty_cdev, &tty_fops); if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 1b93357..d041323 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -131,7 +131,7 @@ EXPORT_SYMBOL(tty_port_free_xmit_buf); */ void tty_port_destroy(struct tty_port *port) { - cancel_work_sync(&port->buf.work); + tty_buffer_flush_work(port); tty_buffer_free_all(port); } EXPORT_SYMBOL(tty_port_destroy); diff --git a/include/linux/tty.h b/include/linux/tty.h index 7bad787..9c19141 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -2,9 +2,9 @@ #define _LINUX_TTY_H #include <linux/fs.h> +#include <linux/kthread.h> #include <linux/major.h> #include <linux/termios.h> -#include <linux/workqueue.h> #include <linux/tty_driver.h> #include <linux/tty_ldisc.h> #include <linux/mutex.h> @@ -59,7 +59,7 @@ static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs) struct tty_bufhead { struct tty_buffer *head; /* Queue head */ - struct work_struct work; + struct kthread_work work; struct mutex lock; atomic_t priority; struct tty_buffer sentinel; @@ -448,6 +448,7 @@ extern void tty_buffer_flush(struct tty_struct *tty); extern void tty_buffer_init(struct tty_port *port); extern void tty_buffer_queue_work(struct tty_port *port); extern void tty_buffer_flush_work(struct tty_port *port); +extern void tty_buffer_init_kthread(void); extern speed_t tty_termios_baud_rate(struct ktermios *termios); extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); extern void tty_termios_encode_baud_rate(struct ktermios *termios, -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html