Skip to content
Permalink
Hammer-Hsieh/d…
Switch branches/tags

Commits on Nov 10, 2021

  1. serial:sunplus-uart:Add Sunplus SoC UART Driver

    Add Sunplus SoC UART Driver
    
    Signed-off-by: Hammer Hsieh <hammer.hsieh@sunplus.com>
    Hammer Hsieh authored and intel-lab-lkp committed Nov 10, 2021
  2. dt-bindings:serial:Add bindings doc for Sunplus SoC UART Driver

    Add bindings doc for Sunplus SoC UART Driver
    
    Signed-off-by: Hammer Hsieh <hammer.hsieh@sunplus.com>
    Hammer Hsieh authored and intel-lab-lkp committed Nov 10, 2021

Commits on Oct 30, 2021

  1. tty: Fix extra "not" in TTY_DRIVER_REAL_RAW description

    TTY_DRIVER_REAL_RAW flag (which is always set for e.g. serial ports)
    documentation says that driver must always set special character
    handling flags in certain conditions.
    
    However, as the following sentence makes clear, what is actually
    intended is the opposite.
    
    Fix that by removing the unintended double negation.
    
    Acked-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Link: https://lore.kernel.org/r/20211027102124.3049414-1-anssi.hannula@bitwise.fi
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    anssih authored and gregkh committed Oct 30, 2021
  2. serial: cpm_uart: Protect udbg definitions by CONFIG_SERIAL_CPM_CONSOLE

    If CONFIG_CONSOLE_POLL=y, and CONFIG_SERIAL_CPM=m (hence
    CONFIG_SERIAL_CPM_CONSOLE=n):
    
        drivers/tty/serial/cpm_uart/cpm_uart_core.c:1109:12: warning: ‘udbg_cpm_getc’ defined but not used [-Wunused-function]
         1109 | static int udbg_cpm_getc(void)
    	  |            ^~~~~~~~~~~~~
        drivers/tty/serial/cpm_uart/cpm_uart_core.c:1095:13: warning: ‘udbg_cpm_putc’ defined but not used [-Wunused-function]
         1095 | static void udbg_cpm_putc(char c)
    	  |             ^~~~~~~~~~~~~
    
    Fix this by making the udbg definitions depend on
    CONFIG_SERIAL_CPM_CONSOLE, in addition to CONFIG_CONSOLE_POLL.
    
    Fixes: a605260 ("tty: serial: cpm_uart: Add udbg support for enabling xmon")
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Link: https://lore.kernel.org/r/20211027075326.3270785-1-geert@linux-m68k.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    geertu authored and gregkh committed Oct 30, 2021

