From: Johan Hovold <johan+linaro@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Douglas Anderson <dianders@chromium.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org,
Johan Hovold <johan+linaro@kernel.org>,
stable@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH v2 3/7] serial: qcom-geni: fix dma rx cancellation
Date: Tue, 1 Oct 2024 14:50:29 +0200 [thread overview]
Message-ID: <20241001125033.10625-4-johan+linaro@kernel.org> (raw)
In-Reply-To: <20241001125033.10625-1-johan+linaro@kernel.org>
Make sure to wait for the DMA transfer to complete when cancelling the
rx command on stop_rx(). This specifically prevents the DMA completion
interrupt from firing after rx has been restarted, something which can
lead to an IOMMU fault and hosed rx when the interrupt handler unmaps
the DMA buffer for the new command:
qcom_geni_serial 988000.serial: serial engine reports 0 RX bytes in!
arm-smmu 15000000.iommu: FSR = 00000402 [Format=2 TF], SID=0x563
arm-smmu 15000000.iommu: FSYNR0 = 00210013 [S1CBNDX=33 WNR PLVL=3]
Bluetooth: hci0: command 0xfc00 tx timeout
Bluetooth: hci0: Reading QCA version information failed (-110)
Also add the missing state machine reset which is needed in case
cancellation fails.
Fixes: 2aaa43c70778 ("tty: serial: qcom-geni-serial: add support for serial engine DMA")
Cc: stable@vger.kernel.org # 6.3
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/tty/serial/qcom_geni_serial.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index b6a8729cee6d..dea688db0d7c 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -787,17 +787,27 @@ static void qcom_geni_serial_start_rx_fifo(struct uart_port *uport)
static void qcom_geni_serial_stop_rx_dma(struct uart_port *uport)
{
struct qcom_geni_serial_port *port = to_dev_port(uport);
+ bool done;
if (!qcom_geni_serial_secondary_active(uport))
return;
geni_se_cancel_s_cmd(&port->se);
- qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS,
- S_CMD_CANCEL_EN, true);
-
- if (qcom_geni_serial_secondary_active(uport))
+ done = qcom_geni_serial_poll_bit(uport, SE_DMA_RX_IRQ_STAT,
+ RX_EOT, true);
+ if (done) {
+ writel(RX_EOT | RX_DMA_DONE,
+ uport->membase + SE_DMA_RX_IRQ_CLR);
+ } else {
qcom_geni_serial_abort_rx(uport);
+ writel(1, uport->membase + SE_DMA_RX_FSM_RST);
+ qcom_geni_serial_poll_bit(uport, SE_DMA_RX_IRQ_STAT,
+ RX_RESET_DONE, true);
+ writel(RX_RESET_DONE | RX_DMA_DONE,
+ uport->membase + SE_DMA_RX_IRQ_CLR);
+ }
+
if (port->rx_dma_addr) {
geni_se_rx_dma_unprep(&port->se, port->rx_dma_addr,
DMA_RX_BUF_SIZE);
--
2.45.2
next prev parent reply other threads:[~2024-10-01 12:51 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 12:50 [PATCH v2 0/7] serial: qcom-geni: fix receiver enable Johan Hovold
2024-10-01 12:50 ` [PATCH v2 1/7] serial: qcom-geni: fix premature " Johan Hovold
2024-10-01 13:50 ` Mukesh Kumar Savaliya
2024-10-02 2:07 ` Bjorn Andersson
2024-10-09 13:43 ` Johan Hovold
2024-10-03 18:29 ` Doug Anderson
2024-10-09 13:55 ` Johan Hovold
2024-10-01 12:50 ` [PATCH v2 2/7] serial: qcom-geni: fix shutdown race Johan Hovold
2024-10-01 13:36 ` Bartosz Golaszewski
2024-10-01 13:39 ` Johan Hovold
2024-10-03 18:30 ` Doug Anderson
2024-10-09 14:10 ` Johan Hovold
2024-10-10 22:30 ` Doug Anderson
2024-10-11 6:51 ` Johan Hovold
2024-10-11 14:30 ` Doug Anderson
2024-10-18 9:21 ` Johan Hovold
2024-10-01 12:50 ` Johan Hovold [this message]
2024-10-01 12:50 ` [PATCH v2 4/7] serial: qcom-geni: fix receiver enable Johan Hovold
2024-10-03 20:10 ` Doug Anderson
2024-10-09 14:17 ` Johan Hovold
2024-10-01 12:50 ` [PATCH v2 5/7] serial: qcom-geni: fix rx cancel dma status bit Johan Hovold
2024-10-03 19:55 ` Doug Anderson
2024-10-09 14:20 ` Johan Hovold
2024-10-01 12:50 ` [PATCH v2 6/7] serial: qcom-geni: drop flip buffer WARN() Johan Hovold
2024-10-03 20:06 ` Doug Anderson
2024-10-09 14:23 ` Johan Hovold
2024-10-01 12:50 ` [PATCH v2 7/7] serial: qcom-geni: drop unused receive parameter Johan Hovold
2024-10-03 20:10 ` Doug Anderson
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=20241001125033.10625-4-johan+linaro@kernel.org \
--to=johan+linaro@kernel.org \
--cc=andersson@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).