Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'tty-4.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial driver fixes from Greg KH:
"Here are a few TTY and Serial driver fixes for reported regressions
and crashes.

All of these have been in linux-next with no reported problems"

* tag 'tty-4.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
n_tty: Fix auditing support for cannonical mode
serial: 8250_omap: provide complete custom startup & shutdown callbacks
n_tty: Fix calculation of size in canon_copy_from_read_buf
serial: imx: Fix DMA handling for IDLE condition aborts
serial/amba-pl011: Unconditionally poll for FIFO space before each TX char

+105 -22
+16 -5
drivers/tty/n_tty.c
··· 162 162 return put_user(x, ptr); 163 163 } 164 164 165 + static inline int tty_copy_to_user(struct tty_struct *tty, 166 + void __user *to, 167 + const void *from, 168 + unsigned long n) 169 + { 170 + struct n_tty_data *ldata = tty->disc_data; 171 + 172 + tty_audit_add_data(tty, to, n, ldata->icanon); 173 + return copy_to_user(to, from, n); 174 + } 175 + 165 176 /** 166 177 * n_tty_kick_worker - start input worker (if required) 167 178 * @tty: terminal ··· 2081 2070 2082 2071 size = N_TTY_BUF_SIZE - tail; 2083 2072 n = eol - tail; 2084 - if (n > 4096) 2085 - n += 4096; 2073 + if (n > N_TTY_BUF_SIZE) 2074 + n += N_TTY_BUF_SIZE; 2086 2075 n += found; 2087 2076 c = n; 2088 2077 ··· 2095 2084 __func__, eol, found, n, c, size, more); 2096 2085 2097 2086 if (n > size) { 2098 - ret = copy_to_user(*b, read_buf_addr(ldata, tail), size); 2087 + ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), size); 2099 2088 if (ret) 2100 2089 return -EFAULT; 2101 - ret = copy_to_user(*b + size, ldata->read_buf, n - size); 2090 + ret = tty_copy_to_user(tty, *b + size, ldata->read_buf, n - size); 2102 2091 } else 2103 - ret = copy_to_user(*b, read_buf_addr(ldata, tail), n); 2092 + ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), n); 2104 2093 2105 2094 if (ret) 2106 2095 return -EFAULT;
+73 -9
drivers/tty/serial/8250/8250_omap.c
··· 562 562 return IRQ_NONE; 563 563 } 564 564 565 + #ifdef CONFIG_SERIAL_8250_DMA 566 + static int omap_8250_dma_handle_irq(struct uart_port *port); 567 + #endif 568 + 569 + static irqreturn_t omap8250_irq(int irq, void *dev_id) 570 + { 571 + struct uart_port *port = dev_id; 572 + struct uart_8250_port *up = up_to_u8250p(port); 573 + unsigned int iir; 574 + int ret; 575 + 576 + #ifdef CONFIG_SERIAL_8250_DMA 577 + if (up->dma) { 578 + ret = omap_8250_dma_handle_irq(port); 579 + return IRQ_RETVAL(ret); 580 + } 581 + #endif 582 + 583 + serial8250_rpm_get(up); 584 + iir = serial_port_in(port, UART_IIR); 585 + ret = serial8250_handle_irq(port, iir); 586 + serial8250_rpm_put(up); 587 + 588 + return IRQ_RETVAL(ret); 589 + } 590 + 565 591 static int omap_8250_startup(struct uart_port *port) 566 592 { 567 - struct uart_8250_port *up = 568 - container_of(port, struct uart_8250_port, port); 593 + struct uart_8250_port *up = up_to_u8250p(port); 569 594 struct omap8250_priv *priv = port->private_data; 570 - 571 595 int ret; 572 596 573 597 if (priv->wakeirq) { ··· 604 580 605 581 pm_runtime_get_sync(port->dev); 606 582 607 - ret = serial8250_do_startup(port); 608 - if (ret) 583 + up->mcr = 0; 584 + serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); 585 + 586 + serial_out(up, UART_LCR, UART_LCR_WLEN8); 587 + 588 + up->lsr_saved_flags = 0; 589 + up->msr_saved_flags = 0; 590 + 591 + if (up->dma) { 592 + ret = serial8250_request_dma(up); 593 + if (ret) { 594 + dev_warn_ratelimited(port->dev, 595 + "failed to request DMA\n"); 596 + up->dma = NULL; 597 + } 598 + } 599 + 600 + ret = request_irq(port->irq, omap8250_irq, IRQF_SHARED, 601 + dev_name(port->dev), port); 602 + if (ret < 0) 609 603 goto err; 604 + 605 + up->ier = UART_IER_RLSI | UART_IER_RDI; 606 + serial_out(up, UART_IER, up->ier); 610 607 611 608 #ifdef CONFIG_PM 612 609 up->capabilities |= UART_CAP_RPM; ··· 655 610 656 611 static void omap_8250_shutdown(struct uart_port *port) 657 612 { 658 - struct uart_8250_port *up = 659 - container_of(port, struct uart_8250_port, port); 613 + struct uart_8250_port *up = up_to_u8250p(port); 660 614 struct omap8250_priv *priv = port->private_data; 661 615 662 616 flush_work(&priv->qos_work); ··· 665 621 pm_runtime_get_sync(port->dev); 666 622 667 623 serial_out(up, UART_OMAP_WER, 0); 668 - serial8250_do_shutdown(port); 624 + 625 + up->ier = 0; 626 + serial_out(up, UART_IER, 0); 627 + 628 + if (up->dma) 629 + serial8250_release_dma(up); 630 + 631 + /* 632 + * Disable break condition and FIFOs 633 + */ 634 + if (up->lcr & UART_LCR_SBC) 635 + serial_out(up, UART_LCR, up->lcr & ~UART_LCR_SBC); 636 + serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); 669 637 670 638 pm_runtime_mark_last_busy(port->dev); 671 639 pm_runtime_put_autosuspend(port->dev); 672 640 641 + free_irq(port->irq, port); 673 642 if (priv->wakeirq) 674 643 free_irq(priv->wakeirq, port); 675 644 } ··· 1031 974 } 1032 975 #endif 1033 976 977 + static int omap8250_no_handle_irq(struct uart_port *port) 978 + { 979 + /* IRQ has not been requested but handling irq? */ 980 + WARN_ONCE(1, "Unexpected irq handling before port startup\n"); 981 + return 0; 982 + } 983 + 1034 984 static int omap8250_probe(struct platform_device *pdev) 1035 985 { 1036 986 struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 1139 1075 pm_runtime_get_sync(&pdev->dev); 1140 1076 1141 1077 omap_serial_fill_features_erratas(&up, priv); 1078 + up.port.handle_irq = omap8250_no_handle_irq; 1142 1079 #ifdef CONFIG_SERIAL_8250_DMA 1143 1080 if (pdev->dev.of_node) { 1144 1081 /* ··· 1153 1088 ret = of_property_count_strings(pdev->dev.of_node, "dma-names"); 1154 1089 if (ret == 2) { 1155 1090 up.dma = &priv->omap8250_dma; 1156 - up.port.handle_irq = omap_8250_dma_handle_irq; 1157 1091 priv->omap8250_dma.fn = the_no_dma_filter_fn; 1158 1092 priv->omap8250_dma.tx_dma = omap_8250_tx_dma; 1159 1093 priv->omap8250_dma.rx_dma = omap_8250_rx_dma;
+8 -8
drivers/tty/serial/amba-pl011.c
··· 1249 1249 1250 1250 /* 1251 1251 * Transmit a character 1252 - * There must be at least one free entry in the TX FIFO to accept the char. 1253 1252 * 1254 - * Returns true if the FIFO might have space in it afterwards; 1255 - * returns false if the FIFO definitely became full. 1253 + * Returns true if the character was successfully queued to the FIFO. 1254 + * Returns false otherwise. 1256 1255 */ 1257 1256 static bool pl011_tx_char(struct uart_amba_port *uap, unsigned char c) 1258 1257 { 1258 + if (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF) 1259 + return false; /* unable to transmit character */ 1260 + 1259 1261 writew(c, uap->port.membase + UART01x_DR); 1260 1262 uap->port.icount.tx++; 1261 1263 1262 - if (likely(uap->tx_irq_seen > 1)) 1263 - return true; 1264 - 1265 - return !(readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF); 1264 + return true; 1266 1265 } 1267 1266 1268 1267 static bool pl011_tx_chars(struct uart_amba_port *uap) ··· 1295 1296 return false; 1296 1297 1297 1298 if (uap->port.x_char) { 1298 - pl011_tx_char(uap, uap->port.x_char); 1299 + if (!pl011_tx_char(uap, uap->port.x_char)) 1300 + goto done; 1299 1301 uap->port.x_char = 0; 1300 1302 --count; 1301 1303 }
+8
drivers/tty/serial/imx.c
··· 911 911 912 912 status = dmaengine_tx_status(chan, (dma_cookie_t)0, &state); 913 913 count = RX_BUF_SIZE - state.residue; 914 + 915 + if (readl(sport->port.membase + USR2) & USR2_IDLE) { 916 + /* In condition [3] the SDMA counted up too early */ 917 + count--; 918 + 919 + writel(USR2_IDLE, sport->port.membase + USR2); 920 + } 921 + 914 922 dev_dbg(sport->port.dev, "We get %d bytes.\n", count); 915 923 916 924 if (count) {