Commits on Oct 26, 2021

  1. tty: rpmsg: Define tty name via constant string literal

    Driver uses already twice the same string literal.
    
    Define it in one place, so every user will have this
    name consistent.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211025135148.53944-5-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  2. tty: rpmsg: Add pr_fmt() to prefix messages

    Make all messages to be prefixed in a unified way.
    Add pr_fmt() to achieve this.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211025135148.53944-4-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  3. tty: rpmsg: Use dev_err_probe() in ->probe()

    It's fine to use dev_err_probe() in ->probe() even if we know
    it won't be deferred.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211025135148.53944-3-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  4. tty: rpmsg: Unify variable used to keep an error code

    In some ret is used, in the other err. Let's unify it across the driver.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211025135148.53944-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  5. tty: rpmsg: Assign returned id to a local variable

    Instead of putting garbage in the data structure, assign allocated id
    or an error code to a temporary variable. This makes code cleaner.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211025135148.53944-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  6. serial: stm32: push DMA RX data before suspending

    Data may be stored in DMA RX buffer, when suspending. The data needs
    to be pushed to the upper layer. We can't rely on the timeout IRQ (RTOR)
    that can't be triggered into low power state. So safely clear DMA request
    (DMAR), force the DMA reception routines to push RX buffer content, before
    disabling RX DMA. This way, handover to pio mode is safe.
    Only call tty_flip_buffer_push() when there is RX data to handle.
    
    Move the locking outside of stm32_usart_receive_chars() to prevent a race
    condition, when disabling DMA request upon suspend / pm_runtime_suspend.
    Data may be received under IRQ and pushed before
    stm32_usart_receive_chars() has pushed older data from DMA rx_buf upon
    suspend.
    The sequence in suspend routine needs proper locking to avoid this.
    
    Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
    Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
    Link: https://lore.kernel.org/r/20211025134229.8456-4-erwan.leray@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Erwan Le Ray authored and gregkh committed Oct 26, 2021
  7. serial: stm32: terminate / restart DMA transfer at suspend / resume

    DMA prevents the system to suspend when an UART RX wake-up source is
    using DMA. DMA can't suspend while DMA channels are still active.
    
    Terminate DMA transfer at suspend, and restart a new DMA transfer at
    resume. Create stm32_usart_start_rx_dma_cyclic function to factorize
    dma RX initialization. Move RX DMA code related to wakeup into
    stm32_usart_serial_en_wakeup() routine to ease further improvements
    on wakeup from low power modes.
    
    Don't enable/disable wakeup on uninitialized port.
    
    There may be data residue in the RX FIFO while suspending. Flush it at
    suspend time. Receiver timeout interrupt won't trigger later in low power
    mode, so call stm32_usart_receive_chars() in case there's data to handle.
    
    Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
    Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
    Link: https://lore.kernel.org/r/20211025134229.8456-3-erwan.leray@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Erwan Le Ray authored and gregkh committed Oct 26, 2021
  8. serial: stm32: rework RX dma initialization and release

    The RX DMA channel is kept active forever (from the probe). That prevents
    going to low power mode when it is used. This change moves the
    DMA configuration and enabling procedures to startup routine to allow
    transition to low power mode.
    The DMA disabling procedure is implemented in stop_rx routine as this
    ops has to stop characters reception, and DMA transation in shutdown.
    Clean useless dma_async_tx_descriptor initialization to NULL value.
    
    Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
    Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
    Link: https://lore.kernel.org/r/20211025134229.8456-2-erwan.leray@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Erwan Le Ray authored and gregkh committed Oct 26, 2021
  9. serial: 8250_pci: Remove empty stub pci_quatech_exit()

    The ->exit() callback is checked for presence anyway,
    no need to have an empty stub.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211026133452.61657-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  10. serial: 8250_pci: Replace custom pci_match_id() implementation

    Replace pci_quatech_amcc() with generic pci_match_id().
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20211026133452.61657-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  11. serial: xilinx_uartps: Fix race condition causing stuck TX

    xilinx_uartps .start_tx() clears TXEMPTY when enabling TXEMPTY to avoid
    any previous TXEVENT event asserting the UART interrupt. This clear
    operation is done immediately after filling the TX FIFO.
    
    However, if the bytes inserted by cdns_uart_handle_tx() are consumed by
    the UART before the TXEMPTY is cleared, the clear operation eats the new
    TXEMPTY event as well, causing cdns_uart_isr() to never receive the
    TXEMPTY event. If there are bytes still queued in circbuf, TX will get
    stuck as they will never get transferred to FIFO (unless new bytes are
    queued to circbuf in which case .start_tx() is called again).
    
    While the racy missed TXEMPTY occurs fairly often with short data
    sequences (e.g. write 1 byte), in those cases circbuf is usually empty
    so no action on TXEMPTY would have been needed anyway. On the other
    hand, longer data sequences make the race much more unlikely as UART
    takes longer to consume the TX FIFO. Therefore it is rare for this race
    to cause visible issues in general.
    
    Fix the race by clearing the TXEMPTY bit in ISR *before* filling the
    FIFO.
    
    The TXEMPTY bit in ISR will only get asserted at the exact moment the
    TX FIFO *becomes* empty, so clearing the bit before filling FIFO does
    not cause an extra immediate assertion even if the FIFO is initially
    empty.
    
    This is hard to reproduce directly on a normal system, but inserting
    e.g. udelay(200) after cdns_uart_handle_tx(port), setting 4000000 baud,
    and then running "dd if=/dev/zero bs=128 of=/dev/ttyPS0 count=50"
    reliably reproduces the issue on my ZynqMP test system unless this fix
    is applied.
    
    Fixes: 85baf54 ("tty: xuartps: support 64 byte FIFO size")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Link: https://lore.kernel.org/r/20211026102741.2910441-1-anssi.hannula@bitwise.fi
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    anssih authored and gregkh committed Oct 26, 2021
  12. serial: sunzilog: Mark sunzilog_putchar() __maybe_unused

    If CONSOLE_POLL=n, CONFIG_SERIAL_SUNZILOG_CONSOLE=n, and CONFIG_SERIO=m:
    
        drivers/tty/serial/sunzilog.c:1128:13: error: ‘sunzilog_putchar’ defined but not used [-Werror=unused-function]
         1128 | static void sunzilog_putchar(struct uart_port *port, int ch)
    	  |             ^~~~~~~~~~~~~~~~
    
    Fix this by marking sunzilog_putchar() __maybe_unused.
    
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Link: https://lore.kernel.org/r/20211026080426.2444756-1-geert@linux-m68k.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    geertu authored and gregkh committed Oct 26, 2021
  13. Revert "tty: hvc: pass DMA capable memory to put_chars()"

    This reverts commit 0986d7b.
    
    It still has some issues and needs to be dropped at this point in time.
    
    Link: https://lore.kernel.org/r/208f7a41-a9fa-630c-cb44-c37c503f3a72@kernel.org
    Reported-by: Jiri Slaby <jirislaby@kernel.org>
    Cc: Xianting Tian <xianting.tian@linux.alibaba.com>
    Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed Oct 26, 2021
  14. Revert "virtio-console: remove unnecessary kmemdup()"

    This reverts commit 9db81ec.
    
    A dependant patch on this one needs to be reverted, so this one also
    needs to be reverted at this point in time.
    
    Link: https://lore.kernel.org/r/208f7a41-a9fa-630c-cb44-c37c503f3a72@kernel.org
    Reported-by: Jiri Slaby <jirislaby@kernel.org>
    Cc: Xianting Tian <xianting.tian@linux.alibaba.com>
    Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed Oct 26, 2021
  15. serial: 8250_pci: Replace dev_*() by pci_*() macros

    PCI subsystem provides convenient shortcut macros for message printing.
    Use those macros instead of dev_*().
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Jiri Slaby <jslaby@kernel.org>
    Link: https://lore.kernel.org/r/20211022135147.70965-3-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  16. serial: 8250_pci: Get rid of redundant 'else' keyword

    The 'else' keyword is not needed when previous conditional branch returns
    to the upper layer. Get rid of redundant 'else' keyword in such cases.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Jiri Slaby <jslaby@kernel.org>
    Link: https://lore.kernel.org/r/20211022135147.70965-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021
  17. serial: 8250_pci: Refactor the loop in pci_ite887x_init()

    The loop can be refactored by using ARRAY_SIZE() instead of NULL terminator.
    This reduces code base and makes it easier to read and understand.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Jiri Slaby <jslaby@kernel.org>
    Link: https://lore.kernel.org/r/20211022135147.70965-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    andy-shev authored and gregkh committed Oct 26, 2021

