serial: stm32: terminate / restart DMA transfer at suspend / resume
authorErwan Le Ray <erwan.leray@foss.st.com>
Mon, 25 Oct 2021 13:42:28 +0000 (15:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Oct 2021 17:18:47 +0000 (19:18 +0200)
commit6eeb348c8482862a788a2903e3fc45e76d4ea6b5
tree2c685cb29ef5d982ab487d2901a23bbeabf6f62a
parente0abc903deea0148955af1e7ccabf3e980af7815
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>
drivers/tty/serial/stm32-usart.c