From: Alain Volmat <alain.volmat@st.com>
To: <broonie@kernel.org>, <amelie.delaunay@st.com>
Cc: <mcoquelin.stm32@gmail.com>, <alexandre.torgue@st.com>,
<linux-spi@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <fabrice.gasnier@st.com>,
<alain.volmat@st.com>
Subject: [PATCH 12/18] spi: stm32: move spi disable out of irq handler
Date: Wed, 5 Aug 2020 09:02:07 +0200 [thread overview]
Message-ID: <1596610933-32599-13-git-send-email-alain.volmat@st.com> (raw)
In-Reply-To: <1596610933-32599-1-git-send-email-alain.volmat@st.com>
From: Antonio Borneo <antonio.borneo@st.com>
The spi disable could potentially require some time to finish.
It has to be executed at the end of a transfer, but there is
no reason to call it in the irq handler.
Simplify the irq handler by moving out the spi disable. The
synchronization through xfer_completion is used to defer the
execution of spi disable.
Signed-off-by: Antonio Borneo <antonio.borneo@st.com>
Signed-off-by: Alain Volmat <alain.volmat@st.com>
---
drivers/spi/spi-stm32.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 0eda9903e11e..1a703c4a65db 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -874,7 +874,6 @@ static irqreturn_t stm32f4_spi_irq_thread(int irq, void *dev_id)
struct spi_master *master = dev_id;
struct stm32_spi *spi = spi_master_get_devdata(master);
- stm32f4_spi_disable(spi);
complete(&spi->xfer_completion);
return IRQ_HANDLED;
@@ -963,15 +962,18 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
stm32h7_spi_read_rxfifo(spi);
- writel_relaxed(ifcr, spi->base + STM32H7_SPI_IFCR);
-
- spin_unlock_irqrestore(&spi->lock, flags);
-
if (end) {
- stm32h7_spi_disable(spi);
+ /* Disable interrupts and clear status flags */
+ writel_relaxed(0, spi->base + STM32H7_SPI_IER);
+ writel_relaxed(STM32H7_SPI_IFCR_ALL,
+ spi->base + STM32H7_SPI_IFCR);
+
complete(&spi->xfer_completion);
+ } else {
+ writel_relaxed(ifcr, spi->base + STM32H7_SPI_IFCR);
}
+ spin_unlock_irqrestore(&spi->lock, flags);
return IRQ_HANDLED;
}
@@ -1039,10 +1041,8 @@ static void stm32f4_spi_dma_tx_cb(void *data)
{
struct stm32_spi *spi = data;
- if (spi->cur_comm == SPI_SIMPLEX_TX || spi->cur_comm == SPI_3WIRE_TX) {
- stm32f4_spi_disable(spi);
+ if (spi->cur_comm == SPI_SIMPLEX_TX || spi->cur_comm == SPI_3WIRE_TX)
complete(&spi->xfer_completion);
- }
}
/**
@@ -1055,7 +1055,6 @@ static void stm32f4_spi_dma_rx_cb(void *data)
{
struct stm32_spi *spi = data;
- stm32f4_spi_disable(spi);
complete(&spi->xfer_completion);
}
@@ -1697,9 +1696,10 @@ static int stm32_spi_transfer_one(struct spi_master *master,
if (!ret) {
dev_err(spi->dev, "SPI transfer timeout (%u ms)\n", xfer_time);
spi->xfer_status = -ETIMEDOUT;
- spi->cfg->disable(spi);
}
+ spi->cfg->disable(spi);
+
spi_finalize_current_transfer(master);
return spi->xfer_status;
--
2.7.4
next prev parent reply other threads:[~2020-08-05 7:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 7:01 [PATCH 00/18] spi: stm32: various driver enhancements Alain Volmat
2020-08-05 7:01 ` [PATCH 01/18] spi: stm32-spi: driver uses reset controller only at init Alain Volmat
2020-08-05 7:01 ` [PATCH 02/18] spi: stm32-spi: defer probe for reset Alain Volmat
2020-08-05 10:49 ` Mark Brown
2020-08-07 13:42 ` Alain Volmat
2020-08-07 14:01 ` Mark Brown
2020-08-05 7:01 ` [PATCH 03/18] spi: stm32h7: remove unused mode fault MODF event handling Alain Volmat
2020-08-05 10:51 ` Mark Brown
2020-08-05 7:01 ` [PATCH 04/18] spi: stm32: use bitfield macros Alain Volmat
2020-08-05 7:02 ` [PATCH 05/18] spi: stm32h7: replace private SPI_1HZ_NS with NSEC_PER_SEC Alain Volmat
2020-08-05 7:02 ` [PATCH 06/18] spi: stm32h7: fix irq handler Alain Volmat
2020-08-05 7:02 ` [PATCH 07/18] spi: stm32h7: rework rx fifo read function Alain Volmat
2020-08-05 7:02 ` [PATCH 08/18] spi: stm32h7: fix dbg/warn/err conditions in irq handler Alain Volmat
2020-08-05 7:02 ` [PATCH 09/18] spi: stm32h7: fix race condition at end of transfer Alain Volmat
2020-08-05 10:53 ` Mark Brown
2020-08-05 7:02 ` [PATCH 10/18] spi: stm32: wait for completion in transfer_one() Alain Volmat
2020-08-05 10:58 ` Mark Brown
2020-08-05 7:02 ` [PATCH 11/18] spi: stm32: fix fifo threshold level in case of short transfer Alain Volmat
2020-08-05 10:59 ` Mark Brown
2020-08-05 7:02 ` Alain Volmat [this message]
2020-08-05 11:01 ` [PATCH 12/18] spi: stm32: move spi disable out of irq handler Mark Brown
2020-08-05 7:02 ` [PATCH 13/18] spi: stm32h7: fix handling of dma transfer completed Alain Volmat
2020-08-05 11:02 ` Mark Brown
2020-08-05 7:02 ` [PATCH 14/18] spi: stm32: improve suspend/resume management Alain Volmat
2020-08-05 7:02 ` [PATCH 15/18] spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate Alain Volmat
2020-08-05 11:02 ` Mark Brown
2020-08-05 7:02 ` [PATCH 16/18] spi: stm32: always perform registers configuration prior to transfer Alain Volmat
2020-08-05 11:03 ` Mark Brown
2020-08-05 7:02 ` [PATCH 17/18] spi: stm32: properly handle 0 byte transfer Alain Volmat
2020-08-05 7:02 ` [PATCH 18/18] spi: stm32h7: ensure message are smaller than max size Alain Volmat
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=1596610933-32599-13-git-send-email-alain.volmat@st.com \
--to=alain.volmat@st.com \
--cc=alexandre.torgue@st.com \
--cc=amelie.delaunay@st.com \
--cc=broonie@kernel.org \
--cc=fabrice.gasnier@st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.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®