linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel()
@ 2019-12-12 13:55 Peter Ujfalusi
  2019-12-12 13:55 ` [PATCH 1/9] spi: atmel: " Peter Ujfalusi
                   ` (8 more replies)
  0 siblings, 9 replies; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: linux-kernel, linux-spi, vkoul, linux-rpi-kernel, linux-stm32,
	linux-arm-kernel

Hi,

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

With dma_request_chan() drivers can receive the real error code and can support
deferred probing against DMA.

The series has been compile tested only (allyesconfig).

Regards,
Peter
---
Peter Ujfalusi (9):
  spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()
  spi: bcm2835: Release the DMA channel if probe fails after dma_init
  spi: bcm2835: Use dma_request_chan() instead
    dma_request_slave_channel()
  spi: img-spfi: Use dma_request_chan() instead
    dma_request_slave_channel()
  spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()
  spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()
  spi: spi-fsl-dspi: Use dma_request_chan() instead
    dma_request_slave_channel()
  spi: stm32-qspi: Use dma_request_chan() instead
    dma_request_slave_channel()
  spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()

 drivers/spi/spi-atmel.c      | 29 ++++++++++----------------
 drivers/spi/spi-bcm2835.c    | 40 +++++++++++++++++++++++++-----------
 drivers/spi/spi-fsl-dspi.c   | 12 +++++------
 drivers/spi/spi-img-spfi.c   | 18 ++++++++++++++--
 drivers/spi/spi-mxs.c        |  6 +++---
 drivers/spi/spi-sirf.c       | 12 +++++------
 drivers/spi/spi-stm32-qspi.c | 30 +++++++++++++++++++++------
 drivers/spi/spi-stm32.c      | 32 ++++++++++++++++++++---------
 8 files changed, 116 insertions(+), 63 deletions(-)

