serial: stm32: move tx dma terminate DMA to shutdown
authorValentin Caron <valentin.caron@foss.st.com>
Tue, 4 Jan 2022 18:24:42 +0000 (19:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Jan 2022 14:58:44 +0000 (15:58 +0100)
Terminate DMA transaction and clear CR3_DMAT when shutdown is requested,
instead of when remove is requested. If DMA transfer is not stopped in
shutdown ops, driver will fail to start a new DMA transfer after next
startup ops.

Fixes: 3489187204eb ("serial: stm32: adding dma support")
Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
Link: https://lore.kernel.org/r/20220104182445.4195-2-valentin.caron@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/stm32-usart.c

index 3244e7f6818caea21bf9d8b86a32b3abb37565f4..6cfc3bec67492cd113e4b3ab92bdf97088af172a 100644 (file)
@@ -883,6 +883,11 @@ static void stm32_usart_shutdown(struct uart_port *port)
        u32 val, isr;
        int ret;
 
+       if (stm32_port->tx_dma_busy) {
+               dmaengine_terminate_async(stm32_port->tx_ch);
+               stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT);
+       }
+
        /* Disable modem control interrupts */
        stm32_usart_disable_ms(port);
 
@@ -1570,7 +1575,6 @@ static int stm32_usart_serial_remove(struct platform_device *pdev)
        writel_relaxed(cr3, port->membase + ofs->cr3);
 
        if (stm32_port->tx_ch) {
-               dmaengine_terminate_async(stm32_port->tx_ch);
                stm32_usart_of_dma_tx_remove(stm32_port, pdev);
                dma_release_channel(stm32_port->tx_ch);
        }