Commits on Oct 21, 2021

  1. tty: add rpmsg driver

    This driver exposes a standard TTY interface on top of the rpmsg
    framework through a rpmsg service.
    
    This driver supports multi-instances, offering a /dev/ttyRPMSGx entry
    per rpmsg endpoint.
    
    Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
    Link: https://lore.kernel.org/r/20211015094701.5732-3-arnaud.pouliquen@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    arnopo authored and gregkh committed Oct 21, 2021
  2. rpmsg: core: add API to get MTU

    Return the rpmsg buffer MTU for sending message, so rpmsg users
    can split a long message in several sub rpmsg buffers.
    
    Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Acked-by: Suman Anna <s-anna@ti.com>
    Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
    Link: https://lore.kernel.org/r/20211015094701.5732-2-arnaud.pouliquen@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    arnopo authored and gregkh committed Oct 21, 2021
  3. serial: 8250_dw: drop bogus uartclk optimisation

    The driver was updating the port uartclk before setting the new rate in
    an attempt to avoid having the clock notifier redundantly update the
    divisors.
    
    The set_termios() callback is however called under the termios semaphore
    and tty-port mutex so the worker scheduled by the clock notifier will
    block in serial8250_update_uartclk() until the uartclk and divisors have
    been updated anyway.
    
    Drop the unnecessary swaps and incorrect comment and simply update the
    uartclk field if the clock-rate change was successful.
    
    Tested-by: Serge Semin <fancer.lancer@gmail.com>
    Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
    Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211015111422.1027-4-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jhovold authored and gregkh committed Oct 21, 2021
  4. serial: 8250: rename unlock labels

    Rename a couple of oddly named labels that are used to unlock before
    returning after what they do (rather than after the context they are
    used in) to improve readability.
    
    Tested-by: Serge Semin <fancer.lancer@gmail.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211015111422.1027-3-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jhovold authored and gregkh committed Oct 21, 2021
  5. serial: 8250: fix racy uartclk update

    Commit 868f3ee ("serial: 8250: Add 8250 port clock update method")
    added a hack to support SoCs where the UART reference clock can
    change behind the back of the driver but failed to add the proper
    locking.
    
    First, make sure to take a reference to the tty struct to avoid
    dereferencing a NULL pointer if the clock change races with a hangup.
    
    Second, the termios semaphore must be held during the update to prevent
    a racing termios change.
    
    Fixes: 868f3ee ("serial: 8250: Add 8250 port clock update method")
    Fixes: c8dff3a ("serial: 8250: Skip uninitialized TTY port baud rate update")
    Cc: stable@vger.kernel.org      # 5.9
    Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>
    Tested-by: Serge Semin <fancer.lancer@gmail.com>
    Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
    Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211015111422.1027-2-johan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jhovold authored and gregkh committed Oct 21, 2021
  6. serial: stm32: update throttle and unthrottle ops for dma mode

    Disable DMA request line (if enabled) to switch in PIO mode in throttle
    ops, so the RX data gets queues into the FIFO. The hardware flow control
    is triggered when the RX FIFO is full.
    
    Switch back to DMA mode (re-enable DMA request line) in unthrottle ops.
    Hardware flow control is stopped when FIFO is not full anymore.
    
    Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
    Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
    Link: https://lore.kernel.org/r/20211020150332.10214-4-erwan.leray@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Erwan Le Ray authored and gregkh committed Oct 21, 2021
  7. serial: stm32: rework RX over DMA

    This patch reworks RX support over DMA to improve reliability:
    - change dma buffer cyclic configuration by using 2 periods. DMA buffer
    data are handled by a flip-flop between the 2 periods in order to avoid
    risk of data loss/corruption
    - change the size of dma buffer to 4096 to limit overruns
    - add rx errors management (breaks, parity, framing and overrun).
      When an error occurs on the uart line, the dma request line is masked at
      HW level. The SW must 1st clear DMAR (dma request line enable), to
      handle the error, then re-enable DMAR to recover. So, any correct data
      is taken from the DMA buffer, before handling the error itself. Then
      errors are handled from RDR/ISR/FIFO (e.g. in PIO mode). Last, DMA
      reception is resumed.
    - add a condition on DMA request line in DMA RX routines in order to
    switch to PIO mode when no DMA request line is disabled, even if the DMA
    channel is still enabled.
      When the UART is wakeup source and is configured to use DMA for RX, any
      incoming data that wakes up the system isn't correctly received.
      At data reception, the irq_handler handles the WUF irq, and then the
      data reception over DMA.
      As the DMA transfer has been terminated at suspend, and will be restored
      by resume callback (which has no yet been called by system), the data
      can't be received.
      The wake-up data has to be handled in PIO mode while suspend callback
      has not been called.
    
    Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
    Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
    Link: https://lore.kernel.org/r/20211020150332.10214-3-erwan.leray@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Erwan Le Ray authored and gregkh committed Oct 21, 2021
  8. serial: stm32: re-introduce an irq flag condition in usart_receive_chars

    Re-introduce an irq flag condition in usart_receive_chars.
    This condition has been deleted by commit 75f4e83 ("serial: do not
    restore interrupt state in sysrq helper").
    This code was present to handle threaded case, and has been removed
    because it is no more needed in this case. Nevertheless an irq safe lock
    is still needed in some cases, when DMA should be stopped to receive errors
    or breaks in PIO mode.
    This patch is a precursor to the complete rework or stm32 serial driver
    DMA implementation.
    
    Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
    Link: https://lore.kernel.org/r/20211020150332.10214-2-erwan.leray@foss.st.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Erwan Le Ray authored and gregkh committed Oct 21, 2021
  9. virtio-console: remove unnecessary kmemdup()

    This revert commit c4baad5 ("virtio-console: avoid DMA from stack")
    
    hvc framework will never pass stack memory to the put_chars() function,
    So the calling of kmemdup() is unnecessary, we can remove it.
    
    Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
    Reviewed-by: Shile Zhang <shile.zhang@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20211015024658.1353987-4-xianting.tian@linux.alibaba.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Xianting Tian authored and gregkh committed Oct 21, 2021
  10. tty: hvc: pass DMA capable memory to put_chars()

    As well known, hvc backend can register its opertions to hvc backend.
    the operations contain put_chars(), get_chars() and so on.
    
    Some hvc backend may do dma in its operations. eg, put_chars() of
    virtio-console. But in the code of hvc framework, it may pass DMA
    incapable memory to put_chars() under a specific configuration, which
    is explained in commit c4baad5(virtio-console: avoid DMA from stack):
    1, c[] is on stack,
       hvc_console_print():
            char c[N_OUTBUF] __ALIGNED__;
            cons_ops[index]->put_chars(vtermnos[index], c, i);
    2, ch is on stack,
       static void hvc_poll_put_char(,,char ch)
       {
            struct tty_struct *tty = driver->ttys[0];
            struct hvc_struct *hp = tty->driver_data;
            int n;
    
            do {
                    n = hp->ops->put_chars(hp->vtermno, &ch, 1);
            } while (n <= 0);
       }
    
    Commit c4baad5 is just the fix to avoid DMA from stack memory, which
    is passed to virtio-console by hvc framework in above code. But I think
    the fix is aggressive, it directly uses kmemdup() to alloc new buffer
    from kmalloc area and do memcpy no matter the memory is in kmalloc area
    or not. But most importantly, it should better be fixed in the hvc
    framework, by changing it to never pass stack memory to the put_chars()
    function in the first place. Otherwise, we still face the same issue if
    a new hvc backend using dma added in the furture.
    
    In this patch, add 'char cons_outbuf[]' as part of 'struct hvc_struct',
    so hp->cons_outbuf is no longer the stack memory, we can use it in above
    cases safely. We also add lock to protect cons_outbuf instead of using
    the global lock of hvc.
    
    Introduce another array(cons_hvcs[]) for hvc pointers next to the
    cons_ops[] and vtermnos[] arrays. With the array, we can easily find
    hvc's cons_outbuf and its lock.
    
    With the patch, we can revert the fix c4baad5.
    
    Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
    Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20211015024658.1353987-3-xianting.tian@linux.alibaba.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Xianting Tian authored and gregkh committed Oct 21, 2021
  11. tty: hvc: use correct dma alignment size

    Use L1_CACHE_BYTES as the dma alignment size, use 'sizeof(long)' as
    dma alignment is wrong.
    
    Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
    Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20211015024658.1353987-2-xianting.tian@linux.alibaba.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Xianting Tian authored and gregkh committed Oct 21, 2021
  12. serial: imx: disable console clocks on unregister

    During console setup imx_uart_console_setup() enables clocks, but they
    are never disabled when the console is unregistered, this leads to
    clk_prepare_enable() being called multiple times without a matching
    clk_disable_unprepare() in case of console unregister.
    
    Ensure that clock enable/disable are balanced adding
    clk_disable_unprepare() in the console exit callback.
    
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Link: https://lore.kernel.org/r/20211020192643.476895-3-francesco.dolcini@toradex.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    dolcini authored and gregkh committed Oct 21, 2021
  13. serial: imx: fix detach/attach of serial console

    If the device used as a serial console gets detached/attached at runtime,
    register_console() will try to call imx_uart_setup_console(), but this
    is not possible since it is marked as __init.
    
    For instance
    
      # cat /sys/devices/virtual/tty/console/active
      tty1 ttymxc0
      # echo -n N > /sys/devices/virtual/tty/console/subsystem/ttymxc0/console
      # echo -n Y > /sys/devices/virtual/tty/console/subsystem/ttymxc0/console
    
    [   73.166649] 8<--- cut here ---
    [   73.167005] Unable to handle kernel paging request at virtual address c154d928
    [   73.167601] pgd = 55433e84
    [   73.167875] [c154d928] *pgd=8141941e(bad)
    [   73.168304] Internal error: Oops: 8000000d [#1] SMP ARM
    [   73.168429] Modules linked in:
    [   73.168522] CPU: 0 PID: 536 Comm: sh Not tainted 5.15.0-rc6-00056-g3968ddcf05fb #3
    [   73.168675] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
    [   73.168791] PC is at imx_uart_console_setup+0x0/0x238
    [   73.168927] LR is at try_enable_new_console+0x98/0x124
    [   73.169056] pc : [<c154d928>]    lr : [<c0196f44>]    psr: a0000013
    [   73.169178] sp : c2ef5e70  ip : 00000000  fp : 00000000
    [   73.169281] r10: 00000000  r9 : c02cf970  r8 : 00000000
    [   73.169389] r7 : 00000001  r6 : 00000001  r5 : c1760164  r4 : c1e0fb08
    [   73.169512] r3 : c154d928  r2 : 00000000  r1 : efffcbd1  r0 : c1760164
    [   73.169641] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
    [   73.169782] Control: 10c5387d  Table: 8345406a  DAC: 00000051
    [   73.169895] Register r0 information: non-slab/vmalloc memory
    [   73.170032] Register r1 information: non-slab/vmalloc memory
    [   73.170158] Register r2 information: NULL pointer
    [   73.170273] Register r3 information: non-slab/vmalloc memory
    [   73.170397] Register r4 information: non-slab/vmalloc memory
    [   73.170521] Register r5 information: non-slab/vmalloc memory
    [   73.170647] Register r6 information: non-paged memory
    [   73.170771] Register r7 information: non-paged memory
    [   73.170892] Register r8 information: NULL pointer
    [   73.171009] Register r9 information: non-slab/vmalloc memory
    [   73.171142] Register r10 information: NULL pointer
    [   73.171259] Register r11 information: NULL pointer
    [   73.171375] Register r12 information: NULL pointer
    [   73.171494] Process sh (pid: 536, stack limit = 0xcd1ba82f)
    [   73.171621] Stack: (0xc2ef5e70 to 0xc2ef6000)
    [   73.171731] 5e60:                                     ???????? ???????? ???????? ????????
    [   73.171899] 5e80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.172059] 5ea0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.172217] 5ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.172377] 5ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.172537] 5f00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.172698] 5f20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.172856] 5f40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.173016] 5f60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.173177] 5f80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.173336] 5fa0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.173496] 5fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.173654] 5fe0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.173826] [<c0196f44>] (try_enable_new_console) from [<c01984a8>] (register_console+0x10c/0x2ec)
    [   73.174053] [<c01984a8>] (register_console) from [<c06e2c90>] (console_store+0x14c/0x168)
    [   73.174262] [<c06e2c90>] (console_store) from [<c0383718>] (kernfs_fop_write_iter+0x110/0x1cc)
    [   73.174470] [<c0383718>] (kernfs_fop_write_iter) from [<c02cf5f4>] (vfs_write+0x31c/0x548)
    [   73.174679] [<c02cf5f4>] (vfs_write) from [<c02cf970>] (ksys_write+0x60/0xec)
    [   73.174863] [<c02cf970>] (ksys_write) from [<c0100080>] (ret_fast_syscall+0x0/0x1c)
    [   73.175052] Exception stack(0xc2ef5fa8 to 0xc2ef5ff0)
    [   73.175167] 5fa0:                   ???????? ???????? ???????? ???????? ???????? ????????
    [   73.175327] 5fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
    [   73.175486] 5fe0: ???????? ???????? ???????? ????????
    [   73.175608] Code: 00000000 00000000 00000000 00000000 (00000000)
    [   73.175744] ---[ end trace 9b75121265109bf1 ]---
    
    A similar issue could be triggered by unbinding/binding the serial
    console device [*].
    
    Drop __init so that imx_uart_setup_console() can be safely called at
    runtime.
    
    [*] https://lore.kernel.org/all/20181114174940.7865-3-stefan@agner.ch/
    
    Fixes: a3cb39d ("serial: core: Allow detach and attach serial device for console")
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Stefan Agner <stefan@agner.ch>
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Link: https://lore.kernel.org/r/20211020192643.476895-2-francesco.dolcini@toradex.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    agners authored and gregkh committed Oct 21, 2021