-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 1/9] spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init Peter Ujfalusi
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-atmel.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 56f0ca361deb..013458cabe3c 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -514,26 +514,19 @@ static int atmel_spi_configure_dma(struct spi_master *master,
 	master->dma_tx = dma_request_chan(dev, "tx");
 	if (IS_ERR(master->dma_tx)) {
 		err = PTR_ERR(master->dma_tx);
-		if (err == -EPROBE_DEFER) {
-			dev_warn(dev, "no DMA channel available at the moment\n");
-			goto error_clear;
-		}
-		dev_err(dev,
-			"DMA TX channel not available, SPI unable to use DMA\n");
-		err = -EBUSY;
+		if (err != -EPROBE_DEFER)
+			dev_err(dev, "No TX DMA channel, DMA is disabled\n");
 		goto error_clear;
 	}
 
-	/*
-	 * No reason to check EPROBE_DEFER here since we have already requested
-	 * tx channel. If it fails here, it's for another reason.
-	 */
-	master->dma_rx = dma_request_slave_channel(dev, "rx");
-
-	if (!master->dma_rx) {
-		dev_err(dev,
-			"DMA RX channel not available, SPI unable to use DMA\n");
-		err = -EBUSY;
+	master->dma_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(master->dma_rx)) {
+		err = PTR_ERR(master->dma_rx);
+		/*
+		 * No reason to check EPROBE_DEFER here since we have already
+		 * requested tx channel.
+		 */
+		dev_err(dev, "No RX DMA channel, DMA is disabled\n");
 		goto error;
 	}
 
@@ -548,7 +541,7 @@ static int atmel_spi_configure_dma(struct spi_master *master,
 
 	return 0;
 error:
-	if (master->dma_rx)
+	if (!IS_ERR(master->dma_rx))
 		dma_release_channel(master->dma_rx);
 	if (!IS_ERR(master->dma_tx))
 		dma_release_channel(master->dma_tx);
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
  2019-12-12 13:55 ` [PATCH 1/9] spi: atmel: " Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 11:34   ` Nicolas Saenz Julienne
  2019-12-16 12:06   ` Applied "spi: bcm2835: Release the DMA channel if probe fails after dma_init" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 3/9] spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

The DMA channel was not released if either devm_request_irq() or
devm_spi_register_controller() failed.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-bcm2835.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index fb61a620effc..662d55e9f21d 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -1327,20 +1327,22 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 			       dev_name(&pdev->dev), ctlr);
 	if (err) {
 		dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
-		goto out_clk_disable;
+		goto out_dma_release;
 	}
 
 	err = devm_spi_register_controller(&pdev->dev, ctlr);
 	if (err) {
 		dev_err(&pdev->dev, "could not register SPI controller: %d\n",
 			err);
-		goto out_clk_disable;
+		goto out_dma_release;
 	}
 
 	bcm2835_debugfs_create(bs, dev_name(&pdev->dev));
 
 	return 0;
 
+out_dma_release:
+	bcm2835_dma_release(ctlr, bs);
 out_clk_disable:
 	clk_disable_unprepare(bs->clk);
 out_controller_put:
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 3/9] spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
  2019-12-12 13:55 ` [PATCH 1/9] spi: atmel: " Peter Ujfalusi
  2019-12-12 13:55 ` [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 4/9] spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-bcm2835.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 662d55e9f21d..69df79914504 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -888,8 +888,8 @@ static void bcm2835_dma_release(struct spi_controller *ctlr,
 	}
 }
 
-static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
-			     struct bcm2835_spi *bs)
+static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
+			    struct bcm2835_spi *bs)
 {
 	struct dma_slave_config slave_config;
 	const __be32 *addr;
@@ -900,19 +900,24 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
 	addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL);
 	if (!addr) {
 		dev_err(dev, "could not get DMA-register address - not using dma mode\n");
-		goto err;
+		/* Fall back to interrupt mode */
+		return 0;
 	}
 	dma_reg_base = be32_to_cpup(addr);
 
 	/* get tx/rx dma */
-	ctlr->dma_tx = dma_request_slave_channel(dev, "tx");
-	if (!ctlr->dma_tx) {
+	ctlr->dma_tx = dma_request_chan(dev, "tx");
+	if (IS_ERR(ctlr->dma_tx)) {
 		dev_err(dev, "no tx-dma configuration found - not using dma mode\n");
+		ret = PTR_ERR(ctlr->dma_tx);
+		ctlr->dma_tx = NULL;
 		goto err;
 	}
-	ctlr->dma_rx = dma_request_slave_channel(dev, "rx");
-	if (!ctlr->dma_rx) {
+	ctlr->dma_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(ctlr->dma_rx)) {
 		dev_err(dev, "no rx-dma configuration found - not using dma mode\n");
+		ret = PTR_ERR(ctlr->dma_rx);
+		ctlr->dma_rx = NULL;
 		goto err_release;
 	}
 
@@ -997,7 +1002,7 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
 	/* all went well, so set can_dma */
 	ctlr->can_dma = bcm2835_spi_can_dma;
 
-	return;
+	return 0;
 
 err_config:
 	dev_err(dev, "issue configuring dma: %d - not using DMA mode\n",
@@ -1005,7 +1010,14 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
 err_release:
 	bcm2835_dma_release(ctlr, bs);
 err:
-	return;
+	/*
+	 * Only report error for deferred probing, otherwise fall back to
+	 * interrupt mode
+	 */
+	if (ret != -EPROBE_DEFER)
+		ret = 0;
+
+	return ret;
 }
 
 static int bcm2835_spi_transfer_one_poll(struct spi_controller *ctlr,
@@ -1317,7 +1329,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 
 	clk_prepare_enable(bs->clk);
 
-	bcm2835_dma_init(ctlr, &pdev->dev, bs);
+	err = bcm2835_dma_init(ctlr, &pdev->dev, bs);
+	if (err)
+		goto out_clk_disable;
 
 	/* initialise the hardware with the default polarities */
 	bcm2835_wr(bs, BCM2835_SPI_CS,
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 4/9] spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2019-12-12 13:55 ` [PATCH 3/9] spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 5/9] spi: mxs: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-img-spfi.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index f4a8f470aecc..8543f5ed1099 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -666,8 +666,22 @@ static int img_spfi_probe(struct platform_device *pdev)
 	master->unprepare_message = img_spfi_unprepare;
 	master->handle_err = img_spfi_handle_err;
 
-	spfi->tx_ch = dma_request_slave_channel(spfi->dev, "tx");
-	spfi->rx_ch = dma_request_slave_channel(spfi->dev, "rx");
+	spfi->tx_ch = dma_request_chan(spfi->dev, "tx");
+	if (IS_ERR(spfi->tx_ch)) {
+		ret = PTR_ERR(spfi->tx_ch);
+		spfi->tx_ch = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto disable_pm;
+	}
+
+	spfi->rx_ch = dma_request_chan(spfi->dev, "rx");
+	if (IS_ERR(spfi->rx_ch)) {
+		ret = PTR_ERR(spfi->rx_ch);
+		spfi->rx_ch = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto disable_pm;
+	}
+
 	if (!spfi->tx_ch || !spfi->rx_ch) {
 		if (spfi->tx_ch)
 			dma_release_channel(spfi->tx_ch);
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 5/9] spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (3 preceding siblings ...)
  2019-12-12 13:55 ` [PATCH 4/9] spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 6/9] spi: sirf: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-mxs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 996c1c8a9c71..dce85ee07cd0 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -590,10 +590,10 @@ static int mxs_spi_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_master_free;
 
-	ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx");
-	if (!ssp->dmach) {
+	ssp->dmach = dma_request_chan(&pdev->dev, "rx-tx");
+	if (IS_ERR(ssp->dmach)) {
 		dev_err(ssp->dev, "Failed to request DMA\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(ssp->dmach);
 		goto out_master_free;
 	}
 
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 6/9] spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (4 preceding siblings ...)
  2019-12-12 13:55 ` [PATCH 5/9] spi: mxs: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 7/9] spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-sirf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index e1e639191557..8419e6722e17 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -1126,16 +1126,16 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 	sspi->bitbang.master->dev.of_node = pdev->dev.of_node;
 
 	/* request DMA channels */
