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

Pull tty/serial fixes from Greg KH:
"Here are some tty and serial driver fixes for reported issues for
4.17-rc3.

Nothing major, but a number of small things:

- device tree fixes/updates for serial ports

- earlycon fixes

- n_gsm fixes

- tty core change reverted to help resolve syszkaller reports

- other serial driver small fixes

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

* tag 'tty-4.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
tty: Use __GFP_NOFAIL for tty_ldisc_get()
tty: serial: xuartps: Setup early console when uartclk is also passed
tty: Don't call panic() at tty_ldisc_init()
tty: Avoid possible error pointer dereference at tty_ldisc_restore().
dt-bindings: mvebu-uart: DT fix s/interrupts-names/interrupt-names/
tty: serial: qcom_geni_serial: Use signed variable to get IRQ
earlycon: Use a pointer table to fix __earlycon_table stride
serial: sh-sci: Document r8a77470 bindings
dt-bindings: meson-uart: DT fix s/clocks-names/clock-names/
serial: imx: fix cached UCR2 read on software reset
serial: imx: warn user when using unsupported configuration
serial: mvebu-uart: Fix local flags handling on termios update
tty: n_gsm: Fix DLCI handling for ADM mode if debug & 2 is not set
tty: n_gsm: Fix long delays with control frame timeouts in ADM mode

