aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-11-30 08:16:41 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 18:18:06 -0500
commit44e4909e453eaa09c7de409fc9ee4ebefd986c1c (patch)
tree5bad1ed70f24c7cedd61a7664afe3706abab4e2f
parent1f100b323d19469b06a63ccd6130ed71760145cc (diff)
tty: tty_port: Change the buffer allocator locking
We want to be able to do this without regard for the activate/own open method being used which causes a problem using port->mutex. Add another mutex for now. Once everything uses port_open to do buffer allocs we can kill it back off Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/char/tty_port.c9
-rw-r--r--include/linux/tty.h1
2 files changed, 6 insertions, 4 deletions
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index dd471d63fae2..3ef644a2e517 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -25,6 +25,7 @@ void tty_port_init(struct tty_port *port)
25 init_waitqueue_head(&port->close_wait); 25 init_waitqueue_head(&port->close_wait);
26 init_waitqueue_head(&port->delta_msr_wait); 26 init_waitqueue_head(&port->delta_msr_wait);
27 mutex_init(&port->mutex); 27 mutex_init(&port->mutex);
28 mutex_init(&port->buf_mutex);
28 spin_lock_init(&port->lock); 29 spin_lock_init(&port->lock);
29 port->close_delay = (50 * HZ) / 100; 30 port->close_delay = (50 * HZ) / 100;
30 port->closing_wait = (3000 * HZ) / 100; 31 port->closing_wait = (3000 * HZ) / 100;
@@ -34,10 +35,10 @@ EXPORT_SYMBOL(tty_port_init);
34int tty_port_alloc_xmit_buf(struct tty_port *port) 35int tty_port_alloc_xmit_buf(struct tty_port *port)
35{ 36{
36 /* We may sleep in get_zeroed_page() */ 37 /* We may sleep in get_zeroed_page() */
37 mutex_lock(&port->mutex); 38 mutex_lock(&port->buf_mutex);
38 if (port->xmit_buf == NULL) 39 if (port->xmit_buf == NULL)
39 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); 40 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
40 mutex_unlock(&port->mutex); 41 mutex_unlock(&port->buf_mutex);
41 if (port->xmit_buf == NULL) 42 if (port->xmit_buf == NULL)
42 return -ENOMEM; 43 return -ENOMEM;
43 return 0; 44 return 0;
@@ -46,12 +47,12 @@ EXPORT_SYMBOL(tty_port_alloc_xmit_buf);
46 47
47void tty_port_free_xmit_buf(struct tty_port *port) 48void tty_port_free_xmit_buf(struct tty_port *port)
48{ 49{
49 mutex_lock(&port->mutex); 50 mutex_lock(&port->buf_mutex);
50 if (port->xmit_buf != NULL) { 51 if (port->xmit_buf != NULL) {
51 free_page((unsigned long)port->xmit_buf); 52 free_page((unsigned long)port->xmit_buf);
52 port->xmit_buf = NULL; 53 port->xmit_buf = NULL;
53 } 54 }
54 mutex_unlock(&port->mutex); 55 mutex_unlock(&port->buf_mutex);
55} 56}
56EXPORT_SYMBOL(tty_port_free_xmit_buf); 57EXPORT_SYMBOL(tty_port_free_xmit_buf);
57 58
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 6352ac257fcb..e9269ca1542a 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -212,6 +212,7 @@ struct tty_port {
212 wait_queue_head_t delta_msr_wait; /* Modem status change */ 212 wait_queue_head_t delta_msr_wait; /* Modem status change */
213 unsigned long flags; /* TTY flags ASY_*/ 213 unsigned long flags; /* TTY flags ASY_*/
214 struct mutex mutex; /* Locking */ 214 struct mutex mutex; /* Locking */
215 struct mutex buf_mutex; /* Buffer alloc lock */
215 unsigned char *xmit_buf; /* Optional buffer */ 216 unsigned char *xmit_buf; /* Optional buffer */
216 unsigned int close_delay; /* Close port delay */ 217 unsigned int close_delay; /* Close port delay */
217 unsigned int closing_wait; /* Delay for output */ 218 unsigned int closing_wait; /* Delay for output */