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-5.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial driver fixes from Greg KH:
"Here are a number of small tty and serial driver fixes for 5.6-rc3
that resolve a bunch of reported issues.

They are:
- vt selection and ioctl fixes
- serdev bugfix
- atmel serial driver fixes
- qcom serial driver fixes
- other minor serial driver fixes

All of these have been in linux-next for a while with no reported
issues"

* tag 'tty-5.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
vt: selection, close sel_buffer race
vt: selection, handle pending signals in paste_selection
serial: cpm_uart: call cpm_muram_init before registering console
tty: serial: qcom_geni_serial: Fix RX cancel command failure
serial: 8250: Check UPF_IRQ_SHARED in advance
tty: serial: imx: setup the correct sg entry for tx dma
vt: vt_ioctl: fix race in VT_RESIZEX
vt: fix scrollback flushing on background consoles
tty: serial: tegra: Handle RX transfer in PIO mode if DMA wasn't started
tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode
serdev: ttyport: restore client ops on deregistration
serial: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE

+104 -51
+2 -4
drivers/tty/serdev/serdev-ttyport.c
··· 265 265 struct device *parent, 266 266 struct tty_driver *drv, int idx) 267 267 { 268 - const struct tty_port_client_operations *old_ops; 269 268 struct serdev_controller *ctrl; 270 269 struct serport *serport; 271 270 int ret; ··· 283 284 284 285 ctrl->ops = &ctrl_ops; 285 286 286 - old_ops = port->client_ops; 287 287 port->client_ops = &client_ops; 288 288 port->client_data = ctrl; 289 289 ··· 295 297 296 298 err_reset_data: 297 299 port->client_data = NULL; 298 - port->client_ops = old_ops; 300 + port->client_ops = &tty_port_default_client_ops; 299 301 serdev_controller_put(ctrl); 300 302 301 303 return ERR_PTR(ret); ··· 310 312 return -ENODEV; 311 313 312 314 serdev_controller_remove(ctrl); 313 - port->client_ops = NULL; 314 315 port->client_data = NULL; 316 + port->client_ops = &tty_port_default_client_ops; 315 317 serdev_controller_put(ctrl); 316 318 317 319 return 0;
-1
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 446 446 port.port.line = rc; 447 447 448 448 port.port.irq = irq_of_parse_and_map(np, 0); 449 - port.port.irqflags = IRQF_SHARED; 450 449 port.port.handle_irq = aspeed_vuart_handle_irq; 451 450 port.port.iotype = UPIO_MEM; 452 451 port.port.type = PORT_16550A;
+2 -3
drivers/tty/serial/8250/8250_core.c
··· 174 174 struct hlist_head *h; 175 175 struct hlist_node *n; 176 176 struct irq_info *i; 177 - int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0; 177 + int ret; 178 178 179 179 mutex_lock(&hash_mutex); 180 180 ··· 209 209 INIT_LIST_HEAD(&up->list); 210 210 i->head = &up->list; 211 211 spin_unlock_irq(&i->lock); 212 - irq_flags |= up->port.irqflags; 213 212 ret = request_irq(up->port.irq, serial8250_interrupt, 214 - irq_flags, up->port.name, i); 213 + up->port.irqflags, up->port.name, i); 215 214 if (ret < 0) 216 215 serial_do_unlink(i, up); 217 216 }
-1
drivers/tty/serial/8250/8250_of.c
··· 202 202 203 203 port->type = type; 204 204 port->uartclk = clk; 205 - port->irqflags |= IRQF_SHARED; 206 205 207 206 if (of_property_read_bool(np, "no-loopback-test")) 208 207 port->flags |= UPF_SKIP_TEST;
+4
drivers/tty/serial/8250/8250_port.c
··· 2177 2177 } 2178 2178 } 2179 2179 2180 + /* Check if we need to have shared IRQs */ 2181 + if (port->irq && (up->port.flags & UPF_SHARE_IRQ)) 2182 + up->port.irqflags |= IRQF_SHARED; 2183 + 2180 2184 if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) { 2181 2185 unsigned char iir1; 2182 2186 /*
+8
drivers/tty/serial/ar933x_uart.c
··· 286 286 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, 287 287 AR933X_UART_CS_HOST_INT_EN); 288 288 289 + /* enable RX and TX ready overide */ 290 + ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, 291 + AR933X_UART_CS_TX_READY_ORIDE | AR933X_UART_CS_RX_READY_ORIDE); 292 + 289 293 /* reenable the UART */ 290 294 ar933x_uart_rmw(up, AR933X_UART_CS_REG, 291 295 AR933X_UART_CS_IF_MODE_M << AR933X_UART_CS_IF_MODE_S, ··· 421 417 /* Enable HOST interrupts */ 422 418 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, 423 419 AR933X_UART_CS_HOST_INT_EN); 420 + 421 + /* enable RX and TX ready overide */ 422 + ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, 423 + AR933X_UART_CS_TX_READY_ORIDE | AR933X_UART_CS_RX_READY_ORIDE); 424 424 425 425 /* Enable RX interrupts */ 426 426 up->ier = AR933X_UART_INT_RX_VALID;
+2 -1
drivers/tty/serial/atmel_serial.c
··· 570 570 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); 571 571 572 572 if (atmel_uart_is_half_duplex(port)) 573 - atmel_start_rx(port); 573 + if (!atomic_read(&atmel_port->tasklet_shutdown)) 574 + atmel_start_rx(port); 574 575 575 576 } 576 577
+1
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 1373 1373 1374 1374 static int __init cpm_uart_console_init(void) 1375 1375 { 1376 + cpm_muram_init(); 1376 1377 register_console(&cpm_scc_uart_console); 1377 1378 return 0; 1378 1379 }
+1 -1
drivers/tty/serial/imx.c
··· 599 599 600 600 sport->tx_bytes = uart_circ_chars_pending(xmit); 601 601 602 - if (xmit->tail < xmit->head) { 602 + if (xmit->tail < xmit->head || xmit->head == 0) { 603 603 sport->dma_tx_nents = 1; 604 604 sg_init_one(sgl, xmit->buf + xmit->tail, sport->tx_bytes); 605 605 } else {
+14 -4
drivers/tty/serial/qcom_geni_serial.c
··· 129 129 static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop); 130 130 static unsigned int qcom_geni_serial_tx_empty(struct uart_port *port); 131 131 static void qcom_geni_serial_stop_rx(struct uart_port *uport); 132 + static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop); 132 133 133 134 static const unsigned long root_freq[] = {7372800, 14745600, 19200000, 29491200, 134 135 32000000, 48000000, 64000000, 80000000, ··· 600 599 u32 irq_en; 601 600 u32 status; 602 601 struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 603 - u32 irq_clear = S_CMD_DONE_EN; 602 + u32 s_irq_status; 604 603 605 604 irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); 606 605 irq_en &= ~(S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN); ··· 616 615 return; 617 616 618 617 geni_se_cancel_s_cmd(&port->se); 619 - qcom_geni_serial_poll_bit(uport, SE_GENI_S_CMD_CTRL_REG, 620 - S_GENI_CMD_CANCEL, false); 618 + qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, 619 + S_CMD_CANCEL_EN, true); 620 + /* 621 + * If timeout occurs secondary engine remains active 622 + * and Abort sequence is executed. 623 + */ 624 + s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); 625 + /* Flush the Rx buffer */ 626 + if (s_irq_status & S_RX_FIFO_LAST_EN) 627 + qcom_geni_serial_handle_rx(uport, true); 628 + writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR); 629 + 621 630 status = readl(uport->membase + SE_GENI_STATUS); 622 - writel(irq_clear, uport->membase + SE_GENI_S_IRQ_CLEAR); 623 631 if (status & S_GENI_CMD_ACTIVE) 624 632 qcom_geni_serial_abort_rx(uport); 625 633 }
+16 -19
drivers/tty/serial/serial-tegra.c
··· 692 692 count, DMA_TO_DEVICE); 693 693 } 694 694 695 + static void do_handle_rx_pio(struct tegra_uart_port *tup) 696 + { 697 + struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); 698 + struct tty_port *port = &tup->uport.state->port; 699 + 700 + tegra_uart_handle_rx_pio(tup, port); 701 + if (tty) { 702 + tty_flip_buffer_push(port); 703 + tty_kref_put(tty); 704 + } 705 + } 706 + 695 707 static void tegra_uart_rx_buffer_push(struct tegra_uart_port *tup, 696 708 unsigned int residue) 697 709 { 698 710 struct tty_port *port = &tup->uport.state->port; 699 - struct tty_struct *tty = tty_port_tty_get(port); 700 711 unsigned int count; 701 712 702 713 async_tx_ack(tup->rx_dma_desc); ··· 716 705 /* If we are here, DMA is stopped */ 717 706 tegra_uart_copy_rx_to_tty(tup, port, count); 718 707 719 - tegra_uart_handle_rx_pio(tup, port); 720 - if (tty) { 721 - tty_flip_buffer_push(port); 722 - tty_kref_put(tty); 723 - } 708 + do_handle_rx_pio(tup); 724 709 } 725 710 726 711 static void tegra_uart_rx_dma_complete(void *args) ··· 756 749 { 757 750 struct dma_tx_state state; 758 751 759 - if (!tup->rx_dma_active) 752 + if (!tup->rx_dma_active) { 753 + do_handle_rx_pio(tup); 760 754 return; 755 + } 761 756 762 757 dmaengine_terminate_all(tup->rx_dma_chan); 763 758 dmaengine_tx_status(tup->rx_dma_chan, tup->rx_cookie, &state); ··· 823 814 /* Will start/stop_tx accordingly */ 824 815 if (msr & UART_MSR_DCTS) 825 816 uart_handle_cts_change(&tup->uport, msr & UART_MSR_CTS); 826 - } 827 - 828 - static void do_handle_rx_pio(struct tegra_uart_port *tup) 829 - { 830 - struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); 831 - struct tty_port *port = &tup->uport.state->port; 832 - 833 - tegra_uart_handle_rx_pio(tup, port); 834 - if (tty) { 835 - tty_flip_buffer_push(port); 836 - tty_kref_put(tty); 837 - } 838 817 } 839 818 840 819 static irqreturn_t tegra_uart_isr(int irq, void *data)
+3 -2
drivers/tty/tty_port.c
··· 52 52 } 53 53 } 54 54 55 - static const struct tty_port_client_operations default_client_ops = { 55 + const struct tty_port_client_operations tty_port_default_client_ops = { 56 56 .receive_buf = tty_port_default_receive_buf, 57 57 .write_wakeup = tty_port_default_wakeup, 58 58 }; 59 + EXPORT_SYMBOL_GPL(tty_port_default_client_ops); 59 60 60 61 void tty_port_init(struct tty_port *port) 61 62 { ··· 69 68 spin_lock_init(&port->lock); 70 69 port->close_delay = (50 * HZ) / 100; 71 70 port->closing_wait = (3000 * HZ) / 100; 72 - port->client_ops = &default_client_ops; 71 + port->client_ops = &tty_port_default_client_ops; 73 72 kref_init(&port->kref); 74 73 } 75 74 EXPORT_SYMBOL(tty_port_init);
+25 -7
drivers/tty/vt/selection.c
··· 16 16 #include <linux/tty.h> 17 17 #include <linux/sched.h> 18 18 #include <linux/mm.h> 19 + #include <linux/mutex.h> 19 20 #include <linux/slab.h> 20 21 #include <linux/types.h> 21 22 ··· 29 28 #include <linux/tiocl.h> 30 29 #include <linux/console.h> 31 30 #include <linux/tty_flip.h> 31 + 32 + #include <linux/sched/signal.h> 32 33 33 34 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */ 34 35 #define isspace(c) ((c) == ' ') ··· 46 43 static int sel_end; 47 44 static int sel_buffer_lth; 48 45 static char *sel_buffer; 46 + static DEFINE_MUTEX(sel_lock); 49 47 50 48 /* clear_selection, highlight and highlight_pointer can be called 51 49 from interrupt (via scrollback/front) */ ··· 188 184 char *bp, *obp; 189 185 int i, ps, pe, multiplier; 190 186 u32 c; 191 - int mode; 187 + int mode, ret = 0; 192 188 193 189 poke_blanked_console(); 194 190 ··· 214 210 if (ps > pe) /* make sel_start <= sel_end */ 215 211 swap(ps, pe); 216 212 213 + mutex_lock(&sel_lock); 217 214 if (sel_cons != vc_cons[fg_console].d) { 218 215 clear_selection(); 219 216 sel_cons = vc_cons[fg_console].d; ··· 260 255 break; 261 256 case TIOCL_SELPOINTER: 262 257 highlight_pointer(pe); 263 - return 0; 258 + goto unlock; 264 259 default: 265 - return -EINVAL; 260 + ret = -EINVAL; 261 + goto unlock; 266 262 } 267 263 268 264 /* remove the pointer */ ··· 285 279 else if (new_sel_start == sel_start) 286 280 { 287 281 if (new_sel_end == sel_end) /* no action required */ 288 - return 0; 282 + goto unlock; 289 283 else if (new_sel_end > sel_end) /* extend to right */ 290 284 highlight(sel_end + 2, new_sel_end); 291 285 else /* contract from right */ ··· 313 307 if (!bp) { 314 308 printk(KERN_WARNING "selection: kmalloc() failed\n"); 315 309 clear_selection(); 316 - return -ENOMEM; 310 + ret = -ENOMEM; 311 + goto unlock; 317 312 } 318 313 kfree(sel_buffer); 319 314 sel_buffer = bp; ··· 339 332 } 340 333 } 341 334 sel_buffer_lth = bp - sel_buffer; 342 - return 0; 335 + unlock: 336 + mutex_unlock(&sel_lock); 337 + return ret; 343 338 } 344 339 EXPORT_SYMBOL_GPL(set_selection_kernel); 345 340 ··· 359 350 unsigned int count; 360 351 struct tty_ldisc *ld; 361 352 DECLARE_WAITQUEUE(wait, current); 353 + int ret = 0; 362 354 363 355 console_lock(); 364 356 poke_blanked_console(); ··· 371 361 tty_buffer_lock_exclusive(&vc->port); 372 362 373 363 add_wait_queue(&vc->paste_wait, &wait); 364 + mutex_lock(&sel_lock); 374 365 while (sel_buffer && sel_buffer_lth > pasted) { 375 366 set_current_state(TASK_INTERRUPTIBLE); 367 + if (signal_pending(current)) { 368 + ret = -EINTR; 369 + break; 370 + } 376 371 if (tty_throttled(tty)) { 372 + mutex_unlock(&sel_lock); 377 373 schedule(); 374 + mutex_lock(&sel_lock); 378 375 continue; 379 376 } 380 377 __set_current_state(TASK_RUNNING); ··· 390 373 count); 391 374 pasted += count; 392 375 } 376 + mutex_unlock(&sel_lock); 393 377 remove_wait_queue(&vc->paste_wait, &wait); 394 378 __set_current_state(TASK_RUNNING); 395 379 396 380 tty_buffer_unlock_exclusive(&vc->port); 397 381 tty_ldisc_deref(ld); 398 - return 0; 382 + return ret; 399 383 } 400 384 EXPORT_SYMBOL_GPL(paste_selection);
+13 -2
drivers/tty/vt/vt.c
··· 936 936 WARN_CONSOLE_UNLOCKED(); 937 937 938 938 set_origin(vc); 939 - if (vc->vc_sw->con_flush_scrollback) 939 + if (vc->vc_sw->con_flush_scrollback) { 940 940 vc->vc_sw->con_flush_scrollback(vc); 941 - else 941 + } else if (con_is_visible(vc)) { 942 + /* 943 + * When no con_flush_scrollback method is provided then the 944 + * legacy way for flushing the scrollback buffer is to use 945 + * a side effect of the con_switch method. We do it only on 946 + * the foreground console as background consoles have no 947 + * scrollback buffers in that case and we obviously don't 948 + * want to switch to them. 949 + */ 950 + hide_cursor(vc); 942 951 vc->vc_sw->con_switch(vc); 952 + set_cursor(vc); 953 + } 943 954 } 944 955 945 956 /*
+11 -6
drivers/tty/vt/vt_ioctl.c
··· 876 876 return -EINVAL; 877 877 878 878 for (i = 0; i < MAX_NR_CONSOLES; i++) { 879 + struct vc_data *vcp; 880 + 879 881 if (!vc_cons[i].d) 880 882 continue; 881 883 console_lock(); 882 - if (v.v_vlin) 883 - vc_cons[i].d->vc_scan_lines = v.v_vlin; 884 - if (v.v_clin) 885 - vc_cons[i].d->vc_font.height = v.v_clin; 886 - vc_cons[i].d->vc_resize_user = 1; 887 - vc_resize(vc_cons[i].d, v.v_cols, v.v_rows); 884 + vcp = vc_cons[i].d; 885 + if (vcp) { 886 + if (v.v_vlin) 887 + vcp->vc_scan_lines = v.v_vlin; 888 + if (v.v_clin) 889 + vcp->vc_font.height = v.v_clin; 890 + vcp->vc_resize_user = 1; 891 + vc_resize(vcp, v.v_cols, v.v_rows); 892 + } 888 893 console_unlock(); 889 894 } 890 895 break;
+2
include/linux/tty.h
··· 225 225 void (*write_wakeup)(struct tty_port *port); 226 226 }; 227 227 228 + extern const struct tty_port_client_operations tty_port_default_client_ops; 229 + 228 230 struct tty_port { 229 231 struct tty_bufhead buf; /* Locked internally */ 230 232 struct tty_struct *tty; /* Back pointer */