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

Pull tty/serial fixes from Greg KH:
"Here are some small tty/serial driver fixes for 4.5-rc2.

They resolve a number of reported problems (the ioctl one specifically
has been pointed out by numerous people) and one patch adds some new
device ids for the 8250_pci driver. All have been in linux-next
successfully"

* tag 'tty-4.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
serial: 8250_pci: Add Intel Broadwell ports
staging/speakup: Use tty_ldisc_ref() for paste kworker
n_tty: Fix unsafe reference to "other" ldisc
tty: Fix unsafe ldisc reference via ioctl(TIOCGETD)
tty: Retry failed reopen if tty teardown in-progress
tty: Wait interruptibly for tty lock on reopen

+82 -12
+4 -1
drivers/staging/speakup/selection.c
··· 142 142 struct tty_ldisc *ld; 143 143 DECLARE_WAITQUEUE(wait, current); 144 144 145 - ld = tty_ldisc_ref_wait(tty); 145 + ld = tty_ldisc_ref(tty); 146 + if (!ld) 147 + goto tty_unref; 146 148 tty_buffer_lock_exclusive(&vc->port); 147 149 148 150 add_wait_queue(&vc->paste_wait, &wait); ··· 164 162 165 163 tty_buffer_unlock_exclusive(&vc->port); 166 164 tty_ldisc_deref(ld); 165 + tty_unref: 167 166 tty_kref_put(tty); 168 167 } 169 168
+2 -5
drivers/tty/n_tty.c
··· 269 269 270 270 static void n_tty_check_unthrottle(struct tty_struct *tty) 271 271 { 272 - if (tty->driver->type == TTY_DRIVER_TYPE_PTY && 273 - tty->link->ldisc->ops->write_wakeup == n_tty_write_wakeup) { 272 + if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { 274 273 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) 275 274 return; 276 275 if (!tty->count) 277 276 return; 278 277 n_tty_kick_worker(tty); 279 - n_tty_write_wakeup(tty->link); 280 - if (waitqueue_active(&tty->link->write_wait)) 281 - wake_up_interruptible_poll(&tty->link->write_wait, POLLOUT); 278 + tty_wakeup(tty->link); 282 279 return; 283 280 } 284 281
+29
drivers/tty/serial/8250/8250_pci.c
··· 1379 1379 #define PCI_DEVICE_ID_INTEL_BSW_UART1 0x228a 1380 1380 #define PCI_DEVICE_ID_INTEL_BSW_UART2 0x228c 1381 1381 1382 + #define PCI_DEVICE_ID_INTEL_BDW_UART1 0x9ce3 1383 + #define PCI_DEVICE_ID_INTEL_BDW_UART2 0x9ce4 1384 + 1382 1385 #define BYT_PRV_CLK 0x800 1383 1386 #define BYT_PRV_CLK_EN (1 << 0) 1384 1387 #define BYT_PRV_CLK_M_VAL_SHIFT 1 ··· 1464 1461 switch (pdev->device) { 1465 1462 case PCI_DEVICE_ID_INTEL_BYT_UART1: 1466 1463 case PCI_DEVICE_ID_INTEL_BSW_UART1: 1464 + case PCI_DEVICE_ID_INTEL_BDW_UART1: 1467 1465 rx_param->src_id = 3; 1468 1466 tx_param->dst_id = 2; 1469 1467 break; 1470 1468 case PCI_DEVICE_ID_INTEL_BYT_UART2: 1471 1469 case PCI_DEVICE_ID_INTEL_BSW_UART2: 1470 + case PCI_DEVICE_ID_INTEL_BDW_UART2: 1472 1471 rx_param->src_id = 5; 1473 1472 tx_param->dst_id = 4; 1474 1473 break; ··· 2063 2058 { 2064 2059 .vendor = PCI_VENDOR_ID_INTEL, 2065 2060 .device = PCI_DEVICE_ID_INTEL_BSW_UART2, 2061 + .subvendor = PCI_ANY_ID, 2062 + .subdevice = PCI_ANY_ID, 2063 + .setup = byt_serial_setup, 2064 + }, 2065 + { 2066 + .vendor = PCI_VENDOR_ID_INTEL, 2067 + .device = PCI_DEVICE_ID_INTEL_BDW_UART1, 2068 + .subvendor = PCI_ANY_ID, 2069 + .subdevice = PCI_ANY_ID, 2070 + .setup = byt_serial_setup, 2071 + }, 2072 + { 2073 + .vendor = PCI_VENDOR_ID_INTEL, 2074 + .device = PCI_DEVICE_ID_INTEL_BDW_UART2, 2066 2075 .subvendor = PCI_ANY_ID, 2067 2076 .subdevice = PCI_ANY_ID, 2068 2077 .setup = byt_serial_setup, ··· 5521 5502 PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, 5522 5503 pbn_byt }, 5523 5504 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW_UART2, 5505 + PCI_ANY_ID, PCI_ANY_ID, 5506 + PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, 5507 + pbn_byt }, 5508 + 5509 + /* Intel Broadwell */ 5510 + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BDW_UART1, 5511 + PCI_ANY_ID, PCI_ANY_ID, 5512 + PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, 5513 + pbn_byt }, 5514 + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BDW_UART2, 5524 5515 PCI_ANY_ID, PCI_ANY_ID, 5525 5516 PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, 5526 5517 pbn_byt },
+38 -6
drivers/tty/tty_io.c
··· 1463 1463 { 1464 1464 struct tty_driver *driver = tty->driver; 1465 1465 1466 - if (!tty->count) 1467 - return -EIO; 1468 - 1469 1466 if (driver->type == TTY_DRIVER_TYPE_PTY && 1470 1467 driver->subtype == PTY_TYPE_MASTER) 1471 1468 return -EIO; 1469 + 1470 + if (!tty->count) 1471 + return -EAGAIN; 1472 1472 1473 1473 if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) 1474 1474 return -EBUSY; ··· 2065 2065 2066 2066 if (tty) { 2067 2067 mutex_unlock(&tty_mutex); 2068 - tty_lock(tty); 2068 + retval = tty_lock_interruptible(tty); 2069 + if (retval) { 2070 + if (retval == -EINTR) 2071 + retval = -ERESTARTSYS; 2072 + goto err_unref; 2073 + } 2069 2074 /* safe to drop the kref from tty_driver_lookup_tty() */ 2070 2075 tty_kref_put(tty); 2071 2076 retval = tty_reopen(tty); ··· 2088 2083 2089 2084 if (IS_ERR(tty)) { 2090 2085 retval = PTR_ERR(tty); 2091 - goto err_file; 2086 + if (retval != -EAGAIN || signal_pending(current)) 2087 + goto err_file; 2088 + tty_free_file(filp); 2089 + schedule(); 2090 + goto retry_open; 2092 2091 } 2093 2092 2094 2093 tty_add_file(tty, filp); ··· 2161 2152 return 0; 2162 2153 err_unlock: 2163 2154 mutex_unlock(&tty_mutex); 2155 + err_unref: 2164 2156 /* after locks to avoid deadlock */ 2165 2157 if (!IS_ERR_OR_NULL(driver)) 2166 2158 tty_driver_kref_put(driver); ··· 2659 2649 } 2660 2650 2661 2651 /** 2652 + * tiocgetd - get line discipline 2653 + * @tty: tty device 2654 + * @p: pointer to user data 2655 + * 2656 + * Retrieves the line discipline id directly from the ldisc. 2657 + * 2658 + * Locking: waits for ldisc reference (in case the line discipline 2659 + * is changing or the tty is being hungup) 2660 + */ 2661 + 2662 + static int tiocgetd(struct tty_struct *tty, int __user *p) 2663 + { 2664 + struct tty_ldisc *ld; 2665 + int ret; 2666 + 2667 + ld = tty_ldisc_ref_wait(tty); 2668 + ret = put_user(ld->ops->num, p); 2669 + tty_ldisc_deref(ld); 2670 + return ret; 2671 + } 2672 + 2673 + /** 2662 2674 * send_break - performed time break 2663 2675 * @tty: device to break on 2664 2676 * @duration: timeout in mS ··· 2906 2874 case TIOCGSID: 2907 2875 return tiocgsid(tty, real_tty, p); 2908 2876 case TIOCGETD: 2909 - return put_user(tty->ldisc->ops->num, (int __user *)p); 2877 + return tiocgetd(tty, p); 2910 2878 case TIOCSETD: 2911 2879 return tiocsetd(tty, p); 2912 2880 case TIOCVHANGUP:
+8
drivers/tty/tty_mutex.c
··· 19 19 } 20 20 EXPORT_SYMBOL(tty_lock); 21 21 22 + int tty_lock_interruptible(struct tty_struct *tty) 23 + { 24 + if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) 25 + return -EIO; 26 + tty_kref_get(tty); 27 + return mutex_lock_interruptible(&tty->legacy_mutex); 28 + } 29 + 22 30 void __lockfunc tty_unlock(struct tty_struct *tty) 23 31 { 24 32 if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
+1
include/linux/tty.h
··· 649 649 /* tty_mutex.c */ 650 650 /* functions for preparation of BKL removal */ 651 651 extern void __lockfunc tty_lock(struct tty_struct *tty); 652 + extern int tty_lock_interruptible(struct tty_struct *tty); 652 653 extern void __lockfunc tty_unlock(struct tty_struct *tty); 653 654 extern void __lockfunc tty_lock_slave(struct tty_struct *tty); 654 655 extern void __lockfunc tty_unlock_slave(struct tty_struct *tty);