-	sspi->rx_chan = dma_request_slave_channel(&pdev->dev, "rx");
-	if (!sspi->rx_chan) {
+	sspi->rx_chan = dma_request_chan(&pdev->dev, "rx");
+	if (IS_ERR(sspi->rx_chan)) {
 		dev_err(&pdev->dev, "can not allocate rx dma channel\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(sspi->rx_chan);
 		goto free_master;
 	}
-	sspi->tx_chan = dma_request_slave_channel(&pdev->dev, "tx");
-	if (!sspi->tx_chan) {
+	sspi->tx_chan = dma_request_chan(&pdev->dev, "tx");
+	if (IS_ERR(sspi->tx_chan)) {
 		dev_err(&pdev->dev, "can not allocate tx dma channel\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(sspi->tx_chan);
 		goto free_rx_dma;
 	}
 
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 7/9] spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (5 preceding siblings ...)
  2019-12-12 13:55 ` [PATCH 6/9] spi: sirf: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
  2019-12-12 13:55 ` [PATCH 9/9] spi: stm32: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-fsl-dspi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 442cff71a0d2..52ccd8397c35 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -395,17 +395,17 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
 	if (!dma)
 		return -ENOMEM;
 
-	dma->chan_rx = dma_request_slave_channel(dev, "rx");
-	if (!dma->chan_rx) {
+	dma->chan_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(dma->chan_rx)) {
 		dev_err(dev, "rx dma channel not available\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(dma->chan_rx);
 		return ret;
 	}
 
-	dma->chan_tx = dma_request_slave_channel(dev, "tx");
-	if (!dma->chan_tx) {
+	dma->chan_tx = dma_request_chan(dev, "tx");
+	if (IS_ERR(dma->chan_tx)) {
 		dev_err(dev, "tx dma channel not available\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(dma->chan_tx);
 		goto err_tx_channel;
 	}
 
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (6 preceding siblings ...)
  2019-12-12 13:55 ` [PATCH 7/9] spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:06   ` Applied "spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  2019-12-12 13:55 ` [PATCH 9/9] spi: stm32: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-stm32-qspi.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 4e726929bb4f..4ef569b47aa6 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -470,10 +470,11 @@ static int stm32_qspi_setup(struct spi_device *spi)
 	return 0;
 }
 
-static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
+static int stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 {
 	struct dma_slave_config dma_cfg;
 	struct device *dev = qspi->dev;
+	int ret = 0;
 
 	memset(&dma_cfg, 0, sizeof(dma_cfg));
 
@@ -484,8 +485,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 	dma_cfg.src_maxburst = 4;
 	dma_cfg.dst_maxburst = 4;
 
-	qspi->dma_chrx = dma_request_slave_channel(dev, "rx");
-	if (qspi->dma_chrx) {
+	qspi->dma_chrx = dma_request_chan(dev, "rx");
+	if (IS_ERR(qspi->dma_chrx)) {
+		ret = PTR_ERR(qspi->dma_chrx);
+		qspi->dma_chrx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto out;
+	} else {
 		if (dmaengine_slave_config(qspi->dma_chrx, &dma_cfg)) {
 			dev_err(dev, "dma rx config failed\n");
 			dma_release_channel(qspi->dma_chrx);
@@ -493,8 +499,11 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 		}
 	}
 
-	qspi->dma_chtx = dma_request_slave_channel(dev, "tx");
-	if (qspi->dma_chtx) {
+	qspi->dma_chtx = dma_request_chan(dev, "tx");
+	if (IS_ERR(qspi->dma_chtx)) {
+		ret = PTR_ERR(qspi->dma_chtx);
+		qspi->dma_chtx = NULL;
+	} else {
 		if (dmaengine_slave_config(qspi->dma_chtx, &dma_cfg)) {
 			dev_err(dev, "dma tx config failed\n");
 			dma_release_channel(qspi->dma_chtx);
@@ -502,7 +511,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 		}
 	}
 
+out:
 	init_completion(&qspi->dma_completion);
+
+	if (ret != -EPROBE_DEFER)
+		ret = 0;
+
+	return ret;
 }
 
 static void stm32_qspi_dma_free(struct stm32_qspi *qspi)
@@ -608,7 +623,10 @@ static int stm32_qspi_probe(struct platform_device *pdev)
 
 	qspi->dev = dev;
 	platform_set_drvdata(pdev, qspi);
-	stm32_qspi_dma_setup(qspi);
+	ret = stm32_qspi_dma_setup(qspi);
+	if (ret)
+		goto err;
+
 	mutex_init(&qspi->lock);
 
 	ctrl->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* [PATCH 9/9] spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()
  2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
                   ` (7 preceding siblings ...)
  2019-12-12 13:55 ` [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-12 13:55 ` Peter Ujfalusi
  2019-12-16 12:05   ` Applied "spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
  8 siblings, 1 reply; 20+ messages in thread
From: Peter Ujfalusi @ 2019-12-12 13:55 UTC (permalink / raw)
  To: broonie, nsaenzjulienne, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-stm32.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 7d75632c4151..e041f9c4ec47 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1879,17 +1879,29 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	master->transfer_one = stm32_spi_transfer_one;
 	master->unprepare_message = stm32_spi_unprepare_msg;
 
-	spi->dma_tx = dma_request_slave_channel(spi->dev, "tx");
-	if (!spi->dma_tx)
+	spi->dma_tx = dma_request_chan(spi->dev, "tx");
+	if (IS_ERR(spi->dma_tx)) {
+		ret = PTR_ERR(spi->dma_tx);
+		spi->dma_tx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto err_clk_disable;
+
 		dev_warn(&pdev->dev, "failed to request tx dma channel\n");
-	else
+	} else {
 		master->dma_tx = spi->dma_tx;
+	}
+
+	spi->dma_rx = dma_request_chan(spi->dev, "rx");
+	if (IS_ERR(spi->dma_rx)) {
+		ret = PTR_ERR(spi->dma_rx);
+		spi->dma_rx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto err_dma_release;
 
-	spi->dma_rx = dma_request_slave_channel(spi->dev, "rx");
-	if (!spi->dma_rx)
 		dev_warn(&pdev->dev, "failed to request rx dma channel\n");
-	else
+	} else {
 		master->dma_rx = spi->dma_rx;
+	}
 
 	if (spi->dma_tx || spi->dma_rx)
 		master->can_dma = stm32_spi_can_dma;
@@ -1901,26 +1913,26 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev, "spi master registration failed: %d\n",
 			ret);
-		goto err_dma_release;
+		goto err_pm_disable;
 	}
 
 	if (!master->cs_gpiods) {
 		dev_err(&pdev->dev, "no CS gpios available\n");
 		ret = -EINVAL;
-		goto err_dma_release;
+		goto err_pm_disable;
 	}
 
 	dev_info(&pdev->dev, "driver initialized\n");
 
 	return 0;
 
+err_pm_disable:
+	pm_runtime_disable(&pdev->dev);
 err_dma_release:
 	if (spi->dma_tx)
 		dma_release_channel(spi->dma_tx);
 	if (spi->dma_rx)
 		dma_release_channel(spi->dma_rx);
-
-	pm_runtime_disable(&pdev->dev);
 err_clk_disable:
 	clk_disable_unprepare(spi->clk);
 err_master_put:
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init
  2019-12-12 13:55 ` [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init Peter Ujfalusi
@ 2019-12-16 11:34   ` Nicolas Saenz Julienne
  2019-12-16 12:06   ` Applied "spi: bcm2835: Release the DMA channel if probe fails after dma_init" to the spi tree Mark Brown
  1 sibling, 0 replies; 20+ messages in thread
From: Nicolas Saenz Julienne @ 2019-12-16 11:34 UTC (permalink / raw)
  To: Peter Ujfalusi, broonie, f.fainelli, rjui, sbranden, shawnguo,
	s.hauer, baohua, mcoquelin.stm32, alexandre.torgue
  Cc: vkoul, linux-spi, linux-kernel, linux-arm-kernel,
	linux-rpi-kernel, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

On Thu, 2019-12-12 at 15:55 +0200, Peter Ujfalusi wrote:
> The DMA channel was not released if either devm_request_irq() or
> devm_spi_register_controller() failed.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---

Thanks!

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Regards,
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Applied "spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 9/9] spi: stm32: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:05   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:05 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From 0a454258febb73e4c60d7f5d9a02d1a8c64fdfb8 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:50 +0200
Subject: [PATCH] spi: stm32: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-10-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-stm32.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 7d75632c4151..e041f9c4ec47 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1879,17 +1879,29 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	master->transfer_one = stm32_spi_transfer_one;
 	master->unprepare_message = stm32_spi_unprepare_msg;
 
-	spi->dma_tx = dma_request_slave_channel(spi->dev, "tx");
-	if (!spi->dma_tx)
+	spi->dma_tx = dma_request_chan(spi->dev, "tx");
+	if (IS_ERR(spi->dma_tx)) {
+		ret = PTR_ERR(spi->dma_tx);
+		spi->dma_tx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto err_clk_disable;
+
 		dev_warn(&pdev->dev, "failed to request tx dma channel\n");
-	else
+	} else {
 		master->dma_tx = spi->dma_tx;
+	}
+
+	spi->dma_rx = dma_request_chan(spi->dev, "rx");
+	if (IS_ERR(spi->dma_rx)) {
+		ret = PTR_ERR(spi->dma_rx);
+		spi->dma_rx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto err_dma_release;
 
-	spi->dma_rx = dma_request_slave_channel(spi->dev, "rx");
-	if (!spi->dma_rx)
 		dev_warn(&pdev->dev, "failed to request rx dma channel\n");
-	else
+	} else {
 		master->dma_rx = spi->dma_rx;
+	}
 
 	if (spi->dma_tx || spi->dma_rx)
 		master->can_dma = stm32_spi_can_dma;
@@ -1901,26 +1913,26 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev, "spi master registration failed: %d\n",
 			ret);
-		goto err_dma_release;
+		goto err_pm_disable;
 	}
 
 	if (!master->cs_gpiods) {
 		dev_err(&pdev->dev, "no CS gpios available\n");
 		ret = -EINVAL;
-		goto err_dma_release;
+		goto err_pm_disable;
 	}
 
 	dev_info(&pdev->dev, "driver initialized\n");
 
 	return 0;
 
+err_pm_disable:
+	pm_runtime_disable(&pdev->dev);
 err_dma_release:
 	if (spi->dma_tx)
 		dma_release_channel(spi->dma_tx);
 	if (spi->dma_rx)
 		dma_release_channel(spi->dma_rx);
-
-	pm_runtime_disable(&pdev->dev);
 err_clk_disable:
 	clk_disable_unprepare(spi->clk);
 err_master_put:
-- 
2.20.1

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

* Applied "spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From 658606ff4cf680ca97380f6ed7295722b0e991b2 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:49 +0200
Subject: [PATCH] spi: stm32-qspi: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-9-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-stm32-qspi.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 4e726929bb4f..4ef569b47aa6 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -470,10 +470,11 @@ static int stm32_qspi_setup(struct spi_device *spi)
 	return 0;
 }
 
-static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
+static int stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 {
 	struct dma_slave_config dma_cfg;
 	struct device *dev = qspi->dev;
+	int ret = 0;
 
 	memset(&dma_cfg, 0, sizeof(dma_cfg));
 
@@ -484,8 +485,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 	dma_cfg.src_maxburst = 4;
 	dma_cfg.dst_maxburst = 4;
 
-	qspi->dma_chrx = dma_request_slave_channel(dev, "rx");
-	if (qspi->dma_chrx) {
+	qspi->dma_chrx = dma_request_chan(dev, "rx");
+	if (IS_ERR(qspi->dma_chrx)) {
+		ret = PTR_ERR(qspi->dma_chrx);
+		qspi->dma_chrx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto out;
+	} else {
 		if (dmaengine_slave_config(qspi->dma_chrx, &dma_cfg)) {
 			dev_err(dev, "dma rx config failed\n");
 			dma_release_channel(qspi->dma_chrx);
@@ -493,8 +499,11 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 		}
 	}
 
-	qspi->dma_chtx = dma_request_slave_channel(dev, "tx");
-	if (qspi->dma_chtx) {
+	qspi->dma_chtx = dma_request_chan(dev, "tx");
+	if (IS_ERR(qspi->dma_chtx)) {
+		ret = PTR_ERR(qspi->dma_chtx);
+		qspi->dma_chtx = NULL;
+	} else {
 		if (dmaengine_slave_config(qspi->dma_chtx, &dma_cfg)) {
 			dev_err(dev, "dma tx config failed\n");
 			dma_release_channel(qspi->dma_chtx);
@@ -502,7 +511,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 		}
 	}
 
+out:
 	init_completion(&qspi->dma_completion);
+
+	if (ret != -EPROBE_DEFER)
+		ret = 0;
+
+	return ret;
 }
 
 static void stm32_qspi_dma_free(struct stm32_qspi *qspi)
@@ -608,7 +623,10 @@ static int stm32_qspi_probe(struct platform_device *pdev)
 
 	qspi->dev = dev;
 	platform_set_drvdata(pdev, qspi);
-	stm32_qspi_dma_setup(qspi);
+	ret = stm32_qspi_dma_setup(qspi);
+	if (ret)
+		goto err;
+
 	mutex_init(&qspi->lock);
 
 	ctrl->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD
-- 
2.20.1

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

* Applied "spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 7/9] spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From b5756b777472eceaa84bc180f458f8eaec65da9a Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:48 +0200
Subject: [PATCH] spi: spi-fsl-dspi: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-8-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-fsl-dspi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 442cff71a0d2..52ccd8397c35 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -395,17 +395,17 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
 	if (!dma)
 		return -ENOMEM;
 
-	dma->chan_rx = dma_request_slave_channel(dev, "rx");
-	if (!dma->chan_rx) {
+	dma->chan_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(dma->chan_rx)) {
 		dev_err(dev, "rx dma channel not available\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(dma->chan_rx);
 		return ret;
 	}
 
-	dma->chan_tx = dma_request_slave_channel(dev, "tx");
-	if (!dma->chan_tx) {
+	dma->chan_tx = dma_request_chan(dev, "tx");
+	if (IS_ERR(dma->chan_tx)) {
 		dev_err(dev, "tx dma channel not available\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(dma->chan_tx);
 		goto err_tx_channel;
 	}
 
-- 
2.20.1

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

* Applied "spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 6/9] spi: sirf: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From 401abb764abb6e42f539528e02127457eb0c5b32 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:47 +0200
Subject: [PATCH] spi: sirf: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-7-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-sirf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index e1e639191557..8419e6722e17 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -1126,16 +1126,16 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 	sspi->bitbang.master->dev.of_node = pdev->dev.of_node;
 
 	/* request DMA channels */
-	sspi->rx_chan = dma_request_slave_channel(&pdev->dev, "rx");
-	if (!sspi->rx_chan) {
+	sspi->rx_chan = dma_request_chan(&pdev->dev, "rx");
+	if (IS_ERR(sspi->rx_chan)) {
 		dev_err(&pdev->dev, "can not allocate rx dma channel\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(sspi->rx_chan);
 		goto free_master;
 	}
-	sspi->tx_chan = dma_request_slave_channel(&pdev->dev, "tx");
-	if (!sspi->tx_chan) {
+	sspi->tx_chan = dma_request_chan(&pdev->dev, "tx");
+	if (IS_ERR(sspi->tx_chan)) {
 		dev_err(&pdev->dev, "can not allocate tx dma channel\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(sspi->tx_chan);
 		goto free_rx_dma;
 	}
 
-- 
2.20.1

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

* Applied "spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 5/9] spi: mxs: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From 7ccffd41b2d4d180dcdcc03c54c446621e34bca5 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:46 +0200
Subject: [PATCH] spi: mxs: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-6-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-mxs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 996c1c8a9c71..dce85ee07cd0 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -590,10 +590,10 @@ static int mxs_spi_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_master_free;
 
-	ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx");
-	if (!ssp->dmach) {
+	ssp->dmach = dma_request_chan(&pdev->dev, "rx-tx");
+	if (IS_ERR(ssp->dmach)) {
 		dev_err(ssp->dev, "Failed to request DMA\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(ssp->dmach);
 		goto out_master_free;
 	}
 
-- 
2.20.1

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

* Applied "spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 4/9] spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From 6bfbf4d0aa0c5ebfd4442e1200b21565703e90ed Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:45 +0200
Subject: [PATCH] spi: img-spfi: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-5-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-img-spfi.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index f4a8f470aecc..8543f5ed1099 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -666,8 +666,22 @@ static int img_spfi_probe(struct platform_device *pdev)
 	master->unprepare_message = img_spfi_unprepare;
 	master->handle_err = img_spfi_handle_err;
 
-	spfi->tx_ch = dma_request_slave_channel(spfi->dev, "tx");
-	spfi->rx_ch = dma_request_slave_channel(spfi->dev, "rx");
+	spfi->tx_ch = dma_request_chan(spfi->dev, "tx");
+	if (IS_ERR(spfi->tx_ch)) {
+		ret = PTR_ERR(spfi->tx_ch);
+		spfi->tx_ch = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto disable_pm;
+	}
+
+	spfi->rx_ch = dma_request_chan(spfi->dev, "rx");
+	if (IS_ERR(spfi->rx_ch)) {
+		ret = PTR_ERR(spfi->rx_ch);
+		spfi->rx_ch = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto disable_pm;
+	}
+
 	if (!spfi->tx_ch || !spfi->rx_ch) {
 		if (spfi->tx_ch)
 			dma_release_channel(spfi->tx_ch);
-- 
2.20.1

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

* Applied "spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 3/9] spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From 6133fed0539bc5c059d3a661b61704159ba448a6 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:44 +0200
Subject: [PATCH] spi: bcm2835: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-4-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-bcm2835.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 662d55e9f21d..69df79914504 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -888,8 +888,8 @@ static void bcm2835_dma_release(struct spi_controller *ctlr,
 	}
 }
 
-static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
-			     struct bcm2835_spi *bs)
+static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
+			    struct bcm2835_spi *bs)
 {
 	struct dma_slave_config slave_config;
 	const __be32 *addr;
@@ -900,19 +900,24 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
 	addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL);
 	if (!addr) {
 		dev_err(dev, "could not get DMA-register address - not using dma mode\n");
-		goto err;
+		/* Fall back to interrupt mode */
+		return 0;
 	}
 	dma_reg_base = be32_to_cpup(addr);
 
 	/* get tx/rx dma */
-	ctlr->dma_tx = dma_request_slave_channel(dev, "tx");
-	if (!ctlr->dma_tx) {
+	ctlr->dma_tx = dma_request_chan(dev, "tx");
+	if (IS_ERR(ctlr->dma_tx)) {
 		dev_err(dev, "no tx-dma configuration found - not using dma mode\n");
+		ret = PTR_ERR(ctlr->dma_tx);
+		ctlr->dma_tx = NULL;
 		goto err;
 	}
-	ctlr->dma_rx = dma_request_slave_channel(dev, "rx");
-	if (!ctlr->dma_rx) {
+	ctlr->dma_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(ctlr->dma_rx)) {
 		dev_err(dev, "no rx-dma configuration found - not using dma mode\n");
+		ret = PTR_ERR(ctlr->dma_rx);
+		ctlr->dma_rx = NULL;
 		goto err_release;
 	}
 
@@ -997,7 +1002,7 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
 	/* all went well, so set can_dma */
 	ctlr->can_dma = bcm2835_spi_can_dma;
 
-	return;
+	return 0;
 
 err_config:
 	dev_err(dev, "issue configuring dma: %d - not using DMA mode\n",
@@ -1005,7 +1010,14 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
 err_release:
 	bcm2835_dma_release(ctlr, bs);
 err:
-	return;
+	/*
+	 * Only report error for deferred probing, otherwise fall back to
+	 * interrupt mode
+	 */
+	if (ret != -EPROBE_DEFER)
+		ret = 0;
+
+	return ret;
 }
 
 static int bcm2835_spi_transfer_one_poll(struct spi_controller *ctlr,
@@ -1317,7 +1329,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 
 	clk_prepare_enable(bs->clk);
 
-	bcm2835_dma_init(ctlr, &pdev->dev, bs);
+	err = bcm2835_dma_init(ctlr, &pdev->dev, bs);
+	if (err)
+		goto out_clk_disable;
 
 	/* initialise the hardware with the default polarities */
 	bcm2835_wr(bs, BCM2835_SPI_CS,
-- 
2.20.1

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

* Applied "spi: bcm2835: Release the DMA channel if probe fails after dma_init" to the spi tree
  2019-12-12 13:55 ` [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init Peter Ujfalusi
  2019-12-16 11:34   ` Nicolas Saenz Julienne
@ 2019-12-16 12:06   ` Mark Brown
  1 sibling, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: bcm2835: Release the DMA channel if probe fails after dma_init

has been applied to the spi tree at

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

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

>From 666224b43b4bd4612ce3b758c038f9bc5c5e3fcb Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:43 +0200
Subject: [PATCH] spi: bcm2835: Release the DMA channel if probe fails after
 dma_init

The DMA channel was not released if either devm_request_irq() or
devm_spi_register_controller() failed.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20191212135550.4634-3-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-bcm2835.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index fb61a620effc..662d55e9f21d 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -1327,20 +1327,22 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 			       dev_name(&pdev->dev), ctlr);
 	if (err) {
 		dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
-		goto out_clk_disable;
+		goto out_dma_release;
 	}
 
 	err = devm_spi_register_controller(&pdev->dev, ctlr);
 	if (err) {
 		dev_err(&pdev->dev, "could not register SPI controller: %d\n",
 			err);
-		goto out_clk_disable;
+		goto out_dma_release;
 	}
 
 	bcm2835_debugfs_create(bs, dev_name(&pdev->dev));
 
 	return 0;
 
+out_dma_release:
+	bcm2835_dma_release(ctlr, bs);
 out_clk_disable:
 	clk_disable_unprepare(bs->clk);
 out_controller_put:
-- 
2.20.1

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

* Applied "spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree
  2019-12-12 13:55 ` [PATCH 1/9] spi: atmel: " Peter Ujfalusi
@ 2019-12-16 12:06   ` Mark Brown
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Brown @ 2019-12-16 12:06 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: alexandre.torgue, baohua, broonie, f.fainelli, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel, linux-spi, linux-stm32,
	Mark Brown, mcoquelin.stm32, nsaenzjulienne, rjui, sbranden,
	s.hauer, shawnguo, vkoul

The patch

   spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()

has been applied to the spi tree at

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

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

>From d947c9d26c2381cc10067e76e71bf9ddb0fedb8b Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
Date: Thu, 12 Dec 2019 15:55:42 +0200
Subject: [PATCH] spi: atmel: Use dma_request_chan() instead
 dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-2-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-atmel.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 56f0ca361deb..013458cabe3c 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -514,26 +514,19 @@ static int atmel_spi_configure_dma(struct spi_master *master,
 	master->dma_tx = dma_request_chan(dev, "tx");
 	if (IS_ERR(master->dma_tx)) {
 		err = PTR_ERR(master->dma_tx);
-		if (err == -EPROBE_DEFER) {
-			dev_warn(dev, "no DMA channel available at the moment\n");
-			goto error_clear;
-		}
-		dev_err(dev,
-			"DMA TX channel not available, SPI unable to use DMA\n");
-		err = -EBUSY;
+		if (err != -EPROBE_DEFER)
+			dev_err(dev, "No TX DMA channel, DMA is disabled\n");
 		goto error_clear;
 	}
 
-	/*
-	 * No reason to check EPROBE_DEFER here since we have already requested
-	 * tx channel. If it fails here, it's for another reason.
-	 */
-	master->dma_rx = dma_request_slave_channel(dev, "rx");
-
-	if (!master->dma_rx) {
-		dev_err(dev,
-			"DMA RX channel not available, SPI unable to use DMA\n");
-		err = -EBUSY;
+	master->dma_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(master->dma_rx)) {
+		err = PTR_ERR(master->dma_rx);
+		/*
+		 * No reason to check EPROBE_DEFER here since we have already
+		 * requested tx channel.
+		 */
+		dev_err(dev, "No RX DMA channel, DMA is disabled\n");
 		goto error;
 	}
 
@@ -548,7 +541,7 @@ static int atmel_spi_configure_dma(struct spi_master *master,
 
 	return 0;
 error:
-	if (master->dma_rx)
+	if (!IS_ERR(master->dma_rx))
 		dma_release_channel(master->dma_rx);
 	if (!IS_ERR(master->dma_tx))
 		dma_release_channel(master->dma_tx);
-- 
2.20.1

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

end of thread, other threads:[~2019-12-16 12:06 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12 13:55 [PATCH 0/9] spi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-12 13:55 ` [PATCH 1/9] spi: atmel: " Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init Peter Ujfalusi
2019-12-16 11:34   ` Nicolas Saenz Julienne
2019-12-16 12:06   ` Applied "spi: bcm2835: Release the DMA channel if probe fails after dma_init" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 3/9] spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 4/9] spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 5/9] spi: mxs: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 6/9] spi: sirf: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 7/9] spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 9/9] spi: stm32: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:05   ` Applied "spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown

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).