aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-28 00:40:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-28 00:40:39 -0400
commitf379a071091b7ff0a7742ac5e02527897aeb8da4 (patch)
tree7bc3c1b980db45f1c8a36cf2faf5423aeed7e173 /drivers/tty
parentd952795d8193c5a7a8eabdc14fab48777fdcd7c8 (diff)
parentd1db0eea852497762cab43b905b879dfcd3b8987 (diff)
Merge 3.15-rc3 into tty-next
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_core.c2
-rw-r--r--drivers/tty/serial/8250/8250_dma.c9
-rw-r--r--drivers/tty/serial/samsung.c23
-rw-r--r--drivers/tty/serial/serial_core.c39
-rw-r--r--drivers/tty/tty_buffer.c16
5 files changed, 55 insertions, 34 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index ffee9825fbac..111ee8acb07e 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1520,7 +1520,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1520 status = serial8250_rx_chars(up, status); 1520 status = serial8250_rx_chars(up, status);
1521 } 1521 }
1522 serial8250_modem_status(up); 1522 serial8250_modem_status(up);
1523 if (status & UART_LSR_THRE) 1523 if (!up->dma && (status & UART_LSR_THRE))
1524 serial8250_tx_chars(up); 1524 serial8250_tx_chars(up);
1525 1525
1526 spin_unlock_irqrestore(&port->lock, flags); 1526 spin_unlock_irqrestore(&port->lock, flags);
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 7046769608d4..ab9096dc3849 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -20,12 +20,15 @@ static void __dma_tx_complete(void *param)
20 struct uart_8250_port *p = param; 20 struct uart_8250_port *p = param;
21 struct uart_8250_dma *dma = p->dma; 21 struct uart_8250_dma *dma = p->dma;
22 struct circ_buf *xmit = &p->port.state->xmit; 22 struct circ_buf *xmit = &p->port.state->xmit;
23 23 unsigned long flags;
24 dma->tx_running = 0;
25 24
26 dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr, 25 dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr,
27 UART_XMIT_SIZE, DMA_TO_DEVICE); 26 UART_XMIT_SIZE, DMA_TO_DEVICE);
28 27
28 spin_lock_irqsave(&p->port.lock, flags);
29
30 dma->tx_running = 0;
31
29 xmit->tail += dma->tx_size; 32 xmit->tail += dma->tx_size;
30 xmit->tail &= UART_XMIT_SIZE - 1; 33 xmit->tail &= UART_XMIT_SIZE - 1;
31 p->port.icount.tx += dma->tx_size; 34 p->port.icount.tx += dma->tx_size;
@@ -35,6 +38,8 @@ static void __dma_tx_complete(void *param)
35 38
36 if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) 39 if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port))
37 serial8250_tx_dma(p); 40 serial8250_tx_dma(p);
41
42 spin_unlock_irqrestore(&p->port.lock, flags);
38} 43}
39 44
40static void __dma_rx_complete(void *param) 45static void __dma_rx_complete(void *param)
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 23f459600738..1f5505e7f90d 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1446,8 +1446,8 @@ static int s3c24xx_serial_get_poll_char(struct uart_port *port)
1446static void s3c24xx_serial_put_poll_char(struct uart_port *port, 1446static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1447 unsigned char c) 1447 unsigned char c)
1448{ 1448{
1449 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1449 unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
1450 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); 1450 unsigned int ucon = rd_regl(port, S3C2410_UCON);
1451 1451
1452 /* not possible to xmit on unconfigured port */ 1452 /* not possible to xmit on unconfigured port */
1453 if (!s3c24xx_port_configured(ucon)) 1453 if (!s3c24xx_port_configured(ucon))
@@ -1455,7 +1455,7 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1455 1455
1456 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1456 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1457 cpu_relax(); 1457 cpu_relax();
1458 wr_regb(cons_uart, S3C2410_UTXH, c); 1458 wr_regb(port, S3C2410_UTXH, c);
1459} 1459}
1460 1460
1461#endif /* CONFIG_CONSOLE_POLL */ 1461#endif /* CONFIG_CONSOLE_POLL */
@@ -1463,22 +1463,23 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1463static void 1463static void
1464s3c24xx_serial_console_putchar(struct uart_port *port, int ch) 1464s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
1465{ 1465{
1466 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1466 unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
1467 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
1468
1469 /* not possible to xmit on unconfigured port */
1470 if (!s3c24xx_port_configured(ucon))
1471 return;
1472 1467
1473 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1468 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1474 barrier(); 1469 cpu_relax();
1475 wr_regb(cons_uart, S3C2410_UTXH, ch); 1470 wr_regb(port, S3C2410_UTXH, ch);
1476} 1471}
1477 1472
1478static void 1473static void
1479s3c24xx_serial_console_write(struct console *co, const char *s, 1474s3c24xx_serial_console_write(struct console *co, const char *s,
1480 unsigned int count) 1475 unsigned int count)
1481{ 1476{
1477 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
1478
1479 /* not possible to xmit on unconfigured port */
1480 if (!s3c24xx_port_configured(ucon))
1481 return;
1482
1482 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar); 1483 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar);
1483} 1484}
1484 1485
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 5dba9766f626..9a01ee4dda6d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -137,6 +137,11 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
137 return 1; 137 return 1;
138 138
139 /* 139 /*
140 * Make sure the device is in D0 state.
141 */
142 uart_change_pm(state, UART_PM_STATE_ON);
143
144 /*
140 * Initialise and allocate the transmit and temporary 145 * Initialise and allocate the transmit and temporary
141 * buffer. 146 * buffer.
142 */ 147 */
@@ -825,25 +830,29 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
825 * If we fail to request resources for the 830 * If we fail to request resources for the
826 * new port, try to restore the old settings. 831 * new port, try to restore the old settings.
827 */ 832 */
828 if (retval && old_type != PORT_UNKNOWN) { 833 if (retval) {
829 uport->iobase = old_iobase; 834 uport->iobase = old_iobase;
830 uport->type = old_type; 835 uport->type = old_type;
831 uport->hub6 = old_hub6; 836 uport->hub6 = old_hub6;
832 uport->iotype = old_iotype; 837 uport->iotype = old_iotype;
833 uport->regshift = old_shift; 838 uport->regshift = old_shift;
834 uport->mapbase = old_mapbase; 839 uport->mapbase = old_mapbase;
835 retval = uport->ops->request_port(uport);
836 /*
837 * If we failed to restore the old settings,
838 * we fail like this.
839 */
840 if (retval)
841 uport->type = PORT_UNKNOWN;
842 840
843 /* 841 if (old_type != PORT_UNKNOWN) {
844 * We failed anyway. 842 retval = uport->ops->request_port(uport);
845 */ 843 /*
846 retval = -EBUSY; 844 * If we failed to restore the old settings,
845 * we fail like this.
846 */
847 if (retval)
848 uport->type = PORT_UNKNOWN;
849
850 /*
851 * We failed anyway.
852 */
853 retval = -EBUSY;
854 }
855
847 /* Added to return the correct error -Ram Gupta */ 856 /* Added to return the correct error -Ram Gupta */
848 goto exit; 857 goto exit;
849 } 858 }
@@ -1571,12 +1580,6 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
1571 } 1580 }
1572 1581
1573 /* 1582 /*
1574 * Make sure the device is in D0 state.
1575 */
1576 if (port->count == 1)
1577 uart_change_pm(state, UART_PM_STATE_ON);
1578
1579 /*
1580 * Start up the serial port. 1583 * Start up the serial port.
1581 */ 1584 */
1582 retval = uart_startup(tty, state, 0); 1585 retval = uart_startup(tty, state, 0);
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 8ebd9f88a6f6..f1d30f6945af 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -255,11 +255,16 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
255 if (change || left < size) { 255 if (change || left < size) {
256 /* This is the slow path - looking for new buffers to use */ 256 /* This is the slow path - looking for new buffers to use */
257 if ((n = tty_buffer_alloc(port, size)) != NULL) { 257 if ((n = tty_buffer_alloc(port, size)) != NULL) {
258 unsigned long iflags;
259
258 n->flags = flags; 260 n->flags = flags;
259 buf->tail = n; 261 buf->tail = n;
262
263 spin_lock_irqsave(&buf->flush_lock, iflags);
260 b->commit = b->used; 264 b->commit = b->used;
261 smp_mb();
262 b->next = n; 265 b->next = n;
266 spin_unlock_irqrestore(&buf->flush_lock, iflags);
267
263 } else if (change) 268 } else if (change)
264 size = 0; 269 size = 0;
265 else 270 else
@@ -443,6 +448,7 @@ static void flush_to_ldisc(struct work_struct *work)
443 mutex_lock(&buf->lock); 448 mutex_lock(&buf->lock);
444 449
445 while (1) { 450 while (1) {
451 unsigned long flags;
446 struct tty_buffer *head = buf->head; 452 struct tty_buffer *head = buf->head;
447 int count; 453 int count;
448 454
@@ -450,14 +456,19 @@ static void flush_to_ldisc(struct work_struct *work)
450 if (atomic_read(&buf->priority)) 456 if (atomic_read(&buf->priority))
451 break; 457 break;
452 458
459 spin_lock_irqsave(&buf->flush_lock, flags);
453 count = head->commit - head->read; 460 count = head->commit - head->read;
454 if (!count) { 461 if (!count) {
455 if (head->next == NULL) 462 if (head->next == NULL) {
463 spin_unlock_irqrestore(&buf->flush_lock, flags);
456 break; 464 break;
465 }
457 buf->head = head->next; 466 buf->head = head->next;
467 spin_unlock_irqrestore(&buf->flush_lock, flags);
458 tty_buffer_free(port, head); 468 tty_buffer_free(port, head);
459 continue; 469 continue;
460 } 470 }
471 spin_unlock_irqrestore(&buf->flush_lock, flags);
461 472
462 count = receive_buf(tty, head, count); 473 count = receive_buf(tty, head, count);
463 if (!count) 474 if (!count)
@@ -512,6 +523,7 @@ void tty_buffer_init(struct tty_port *port)
512 struct tty_bufhead *buf = &port->buf; 523 struct tty_bufhead *buf = &port->buf;
513 524
514 mutex_init(&buf->lock); 525 mutex_init(&buf->lock);
526 spin_lock_init(&buf->flush_lock);
515 tty_buffer_reset(&buf->sentinel, 0); 527 tty_buffer_reset(&buf->sentinel, 0);
516 buf->head = &buf->sentinel; 528 buf->head = &buf->sentinel;
517 buf->tail = &buf->sentinel; 529 buf->tail = &buf->sentinel;