aboutsummaryrefslogtreecommitdiff
path: root/drivers/tty
AgeCommit message (Collapse)AuthorFilesLines
2017-06-29serial: 8250: Fix THRE flag usage for CAP_MINIPhil Elwell1-0/+4
The BCM2835 MINI UART has non-standard THRE semantics. Conventionally the bit means that the FIFO is empty (although there may still be a byte in the transmit register), but on 2835 it indicates that the FIFO is not full. This causes interrupts after every byte is transmitted, with the FIFO providing some interrupt latency tolerance. A consequence of this difference is that the usual strategy of writing multiple bytes into the TX FIFO after checking THRE once is unsafe. In the worst case of 7 bytes in the FIFO, writing 8 bytes loses all but the first since by then the FIFO is full. There is an HFIFO ("Hidden FIFO") capability that causes the transmit loop to terminate when both THRE and TEMT are set, i.e. when the TX block is completely idle. This is unnecessarily cautious, potentially causing gaps in transmission. Add a new conditional to the transmit loop, predicated on CAP_MINI, that exits when THRE is no longer set (the FIFO is full). This allows the FIFO to fill quickly but subsequent writes are paced by the transmission rate. Signed-off-by: Phil Elwell <[email protected]> Acked-by: Eric Anholt <[email protected]> Acked-by: Andy Shevchenko <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-27tty: add function to convert device name to numberOkash Khawaja1-0/+50
The function converts strings like ttyS0 and ttyUSB0 to dev_t like (4, 64) and (188, 0). It does this by scanning tty_drivers list for corresponding device name and index. If the driver is not registered, this function returns -ENODEV. It also acquires tty_mutex. Signed-off-by: Okash Khawaja <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-20sched/wait: Rename wait_queue_t => wait_queue_entry_tIngo Molnar1-1/+1
Rename: wait_queue_t => wait_queue_entry_t 'wait_queue_t' was always a slight misnomer: its name implies that it's a "queue", but in reality it's a queue *entry*. The 'real' queue is the wait queue head, which had to carry the name. Start sorting this out by renaming it to 'wait_queue_entry_t'. This also allows the real structure name 'struct __wait_queue' to lose its double underscore and become 'struct wait_queue_entry', which is the more canonical nomenclature for such data types. Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
2017-06-20gpio-exar/8250-exar: Fix passing in of parent PCI deviceJan Kiszka1-1/+2
This fixes reloading of the GPIO driver for the same platform device instance as created by the exar UART driver: First of all, the driver sets drvdata to its own value during probing and does not restore the original value on exit. But this won't help anyway as the core clears drvdata after the driver left. Set the platform device parent instead. Signed-off-by: Jan Kiszka <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Linus Walleij <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2017-06-20tty/serial: meson_uart: update to stable bindingsHelmut Klein1-6/+84
This patch handle the stable UART bindings but also keeps compatibility with the legacy non-stable bindings until all boards uses them. Reviewed-by: Jerome Brunet <[email protected]> Signed-off-by: Helmut Klein <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-20serial: Delete dead code for CIR serial portsMatthias Brugger1-17/+6
Commit e4fda3a04275 ("serial: don't register CIR serial ports") adds a check for PORT_8250_CIR to serial8250_register_8250_port(). But the code isn't needed as the function never takes the branch when the port is CIR serial port. This patch deletes the dead code. Signed-off-by: Matthias Brugger <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-20serial: sirf: make of_device_ids constArvind Yadav1-1/+1
of_device_ids are not supposed to change at runtime. All functions working with of_device_ids provided by <linux/of.h> work with const of_device_ids. So mark the non-const structs as const. Signed-off-by: Arvind Yadav <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-20serial/mpsc: switch to dma_alloc_attrsChristoph Hellwig1-4/+6
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-20tty: serial: Add Actions Semi Owl UART earlyconAndreas Färber3-0/+155
This implements an earlycon for Actions Semi S500/S900 SoCs. Based on LeMaker linux-actions tree. Signed-off-by: Andreas Färber <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-16networking: introduce and use skb_put_data()Johannes Berg5-5/+5
A common pattern with skb_put() is to just want to memcpy() some data into the new space, introduce skb_put_data() for this. An spatch similar to the one for skb_put_zero() converts many of the places using it: @@ identifier p, p2; expression len, skb, data; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_data(skb, data, len); | -p = (t)skb_put(skb, len); +p = skb_put_data(skb, data, len); ) ( p2 = (t2)p; -memcpy(p2, data, len); | -memcpy(p, data, len); ) @@ type t, t2; identifier p, p2; expression skb, data; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); ) ( p2 = (t2)p; -memcpy(p2, data, sizeof(*p)); | -memcpy(p, data, sizeof(*p)); ) @@ expression skb, len, data; @@ -memcpy(skb_put(skb, len), data, len); +skb_put_data(skb, data, len); (again, manually post-processed to retain some comments) Reviewed-by: Stephen Hemminger <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2017-06-14tty/serial: atmel: make the driver DT onlyAlexandre Belloni1-63/+33
Now that AVR32 is gone, platform_data are not used to initialize the driver anymore, remove that path from the driver. Also remove the now unused struct atmel_uart_data. Signed-off-by: Alexandre Belloni <[email protected]> Acked-by: Richard Genoud <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-14tty/serial: atmel: remove atmel_default_console_device handlingAlexandre Belloni1-43/+0
atmel_default_console_device was only used by AVR32, in particular arch/avr32/mach-at32ap/at32ap700x.c which is now gone. Remove it from the driver. Signed-off-by: Alexandre Belloni <[email protected]> Acked-by: Richard Genoud <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-13tty: rocket: drop broken alt-speed supportJohan Hovold1-21/+6
Setting an alt_speed using the ROCKET_SPD flags has been deprecated since v2.1.69, and has been broken since commit 6865ff222cca ("TTY: do not warn about setting speed via SPD_*") without anyone noticing. To make things worse commit 6df3526b6649 ("rocket: first pass at termios reporting") in v2.6.25 started reporting back the actual baud rate used, something which also required 38400 to again be set whenever changing a SPD flag. Drop the broken alt-speed handling altogether, and add a ratelimited warning about using TIOCCSERIAL to change speed as being deprecated. Note that the rocket driver has never supported using a custom divisor (ASYNC_SPD_CUST equivalent). Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-13tty: cyclades: drop broken alt-speed supportJohan Hovold1-12/+9
Setting an alt_speed using the ASYNC_SPD flags has been deprecated since v2.1.69, and has been broken since v3.10 and commit 6865ff222cca ("TTY: do not warn about setting speed via SPD_*") without anyone noticing. Drop the broken alt-speed handling altogether, and add a ratelimited warning about using TIOCCSERIAL to to change speed as being deprecated. Note that using ASYNC_SPD_CUST is still supported. Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-13tty: amiserial: drop broken alt-speed supportJohan Hovold1-20/+3
Setting an alt_speed using the ASYNC_SPD flags has been deprecated since v2.1.69, and has been broken since v3.10 and commit 6865ff222cca ("TTY: do not warn about setting speed via SPD_*") without anyone noticing. Drop the broken alt-speed handling altogether, and add a ratelimited warning about using TIOCCSERIAL to change speed as being deprecated. Note that using ASYNC_SPD_CUST is still supported. Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-13serial: rate limit custom-speed deprecation noticeJohan Hovold1-3/+2
Contrary to what a comment claimed, the ASYNC_SPD flags and custom divisor can be set by a non-privileged user so rate limit the deprecation notice as was intended. Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-12s390/hvc_iucv: fix broken Kconfig select statementHeiko Carstens1-1/+1
Select statements in Kconfig do not necessarily enable all required dependencies and can lead to broken configs. This is also the case for the "select IUCV" statement within HVC_IUCV: warning: (HVC_IUCV) selects IUCV which has unmet direct dependencies (NET && S390) Just add the missing "depends on NET" to avoid broken configs. Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
2017-06-12TTY: hvc: convert to use DRIVER_ATTR_RWGreg Kroah-Hartman1-4/+3
We are trying to get rid of DRIVER_ATTR(), and the hvc driver's attribute can be trivially changed to use DRIVER_ATTR_RW(). Cc: Jiri Slaby <[email protected]> Cc: <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-12Merge 4.12-rc5 into staging-nextGreg Kroah-Hartman11-40/+139
We want the IIO fixes and other staging driver fixes in here as well. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09tty: add TIOCGPTPEER ioctlAleksa Sarai1-4/+67
When opening the slave end of a PTY, it is not possible for userspace to safely ensure that /dev/pts/$num is actually a slave (in cases where the mount namespace in which devpts was mounted is controlled by an untrusted process). In addition, there are several unresolvable race conditions if userspace were to attempt to detect attacks through stat(2) and other similar methods [in addition it is not clear how userspace could detect attacks involving FUSE]. Resolve this by providing an interface for userpace to safely open the "peer" end of a PTY file descriptor by using the dentry cached by devpts. Since it is not possible to have an open master PTY without having its slave exposed in /dev/pts this interface is safe. This interface currently does not provide a way to get the master pty (since it is not clear whether such an interface is safe or even useful). Cc: Christian Brauner <[email protected]> Cc: Valentin Rothberg <[email protected]> Signed-off-by: Aleksa Sarai <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09tty: add compat_ioctl callbacksAleksa Sarai1-0/+22
In order to avoid future diversions between fs/compat_ioctl.c and drivers/tty/pty.c, define .compat_ioctl callbacks for the relevant tty_operations structs. Since both pty_unix98_ioctl() and pty_bsd_ioctl() are compatible between 32-bit and 64-bit userspace no special translation is required. Signed-off-by: Aleksa Sarai <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09serial: exar: Leave MPIOs as output for Commtech adaptersJan Kiszka1-4/+11
Commtech adapters apparently need the original setting as outputs, see https://marc.info/?l=linux-gpio&m=149557425201323&w=2. Account for that. Fixes: 7dea8165f1d6 ("serial: exar: Preconfigure xr17v35x MPIOs as output") Signed-off-by: Jan Kiszka <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09tty/serial: atmel: Remove AVR32 bits from the driverAndy Shevchenko2-27/+9
AVR32 is gone. Now it's time to clean up the driver by removing leftovers that was used by AVR32 related code. Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Richard Genoud <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09vt: fix \e[2m using the wrong placeholder color on graphical consolesAdam Borowski1-1/+1
Only vgacon and sisusbcon did it right, the rest (via generic code) tried underline (usually cyan). Signed-off-by: Adam Borowski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09Merge branch 'vt_copy_cleanup' into tty-nextGreg Kroah-Hartman3-51/+19
The vt copy_from/to_user cleanups were in a separate branch for others to work off of. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09vt: drop access_ok() calls in unimap ioctlsAdam Borowski1-8/+0
Done by copy_{from,to}_user(). Signed-off-by: Adam Borowski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09vt: use memdup_user in PIO_UNIMAP ioctlAdam Borowski1-8/+3
Again, a nice linear transfer that simplifies the code. Signed-off-by: Adam Borowski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09vt: use copy_to_user instead of __put_user in GIO_UNIMAP ioctlAdam Borowski1-8/+6
A nice big linear transfer, no need to flip stac/PAN/etc every half-entry. Also, yay __put_user() after checking only read. Signed-off-by: Adam Borowski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09vt: fix unchecked __put_user() in tioclinux ioctlsAdam Borowski1-3/+3
Only read access is checked before this call. Actually, at the moment this is not an issue, as every in-tree arch does the same manual checks for VERIFY_READ vs VERIFY_WRITE, relying on the MMU to tell them apart, but this wasn't the case in the past and may happen again on some odd arch in the future. If anyone cares about 3.7 and earlier, this is a security hole (untested) on real 80386 CPUs. Signed-off-by: Adam Borowski <[email protected]> CC: [email protected] # v3.7- Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09vt: use copy_from/to_user instead of __get/put_user for scrnmap ioctlsAdam Borowski1-24/+7
Linus wants to get rid of these functions, and these uses are especially egregious: they copy a big linear array element by element. Signed-off-by: Adam Borowski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-09tty: serdev: use dev_groups and not dev_attrs for bus_typeGreg Kroah-Hartman1-4/+6
The dev_attrs field has long been "depreciated" and is finally being removed, so move the driver to use the "correct" dev_groups field instead for struct bus_type. Cc: Rob Herring <[email protected]> Cc: Jiri Slaby <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-05Merge 4.12-rc4 into tty-nextGreg Kroah-Hartman1-2/+0
We want the tty locking fix in here, so that maybe we can finally get it fixed for real... Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-04Revert "tty: fix port buffer locking"Greg Kroah-Hartman1-2/+0
This reverts commit 925bb1ce47f429f69aad35876df7ecd8c53deb7e. It causes lots of warnings and problems so for now, let's just revert it. Reported-by: <[email protected]> Reported-by: Russell King <[email protected]> Reported-by: Sergey Senozhatsky <[email protected]> Reported-by: Geert Uytterhoeven <[email protected]> Reported-by: Jiri Slaby <[email protected]> Reported-by: Andrey Konovalov <[email protected]> Acked-by: Vegard Nossum <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-03serial: uartps: Fix kernel doc warningsNava kishore Manne1-0/+1
This patch fixes the kernel doc warnings in the driver. Signed-off-by: Nava kishore Manne <[email protected]> Signed-off-by: Michal Simek <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-03serial: 8250_of: Add reset supportJoel Stanley1-0/+10
This adds the hooks for an optional reset controller in the 8250 device tree node. Signed-off-by: Joel Stanley <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-03tty: n_gsm: do not send/receive in ldisc close pathSascha Hauer1-19/+35
gsm_cleanup_mux() is called in the line discipline close path which is called at tty_release() time. At this stage the tty is no longer operational enough to send any frames. Sending close frames is therefore not possible and waiting for their answers always times out. This patch removes sending close messages and waiting for their answers from the tty_release path. This patch makes explicit what previously implicitly had been the case already: We are not able to tell the modem that we are about to close the multiplexer on our side. This means the modem will stay in multiplexer mode and re-establishing the multiplexer later fails. The only way for userspace to work around this is to manually send a close frame in N_TTY mode after closing the mux. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-03Fix serial console on SNI RM400 machinesThomas Bogendoerfer1-5/+10
sccnxp driver doesn't get the correct uart clock rate, if CONFIG_HAVE_CLOCK is disabled. Correct usage of clk API to make it work with/without it. Fixes: 90efa75f7ab0 (serial: sccnxp: Using CLK API for getting UART clock) Suggested-by: Russell King - ARM Linux <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-06-03tty: handle the case where we cannot restore a line disciplineAlan Cox3-15/+112
Historically the N_TTY driver could never fail but this has become broken over time. Rather than trying to rewrite half the ldisc layer to fix the breakage introduce a second level of fallback with an N_NULL ldisc which cannot fail, and thus restore the guarantees required by the ldisc layer. We still try and fail to N_TTY first. It's much more useful to find yourself back in your old ldisc (first attempt) or in N_TTY (second attempt), and while I'm not aware of any code out there that makes those assumptions it's good to drive(r) defensively. Signed-off-by: Alan Cox <[email protected]> Reported-by: Dmitry Vyukov <[email protected]> Tested-by: Dmitry Vyukov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-29Merge 4.12-rc3 into tty-nextGreg Kroah-Hartman11-40/+141
We need the tty fixes/changes here to handle future work. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-25serial: altera_uart: call iounmap() at driver removeTobias Klauser1-0/+1
The driver calls ioremap() in the probe function but doesn't call iounmap() in the remove function correspondingly. Do so now. Follow commit 5c9d6abed9e0 ("serial: altera_jtaguart: adding iounmap()") Cc: Alexey Khoroshilov <[email protected]> Signed-off-by: Tobias Klauser <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-25serial: imx: ensure UCR3 and UFCR are setup correctlyUwe Kleine-König1-2/+12
Commit e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off") has a flaw: While UCR3 and UFCR were modified using read-modify-write before it switched to write register values independent of the previous state. That's a good idea in principle (and that's why I did it) but needs more care. This patch reinstates read-modify-write for UFCR and for UCR3 ensures that RXDMUXSEL and ADNIMP are set for post imx1. Fixes: e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off") Signed-off-by: Uwe Kleine-König <[email protected]> Acked-by: Mika Penttilä <[email protected]> Tested-by: Mika Penttilä <[email protected]> Acked-by: Steve Twiss <[email protected]> Tested-by: Steve Twiss <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-24serial: 8250: Add CAP_MINI, set for bcm2835auxPhil Elwell3-1/+10
The AUX/mini-UART in the BCM2835 family of procesors is a cut-down 8250 clone. In particular it is lacking support for the following features: CSTOPB PARENB PARODD CMSPAR CS5 CS6 Add a new capability (UART_CAP_MINI) that exposes the restrictions to the user of the termios API by turning off the unsupported features in the request. N.B. It is almost possible to automatically discover the missing features by reading back the LCR register, but the CSIZE bits don't cooperate (contrary to the documentation, both bits are significant, but CS5 and CS6 are mapped to CS7) and the code is much longer. See: https://github.com/raspberrypi/linux/issues/1561 Signed-off-by: Phil Elwell <[email protected]> Acked-by: Eric Anholt <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-24serial: sh-sci: Update warning message in sci_request_dma_chan()Geert Uytterhoeven1-2/+1
The commit below changed a function call from dma_request_slave_channel_compat() to dma_request_slave_channel(), but forgot to update the printed failure message. Fixes: 219fb0c1436e4893 ("serial: sh-sci: Remove the platform data dma slave rx/tx channel IDs") Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-24serial: meson: hide an unused functionArnd Bergmann1-9/+8
The newly added meson_uart_enable_tx_engine function is only called from the console setup, not the runtime uart, which has an open-coded version of the same register access. This produces a harmless warning when the console code is disabled: drivers/tty/serial/meson_uart.c:127:13: error: 'meson_uart_enable_tx_engine' defined but not used [-Werror=unused-function] Let's move the function inside of the #ifdef to avoid the warning. Fixes: ba50f1df13c8 ("serial: meson: remove unneeded variable assignment in meson_serial_port_write") Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-18serial: enable serdev supportJohan Hovold1-2/+2
Enable serdev support by using the new device-registration helpers. Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-18tty/serdev: add serdev registration interfaceJohan Hovold2-2/+79
Add a new interface for registering a serdev controller and clients, and a helper function to deregister serdev devices (or a tty device) that were previously registered using the new interface. Once every driver currently using the tty_port_register_device() helpers have been vetted and converted to use the new serdev registration interface (at least for deregistration), we can move serdev registration to the current helpers and get rid of the serdev-specific functions. Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-18serdev: Restore serdev_device_write_buf for atomic contextStefan Wahren1-0/+12
Starting with commit 6fe729c4bdae ("serdev: Add serdev_device_write subroutine") the function serdev_device_write_buf cannot be used in atomic context anymore (mutex_lock is sleeping). So restore the old behavior. Signed-off-by: Stefan Wahren <[email protected]> Fixes: 6fe729c4bdae ("serdev: Add serdev_device_write subroutine") Acked-by: Rob Herring <[email protected]> Reviewed-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-18serial: core: fix crash in uart_suspend_portLucas Stach1-1/+1
With serdev we might end up with serial ports that have no cdev exported to userspace, as they are used as the bus interface to other devices. In that case serial_match_port() won't be able to find a matching tty_dev. Skip the irq wakeup enabling in that case, as serdev will make sure to keep the port active, as long as there are devices depending on it. Fixes: 8ee3fde04758 (tty_port: register tty ports with serdev bus) Signed-off-by: Lucas Stach <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-18tty: fix port buffer lockingVegard Nossum1-0/+2
tty_insert_flip_string_fixed_flag() is racy against itself when called from the ioctl(TCXONC, TCION/TCIOFF) path [1] and the flush_to_ldisc() workqueue path [2]. The problem is that port->buf.tail->used is modified without consistent locking; the ioctl path takes tty->atomic_write_lock, whereas the workqueue path takes ldata->output_lock. We cannot simply take ldata->output_lock, since that is specific to the N_TTY line discipline. It might seem natural to try to take port->buf.lock inside tty_insert_flip_string_fixed_flag() and friends (where port->buf is actually used/modified), but this creates problems for flush_to_ldisc() which takes it before grabbing tty->ldisc_sem, o_tty->termios_rwsem, and ldata->output_lock. Therefore, the simplest solution for now seems to be to take tty->atomic_write_lock inside tty_port_default_receive_buf(). This lock is also used in the write path [3] with a consistent ordering. [1]: Call Trace: tty_insert_flip_string_fixed_flag pty_write tty_send_xchar // down_read(&o_tty->termios_rwsem) // mutex_lock(&tty->atomic_write_lock) n_tty_ioctl_helper n_tty_ioctl tty_ioctl // down_read(&tty->ldisc_sem) do_vfs_ioctl SyS_ioctl [2]: Workqueue: events_unbound flush_to_ldisc Call Trace: tty_insert_flip_string_fixed_flag pty_write tty_put_char __process_echoes commit_echoes // mutex_lock(&ldata->output_lock) n_tty_receive_buf_common n_tty_receive_buf2 tty_ldisc_receive_buf // down_read(&o_tty->termios_rwsem) tty_port_default_receive_buf // down_read(&tty->ldisc_sem) flush_to_ldisc // mutex_lock(&port->buf.lock) process_one_work [3]: Call Trace: tty_insert_flip_string_fixed_flag pty_write n_tty_write // mutex_lock(&ldata->output_lock) // down_read(&tty->termios_rwsem) do_tty_write (inline) // mutex_lock(&tty->atomic_write_lock) tty_write // down_read(&tty->ldisc_sem) __vfs_write vfs_write SyS_write The bug can result in about a dozen different crashes depending on what exactly gets corrupted when port->buf.tail->used points outside the buffer. The patch passes my LOCKDEP/PROVE_LOCKING testing but more testing is always welcome. Found using syzkaller. Cc: <[email protected]> Signed-off-by: Vegard Nossum <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2017-05-18tty: ehv_bytechan: clean up init error handlingJohan Hovold1-9/+8
Straighten out the initcall error handling to avoid deregistering a never-registered tty driver (something which would lead to a NULL-pointer dereference) in the most unlikely event that driver registration fails (e.g. we've run out of major numbers). Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>