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

Pull tty/serial fixes from Greg KH:
"Here are some small tty and serial core fixes for 6.5-rc7 that resolve
a lot of reported issues.

Primarily in here are the fixes for the serial bus code from Tony that
came in -rc1, as it hit wider testing with the huge number of
different types of systems and serial ports. All of the reported
issues with duplicate names and other issues with this code are now
resolved.

Other than that included in here is:

- n_gsm fix for a previous fix

- 8250 lockdep annotation fix

- fsl_lpuart serial driver fix

- TIOCSTI documentation update for previous CAP_SYS_ADMIN change

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

* tag 'tty-6.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
serial: core: Fix serial core port id, including multiport devices
serial: 8250: drop lockdep annotation from serial8250_clear_IER()
tty: n_gsm: fix the UAF caused by race condition in gsm_cleanup_mux
serial: core: Revert port_id use
TIOCSTI: Document CAP_SYS_ADMIN behaviour in Kconfig
serial: 8250: Fix oops for port->pm on uart_change_pm()
serial: 8250: Reinit port_id when adding back serial8250_isa_devs
serial: core: Fix kmemleak issue for serial core device remove
MAINTAINERS: Merge TTY layer and serial drivers
serial: core: Fix serial_base_match() after fixing controller port name
serial: core: Fix serial core controller port name to show controller id
serial: core: Fix serial core port id to not use port->line
serial: core: Controller id cannot be negative
tty: serial: fsl_lpuart: Clear the error flags by writing 1 for lpuart32 platforms

