From: Valentin Caron <valentin.caron@foss.st.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Amelie Delaunay <amelie.delaunay@foss.st.com>,
<linux-serial@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
Valentin Caron <valentin.caron@foss.st.com>
Subject: [PATCH 6/6] serial: stm32: synchronize RX DMA channel in shutdown
Date: Thu, 3 Aug 2023 15:01:34 +0200 [thread overview]
Message-ID: <20230803130134.155355-7-valentin.caron@foss.st.com> (raw)
In-Reply-To: <20230803130134.155355-1-valentin.caron@foss.st.com>
From: Amelie Delaunay <amelie.delaunay@foss.st.com>
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>
---
drivers/tty/serial/stm32-usart.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 8fc0526be898..5e9cf0c48813 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -1123,8 +1123,10 @@ static void stm32_usart_shutdown(struct uart_port *port)
dev_err(port->dev, "Transmission is not complete\n");
/* Disable RX DMA. */
- if (stm32_port->rx_ch)
+ if (stm32_port->rx_ch) {
stm32_usart_rx_dma_terminate(stm32_port);
+ dmaengine_synchronize(stm32_port->rx_ch);
+ }
/* flush RX & TX FIFO */
if (ofs->rqr != UNDEF_REG)
--
2.25.1
next prev parent reply other threads:[~2023-08-03 13:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 13:01 [PATCH 0/6] serial: stm32: improve DMA pause and resume Valentin Caron
2023-08-03 13:01 ` [PATCH 1/6] serial: stm32: avoid clearing DMAT bit during transfer Valentin Caron
2023-08-03 13:01 ` [PATCH 2/6] serial: stm32: use DMAT as a configuration bit Valentin Caron
2023-08-03 13:01 ` [PATCH 3/6] serial: stm32: modify parameter and rename stm32_usart_rx_dma_enabled Valentin Caron
2023-08-03 13:01 ` [PATCH 4/6] serial: stm32: group dma pause/resume error handling into single function Valentin Caron
2023-08-03 13:01 ` [PATCH 5/6] serial: stm32: replace access to DMAR bit by dmaengine_pause/resume Valentin Caron
2023-08-03 13:01 ` Valentin Caron [this message]
2023-08-04 13:05 ` [PATCH 6/6] serial: stm32: synchronize RX DMA channel in shutdown Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230803130134.155355-7-valentin.caron@foss.st.com \
--to=valentin.caron@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=amelie.delaunay@foss.st.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®