tty: Use non-atomic state to signal flip buffer flush pending
authorPeter Hurley <peter@hurleysoftware.com>
Sat, 15 Jun 2013 13:36:13 +0000 (09:36 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 23:47:09 +0000 (16:47 -0700)
Atomic bit ops are no longer required to indicate a flip buffer
flush is pending, as the flush_mutex is sufficient barrier.

Remove the unnecessary port .iflags field and localize flip buffer
state to struct tty_bufhead.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_buffer.c
include/linux/tty.h

index 39cae611fe59808e1f05594bf54495f5f65fbdfa..fb042b9a8d6881c06bd2812a4808dd6c73f43aac 100644 (file)
@@ -189,11 +189,11 @@ void tty_buffer_flush(struct tty_struct *tty)
        struct tty_port *port = tty->port;
        struct tty_bufhead *buf = &port->buf;
 
-       set_bit(TTYP_FLUSHPENDING, &port->iflags);
+       buf->flushpending = 1;
 
        mutex_lock(&buf->flush_mutex);
        __tty_buffer_flush(port);
-       clear_bit(TTYP_FLUSHPENDING, &port->iflags);
+       buf->flushpending = 0;
        mutex_unlock(&buf->flush_mutex);
 }
 
@@ -426,7 +426,7 @@ static void flush_to_ldisc(struct work_struct *work)
                int count;
 
                /* Ldisc or user is trying to flush the buffers. */
-               if (test_bit(TTYP_FLUSHPENDING, &port->iflags))
+               if (buf->flushpending)
                        break;
 
                count = head->commit - head->read;
@@ -505,6 +505,7 @@ void tty_buffer_init(struct tty_port *port)
        buf->tail = &buf->sentinel;
        init_llist_head(&buf->free);
        atomic_set(&buf->memory_used, 0);
+       buf->flushpending = 0;
        INIT_WORK(&buf->work, flush_to_ldisc);
 }
 
index b8e8adf95bf3aeb3977e9db5e8bb59e6abcdb0da..991575fe34519e77859f6f533538838a5c11cb4a 100644 (file)
@@ -68,6 +68,7 @@ struct tty_bufhead {
        struct tty_buffer *head;        /* Queue head */
        struct work_struct work;
        struct mutex flush_mutex;
+       unsigned int flushpending:1;
        struct tty_buffer sentinel;
        struct llist_head free;         /* Free queue head */
        atomic_t           memory_used; /* In-use buffers excluding free list */
@@ -212,8 +213,6 @@ struct tty_port {
        wait_queue_head_t       close_wait;     /* Close waiters */
        wait_queue_head_t       delta_msr_wait; /* Modem status change */
        unsigned long           flags;          /* TTY flags ASY_*/
-       unsigned long           iflags;         /* TTYP_ internal flags */
-#define TTYP_FLUSHPENDING              2  /* Queued buffer flush pending */
        unsigned char           console:1,      /* port is a console */
                                low_latency:1;  /* direct buffer flush */
        struct mutex            mutex;          /* Locking */