+72 -34
+2 -13
MAINTAINERS
··· 19224 19224 F: drivers/tty/serdev/ 19225 19225 F: include/linux/serdev.h 19226 19226 19227 - SERIAL DRIVERS 19228 - M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 19229 - L: linux-serial@vger.kernel.org 19230 - S: Maintained 19231 - F: Documentation/devicetree/bindings/serial/ 19232 - F: drivers/tty/serial/ 19233 - 19234 19227 SERIAL IR RECEIVER 19235 19228 M: Sean Young <sean@mess.org> 19236 19229 L: linux-media@vger.kernel.org ··· 21628 21635 T: git git://github.com/srcres258/linux-doc.git doc-zh-tw 21629 21636 F: Documentation/translations/zh_TW/ 21630 21637 21631 - TTY LAYER 21638 + TTY LAYER AND SERIAL DRIVERS 21632 21639 M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 21633 21640 M: Jiri Slaby <jirislaby@kernel.org> 21634 21641 L: linux-kernel@vger.kernel.org 21635 21642 L: linux-serial@vger.kernel.org 21636 21643 S: Supported 21637 21644 T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git 21645 + F: Documentation/devicetree/bindings/serial/ 21638 21646 F: Documentation/driver-api/serial/ 21639 21647 F: drivers/tty/ 21640 - F: drivers/tty/serial/serial_base.h 21641 - F: drivers/tty/serial/serial_base_bus.c 21642 - F: drivers/tty/serial/serial_core.c 21643 - F: drivers/tty/serial/serial_ctrl.c 21644 - F: drivers/tty/serial/serial_port.c 21645 21648 F: include/linux/selection.h 21646 21649 F: include/linux/serial.h 21647 21650 F: include/linux/serial_core.h
+3
drivers/tty/Kconfig
··· 164 164 userspace depends on this functionality to continue operating 165 165 normally. 166 166 167 + Processes which run with CAP_SYS_ADMIN, such as BRLTTY, can 168 + use TIOCSTI even when this is set to N. 169 + 167 170 This functionality can be changed at runtime with the 168 171 dev.tty.legacy_tiocsti sysctl. This configuration option sets 169 172 the default value of the sysctl.
+2 -1
drivers/tty/n_gsm.c
··· 3042 3042 static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc) 3043 3043 { 3044 3044 int i; 3045 - struct gsm_dlci *dlci = gsm->dlci[0]; 3045 + struct gsm_dlci *dlci; 3046 3046 struct gsm_msg *txq, *ntxq; 3047 3047 3048 3048 gsm->dead = true; 3049 3049 mutex_lock(&gsm->mutex); 3050 3050 3051 + dlci = gsm->dlci[0]; 3051 3052 if (dlci) { 3052 3053 if (disc && dlci->state != DLCI_CLOSED) { 3053 3054 gsm_dlci_begin_close(dlci);
+3
drivers/tty/serial/8250/8250_core.c
··· 497 497 498 498 up = &serial8250_ports[index]; 499 499 up->port.line = index; 500 + up->port.port_id = index; 500 501 501 502 serial8250_init_port(up); 502 503 if (!base_ops) ··· 1041 1040 uart_remove_one_port(&serial8250_reg, &uart->port); 1042 1041 1043 1042 uart->port.ctrl_id = up->port.ctrl_id; 1043 + uart->port.port_id = up->port.port_id; 1044 1044 uart->port.iobase = up->port.iobase; 1045 1045 uart->port.membase = up->port.membase; 1046 1046 uart->port.irq = up->port.irq; ··· 1204 1202 uart->port.flags &= ~UPF_BOOT_AUTOCONF; 1205 1203 uart->port.type = PORT_UNKNOWN; 1206 1204 uart->port.dev = &serial8250_isa_devs->dev; 1205 + uart->port.port_id = line; 1207 1206 uart->capabilities = 0; 1208 1207 serial8250_init_port(uart); 1209 1208 serial8250_apply_quirks(uart);
+1 -3
drivers/tty/serial/8250/8250_port.c
··· 703 703 704 704 static void serial8250_clear_IER(struct uart_8250_port *up) 705 705 { 706 - /* Port locked to synchronize UART_IER access against the console. */ 707 - lockdep_assert_held_once(&up->port.lock); 708 - 709 706 if (up->capabilities & UART_CAP_UUE) 710 707 serial_out(up, UART_IER, UART_IER_UUE); 711 708 else ··· 3275 3278 3276 3279 spin_lock_init(&port->lock); 3277 3280 port->ctrl_id = 0; 3281 + port->pm = NULL; 3278 3282 port->ops = &serial8250_pops; 3279 3283 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); 3280 3284
+2 -2
drivers/tty/serial/fsl_lpuart.c
··· 1139 1139 unsigned long sr = lpuart32_read(&sport->port, UARTSTAT); 1140 1140 1141 1141 if (sr & (UARTSTAT_PE | UARTSTAT_FE)) { 1142 - /* Read DR to clear the error flags */ 1143 - lpuart32_read(&sport->port, UARTDATA); 1142 + /* Clear the error flags */ 1143 + lpuart32_write(&sport->port, sr, UARTSTAT); 1144 1144 1145 1145 if (sr & UARTSTAT_PE) 1146 1146 sport->port.icount.parity++;
+1
drivers/tty/serial/serial_base.h
··· 16 16 17 17 struct serial_ctrl_device { 18 18 struct device dev; 19 + struct ida port_ida; 19 20 }; 20 21 21 22 struct serial_port_device {
+56 -14
drivers/tty/serial/serial_base_bus.c
··· 10 10 11 11 #include <linux/container_of.h> 12 12 #include <linux/device.h> 13 + #include <linux/idr.h> 13 14 #include <linux/module.h> 14 15 #include <linux/serial_core.h> 15 16 #include <linux/slab.h> ··· 20 19 21 20 static bool serial_base_initialized; 22 21 22 + static const struct device_type serial_ctrl_type = { 23 + .name = "ctrl", 24 + }; 25 + 26 + static const struct device_type serial_port_type = { 27 + .name = "port", 28 + }; 29 + 23 30 static int serial_base_match(struct device *dev, struct device_driver *drv) 24 31 { 25 - int len = strlen(drv->name); 32 + if (dev->type == &serial_ctrl_type && 33 + str_has_prefix(drv->name, serial_ctrl_type.name)) 34 + return 1; 26 35 27 - return !strncmp(dev_name(dev), drv->name, len); 36 + if (dev->type == &serial_port_type && 37 + str_has_prefix(drv->name, serial_port_type.name)) 38 + return 1; 39 + 40 + return 0; 28 41 } 29 42 30 43 static struct bus_type serial_base_bus_type = { ··· 63 48 struct device *parent_dev, 64 49 const struct device_type *type, 65 50 void (*release)(struct device *dev), 66 - int id) 51 + unsigned int ctrl_id, 52 + unsigned int port_id) 67 53 { 68 54 device_initialize(dev); 69 55 dev->type = type; ··· 77 61 return -EPROBE_DEFER; 78 62 } 79 63 80 - return dev_set_name(dev, "%s.%s.%d", type->name, dev_name(port->dev), id); 81 - } 64 + if (type == &serial_ctrl_type) 65 + return dev_set_name(dev, "%s:%d", dev_name(port->dev), ctrl_id); 82 66 83 - static const struct device_type serial_ctrl_type = { 84 - .name = "ctrl", 85 - }; 67 + if (type == &serial_port_type) 68 + return dev_set_name(dev, "%s:%d.%d", dev_name(port->dev), 69 + ctrl_id, port_id); 70 + 71 + return -EINVAL; 72 + } 86 73 87 74 static void serial_base_ctrl_release(struct device *dev) 88 75 { ··· 100 81 return; 101 82 102 83 device_del(&ctrl_dev->dev); 84 + put_device(&ctrl_dev->dev); 103 85 } 104 86 105 87 struct serial_ctrl_device *serial_base_ctrl_add(struct uart_port *port, ··· 113 93 if (!ctrl_dev) 114 94 return ERR_PTR(-ENOMEM); 115 95 96 + ida_init(&ctrl_dev->port_ida); 97 + 116 98 err = serial_base_device_init(port, &ctrl_dev->dev, 117 99 parent, &serial_ctrl_type, 118 100 serial_base_ctrl_release, 119 - port->ctrl_id); 101 + port->ctrl_id, 0); 120 102 if (err) 121 103 goto err_put_device; 122 104 ··· 134 112 return ERR_PTR(err); 135 113 } 136 114 137 - static const struct device_type serial_port_type = { 138 - .name = "port", 139 - }; 140 - 141 115 static void serial_base_port_release(struct device *dev) 142 116 { 143 117 struct serial_port_device *port_dev = to_serial_base_port_device(dev); ··· 145 127 struct serial_ctrl_device *ctrl_dev) 146 128 { 147 129 struct serial_port_device *port_dev; 130 + int min = 0, max = -1; /* Use -1 for max to apply IDA defaults */ 148 131 int err; 149 132 150 133 port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); 151 134 if (!port_dev) 152 135 return ERR_PTR(-ENOMEM); 153 136 137 + /* Device driver specified port_id vs automatic assignment? */ 138 + if (port->port_id) { 139 + min = port->port_id; 140 + max = port->port_id; 141 + } 142 + 143 + err = ida_alloc_range(&ctrl_dev->port_ida, min, max, GFP_KERNEL); 144 + if (err < 0) { 145 + kfree(port_dev); 146 + return ERR_PTR(err); 147 + } 148 + 149 + port->port_id = err; 150 + 154 151 err = serial_base_device_init(port, &port_dev->dev, 155 152 &ctrl_dev->dev, &serial_port_type, 156 153 serial_base_port_release, 157 - port->line); 154 + port->ctrl_id, port->port_id); 158 155 if (err) 159 156 goto err_put_device; 160 157 ··· 183 150 184 151 err_put_device: 185 152 put_device(&port_dev->dev); 153 + ida_free(&ctrl_dev->port_ida, port->port_id); 186 154 187 155 return ERR_PTR(err); 188 156 } 189 157 190 158 void serial_base_port_device_remove(struct serial_port_device *port_dev) 191 159 { 160 + struct serial_ctrl_device *ctrl_dev; 161 + struct device *parent; 162 + 192 163 if (!port_dev) 193 164 return; 194 165 166 + parent = port_dev->dev.parent; 167 + ctrl_dev = to_serial_base_ctrl_device(parent); 168 + 195 169 device_del(&port_dev->dev); 170 + ida_free(&ctrl_dev->port_ida, port_dev->port->port_id); 171 + put_device(&port_dev->dev); 196 172 } 197 173 198 174 static int serial_base_init(void)
+2 -1
include/linux/serial_core.h
··· 459 459 struct serial_rs485 *rs485); 460 460 int (*iso7816_config)(struct uart_port *, 461 461 struct serial_iso7816 *iso7816); 462 - int ctrl_id; /* optional serial core controller id */ 462 + unsigned int ctrl_id; /* optional serial core controller id */ 463 + unsigned int port_id; /* optional serial core port id */ 463 464 unsigned int irq; /* irq number */ 464 465 unsigned long irqflags; /* irq flags */ 465 466 unsigned int uartclk; /* base uart clock */