Commits on Oct 18, 2021

  1. tty: tty_buffer: Fix the softlockup issue in flush_to_ldisc

    When running ltp testcase(ltp/testcases/kernel/pty/pty04.c) with arm64, there is a soft lockup,
    which look like this one:
    
      Workqueue: events_unbound flush_to_ldisc
      Call trace:
       dump_backtrace+0x0/0x1ec
       show_stack+0x24/0x30
       dump_stack+0xd0/0x128
       panic+0x15c/0x374
       watchdog_timer_fn+0x2b8/0x304
       __run_hrtimer+0x88/0x2c0
       __hrtimer_run_queues+0xa4/0x120
       hrtimer_interrupt+0xfc/0x270
       arch_timer_handler_phys+0x40/0x50
       handle_percpu_devid_irq+0x94/0x220
       __handle_domain_irq+0x88/0xf0
       gic_handle_irq+0x84/0xfc
       el1_irq+0xc8/0x180
       slip_unesc+0x80/0x214 [slip]
       tty_ldisc_receive_buf+0x64/0x80
       tty_port_default_receive_buf+0x50/0x90
       flush_to_ldisc+0xbc/0x110
       process_one_work+0x1d4/0x4b0
       worker_thread+0x180/0x430
       kthread+0x11c/0x120
    
    In the testcase pty04, The first process call the write syscall to send
    data to the pty master. At the same time, the workqueue will do the
    flush_to_ldisc to pop data in a loop until there is no more data left.
    When the sender and workqueue running in different core, the sender sends
    data fastly in full time which will result in workqueue doing work in loop
    for a long time and occuring softlockup in flush_to_ldisc with kernel
    configured without preempt. So I add need_resched check and cond_resched
    in the flush_to_ldisc loop to avoid it.
    
    Signed-off-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
    Link: https://lore.kernel.org/r/1633961304-24759-1-git-send-email-guanghuifeng@linux.alibaba.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Guanghui Feng authored and gregkh committed Oct 18, 2021
Older