+93 -40
+1 -1
Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
··· 21 21 - interrupts : identifier to the device interrupt 22 22 - clocks : a list of phandle + clock-specifier pairs, one for each 23 23 entry in clock names. 24 - - clocks-names : 24 + - clock-names : 25 25 * "xtal" for external xtal clock identifier 26 26 * "pclk" for the bus core clock, either the clk81 clock or the gate clock 27 27 * "baud" for the source of the baudrate generator, can be either the xtal
+1 -1
Documentation/devicetree/bindings/serial/mvebu-uart.txt
··· 24 24 - Must contain two elements for the extended variant of the IP 25 25 (marvell,armada-3700-uart-ext): "uart-tx" and "uart-rx", 26 26 respectively the UART TX interrupt and the UART RX interrupt. A 27 - corresponding interrupts-names property must be defined. 27 + corresponding interrupt-names property must be defined. 28 28 - For backward compatibility reasons, a single element interrupts 29 29 property is also supported for the standard variant of the IP, 30 30 containing only the UART sum interrupt. This form is deprecated
+2
Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
··· 17 17 - "renesas,scifa-r8a7745" for R8A7745 (RZ/G1E) SCIFA compatible UART. 18 18 - "renesas,scifb-r8a7745" for R8A7745 (RZ/G1E) SCIFB compatible UART. 19 19 - "renesas,hscif-r8a7745" for R8A7745 (RZ/G1E) HSCIF compatible UART. 20 + - "renesas,scif-r8a77470" for R8A77470 (RZ/G1C) SCIF compatible UART. 21 + - "renesas,hscif-r8a77470" for R8A77470 (RZ/G1C) HSCIF compatible UART. 20 22 - "renesas,scif-r8a7778" for R8A7778 (R-Car M1) SCIF compatible UART. 21 23 - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART. 22 24 - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART.
+5 -2
drivers/of/fdt.c
··· 942 942 int offset; 943 943 const char *p, *q, *options = NULL; 944 944 int l; 945 - const struct earlycon_id *match; 945 + const struct earlycon_id **p_match; 946 946 const void *fdt = initial_boot_params; 947 947 948 948 offset = fdt_path_offset(fdt, "/chosen"); ··· 969 969 return 0; 970 970 } 971 971 972 - for (match = __earlycon_table; match < __earlycon_table_end; match++) { 972 + for (p_match = __earlycon_table; p_match < __earlycon_table_end; 973 + p_match++) { 974 + const struct earlycon_id *match = *p_match; 975 + 973 976 if (!match->compatible[0]) 974 977 continue; 975 978
+22 -1
drivers/tty/n_gsm.c
··· 121 121 struct mutex mutex; 122 122 123 123 /* Link layer */ 124 + int mode; 125 + #define DLCI_MODE_ABM 0 /* Normal Asynchronous Balanced Mode */ 126 + #define DLCI_MODE_ADM 1 /* Asynchronous Disconnected Mode */ 124 127 spinlock_t lock; /* Protects the internal state */ 125 128 struct timer_list t1; /* Retransmit timer for SABM and UA */ 126 129 int retries; ··· 1367 1364 ctrl->data = data; 1368 1365 ctrl->len = clen; 1369 1366 gsm->pending_cmd = ctrl; 1370 - gsm->cretries = gsm->n2; 1367 + 1368 + /* If DLCI0 is in ADM mode skip retries, it won't respond */ 1369 + if (gsm->dlci[0]->mode == DLCI_MODE_ADM) 1370 + gsm->cretries = 1; 1371 + else 1372 + gsm->cretries = gsm->n2; 1373 + 1371 1374 mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100); 1372 1375 gsm_control_transmit(gsm, ctrl); 1373 1376 spin_unlock_irqrestore(&gsm->control_lock, flags); ··· 1481 1472 if (debug & 8) 1482 1473 pr_info("DLCI %d opening in ADM mode.\n", 1483 1474 dlci->addr); 1475 + dlci->mode = DLCI_MODE_ADM; 1484 1476 gsm_dlci_open(dlci); 1485 1477 } else { 1486 1478 gsm_dlci_close(dlci); ··· 2871 2861 static int gsm_carrier_raised(struct tty_port *port) 2872 2862 { 2873 2863 struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port); 2864 + struct gsm_mux *gsm = dlci->gsm; 2865 + 2874 2866 /* Not yet open so no carrier info */ 2875 2867 if (dlci->state != DLCI_OPEN) 2876 2868 return 0; 2877 2869 if (debug & 2) 2878 2870 return 1; 2871 + 2872 + /* 2873 + * Basic mode with control channel in ADM mode may not respond 2874 + * to CMD_MSC at all and modem_rx is empty. 2875 + */ 2876 + if (gsm->encoding == 0 && gsm->dlci[0]->mode == DLCI_MODE_ADM && 2877 + !dlci->modem_rx) 2878 + return 1; 2879 + 2879 2880 return dlci->modem_rx & TIOCM_CD; 2880 2881 } 2881 2882
+4 -2
drivers/tty/serial/earlycon.c
··· 169 169 */ 170 170 int __init setup_earlycon(char *buf) 171 171 { 172 - const struct earlycon_id *match; 172 + const struct earlycon_id **p_match; 173 173 174 174 if (!buf || !buf[0]) 175 175 return -EINVAL; ··· 177 177 if (early_con.flags & CON_ENABLED) 178 178 return -EALREADY; 179 179 180 - for (match = __earlycon_table; match < __earlycon_table_end; match++) { 180 + for (p_match = __earlycon_table; p_match < __earlycon_table_end; 181 + p_match++) { 182 + const struct earlycon_id *match = *p_match; 181 183 size_t len = strlen(match->name); 182 184 183 185 if (strncmp(buf, match->name, len))
+18 -1
drivers/tty/serial/imx.c
··· 316 316 * differ from the value that was last written. As it only 317 317 * clears after being set, reread conditionally. 318 318 */ 319 - if (sport->ucr2 & UCR2_SRST) 319 + if (!(sport->ucr2 & UCR2_SRST)) 320 320 sport->ucr2 = readl(sport->port.membase + offset); 321 321 return sport->ucr2; 322 322 break; ··· 1833 1833 rs485conf->flags &= ~SER_RS485_ENABLED; 1834 1834 1835 1835 if (rs485conf->flags & SER_RS485_ENABLED) { 1836 + /* Enable receiver if low-active RTS signal is requested */ 1837 + if (sport->have_rtscts && !sport->have_rtsgpio && 1838 + !(rs485conf->flags & SER_RS485_RTS_ON_SEND)) 1839 + rs485conf->flags |= SER_RS485_RX_DURING_TX; 1840 + 1836 1841 /* disable transmitter */ 1837 1842 ucr2 = imx_uart_readl(sport, UCR2); 1838 1843 if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) ··· 2269 2264 if (sport->port.rs485.flags & SER_RS485_ENABLED && 2270 2265 (!sport->have_rtscts && !sport->have_rtsgpio)) 2271 2266 dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); 2267 + 2268 + /* 2269 + * If using the i.MX UART RTS/CTS control then the RTS (CTS_B) 2270 + * signal cannot be set low during transmission in case the 2271 + * receiver is off (limitation of the i.MX UART IP). 2272 + */ 2273 + if (sport->port.rs485.flags & SER_RS485_ENABLED && 2274 + sport->have_rtscts && !sport->have_rtsgpio && 2275 + (!(sport->port.rs485.flags & SER_RS485_RTS_ON_SEND) && 2276 + !(sport->port.rs485.flags & SER_RS485_RX_DURING_TX))) 2277 + dev_err(&pdev->dev, 2278 + "low-active RTS not possible when receiver is off, enabling receiver\n"); 2272 2279 2273 2280 imx_uart_rs485_config(&sport->port, &sport->port.rs485); 2274 2281
-1
drivers/tty/serial/mvebu-uart.c
··· 495 495 termios->c_iflag |= old->c_iflag & ~(INPCK | IGNPAR); 496 496 termios->c_cflag &= CREAD | CBAUD; 497 497 termios->c_cflag |= old->c_cflag & ~(CREAD | CBAUD); 498 - termios->c_lflag = old->c_lflag; 499 498 } 500 499 501 500 spin_unlock_irqrestore(&port->lock, flags);
+6 -4
drivers/tty/serial/qcom_geni_serial.c
··· 1022 1022 struct qcom_geni_serial_port *port; 1023 1023 struct uart_port *uport; 1024 1024 struct resource *res; 1025 + int irq; 1025 1026 1026 1027 if (pdev->dev.of_node) 1027 1028 line = of_alias_get_id(pdev->dev.of_node, "serial"); ··· 1062 1061 port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS; 1063 1062 port->tx_fifo_width = DEF_FIFO_WIDTH_BITS; 1064 1063 1065 - uport->irq = platform_get_irq(pdev, 0); 1066 - if (uport->irq < 0) { 1067 - dev_err(&pdev->dev, "Failed to get IRQ %d\n", uport->irq); 1068 - return uport->irq; 1064 + irq = platform_get_irq(pdev, 0); 1065 + if (irq < 0) { 1066 + dev_err(&pdev->dev, "Failed to get IRQ %d\n", irq); 1067 + return irq; 1069 1068 } 1069 + uport->irq = irq; 1070 1070 1071 1071 uport->private_data = &qcom_geni_console_driver; 1072 1072 platform_set_drvdata(pdev, port);
+1 -1
drivers/tty/serial/xilinx_uartps.c
··· 1181 1181 /* only set baud if specified on command line - otherwise 1182 1182 * assume it has been initialized by a boot loader. 1183 1183 */ 1184 - if (device->baud) { 1184 + if (port->uartclk && device->baud) { 1185 1185 u32 cd = 0, bdiv = 0; 1186 1186 u32 mr; 1187 1187 int div8;
+4 -1
drivers/tty/tty_io.c
··· 2816 2816 2817 2817 kref_init(&tty->kref); 2818 2818 tty->magic = TTY_MAGIC; 2819 - tty_ldisc_init(tty); 2819 + if (tty_ldisc_init(tty)) { 2820 + kfree(tty); 2821 + return NULL; 2822 + } 2820 2823 tty->session = NULL; 2821 2824 tty->pgrp = NULL; 2822 2825 mutex_init(&tty->legacy_mutex);
+13 -16
drivers/tty/tty_ldisc.c
··· 176 176 return ERR_CAST(ldops); 177 177 } 178 178 179 - ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL); 180 - if (ld == NULL) { 181 - put_ldops(ldops); 182 - return ERR_PTR(-ENOMEM); 183 - } 184 - 179 + /* 180 + * There is no way to handle allocation failure of only 16 bytes. 181 + * Let's simplify error handling and save more memory. 182 + */ 183 + ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL | __GFP_NOFAIL); 185 184 ld->ops = ldops; 186 185 ld->tty = tty; 187 186 ··· 526 527 static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) 527 528 { 528 529 /* There is an outstanding reference here so this is safe */ 529 - old = tty_ldisc_get(tty, old->ops->num); 530 - WARN_ON(IS_ERR(old)); 531 - tty->ldisc = old; 532 - tty_set_termios_ldisc(tty, old->ops->num); 533 - if (tty_ldisc_open(tty, old) < 0) { 534 - tty_ldisc_put(old); 530 + if (tty_ldisc_failto(tty, old->ops->num) < 0) { 531 + const char *name = tty_name(tty); 532 + 533 + pr_warn("Falling back ldisc for %s.\n", name); 535 534 /* The traditional behaviour is to fall back to N_TTY, we 536 535 want to avoid falling back to N_NULL unless we have no 537 536 choice to avoid the risk of breaking anything */ 538 537 if (tty_ldisc_failto(tty, N_TTY) < 0 && 539 538 tty_ldisc_failto(tty, N_NULL) < 0) 540 - panic("Couldn't open N_NULL ldisc for %s.", 541 - tty_name(tty)); 539 + panic("Couldn't open N_NULL ldisc for %s.", name); 542 540 } 543 541 } 544 542 ··· 820 824 * the tty structure is not completely set up when this call is made. 821 825 */ 822 826 823 - void tty_ldisc_init(struct tty_struct *tty) 827 + int tty_ldisc_init(struct tty_struct *tty) 824 828 { 825 829 struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY); 826 830 if (IS_ERR(ld)) 827 - panic("n_tty: init_tty"); 831 + return PTR_ERR(ld); 828 832 tty->ldisc = ld; 833 + return 0; 829 834 } 830 835 831 836 /**
+1 -1
include/asm-generic/vmlinux.lds.h
··· 188 188 #endif 189 189 190 190 #ifdef CONFIG_SERIAL_EARLYCON 191 - #define EARLYCON_TABLE() STRUCT_ALIGN(); \ 191 + #define EARLYCON_TABLE() . = ALIGN(8); \ 192 192 VMLINUX_SYMBOL(__earlycon_table) = .; \ 193 193 KEEP(*(__earlycon_table)) \ 194 194 VMLINUX_SYMBOL(__earlycon_table_end) = .;
+14 -7
include/linux/serial_core.h
··· 351 351 char name[16]; 352 352 char compatible[128]; 353 353 int (*setup)(struct earlycon_device *, const char *options); 354 - } __aligned(32); 354 + }; 355 355 356 - extern const struct earlycon_id __earlycon_table[]; 357 - extern const struct earlycon_id __earlycon_table_end[]; 356 + extern const struct earlycon_id *__earlycon_table[]; 357 + extern const struct earlycon_id *__earlycon_table_end[]; 358 358 359 359 #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE) 360 360 #define EARLYCON_USED_OR_UNUSED __used ··· 362 362 #define EARLYCON_USED_OR_UNUSED __maybe_unused 363 363 #endif 364 364 365 - #define OF_EARLYCON_DECLARE(_name, compat, fn) \ 366 - static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \ 367 - EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \ 365 + #define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \ 366 + static const struct earlycon_id unique_id \ 367 + EARLYCON_USED_OR_UNUSED __initconst \ 368 368 = { .name = __stringify(_name), \ 369 369 .compatible = compat, \ 370 - .setup = fn } 370 + .setup = fn }; \ 371 + static const struct earlycon_id EARLYCON_USED_OR_UNUSED \ 372 + __section(__earlycon_table) \ 373 + * const __PASTE(__p, unique_id) = &unique_id 374 + 375 + #define OF_EARLYCON_DECLARE(_name, compat, fn) \ 376 + _OF_EARLYCON_DECLARE(_name, compat, fn, \ 377 + __UNIQUE_ID(__earlycon_##_name)) 371 378 372 379 #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn) 373 380
+1 -1
include/linux/tty.h
··· 701 701 extern int tty_set_ldisc(struct tty_struct *tty, int disc); 702 702 extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty); 703 703 extern void tty_ldisc_release(struct tty_struct *tty); 704 - extern void tty_ldisc_init(struct tty_struct *tty); 704 + extern int __must_check tty_ldisc_init(struct tty_struct *tty); 705 705 extern void tty_ldisc_deinit(struct tty_struct *tty); 706 706 extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 707 707 char *f, int count);