Linux-SPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails
@ 2020-10-05 13:22 Marek Vasut
  2020-10-05 17:54 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2020-10-05 13:22 UTC (permalink / raw)
  To: linux-spi
  Cc: Marek Vasut, Fabio Estevam, Mark Brown, NXP Linux Team,
	Robin Gong, Shawn Guo, linux-arm-kernel

If the SPI controller has has_dmamode = true and spi_bitbang_start() fails
in spi_imx_probe(), then the driver must release the DMA channels acquired
in spi_imx_sdma_init() by calling spi_imx_sdma_exit() in the fail path.

Fixes: f62caccd12c1 ("spi: spi-imx: add DMA support")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Robin Gong <b38343@freescale.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
To: linux-spi@vger.kernel.org
---
 drivers/spi/spi-imx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 38a5f1304cec..e38e5ad3c706 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1707,7 +1707,7 @@ static int spi_imx_probe(struct platform_device *pdev)
 	ret = spi_bitbang_start(&spi_imx->bitbang);
 	if (ret) {
 		dev_err(&pdev->dev, "bitbang start failed with %d\n", ret);
-		goto out_runtime_pm_put;
+		goto out_bitbang_start;
 	}
 
 	dev_info(&pdev->dev, "probed\n");
@@ -1717,6 +1717,9 @@ static int spi_imx_probe(struct platform_device *pdev)
 
 	return ret;
 
+out_bitbang_start:
+	if (spi_imx->devtype_data->has_dmamode)
+		spi_imx_sdma_exit(spi_imx);
 out_runtime_pm_put:
 	pm_runtime_dont_use_autosuspend(spi_imx->dev);
 	pm_runtime_put_sync(spi_imx->dev);
-- 
2.28.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails
  2020-10-05 13:22 [PATCH] spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails Marek Vasut
@ 2020-10-05 17:54 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-10-05 17:54 UTC (permalink / raw)
  To: Marek Vasut, linux-spi
  Cc: linux-arm-kernel, Fabio Estevam, NXP Linux Team, Shawn Guo, Robin Gong

On Mon, 5 Oct 2020 15:22:29 +0200, Marek Vasut wrote:
> If the SPI controller has has_dmamode = true and spi_bitbang_start() fails
> in spi_imx_probe(), then the driver must release the DMA channels acquired
> in spi_imx_sdma_init() by calling spi_imx_sdma_exit() in the fail path.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails
      commit: 45f0bbdafd26d6d772172563b30bff561cec9133

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] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 13:22 [PATCH] spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails Marek Vasut
2020-10-05 17:54 ` Mark Brown

Linux-SPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-spi/0 linux-spi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-spi linux-spi/ https://lore.kernel.org/linux-spi \
		linux-spi@vger.kernel.org
	public-inbox-index linux-spi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-spi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git