* [PATCH] spi: imx: keep dma request disabled before dma transfer setup
@ 2025-10-24 5:53 carlos.song
2025-10-24 14:16 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: carlos.song @ 2025-10-24 5:53 UTC (permalink / raw)
To: frank.li, broonie, shawnguo, s.hauer, kernel, festevam
Cc: linux-spi, imx, linux-arm-kernel, linux-kernel
From: Robin Gong <yibin.gong@nxp.com>
Since sdma hardware configure postpone to transfer phase, have to disable
dma request before dma transfer setup because there is a hardware
limitation on sdma event enable(ENBLn) as below:
"It is thus essential for the Arm platform to program them before any DMA
request is triggered to the SDMA, otherwise an unpredictable combination
of channels may be started."
Signed-off-by: Carlos Song <carlos.song@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
---
drivers/spi/spi-imx.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index cd40db61d8d1..765ea507dd8d 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -529,9 +529,15 @@ static void mx51_ecspi_trigger(struct spi_imx_data *spi_imx)
{
u32 reg;
- reg = readl(spi_imx->base + MX51_ECSPI_CTRL);
- reg |= MX51_ECSPI_CTRL_XCH;
- writel(reg, spi_imx->base + MX51_ECSPI_CTRL);
+ if (spi_imx->usedma) {
+ reg = readl(spi_imx->base + MX51_ECSPI_DMA);
+ reg |= MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN;
+ writel(reg, spi_imx->base + MX51_ECSPI_DMA);
+ } else {
+ reg = readl(spi_imx->base + MX51_ECSPI_CTRL);
+ reg |= MX51_ECSPI_CTRL_XCH;
+ writel(reg, spi_imx->base + MX51_ECSPI_CTRL);
+ }
}
static void mx51_ecspi_disable(struct spi_imx_data *spi_imx)
@@ -772,7 +778,6 @@ static void mx51_setup_wml(struct spi_imx_data *spi_imx)
writel(MX51_ECSPI_DMA_RX_WML(spi_imx->wml - 1) |
MX51_ECSPI_DMA_TX_WML(tx_wml) |
MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) |
- MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN |
MX51_ECSPI_DMA_RXTDEN, spi_imx->base + MX51_ECSPI_DMA);
}
@@ -1539,6 +1544,8 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
reinit_completion(&spi_imx->dma_tx_completion);
dma_async_issue_pending(controller->dma_tx);
+ spi_imx->devtype_data->trigger(spi_imx);
+
transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len);
/* Wait SDMA to finish the data transfer.*/
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: imx: keep dma request disabled before dma transfer setup
2025-10-24 5:53 [PATCH] spi: imx: keep dma request disabled before dma transfer setup carlos.song
@ 2025-10-24 14:16 ` Frank Li
2025-11-05 13:22 ` Mark Brown
2025-11-06 23:54 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2025-10-24 14:16 UTC (permalink / raw)
To: carlos.song
Cc: broonie, shawnguo, s.hauer, kernel, festevam, linux-spi, imx,
linux-arm-kernel, linux-kernel
On Fri, Oct 24, 2025 at 01:53:20PM +0800, carlos.song@nxp.com wrote:
> From: Robin Gong <yibin.gong@nxp.com>
>
> Since sdma hardware configure postpone to transfer phase, have to disable
> dma request before dma transfer setup because there is a hardware
> limitation on sdma event enable(ENBLn) as below:
Due to a hardware limitation on SDMA event enable (ENBLn), the DMA request
must remain disabled until the DMA transfer setup is complete.
Ref spec section [...]
>
> "It is thus essential for the Arm platform to program them before any DMA
> request is triggered to the SDMA, otherwise an unpredictable combination
> of channels may be started."
SDMA hardware configuration is postponed to the transfer phase, so enabling
the DMA request too early may cause unpredictable channel activation. Then
keep dma request disabled before dma transfer setup.
Frank
>
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Signed-off-by: Robin Gong <yibin.gong@nxp.com>
> ---
> drivers/spi/spi-imx.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index cd40db61d8d1..765ea507dd8d 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -529,9 +529,15 @@ static void mx51_ecspi_trigger(struct spi_imx_data *spi_imx)
> {
> u32 reg;
>
> - reg = readl(spi_imx->base + MX51_ECSPI_CTRL);
> - reg |= MX51_ECSPI_CTRL_XCH;
> - writel(reg, spi_imx->base + MX51_ECSPI_CTRL);
> + if (spi_imx->usedma) {
> + reg = readl(spi_imx->base + MX51_ECSPI_DMA);
> + reg |= MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN;
> + writel(reg, spi_imx->base + MX51_ECSPI_DMA);
> + } else {
> + reg = readl(spi_imx->base + MX51_ECSPI_CTRL);
> + reg |= MX51_ECSPI_CTRL_XCH;
> + writel(reg, spi_imx->base + MX51_ECSPI_CTRL);
> + }
> }
>
> static void mx51_ecspi_disable(struct spi_imx_data *spi_imx)
> @@ -772,7 +778,6 @@ static void mx51_setup_wml(struct spi_imx_data *spi_imx)
> writel(MX51_ECSPI_DMA_RX_WML(spi_imx->wml - 1) |
> MX51_ECSPI_DMA_TX_WML(tx_wml) |
> MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) |
> - MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN |
> MX51_ECSPI_DMA_RXTDEN, spi_imx->base + MX51_ECSPI_DMA);
> }
>
> @@ -1539,6 +1544,8 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
> reinit_completion(&spi_imx->dma_tx_completion);
> dma_async_issue_pending(controller->dma_tx);
>
> + spi_imx->devtype_data->trigger(spi_imx);
> +
> transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len);
>
> /* Wait SDMA to finish the data transfer.*/
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: imx: keep dma request disabled before dma transfer setup
2025-10-24 5:53 [PATCH] spi: imx: keep dma request disabled before dma transfer setup carlos.song
2025-10-24 14:16 ` Frank Li
@ 2025-11-05 13:22 ` Mark Brown
2025-11-06 23:54 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-11-05 13:22 UTC (permalink / raw)
To: carlos.song
Cc: frank.li, shawnguo, s.hauer, kernel, festevam, linux-spi, imx,
linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 406 bytes --]
On Fri, Oct 24, 2025 at 01:53:20PM +0800, carlos.song@nxp.com wrote:
> From: Robin Gong <yibin.gong@nxp.com>
...
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Signed-off-by: Robin Gong <yibin.gong@nxp.com>
If you're sending a patch your signoff should go last in the chain, here
it looks like you're forwarding something Robin wrote so his signoff
should be first then you add yours after that.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: imx: keep dma request disabled before dma transfer setup
2025-10-24 5:53 [PATCH] spi: imx: keep dma request disabled before dma transfer setup carlos.song
2025-10-24 14:16 ` Frank Li
2025-11-05 13:22 ` Mark Brown
@ 2025-11-06 23:54 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-11-06 23:54 UTC (permalink / raw)
To: frank.li, shawnguo, s.hauer, kernel, festevam, carlos.song
Cc: linux-spi, imx, linux-arm-kernel, linux-kernel
On Fri, 24 Oct 2025 13:53:20 +0800, carlos.song@nxp.com wrote:
> Since sdma hardware configure postpone to transfer phase, have to disable
> dma request before dma transfer setup because there is a hardware
> limitation on sdma event enable(ENBLn) as below:
>
> "It is thus essential for the Arm platform to program them before any DMA
> request is triggered to the SDMA, otherwise an unpredictable combination
> of channels may be started."
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: imx: keep dma request disabled before dma transfer setup
commit: 86d57d9c07d54e8cb385ffe800930816ccdba0c1
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-06 23:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 5:53 [PATCH] spi: imx: keep dma request disabled before dma transfer setup carlos.song
2025-10-24 14:16 ` Frank Li
2025-11-05 13:22 ` Mark Brown
2025-11-06 23:54 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox