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

Pull tty/serial driver fixes from Greg KH:
"Here are some small tty/serial/vt driver fixes for 6.0-rc4 that
resolve a number of reported issues:

- n_gsm fixups for previous changes that caused problems

- much-reported serdev crash fix that showed up in 6.0-rc1

- vt font selection bugfix

- kerneldoc build warning fixes

- other tiny serial core fixes

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

* tag 'tty-6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
tty: n_gsm: avoid call of sleeping functions from atomic context
tty: n_gsm: replace kicktimer with delayed_work
tty: n_gsm: initialize more members at gsm_alloc_mux()
tty: n_gsm: add sanity check for gsm->receive in gsm_receive_buf()
tty: serial: atmel: Preserve previous USART mode if RS485 disabled
tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete
tty: Fix lookahead_buf crash with serdev
serial: fsl_lpuart: RS485 RTS polariy is inverse
vt: Clear selection before changing the font
serial: document start_rx member at struct uart_ops

+67 -61
+38 -47
drivers/tty/n_gsm.c
··· 248 248 bool constipated; /* Asked by remote to shut up */ 249 249 bool has_devices; /* Devices were registered */ 250 250 251 - spinlock_t tx_lock; 251 + struct mutex tx_mutex; 252 252 unsigned int tx_bytes; /* TX data outstanding */ 253 253 #define TX_THRESH_HI 8192 254 254 #define TX_THRESH_LO 2048 ··· 256 256 struct list_head tx_data_list; /* Pending data packets */ 257 257 258 258 /* Control messages */ 259 - struct timer_list kick_timer; /* Kick TX queuing on timeout */ 259 + struct delayed_work kick_timeout; /* Kick TX queuing on timeout */ 260 260 struct timer_list t2_timer; /* Retransmit timer for commands */ 261 261 int cretries; /* Command retry counter */ 262 262 struct gsm_control *pending_cmd;/* Our current pending command */ ··· 680 680 struct gsm_msg *msg; 681 681 u8 *dp; 682 682 int ocr; 683 - unsigned long flags; 684 683 685 684 msg = gsm_data_alloc(gsm, addr, 0, control); 686 685 if (!msg) ··· 701 702 702 703 gsm_print_packet("Q->", addr, cr, control, NULL, 0); 703 704 704 - spin_lock_irqsave(&gsm->tx_lock, flags); 705 + mutex_lock(&gsm->tx_mutex); 705 706 list_add_tail(&msg->list, &gsm->tx_ctrl_list); 706 707 gsm->tx_bytes += msg->len; 707 - spin_unlock_irqrestore(&gsm->tx_lock, flags); 708 + mutex_unlock(&gsm->tx_mutex); 708 709 gsmld_write_trigger(gsm); 709 710 710 711 return 0; ··· 729 730 spin_unlock_irqrestore(&dlci->lock, flags); 730 731 731 732 /* Clear data packets in MUX write queue */ 732 - spin_lock_irqsave(&gsm->tx_lock, flags); 733 + mutex_lock(&gsm->tx_mutex); 733 734 list_for_each_entry_safe(msg, nmsg, &gsm->tx_data_list, list) { 734 735 if (msg->addr != addr) 735 736 continue; ··· 737 738 list_del(&msg->list); 738 739 kfree(msg); 739 740 } 740 - spin_unlock_irqrestore(&gsm->tx_lock, flags); 741 + mutex_unlock(&gsm->tx_mutex); 741 742 } 742 743 743 744 /** ··· 1008 1009 gsm->tx_bytes += msg->len; 1009 1010 1010 1011 gsmld_write_trigger(gsm); 1011 - mod_timer(&gsm->kick_timer, jiffies + 10 * gsm->t1 * HZ / 100); 1012 + schedule_delayed_work(&gsm->kick_timeout, 10 * gsm->t1 * HZ / 100); 1012 1013 } 1013 1014 1014 1015 /** ··· 1023 1024 1024 1025 static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg) 1025 1026 { 1026 - unsigned long flags; 1027 - spin_lock_irqsave(&dlci->gsm->tx_lock, flags); 1027 + mutex_lock(&dlci->gsm->tx_mutex); 1028 1028 __gsm_data_queue(dlci, msg); 1029 - spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags); 1029 + mutex_unlock(&dlci->gsm->tx_mutex); 1030 1030 } 1031 1031 1032 1032 /** ··· 1037 1039 * is data. Keep to the MRU of the mux. This path handles the usual tty 1038 1040 * interface which is a byte stream with optional modem data. 1039 1041 * 1040 - * Caller must hold the tx_lock of the mux. 1042 + * Caller must hold the tx_mutex of the mux. 1041 1043 */ 1042 1044 1043 1045 static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci) ··· 1097 1099 * is data. Keep to the MRU of the mux. This path handles framed data 1098 1100 * queued as skbuffs to the DLCI. 1099 1101 * 1100 - * Caller must hold the tx_lock of the mux. 1102 + * Caller must hold the tx_mutex of the mux. 1101 1103 */ 1102 1104 1103 1105 static int gsm_dlci_data_output_framed(struct gsm_mux *gsm, ··· 1113 1115 if (dlci->adaption == 4) 1114 1116 overhead = 1; 1115 1117 1116 - /* dlci->skb is locked by tx_lock */ 1118 + /* dlci->skb is locked by tx_mutex */ 1117 1119 if (dlci->skb == NULL) { 1118 1120 dlci->skb = skb_dequeue_tail(&dlci->skb_list); 1119 1121 if (dlci->skb == NULL) ··· 1167 1169 * Push an empty frame in to the transmit queue to update the modem status 1168 1170 * bits and to transmit an optional break. 1169 1171 * 1170 - * Caller must hold the tx_lock of the mux. 1172 + * Caller must hold the tx_mutex of the mux. 1171 1173 */ 1172 1174 1173 1175 static int gsm_dlci_modem_output(struct gsm_mux *gsm, struct gsm_dlci *dlci, ··· 1281 1283 1282 1284 static void gsm_dlci_data_kick(struct gsm_dlci *dlci) 1283 1285 { 1284 - unsigned long flags; 1285 1286 int sweep; 1286 1287 1287 1288 if (dlci->constipated) 1288 1289 return; 1289 1290 1290 - spin_lock_irqsave(&dlci->gsm->tx_lock, flags); 1291 + mutex_lock(&dlci->gsm->tx_mutex); 1291 1292 /* If we have nothing running then we need to fire up */ 1292 1293 sweep = (dlci->gsm->tx_bytes < TX_THRESH_LO); 1293 1294 if (dlci->gsm->tx_bytes == 0) { ··· 1297 1300 } 1298 1301 if (sweep) 1299 1302 gsm_dlci_data_sweep(dlci->gsm); 1300 - spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags); 1303 + mutex_unlock(&dlci->gsm->tx_mutex); 1301 1304 } 1302 1305 1303 1306 /* ··· 1981 1984 } 1982 1985 1983 1986 /** 1984 - * gsm_kick_timer - transmit if possible 1985 - * @t: timer contained in our gsm object 1987 + * gsm_kick_timeout - transmit if possible 1988 + * @work: work contained in our gsm object 1986 1989 * 1987 1990 * Transmit data from DLCIs if the queue is empty. We can't rely on 1988 1991 * a tty wakeup except when we filled the pipe so we need to fire off 1989 1992 * new data ourselves in other cases. 1990 1993 */ 1991 - static void gsm_kick_timer(struct timer_list *t) 1994 + static void gsm_kick_timeout(struct work_struct *work) 1992 1995 { 1993 - struct gsm_mux *gsm = from_timer(gsm, t, kick_timer); 1994 - unsigned long flags; 1996 + struct gsm_mux *gsm = container_of(work, struct gsm_mux, kick_timeout.work); 1995 1997 int sent = 0; 1996 1998 1997 - spin_lock_irqsave(&gsm->tx_lock, flags); 1999 + mutex_lock(&gsm->tx_mutex); 1998 2000 /* If we have nothing running then we need to fire up */ 1999 2001 if (gsm->tx_bytes < TX_THRESH_LO) 2000 2002 sent = gsm_dlci_data_sweep(gsm); 2001 - spin_unlock_irqrestore(&gsm->tx_lock, flags); 2003 + mutex_unlock(&gsm->tx_mutex); 2002 2004 2003 2005 if (sent && debug & 4) 2004 2006 pr_info("%s TX queue stalled\n", __func__); ··· 2454 2458 } 2455 2459 2456 2460 /* Finish outstanding timers, making sure they are done */ 2457 - del_timer_sync(&gsm->kick_timer); 2461 + cancel_delayed_work_sync(&gsm->kick_timeout); 2458 2462 del_timer_sync(&gsm->t2_timer); 2459 2463 2460 2464 /* Finish writing to ldisc */ ··· 2497 2501 if (dlci == NULL) 2498 2502 return -ENOMEM; 2499 2503 2500 - timer_setup(&gsm->kick_timer, gsm_kick_timer, 0); 2501 - timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0); 2502 - INIT_WORK(&gsm->tx_work, gsmld_write_task); 2503 - init_waitqueue_head(&gsm->event); 2504 - spin_lock_init(&gsm->control_lock); 2505 - spin_lock_init(&gsm->tx_lock); 2506 - 2507 2504 if (gsm->encoding == 0) 2508 2505 gsm->receive = gsm0_receive; 2509 2506 else ··· 2527 2538 break; 2528 2539 } 2529 2540 } 2541 + mutex_destroy(&gsm->tx_mutex); 2530 2542 mutex_destroy(&gsm->mutex); 2531 2543 kfree(gsm->txframe); 2532 2544 kfree(gsm->buf); ··· 2599 2609 } 2600 2610 spin_lock_init(&gsm->lock); 2601 2611 mutex_init(&gsm->mutex); 2612 + mutex_init(&gsm->tx_mutex); 2602 2613 kref_init(&gsm->ref); 2603 2614 INIT_LIST_HEAD(&gsm->tx_ctrl_list); 2604 2615 INIT_LIST_HEAD(&gsm->tx_data_list); 2616 + INIT_DELAYED_WORK(&gsm->kick_timeout, gsm_kick_timeout); 2617 + timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0); 2618 + INIT_WORK(&gsm->tx_work, gsmld_write_task); 2619 + init_waitqueue_head(&gsm->event); 2620 + spin_lock_init(&gsm->control_lock); 2605 2621 2606 2622 gsm->t1 = T1; 2607 2623 gsm->t2 = T2; ··· 2632 2636 } 2633 2637 spin_unlock(&gsm_mux_lock); 2634 2638 if (i == MAX_MUX) { 2639 + mutex_destroy(&gsm->tx_mutex); 2635 2640 mutex_destroy(&gsm->mutex); 2636 2641 kfree(gsm->txframe); 2637 2642 kfree(gsm->buf); ··· 2788 2791 static void gsmld_write_task(struct work_struct *work) 2789 2792 { 2790 2793 struct gsm_mux *gsm = container_of(work, struct gsm_mux, tx_work); 2791 - unsigned long flags; 2792 2794 int i, ret; 2793 2795 2794 2796 /* All outstanding control channel and control messages and one data 2795 2797 * frame is sent. 2796 2798 */ 2797 2799 ret = -ENODEV; 2798 - spin_lock_irqsave(&gsm->tx_lock, flags); 2800 + mutex_lock(&gsm->tx_mutex); 2799 2801 if (gsm->tty) 2800 2802 ret = gsm_data_kick(gsm); 2801 - spin_unlock_irqrestore(&gsm->tx_lock, flags); 2803 + mutex_unlock(&gsm->tx_mutex); 2802 2804 2803 2805 if (ret >= 0) 2804 2806 for (i = 0; i < NUM_DLCI; i++) ··· 2854 2858 flags = *fp++; 2855 2859 switch (flags) { 2856 2860 case TTY_NORMAL: 2857 - gsm->receive(gsm, *cp); 2861 + if (gsm->receive) 2862 + gsm->receive(gsm, *cp); 2858 2863 break; 2859 2864 case TTY_OVERRUN: 2860 2865 case TTY_BREAK: ··· 2943 2946 2944 2947 gsmld_attach_gsm(tty, gsm); 2945 2948 2946 - timer_setup(&gsm->kick_timer, gsm_kick_timer, 0); 2947 - timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0); 2948 - INIT_WORK(&gsm->tx_work, gsmld_write_task); 2949 - 2950 2949 return 0; 2951 2950 } 2952 2951 ··· 3005 3012 const unsigned char *buf, size_t nr) 3006 3013 { 3007 3014 struct gsm_mux *gsm = tty->disc_data; 3008 - unsigned long flags; 3009 3015 int space; 3010 3016 int ret; 3011 3017 ··· 3012 3020 return -ENODEV; 3013 3021 3014 3022 ret = -ENOBUFS; 3015 - spin_lock_irqsave(&gsm->tx_lock, flags); 3023 + mutex_lock(&gsm->tx_mutex); 3016 3024 space = tty_write_room(tty); 3017 3025 if (space >= nr) 3018 3026 ret = tty->ops->write(tty, buf, nr); 3019 3027 else 3020 3028 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 3021 - spin_unlock_irqrestore(&gsm->tx_lock, flags); 3029 + mutex_unlock(&gsm->tx_mutex); 3022 3030 3023 3031 return ret; 3024 3032 } ··· 3315 3323 static void gsm_modem_upd_via_data(struct gsm_dlci *dlci, u8 brk) 3316 3324 { 3317 3325 struct gsm_mux *gsm = dlci->gsm; 3318 - unsigned long flags; 3319 3326 3320 3327 if (dlci->state != DLCI_OPEN || dlci->adaption != 2) 3321 3328 return; 3322 3329 3323 - spin_lock_irqsave(&gsm->tx_lock, flags); 3330 + mutex_lock(&gsm->tx_mutex); 3324 3331 gsm_dlci_modem_output(gsm, dlci, brk); 3325 - spin_unlock_irqrestore(&gsm->tx_lock, flags); 3332 + mutex_unlock(&gsm->tx_mutex); 3326 3333 } 3327 3334 3328 3335 /**
+1 -3
drivers/tty/serial/atmel_serial.c
··· 294 294 295 295 mode = atmel_uart_readl(port, ATMEL_US_MR); 296 296 297 - /* Resetting serial mode to RS232 (0x0) */ 298 - mode &= ~ATMEL_US_USMODE; 299 - 300 297 if (rs485conf->flags & SER_RS485_ENABLED) { 301 298 dev_dbg(port->dev, "Setting UART to RS485\n"); 302 299 if (rs485conf->flags & SER_RS485_RX_DURING_TX) ··· 303 306 304 307 atmel_uart_writel(port, ATMEL_US_TTGR, 305 308 rs485conf->delay_rts_after_send); 309 + mode &= ~ATMEL_US_USMODE; 306 310 mode |= ATMEL_US_USMODE_RS485; 307 311 } else { 308 312 dev_dbg(port->dev, "Setting UART to RS232\n");
+3 -2
drivers/tty/serial/fsl_lpuart.c
··· 1394 1394 * Note: UART is assumed to be active high. 1395 1395 */ 1396 1396 if (rs485->flags & SER_RS485_RTS_ON_SEND) 1397 - modem &= ~UARTMODEM_TXRTSPOL; 1398 - else if (rs485->flags & SER_RS485_RTS_AFTER_SEND) 1399 1397 modem |= UARTMODEM_TXRTSPOL; 1398 + else if (rs485->flags & SER_RS485_RTS_AFTER_SEND) 1399 + modem &= ~UARTMODEM_TXRTSPOL; 1400 1400 } 1401 1401 1402 1402 writeb(modem, sport->port.membase + UARTMODEM); ··· 2191 2191 uart_update_timeout(port, termios->c_cflag, baud); 2192 2192 2193 2193 /* wait transmit engin complete */ 2194 + lpuart32_write(&sport->port, 0, UARTMODIR); 2194 2195 lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC); 2195 2196 2196 2197 /* disable transmit and receive */
+9 -5
drivers/tty/tty_buffer.c
··· 470 470 471 471 while (head) { 472 472 struct tty_buffer *next; 473 - unsigned char *p, *f = NULL; 474 473 unsigned int count; 475 474 476 475 /* ··· 488 489 continue; 489 490 } 490 491 491 - p = char_buf_ptr(head, head->lookahead); 492 - if (~head->flags & TTYB_NORMAL) 493 - f = flag_buf_ptr(head, head->lookahead); 492 + if (port->client_ops->lookahead_buf) { 493 + unsigned char *p, *f = NULL; 494 494 495 - port->client_ops->lookahead_buf(port, p, f, count); 495 + p = char_buf_ptr(head, head->lookahead); 496 + if (~head->flags & TTYB_NORMAL) 497 + f = flag_buf_ptr(head, head->lookahead); 498 + 499 + port->client_ops->lookahead_buf(port, p, f, count); 500 + } 501 + 496 502 head->lookahead += count; 497 503 } 498 504 }
+8 -4
drivers/tty/vt/vt.c
··· 4662 4662 console_lock(); 4663 4663 if (vc->vc_mode != KD_TEXT) 4664 4664 rc = -EINVAL; 4665 - else if (vc->vc_sw->con_font_set) 4665 + else if (vc->vc_sw->con_font_set) { 4666 + if (vc_is_sel(vc)) 4667 + clear_selection(); 4666 4668 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); 4667 - else 4669 + } else 4668 4670 rc = -ENOSYS; 4669 4671 console_unlock(); 4670 4672 kfree(font.data); ··· 4693 4691 console_unlock(); 4694 4692 return -EINVAL; 4695 4693 } 4696 - if (vc->vc_sw->con_font_default) 4694 + if (vc->vc_sw->con_font_default) { 4695 + if (vc_is_sel(vc)) 4696 + clear_selection(); 4697 4697 rc = vc->vc_sw->con_font_default(vc, &font, s); 4698 - else 4698 + } else 4699 4699 rc = -ENOSYS; 4700 4700 console_unlock(); 4701 4701 if (!rc) {
+8
include/linux/serial_core.h
··· 141 141 * Locking: none. 142 142 * Interrupts: caller dependent. 143 143 * 144 + * @start_rx: ``void ()(struct uart_port *port)`` 145 + * 146 + * Start receiving characters. 147 + * 148 + * Locking: @port->lock taken. 149 + * Interrupts: locally disabled. 150 + * This call must not sleep 151 + * 144 152 * @stop_rx: ``void ()(struct uart_port *port)`` 145 153 * 146 154 * Stop receiving characters; the @port is in the process of being closed.