summaryrefslogtreecommitdiffstats
path: root/drivers/tty
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'tty-6.6-rc1' of ↵Linus Torvalds2023-09-01110-1628/+1606
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty Pull tty/serial driver updates from Greg KH: "Here is the big set of tty and serial driver changes for 6.6-rc1. Lots of cleanups in here this cycle, and some driver updates. Short summary is: - Jiri's continued work to make the tty code and apis be a bit more sane with regards to modern kernel coding style and types - cpm_uart driver updates - n_gsm updates and fixes - meson driver updates - sc16is7xx driver updates - 8250 driver updates for different hardware types - qcom-geni driver fixes - tegra serial driver change - stm32 driver updates - synclink_gt driver cleanups - tty structure size reduction All of these have been in linux-next this week with no reported issues. The last bit of cleanups from Jiri and the tty structure size reduction came in last week, a bit late but as they were just style changes and size reductions, I figured they should get into this merge cycle so that others can work on top of them with no merge conflicts" * tag 'tty-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (199 commits) tty: shrink the size of struct tty_struct by 40 bytes tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw() tty: n_tty: extract ECHO_OP processing to a separate function tty: n_tty: unify counts to size_t tty: n_tty: use u8 for chars and flags tty: n_tty: simplify chars_in_buffer() tty: n_tty: remove unsigned char casts from character constants tty: n_tty: move newline handling to a separate function tty: n_tty: move canon handling to a separate function tty: n_tty: use MASK() for masking out size bits tty: n_tty: make n_tty_data::num_overrun unsigned tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun() tty: n_tty: use 'num' for writes' counts tty: n_tty: use output character directly tty: n_tty: make flow of n_tty_receive_buf_common() a bool Revert "tty: serial: meson: Add a earlycon for the T7 SoC" Documentation: devices.txt: Fix minors for ttyCPM* Documentation: devices.txt: Remove ttySIOC* Documentation: devices.txt: Remove ttyIOC* serial: 8250_bcm7271: improve bcm7271 8250 port ...
| * tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw()Jiri Slaby (SUSE)2023-08-271-13/+12
| | | | | | | | | | | | | | | | | | | | | | The code is duplicated to perform the copy twice -- to handle buffer wrap-around. Instead of the duplication, roll this into the loop. (And add some blank lines around to have the code a bit more readable.) Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-15-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: extract ECHO_OP processing to a separate functionJiri Slaby (SUSE)2023-08-271-96/+98
| | | | | | | | | | | | | | | | | | | | __process_echoes() contains ECHO_OPs processing. It is stuffed in a while loop and the whole function is barely readable. Separate it to a new function: n_tty_process_echo_ops(). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-14-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: unify counts to size_tJiri Slaby (SUSE)2023-08-271-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | Some count types are already 'size_t' for a long time. Some were switched to 'size_t' recently. Unify the rest with those now. This allows for some min_t()s to become min()s. And make one min() an explicit min_t() as we are comparing signed 'room' to unsigned 'count'. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-13-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: use u8 for chars and flagsJiri Slaby (SUSE)2023-08-271-36/+36
| | | | | | | | | | | | | | | | Unify with the tty layer and use u8 for both chars and flags. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-12-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: simplify chars_in_buffer()Jiri Slaby (SUSE)2023-08-271-6/+2
| | | | | | | | | | | | | | | | | | | | The 'if' in chars_in_buffer() is misleadingly inverted. And since the only difference is the head used for computation, cache the head using ternary operator. And use that in return directly. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-11-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: remove unsigned char casts from character constantsJiri Slaby (SUSE)2023-08-271-3/+3
| | | | | | | | | | | | | | | | | | We compile with -funsigned-char, so all character constants are already unsigned chars. Therefore, remove superfluous casts. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-10-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: move newline handling to a separate functionJiri Slaby (SUSE)2023-08-271-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | Currently, n_tty handles the newline in a label in n_tty_receive_char_canon(). That is invoked from two more places. Split this code to a separate function and avoid the label in this case. This makes the code flow more understandable. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-9-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: move canon handling to a separate functionJiri Slaby (SUSE)2023-08-271-71/+87
| | | | | | | | | | | | | | | | | | n_tty_receive_char_special() is already complicated enough. Split the canon handling to a separate function: n_tty_receive_char_canon(). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: use MASK() for masking out size bitsJiri Slaby (SUSE)2023-08-271-12/+11
| | | | | | | | | | | | | | | | | | | | In n_tty, there is already a macro to mask out top bits from ring buffer counters. It is MASK() added some time ago. So use it more in the code to make it more readable. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-7-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: make n_tty_data::num_overrun unsignedJiri Slaby (SUSE)2023-08-271-2/+2
| | | | | | | | | | | | | | | | | | n_tty_data::num_overrun is unlikely to overflow in a second. But make it explicitly unsigned to avoid printing negative values. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-6-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun()Jiri Slaby (SUSE)2023-08-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The jiffies tests in n_tty_receive_overrun() are simplified ratelimiting (without locking). We could use struct ratelimit_state and the helpers, but to me, it occurs to be too complex for this use case. But the code currently tests both if the time passed (the first time_after()) and if jiffies wrapped around (the second time_after()). time_is_before_jiffies() takes care of both, provided overrun_time is initialized at the allocation time. So switch to time_is_before_jiffies(), the same what ratelimiting does. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-5-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: use 'num' for writes' countsJiri Slaby (SUSE)2023-08-271-9/+8
| | | | | | | | | | | | | | | | | | | | We have a separate misnomer 'c' to hold the retuned value from tty->ops->write(). Instead, use 'num' already defined on another place (and already properly typed). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-4-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: use output character directlyJiri Slaby (SUSE)2023-08-271-2/+1
| | | | | | | | | | | | | | | | | | | | There is no point to use a local variable to store the character when we can pass it directly. This assignment comes from era when we used to do get_user(c, b). We no longer need this, so fix this. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_tty: make flow of n_tty_receive_buf_common() a boolJiri Slaby (SUSE)2023-08-271-3/+3
| | | | | | | | | | | | | | | | | | The 'flow' parameter of n_tty_receive_buf_common() is meant to be a boolean value. So use bool and alter call sites accordingly. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230827074147.2287-2-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * Revert "tty: serial: meson: Add a earlycon for the T7 SoC"Lucas Tanure2023-08-271-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6a4197f9763325043abf7690a21124a9facbf52e New SoC will use ttyS0 instead of ttyAML, so T7 SoC doesn't need a OF_EARLYCON_DECLARE. Fixes: 6a4197f97633 ("tty: serial: meson: Add a earlycon for the T7 SoC") Signed-off-by: Lucas Tanure <tanure@linux.com> Link: https://lore.kernel.org/r/20230827082944.5100-1-tanure@linux.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: 8250_bcm7271: improve bcm7271 8250 portJustin Chen2023-08-222-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 8250 BCM7271 UART is not a direct match to PORT_16550A and other generic ports do not match its hardware capabilities. PORT_ALTR matches the rx trigger levels, but its vendor configurations are not compatible. Unfortunately this means we need to create another port to fully capture the hardware capabilities of the BCM7271 UART. To alleviate some latency pressures, we default the rx trigger level to 8. Signed-off-by: Justin Chen <justin.chen@broadcom.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Acked-by: Doug Berger <opendmb@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/1692643978-16570-1-git-send-email-justin.chen@broadcom.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sc16is7xx: add missing support for rs485 devicetree propertiesHugo Villeneuve2023-08-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Retrieve rs485 devicetree properties on registration of sc16is7xx ports in case they are attached to an rs485 transceiver. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Lech Perczak <lech.perczak@camlingroup.com> Tested-by: Lech Perczak <lech.perczak@camlingroup.com> Link: https://lore.kernel.org/r/20230807214556.540627-7-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sc16is7xx: fix bug when first setting GPIO directionHugo Villeneuve2023-08-221-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When configuring a pin as an output pin with a value of logic 0, we end up as having a value of logic 1 on the output pin. Setting a logic 0 a second time (or more) after that will correctly output a logic 0 on the output pin. By default, all GPIO pins are configured as inputs. When we enter sc16is7xx_gpio_direction_output() for the first time, we first set the desired value in IOSTATE, and then we configure the pin as an output. The datasheet states that writing to IOSTATE register will trigger a transfer of the value to the I/O pin configured as output, so if the pin is configured as an input, nothing will be transferred. Therefore, set the direction first in IODIR, and then set the desired value in IOSTATE. This is what is done in NXP application note AN10587. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: stable@vger.kernel.org Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Reviewed-by: Lech Perczak <lech.perczak@camlingroup.com> Tested-by: Lech Perczak <lech.perczak@camlingroup.com> Link: https://lore.kernel.org/r/20230807214556.540627-6-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sc16is7xx: fix regression with GPIO configurationHugo Villeneuve2023-08-221-35/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 679875d1d880 ("sc16is7xx: Separate GPIOs from modem control lines") and commit 21144bab4f11 ("sc16is7xx: Handle modem status lines") changed the function of the GPIOs pins to act as modem control lines without any possibility of selecting GPIO function. As a consequence, applications that depends on GPIO lines configured by default as GPIO pins no longer work as expected. Also, the change to select modem control lines function was done only for channel A of dual UART variants (752/762). This was not documented in the log message. Allow to specify GPIO or modem control line function in the device tree, and for each of the ports (A or B). Do so by using the new device-tree property named "nxp,modem-control-line-ports" (property added in separate patch). When registering GPIO chip controller, mask-out GPIO pins declared as modem control lines according to this new DT property. Fixes: 679875d1d880 ("sc16is7xx: Separate GPIOs from modem control lines") Fixes: 21144bab4f11 ("sc16is7xx: Handle modem status lines") Cc: stable@vger.kernel.org Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lech Perczak <lech.perczak@camlingroup.com> Tested-by: Lech Perczak <lech.perczak@camlingroup.com> Acked-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230807214556.540627-5-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sc16is7xx: remove obsolete out_thread labelHugo Villeneuve2023-08-221-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit c8f71b49ee4d ("serial: sc16is7xx: setup GPIO controller later in probe") moved GPIO setup code later in probe function. Doing so also required to move ports cleanup code (out_ports label) after the GPIO cleanup code. After these moves, the out_thread label becomes misplaced and makes part of the cleanup code illogical. This patch remove the now obsolete out_thread label and make GPIO setup code jump to out_ports label if it fails. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Reviewed-by: Lech Perczak <lech.perczak@camlingroup.com> Tested-by: Lech Perczak <lech.perczak@camlingroup.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230807214556.540627-3-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sc16is7xx: fix broken port 0 uart initHugo Villeneuve2023-08-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The sc16is7xx_config_rs485() function is called only for the second port (index 1, channel B), causing initialization problems for the first port. For the sc16is7xx driver, port->membase and port->mapbase are not set, and their default values are 0. And we set port->iobase to the device index. This means that when the first device is registered using the uart_add_one_port() function, the following values will be in the port structure: port->membase = 0 port->mapbase = 0 port->iobase = 0 Therefore, the function uart_configure_port() in serial_core.c will exit early because of the following check: /* * If there isn't a port here, don't do anything further. */ if (!port->iobase && !port->mapbase && !port->membase) return; Typically, I2C and SPI drivers do not set port->membase and port->mapbase. The max310x driver sets port->membase to ~0 (all ones). By implementing the same change in this driver, uart_configure_port() is now correctly executed for all ports. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: stable@vger.kernel.org Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Lech Perczak <lech.perczak@camlingroup.com> Tested-by: Lech Perczak <lech.perczak@camlingroup.com> Link: https://lore.kernel.org/r/20230807214556.540627-2-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: 8250_dw: fall back to poll if there's no interruptJisheng Zhang2023-08-221-1/+4
| | | | | | | | | | | | | | | | | | | | When there's no irq(this can be due to various reasons, for example, no irq from HW support, or we just want to use poll solution, and so on), falling back to poll is still better than no support at all. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Link: https://lore.kernel.org/r/20230806092056.2467-3-jszhang@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: tegra: handle clk prepare error in tegra_uart_hw_init()Yi Yang2023-08-221-1/+5
| | | | | | | | | | | | | | | | | | | | In tegra_uart_hw_init(), the return value of clk_prepare_enable() should be checked since it might fail. Fixes: e9ea096dd225 ("serial: tegra: add serial driver") Signed-off-by: Yi Yang <yiyang13@huawei.com> Link: https://lore.kernel.org/r/20230817105406.228674-1-yiyang13@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sifive: Add suspend and resume operationsNick Hu2023-08-221-0/+18
| | | | | | | | | | | | | | | | | | | | | | If the Sifive Uart is not used as the wake up source, suspend the uart before the system enter the suspend state to prevent it woken up by unexpected uart interrupt. Resume the uart once the system woken up. Signed-off-by: Nick Hu <nick.hu@sifive.com> Reviewed-by: Ben Dooks <ben.dooks@codethink.co.uk> Link: https://lore.kernel.org/r/20230815090216.2575971-1-nick.hu@sifive.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: serial: meson: Add a earlycon for the T7 SoCLucas Tanure2023-08-221-0/+2
| | | | | | | | | | | | | | | | | | | | The new Amlogic T7 SoC does not have a always-on uart, so add OF_EARLYCON_DECLARE for it. Signed-off-by: Lucas Tanure <tanure@linux.com> Acked-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20230814080128.143613-2-tanure@linux.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: stm32: synchronize RX DMA channel in shutdownAmelie Delaunay2023-08-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | In shutdown, RX DMA channel is terminated. If the DMA RX callback is scheduled but not yet executed, while a new RX DMA transfer is started, the callback can be executed, and then disturb the ongoing RX DMA transfer. To avoid such a case, call dmaengine_synchronize in shutdown, after the DMA RX channel is terminated. Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20230808161906.178996-7-valentin.caron@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: stm32: replace access to DMAR bit by dmaengine_pause/resumeValentin Caron2023-08-221-94/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's rather advised to rely on DMA pause / resume instead of clearing/setting DMA request enable bit for the same purpose. Some DMA request/acknowledge race may encountered by doing so. We prefer to use dmaengine_pause and resume instead to pause a dma transfer when it is necessary. Create two new functions (stm32_usart_rx_dma_pause, stm32_usart_rx_dma _resume) to handle dma error when pausing/resuming. And rename stm32_usart_start_rx_dma_cyclic() to stm32_usart_rx_dma_start_or_resume() and use this function to resume an rx dma transfer. If resume fail, stm32_usart_rx_dma_start_or_resume can create a new transfer to continue. It is also safer to close DMA before reset DMAR in stm32_usart_shutdown. Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20230808161906.178996-6-valentin.caron@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: stm32: group dma pause/resume error handling into single functionValentin Caron2023-08-222-45/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | Create new function "stm32_usart_dma_pause_resume" that called dmaengine_ pause/resume and in case of error, terminate dma transaction. Two other functions are created to facilitate the use of stm32_usart_dma _pause_resume : stm32_usart_tx_dma_pause, stm32_usart_tx_dma_resume. Equivalent functions for rx will be added in future patch. Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20230808161906.178996-5-valentin.caron@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: stm32: modify parameter and rename stm32_usart_rx_dma_enabledValentin Caron2023-08-221-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | Rename stm32_usart_rx_dma_enabled to stm32_usart_rx_dma_started in order to match with stm32_usart_tx_dma_started. Modify argument of stm32_usart_rx_dma_started from uart_port structure to stm32_port structure to match with stm32_usart_tx_dma_started. Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20230808161906.178996-4-valentin.caron@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: stm32: use DMAT as a configuration bitValentin Caron2023-08-221-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | DMAT is a configuration bit so it should be set at the startup of uart port and not when a DMA transfer begins. This patch move set of DMAT into set_termios and remove DMAT reset except in shutdown. Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20230808161906.178996-3-valentin.caron@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: stm32: avoid clearing DMAT bit during transferValentin Caron2023-08-221-32/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It's rather advised to rely on DMA pause / resume instead of clearing/setting DMA request enable bit for the same purpose. Some DMA request/acknowledge race may encountered by doing so. We prefer to use dmaengine_pause and resume instead to pause a dma transfer when it is necessary. It is also safer to close DMA before reset DMAT in stm32_usart_shutdown. Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Link: https://lore.kernel.org/r/20230808161906.178996-2-valentin.caron@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: add restart flag to extended ioctl configDaniel Starke2023-08-221-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, changing the parameters of the n_gsm mux gives no direct control to the user whether this should trigger a mux reset or not. The decision is solely made by the driver based on the assumption which parameter changes are compatible or not. Therefore, the user has no means to perform an automatic mux reset after parameter configuration for non-conflicting changes. Add the parameter 'flags' to 'gsm_config_ext' to force a mux reset after ioctl setting regardless of whether the changes made require this or not by setting this to 'GSM_FL_RESTART'. This is done similar to 'GSM_FL_RESTART' in gsm_dlci_config.flags. Note that 'GSM_FL_RESTART' is currently the only allowed flag to allow additions here. Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-9-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: cleanup gsm_control_command and gsm_control_replyDaniel Starke2023-08-221-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | There are multiple places in gsm_control_command and gsm_control_reply that derive the specific DLCI handle directly out of the DLCI table in gsm. Add a local variable which holds this handle and use it instead to improve code readability. Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-7-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: increase gsm_mux unsupported counted where appropriateDaniel Starke2023-08-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The structure gsm_mux contains the 'unsupported' field. However, there is currently no place in the code which increases this counter. Increase the 'unsupported' statistics counter in the following case: - an unsupported frame type has been requested by the peer via parameter negotiation - a control frame with an unsupported but known command has been received Note that we have no means to detect an inconsistent/unsupported adaptation sufficient accuracy as this changes the structure of the UI/UIH frames. E.g. a one byte header is added in case of convergence layer type 2 instead of 1 and contains the modem signal octet with the state of the signal lines. There is no checksum or other value which indicates of this field is correct or should be present. Therefore, we can only assume protocol correctness here. See also 'gsm_dlci_data()' where this is handled. Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-6-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: increase malformed counter for malformed control framesDaniel Starke2023-08-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The malformed counter in gsm_mux is already increased in case of errors detected in gsm_queue() and gsm1_receive(). gsm_dlci_command() also detects a case for a malformed frame but does not increase the malformed counter yet. Fix this by also increasing the gsm_mux malformed counter in case of a malformed frame in gsm_dlci_command(). Note that the malformed counter is not yet exposed and only set internally. Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-5-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: add open_error counter to gsm_muxDaniel Starke2023-08-221-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the n_gsm link statistics by a failed link open counter in preparation for an upcoming patch which will expose these. This counter is increased whenever an attempt to open the control channel failed. This is true in the following cases: - new DLCI allocation failed - connection request (SAMB) with invalid CR flag has been received - connection response (UA) timed out - parameter negotiation timed out or failed Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-4-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: remove unneeded initialization of ret in gsm_dlci_configDaniel Starke2023-08-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The variable 'ret' is not used before assignment from gsm_activate_mux(). Still it gets initialized to zero at declaration. Fix this as remarked in the link below by moving the declaration to the first assignment. Link: https://lore.kernel.org/all/b42bc4d1-cc9d-d115-c981-aaa053bdc59f@kernel.org/ Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-3-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: n_gsm: add restart flag to DLC specific ioctl configDaniel Starke2023-08-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, changing the parameters of a DLCI gives no direct control to the user whether this should trigger a channel reset or not. The decision is solely made by the driver based on the assumption which parameter changes are compatible or not. Therefore, the user has no means to perform an automatic channel reset after parameter configuration for non-conflicting changes. Add the parameter 'flags' to 'gsm_dlci_config' to force a channel reset after ioctl setting regardless of whether the changes made require this or not by setting this to 'GSM_FL_RESTART'. Note that 'GSM_FL_RESTART' is currently the only allow flag to allow additions here. Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230817093231.2317-1-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: invert conditions in __tty_buffer_request_room()Jiri Slaby (SUSE)2023-08-221-22/+22
| | | | | | | | | | | | | | | | | | | | | | We are used to handle "bad" states in the 'if's in the kernel. Refactor (invert the two conditions in) __tty_buffer_request_room(), so that the code returns from the fast paths immediately instead of postponing to the heavy end of the function. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-11-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: initialize variables in initializers alreadyJiri Slaby (SUSE)2023-08-221-10/+3
| | | | | | | | | | | | | | | | It makes the code both more compact, and more understandable. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-10-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: better types in __tty_buffer_request_room()Jiri Slaby (SUSE)2023-08-221-1/+2
| | | | | | | | | | | | | | | | | | | | * use bool for 'change' as it holds a result of a boolean. * use size_t for 'left', so it is the same as 'size' which it is compared to. Both are supposed to contain an unsigned value. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-9-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: use __tty_insert_flip_string_flags() in tty_insert_flip_char()Jiri Slaby (SUSE)2023-08-221-26/+0
| | | | | | | | | | | | | | | | | | | | | | | | Use __tty_insert_flip_string_flags() for the slow path of tty_insert_flip_char(). The former is generic enough, so there is no reason to reimplement the injection once again. So now we have a single function stuffing into tty buffers. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: let tty_prepare_flip_string() return size_tJiri Slaby (SUSE)2023-08-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The same as in the previous patch, tty_prepare_flip_string() accepts size_t as an size argument. It returns the same size (or less). It is unexpected that it returns a signed value and can confuse users to check for negative values. Instead, return the same size_t as accepted to make clear we return values >= 0, where zero in fact means failure. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-7-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: switch insert functions to size_tJiri Slaby (SUSE)2023-08-221-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | All the functions accept size_t as a size argument. They finally return the same size (or less). It is quite unexpected that they return a signed value and can confuse users to check for negative values. Instead, return the same size_t as accepted to make clear we return values >= 0, where zero in fact means failure. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-6-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: warn if losing flags in __tty_insert_flip_string_flags()Jiri Slaby (SUSE)2023-08-221-0/+3
| | | | | | | | | | | | | | | | | | And add a WARN_ON_ONCE(need_flags) to make sure we are not losing flags in __tty_insert_flip_string_flags(). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-5-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: unify tty_insert_flip_string_{fixed_flag,flags}()Jiri Slaby (SUSE)2023-08-221-55/+15
| | | | | | | | | | | | | | | | | | | | They both do the same except for flags. One mem-copies the flags from the caller, the other mem-sets to one flag given by the caller. This can be unified with a simple if in the unified function. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-4-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: tty_buffer: use struct_size() in tty_buffer_alloc()Jiri Slaby (SUSE)2023-08-221-2/+1
| | | | | | | | | | | | | | | | | | | | Now, that tty_buffer::data has the right type, use struct_size() for size calculation. struct_size() makes the code less error-prone and more readable. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230816105530.3335-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * Merge commit b320441c04c9 ("Merge tag 'tty-6.5-rc7' of ↵Greg Kroah-Hartman2023-08-207-20/+68
| |\ | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty") into tty-next We need the serial-core fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * | tty: vcc: convert counts to size_tJiri Slaby (SUSE)2023-08-111-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unify the type of tty_operations::write() counters with the 'count' parameter. I.e. use size_t for them. This includes changing vcc_port::chars_in_buffer to size_t to keep min() and avoid min_t(). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Link: https://lore.kernel.org/r/20230810091510.13006-34-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>