All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] spi: rspi and sh-msiof driver updates
@ 2014-08-06 12:58 ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:58 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

	Hi Mark, Simon,

Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
I grouped them in three parts:
  - [1-5] are for the rspi driver (Mark),
  - [6-8] are for the sh-msiof driver (Mark),
  - [9-12] are for the R-Car Gen2 DTSes (Simon).

Summary of changes:
  - [1] and [6] are bug fixes I have sent before, but that weren't applied
    due to dependency confusion,
  - [2] is a new cosmetic fix,
  - [3] makes rspi use a new helper function that will be available as of
    v3.17-rc1,
  - [4-5] and [7-8] make DMA work with the new R-Car DMAC driver,
    developed by Laurent Pinchart in the series "[PATCH v2 0/8] R-Car Gen2
    DMA Controller driver"
    (http://www.spinics.net/lists/linux-sh/msg33890.html),
  - [9-12] enable DMA in DT for r8a7791 and r8a7790, and depend on
    "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices to DT"
    (http://www.spinics.net/lists/linux-sh/msg33897.html) resp.
    "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices to DT"
    (http://www.spinics.net/lists/linux-sh/msg33896.html) of the
    aforementioned series.

This has been tested on r8a7791/koelsch.

Geert Uytterhoeven (12):
   [1] spi: rspi: Fix leaking of unused DMA descriptors
   [2] spi: rspi: Remove unneeded semicolon
   [3] spi: rspi: Use devm_kasprintf()
   [4] spi: rspi: Configure DMA slave bus width to 8 bit
   [5] spi: rspi: Add DT support to DMA setup
   [6] spi: sh-msiof: Fix leaking of unused DMA descriptors
   [7] spi: sh-msiof: Configure DMA slave bus width
   [8] spi: sh-msiof: Add DT support to DMA setup
   [9] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
  [10] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF
  [11] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI
  [12] ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIOF

 Documentation/devicetree/bindings/spi/sh-msiof.txt |  17 ++-
 Documentation/devicetree/bindings/spi/spi-rspi.txt |   5 +
 arch/arm/boot/dts/r8a7790.dtsi                     |  18 ++-
 arch/arm/boot/dts/r8a7791.dtsi                     |  14 +-
 drivers/spi/spi-rspi.c                             | 147 +++++++++++++--------
 drivers/spi/spi-sh-msiof.c                         | 103 +++++++++------
 6 files changed, 195 insertions(+), 109 deletions(-)

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH 00/12] spi: rspi and sh-msiof driver updates
@ 2014-08-06 12:58 ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:58 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

	Hi Mark, Simon,

Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
I grouped them in three parts:
  - [1-5] are for the rspi driver (Mark),
  - [6-8] are for the sh-msiof driver (Mark),
  - [9-12] are for the R-Car Gen2 DTSes (Simon).

Summary of changes:
  - [1] and [6] are bug fixes I have sent before, but that weren't applied
    due to dependency confusion,
  - [2] is a new cosmetic fix,
  - [3] makes rspi use a new helper function that will be available as of
    v3.17-rc1,
  - [4-5] and [7-8] make DMA work with the new R-Car DMAC driver,
    developed by Laurent Pinchart in the series "[PATCH v2 0/8] R-Car Gen2
    DMA Controller driver"
    (http://www.spinics.net/lists/linux-sh/msg33890.html),
  - [9-12] enable DMA in DT for r8a7791 and r8a7790, and depend on
    "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices to DT"
    (http://www.spinics.net/lists/linux-sh/msg33897.html) resp.
    "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices to DT"
    (http://www.spinics.net/lists/linux-sh/msg33896.html) of the
    aforementioned series.

This has been tested on r8a7791/koelsch.

Geert Uytterhoeven (12):
   [1] spi: rspi: Fix leaking of unused DMA descriptors
   [2] spi: rspi: Remove unneeded semicolon
   [3] spi: rspi: Use devm_kasprintf()
   [4] spi: rspi: Configure DMA slave bus width to 8 bit
   [5] spi: rspi: Add DT support to DMA setup
   [6] spi: sh-msiof: Fix leaking of unused DMA descriptors
   [7] spi: sh-msiof: Configure DMA slave bus width
   [8] spi: sh-msiof: Add DT support to DMA setup
   [9] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
  [10] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF
  [11] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI
  [12] ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIOF

 Documentation/devicetree/bindings/spi/sh-msiof.txt |  17 ++-
 Documentation/devicetree/bindings/spi/spi-rspi.txt |   5 +
 arch/arm/boot/dts/r8a7790.dtsi                     |  18 ++-
 arch/arm/boot/dts/r8a7791.dtsi                     |  14 +-
 drivers/spi/spi-rspi.c                             | 147 +++++++++++++--------
 drivers/spi/spi-sh-msiof.c                         | 103 +++++++++------
 6 files changed, 195 insertions(+), 109 deletions(-)

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH 01/12] spi: rspi: Fix leaking of unused DMA descriptors
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 12:58   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:58 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
unused DMA descriptors.

As per Documentation/dmaengine.txt, once a DMA descriptor has been
obtained, it must be submitted. Hence:
  - First prepare and submit all DMA descriptors,
  - Prepare the SPI controller for DMA,
  - Start DMA by calling dma_async_issue_pending(),
  - Make sure to call dmaengine_terminate_all() on all descriptors that
    haven't completed.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-rspi.c | 94 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index c850dfdfa9e3..ad87a98f8f68 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -472,25 +472,52 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 	dma_cookie_t cookie;
 	int ret;
 
-	if (tx) {
-		desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
-					tx->sgl, tx->nents, DMA_TO_DEVICE,
-					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_tx)
-			goto no_dma;
-
-		irq_mask |= SPCR_SPTIE;
-	}
+	/* First prepare and submit the DMA request(s), as this may fail */
 	if (rx) {
 		desc_rx = dmaengine_prep_slave_sg(rspi->master->dma_rx,
 					rx->sgl, rx->nents, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx)
-			goto no_dma;
+		if (!desc_rx) {
+			ret = -EAGAIN;
+			goto no_dma_rx;
+		}
+
+		desc_rx->callback = rspi_dma_complete;
+		desc_rx->callback_param = rspi;
+		cookie = dmaengine_submit(desc_rx);
+		if (dma_submit_error(cookie)) {
+			ret = cookie;
+			goto no_dma_rx;
+		}
 
 		irq_mask |= SPCR_SPRIE;
 	}
 
+	if (tx) {
+		desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
+					tx->sgl, tx->nents, DMA_TO_DEVICE,
+					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+		if (!desc_tx) {
+			ret = -EAGAIN;
+			goto no_dma_tx;
+		}
+
+		if (rx) {
+			/* No callback */
+			desc_tx->callback = NULL;
+		} else {
+			desc_tx->callback = rspi_dma_complete;
+			desc_tx->callback_param = rspi;
+		}
+		cookie = dmaengine_submit(desc_tx);
+		if (dma_submit_error(cookie)) {
+			ret = cookie;
+			goto no_dma_tx;
+		}
+
+		irq_mask |= SPCR_SPTIE;
+	}
+
 	/*
 	 * DMAC needs SPxIE, but if SPxIE is set, the IRQ routine will be
 	 * called. So, this driver disables the IRQ while DMA transfer.
@@ -503,34 +530,24 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 	rspi_enable_irq(rspi, irq_mask);
 	rspi->dma_callbacked = 0;
 
-	if (rx) {
-		desc_rx->callback = rspi_dma_complete;
-		desc_rx->callback_param = rspi;
-		cookie = dmaengine_submit(desc_rx);
-		if (dma_submit_error(cookie))
-			return cookie;
+	/* Now start DMA */
+	if (rx)
 		dma_async_issue_pending(rspi->master->dma_rx);
-	}
-	if (tx) {
-		if (rx) {
-			/* No callback */
-			desc_tx->callback = NULL;
-		} else {
-			desc_tx->callback = rspi_dma_complete;
-			desc_tx->callback_param = rspi;
-		}
-		cookie = dmaengine_submit(desc_tx);
-		if (dma_submit_error(cookie))
-			return cookie;
+	if (tx)
 		dma_async_issue_pending(rspi->master->dma_tx);
-	}
 
 	ret = wait_event_interruptible_timeout(rspi->wait,
 					       rspi->dma_callbacked, HZ);
 	if (ret > 0 && rspi->dma_callbacked)
 		ret = 0;
-	else if (!ret)
+	else if (!ret) {
+		dev_err(&rspi->master->dev, "DMA timeout\n");
 		ret = -ETIMEDOUT;
+		if (tx)
+			dmaengine_terminate_all(rspi->master->dma_tx);
+		if (rx)
+			dmaengine_terminate_all(rspi->master->dma_rx);
+	}
 
 	rspi_disable_irq(rspi, irq_mask);
 
@@ -541,11 +558,16 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 
 	return ret;
 
-no_dma:
-	pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
-		     dev_driver_string(&rspi->master->dev),
-		     dev_name(&rspi->master->dev));
-	return -EAGAIN;
+no_dma_tx:
+	if (rx)
+		dmaengine_terminate_all(rspi->master->dma_rx);
+no_dma_rx:
+	if (ret = -EAGAIN) {
+		pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
+			     dev_driver_string(&rspi->master->dev),
+			     dev_name(&rspi->master->dev));
+	}
+	return ret;
 }
 
 static void rspi_receive_init(const struct rspi_data *rspi)
-- 
1.9.1


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

* [PATCH 01/12] spi: rspi: Fix leaking of unused DMA descriptors
@ 2014-08-06 12:58   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:58 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
unused DMA descriptors.

As per Documentation/dmaengine.txt, once a DMA descriptor has been
obtained, it must be submitted. Hence:
  - First prepare and submit all DMA descriptors,
  - Prepare the SPI controller for DMA,
  - Start DMA by calling dma_async_issue_pending(),
  - Make sure to call dmaengine_terminate_all() on all descriptors that
    haven't completed.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-rspi.c | 94 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index c850dfdfa9e3..ad87a98f8f68 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -472,25 +472,52 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 	dma_cookie_t cookie;
 	int ret;
 
-	if (tx) {
-		desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
-					tx->sgl, tx->nents, DMA_TO_DEVICE,
-					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_tx)
-			goto no_dma;
-
-		irq_mask |= SPCR_SPTIE;
-	}
+	/* First prepare and submit the DMA request(s), as this may fail */
 	if (rx) {
 		desc_rx = dmaengine_prep_slave_sg(rspi->master->dma_rx,
 					rx->sgl, rx->nents, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx)
-			goto no_dma;
+		if (!desc_rx) {
+			ret = -EAGAIN;
+			goto no_dma_rx;
+		}
+
+		desc_rx->callback = rspi_dma_complete;
+		desc_rx->callback_param = rspi;
+		cookie = dmaengine_submit(desc_rx);
+		if (dma_submit_error(cookie)) {
+			ret = cookie;
+			goto no_dma_rx;
+		}
 
 		irq_mask |= SPCR_SPRIE;
 	}
 
+	if (tx) {
+		desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
+					tx->sgl, tx->nents, DMA_TO_DEVICE,
+					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+		if (!desc_tx) {
+			ret = -EAGAIN;
+			goto no_dma_tx;
+		}
+
+		if (rx) {
+			/* No callback */
+			desc_tx->callback = NULL;
+		} else {
+			desc_tx->callback = rspi_dma_complete;
+			desc_tx->callback_param = rspi;
+		}
+		cookie = dmaengine_submit(desc_tx);
+		if (dma_submit_error(cookie)) {
+			ret = cookie;
+			goto no_dma_tx;
+		}
+
+		irq_mask |= SPCR_SPTIE;
+	}
+
 	/*
 	 * DMAC needs SPxIE, but if SPxIE is set, the IRQ routine will be
 	 * called. So, this driver disables the IRQ while DMA transfer.
@@ -503,34 +530,24 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 	rspi_enable_irq(rspi, irq_mask);
 	rspi->dma_callbacked = 0;
 
-	if (rx) {
-		desc_rx->callback = rspi_dma_complete;
-		desc_rx->callback_param = rspi;
-		cookie = dmaengine_submit(desc_rx);
-		if (dma_submit_error(cookie))
-			return cookie;
+	/* Now start DMA */
+	if (rx)
 		dma_async_issue_pending(rspi->master->dma_rx);
-	}
-	if (tx) {
-		if (rx) {
-			/* No callback */
-			desc_tx->callback = NULL;
-		} else {
-			desc_tx->callback = rspi_dma_complete;
-			desc_tx->callback_param = rspi;
-		}
-		cookie = dmaengine_submit(desc_tx);
-		if (dma_submit_error(cookie))
-			return cookie;
+	if (tx)
 		dma_async_issue_pending(rspi->master->dma_tx);
-	}
 
 	ret = wait_event_interruptible_timeout(rspi->wait,
 					       rspi->dma_callbacked, HZ);
 	if (ret > 0 && rspi->dma_callbacked)
 		ret = 0;
-	else if (!ret)
+	else if (!ret) {
+		dev_err(&rspi->master->dev, "DMA timeout\n");
 		ret = -ETIMEDOUT;
+		if (tx)
+			dmaengine_terminate_all(rspi->master->dma_tx);
+		if (rx)
+			dmaengine_terminate_all(rspi->master->dma_rx);
+	}
 
 	rspi_disable_irq(rspi, irq_mask);
 
@@ -541,11 +558,16 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
 
 	return ret;
 
-no_dma:
-	pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
-		     dev_driver_string(&rspi->master->dev),
-		     dev_name(&rspi->master->dev));
-	return -EAGAIN;
+no_dma_tx:
+	if (rx)
+		dmaengine_terminate_all(rspi->master->dma_rx);
+no_dma_rx:
+	if (ret == -EAGAIN) {
+		pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
+			     dev_driver_string(&rspi->master->dev),
+			     dev_name(&rspi->master->dev));
+	}
+	return ret;
 }
 
 static void rspi_receive_init(const struct rspi_data *rspi)
-- 
1.9.1


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

* [PATCH 02/12] spi: rspi: Remove unneeded semicolon
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 12:58   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:58 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

Introduced by commit 426ef76dd8a394a0e04d096941cd9acb49539a3e ("spi:
rspi: Add DT support").

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-rspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index ad87a98f8f68..a4d8d3cf2912 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1084,7 +1084,7 @@ static int rspi_probe(struct platform_device *pdev)
 			master->num_chipselect = rspi_pd->num_chipselect;
 		else
 			master->num_chipselect = 2; /* default */
-	};
+	}
 
 	/* ops parameter check */
 	if (!ops->set_config_register) {
-- 
1.9.1


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

* [PATCH 02/12] spi: rspi: Remove unneeded semicolon
@ 2014-08-06 12:58   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:58 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

Introduced by commit 426ef76dd8a394a0e04d096941cd9acb49539a3e ("spi:
rspi: Add DT support").

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-rspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index ad87a98f8f68..a4d8d3cf2912 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1084,7 +1084,7 @@ static int rspi_probe(struct platform_device *pdev)
 			master->num_chipselect = rspi_pd->num_chipselect;
 		else
 			master->num_chipselect = 2; /* default */
-	};
+	}
 
 	/* ops parameter check */
 	if (!ops->set_config_register) {
-- 
1.9.1


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

* [PATCH 03/12] spi: rspi: Use devm_kasprintf()
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Use the devm_kasprintf() helper function instead of open coding
error-prone buffer handling and string formatting.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
devm_kasprintf() was included in upstream, and will be available as of
release v3.17-rc1.
---
 drivers/spi/spi-rspi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index a4d8d3cf2912..aa1c6a893570 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1046,12 +1046,11 @@ static int rspi_request_irq(struct device *dev, unsigned int irq,
 			    irq_handler_t handler, const char *suffix,
 			    void *dev_id)
 {
-	const char *base = dev_name(dev);
-	size_t len = strlen(base) + strlen(suffix) + 2;
-	char *name = devm_kzalloc(dev, len, GFP_KERNEL);
+	const char *name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s",
+					  dev_name(dev), suffix);
 	if (!name)
 		return -ENOMEM;
-	snprintf(name, len, "%s:%s", base, suffix);
+
 	return devm_request_irq(dev, irq, handler, 0, name, dev_id);
 }
 
-- 
1.9.1


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

* [PATCH 03/12] spi: rspi: Use devm_kasprintf()
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Use the devm_kasprintf() helper function instead of open coding
error-prone buffer handling and string formatting.

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
devm_kasprintf() was included in upstream, and will be available as of
release v3.17-rc1.
---
 drivers/spi/spi-rspi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index a4d8d3cf2912..aa1c6a893570 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1046,12 +1046,11 @@ static int rspi_request_irq(struct device *dev, unsigned int irq,
 			    irq_handler_t handler, const char *suffix,
 			    void *dev_id)
 {
-	const char *base = dev_name(dev);
-	size_t len = strlen(base) + strlen(suffix) + 2;
-	char *name = devm_kzalloc(dev, len, GFP_KERNEL);
+	const char *name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s",
+					  dev_name(dev), suffix);
 	if (!name)
 		return -ENOMEM;
-	snprintf(name, len, "%s:%s", base, suffix);
+
 	return devm_request_irq(dev, irq, handler, 0, name, dev_id);
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 04/12] spi: rspi: Configure DMA slave bus width to 8 bit
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
explicit configuration of the DMA slave bus width.
Hardcode the DMA transfer size to 1 byte for both directions, as that's
the only supported configuration (16-bit DMA support was removed in
commit 9c5de2c1754c2bb3c69c4d7bf0d0edc0a61d8232 ("spi: rspi: Remove
unused 16-bit DMA support")).

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-rspi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index aa1c6a893570..6a4eb2d7f644 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -919,10 +919,13 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,
 	memset(&cfg, 0, sizeof(cfg));
 	cfg.slave_id = id;
 	cfg.direction = dir;
-	if (dir = DMA_MEM_TO_DEV)
+	if (dir = DMA_MEM_TO_DEV) {
 		cfg.dst_addr = port_addr;
-	else
+		cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+	} else {
 		cfg.src_addr = port_addr;
+		cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+	}
 
 	ret = dmaengine_slave_config(chan, &cfg);
 	if (ret) {
-- 
1.9.1


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

* [PATCH 04/12] spi: rspi: Configure DMA slave bus width to 8 bit
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
explicit configuration of the DMA slave bus width.
Hardcode the DMA transfer size to 1 byte for both directions, as that's
the only supported configuration (16-bit DMA support was removed in
commit 9c5de2c1754c2bb3c69c4d7bf0d0edc0a61d8232 ("spi: rspi: Remove
unused 16-bit DMA support")).

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
 drivers/spi/spi-rspi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index aa1c6a893570..6a4eb2d7f644 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -919,10 +919,13 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,
 	memset(&cfg, 0, sizeof(cfg));
 	cfg.slave_id = id;
 	cfg.direction = dir;
-	if (dir == DMA_MEM_TO_DEV)
+	if (dir == DMA_MEM_TO_DEV) {
 		cfg.dst_addr = port_addr;
-	else
+		cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+	} else {
 		cfg.src_addr = port_addr;
+		cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+	}
 
 	ret = dmaengine_slave_config(chan, &cfg);
 	if (ret) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 05/12] [v2] spi: rspi: Add DT support to DMA setup
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
v2:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings
---
 Documentation/devicetree/bindings/spi/spi-rspi.txt |  5 +++
 drivers/spi/spi-rspi.c                             | 37 ++++++++++++++--------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-rspi.txt b/Documentation/devicetree/bindings/spi/spi-rspi.txt
index d57d82a74054..f9929aceeacc 100644
--- a/Documentation/devicetree/bindings/spi/spi-rspi.txt
+++ b/Documentation/devicetree/bindings/spi/spi-rspi.txt
@@ -30,6 +30,9 @@ Required properties:
 
 Optional properties:
 - clocks           : Must contain a reference to the functional clock.
+- dmas             : Must contain a list of two references to DMA specifiers,
+		     one for transmission, and one for reception.
+- dma-names        : Must contain a list of two DMA names, "tx" and "rx".
 
 Pinctrl properties might be needed, too.  See
 Documentation/devicetree/bindings/pinctrl/renesas,*.
@@ -58,4 +61,6 @@ Examples:
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+		dma-names = "tx", "rx";
 	};
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 6a4eb2d7f644..1da609e4491d 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -909,10 +909,11 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter,
-				   (void *)(unsigned long)id);
+	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				(void *)(unsigned long)id, dev,
+				dir = DMA_MEM_TO_DEV ? "tx" : "rx");
 	if (!chan) {
-		dev_warn(dev, "dma_request_channel failed\n");
+		dev_warn(dev, "dma_request_slave_channel_compat failed\n");
 		return NULL;
 	}
 
@@ -941,22 +942,30 @@ static int rspi_request_dma(struct device *dev, struct spi_master *master,
 			    const struct resource *res)
 {
 	const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev);
+	unsigned int dma_tx_id, dma_rx_id;
+
+	if (dev->of_node) {
+		/* In the OF case we will get the slave IDs from the DT */
+		dma_tx_id = 0;
+		dma_rx_id = 0;
+	} else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) {
+		dma_tx_id = rspi_pd->dma_tx_id;
+		dma_rx_id = rspi_pd->dma_rx_id;
+	} else {
+		/* The driver assumes no error. */
+		return 0;
+	}
 
-	if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id)
-		return 0;	/* The driver assumes no error. */
-
-	master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM,
-					       rspi_pd->dma_rx_id,
+	master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id,
 					       res->start + RSPI_SPDR);
-	if (!master->dma_rx)
+	if (!master->dma_tx)
 		return -ENODEV;
 
-	master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV,
-					       rspi_pd->dma_tx_id,
+	master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, dma_rx_id,
 					       res->start + RSPI_SPDR);
-	if (!master->dma_tx) {
-		dma_release_channel(master->dma_rx);
-		master->dma_rx = NULL;
+	if (!master->dma_rx) {
+		dma_release_channel(master->dma_tx);
+		master->dma_tx = NULL;
 		return -ENODEV;
 	}
 
-- 
1.9.1


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

* [PATCH 05/12] [v2] spi: rspi: Add DT support to DMA setup
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
v2:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings
---
 Documentation/devicetree/bindings/spi/spi-rspi.txt |  5 +++
 drivers/spi/spi-rspi.c                             | 37 ++++++++++++++--------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-rspi.txt b/Documentation/devicetree/bindings/spi/spi-rspi.txt
index d57d82a74054..f9929aceeacc 100644
--- a/Documentation/devicetree/bindings/spi/spi-rspi.txt
+++ b/Documentation/devicetree/bindings/spi/spi-rspi.txt
@@ -30,6 +30,9 @@ Required properties:
 
 Optional properties:
 - clocks           : Must contain a reference to the functional clock.
+- dmas             : Must contain a list of two references to DMA specifiers,
+		     one for transmission, and one for reception.
+- dma-names        : Must contain a list of two DMA names, "tx" and "rx".
 
 Pinctrl properties might be needed, too.  See
 Documentation/devicetree/bindings/pinctrl/renesas,*.
@@ -58,4 +61,6 @@ Examples:
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+		dma-names = "tx", "rx";
 	};
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 6a4eb2d7f644..1da609e4491d 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -909,10 +909,11 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter,
-				   (void *)(unsigned long)id);
+	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				(void *)(unsigned long)id, dev,
+				dir == DMA_MEM_TO_DEV ? "tx" : "rx");
 	if (!chan) {
-		dev_warn(dev, "dma_request_channel failed\n");
+		dev_warn(dev, "dma_request_slave_channel_compat failed\n");
 		return NULL;
 	}
 
@@ -941,22 +942,30 @@ static int rspi_request_dma(struct device *dev, struct spi_master *master,
 			    const struct resource *res)
 {
 	const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev);
+	unsigned int dma_tx_id, dma_rx_id;
+
+	if (dev->of_node) {
+		/* In the OF case we will get the slave IDs from the DT */
+		dma_tx_id = 0;
+		dma_rx_id = 0;
+	} else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) {
+		dma_tx_id = rspi_pd->dma_tx_id;
+		dma_rx_id = rspi_pd->dma_rx_id;
+	} else {
+		/* The driver assumes no error. */
+		return 0;
+	}
 
-	if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id)
-		return 0;	/* The driver assumes no error. */
-
-	master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM,
-					       rspi_pd->dma_rx_id,
+	master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id,
 					       res->start + RSPI_SPDR);
-	if (!master->dma_rx)
+	if (!master->dma_tx)
 		return -ENODEV;
 
-	master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV,
-					       rspi_pd->dma_tx_id,
+	master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, dma_rx_id,
 					       res->start + RSPI_SPDR);
-	if (!master->dma_tx) {
-		dma_release_channel(master->dma_rx);
-		master->dma_rx = NULL;
+	if (!master->dma_rx) {
+		dma_release_channel(master->dma_tx);
+		master->dma_tx = NULL;
 		return -ENODEV;
 	}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
unused DMA descriptors.

As per Documentation/dmaengine.txt, once a DMA descriptor has been
obtained, it must be submitted. Hence:
  - First prepare and submit all DMA descriptors,
  - Prepare the SPI controller for DMA,
  - Start DMA by calling dma_async_issue_pending(),
  - Make sure to call dmaengine_terminate_all() on all descriptors that
    haven't completed.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-sh-msiof.c | 71 +++++++++++++++++++++++++---------------------
 1 file changed, 38 insertions(+), 33 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 2a4354dcd661..887c2084130f 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 	dma_cookie_t cookie;
 	int ret;
 
-	if (tx) {
-		ier_bits |= IER_TDREQE | IER_TDMAE;
-		dma_sync_single_for_device(p->master->dma_tx->device->dev,
-					   p->tx_dma_addr, len, DMA_TO_DEVICE);
-		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
-					p->tx_dma_addr, len, DMA_TO_DEVICE,
-					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_tx)
-			return -EAGAIN;
-	}
-
+	/* First prepare and submit the DMA request(s), as this may fail */
 	if (rx) {
 		ier_bits |= IER_RDREQE | IER_RDMAE;
 		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
 					p->rx_dma_addr, len, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx)
-			return -EAGAIN;
-	}
-
-	/* 1 stage FIFO watermarks for DMA */
-	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
-
-	/* setup msiof transfer mode registers (32-bit words) */
-	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
-
-	sh_msiof_write(p, IER, ier_bits);
-
-	reinit_completion(&p->done);
+		if (!desc_rx) {
+			ret = -EAGAIN;
+			goto no_dma_rx;
+		}
 
-	if (rx) {
 		desc_rx->callback = sh_msiof_dma_complete;
 		desc_rx->callback_param = p;
 		cookie = dmaengine_submit(desc_rx);
 		if (dma_submit_error(cookie)) {
 			ret = cookie;
-			goto stop_ier;
+			goto no_dma_rx;
 		}
-		dma_async_issue_pending(p->master->dma_rx);
 	}
 
 	if (tx) {
+		ier_bits |= IER_TDREQE | IER_TDMAE;
+		dma_sync_single_for_device(p->master->dma_tx->device->dev,
+					   p->tx_dma_addr, len, DMA_TO_DEVICE);
+		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
+					p->tx_dma_addr, len, DMA_TO_DEVICE,
+					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+		if (!desc_tx) {
+			ret = -EAGAIN;
+			goto no_dma_tx;
+		}
+
 		if (rx) {
 			/* No callback */
 			desc_tx->callback = NULL;
@@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 		cookie = dmaengine_submit(desc_tx);
 		if (dma_submit_error(cookie)) {
 			ret = cookie;
-			goto stop_rx;
+			goto no_dma_tx;
 		}
-		dma_async_issue_pending(p->master->dma_tx);
 	}
 
+	/* 1 stage FIFO watermarks for DMA */
+	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
+
+	/* setup msiof transfer mode registers (32-bit words) */
+	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
+
+	sh_msiof_write(p, IER, ier_bits);
+
+	reinit_completion(&p->done);
+
+	/* Now start DMA */
+	if (tx)
+		dma_async_issue_pending(p->master->dma_rx);
+	if (rx)
+		dma_async_issue_pending(p->master->dma_tx);
+
 	ret = sh_msiof_spi_start(p, rx);
 	if (ret) {
 		dev_err(&p->pdev->dev, "failed to start hardware\n");
-		goto stop_tx;
+		goto stop_dma;
 	}
 
 	/* wait for tx fifo to be emptied / rx fifo to be filled */
@@ -726,14 +731,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 stop_reset:
 	sh_msiof_reset_str(p);
 	sh_msiof_spi_stop(p, rx);
-stop_tx:
+stop_dma:
 	if (tx)
 		dmaengine_terminate_all(p->master->dma_tx);
-stop_rx:
+no_dma_tx:
 	if (rx)
 		dmaengine_terminate_all(p->master->dma_rx);
-stop_ier:
 	sh_msiof_write(p, IER, 0);
+no_dma_rx:
 	return ret;
 }
 
-- 
1.9.1


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

* [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
unused DMA descriptors.

As per Documentation/dmaengine.txt, once a DMA descriptor has been
obtained, it must be submitted. Hence:
  - First prepare and submit all DMA descriptors,
  - Prepare the SPI controller for DMA,
  - Start DMA by calling dma_async_issue_pending(),
  - Make sure to call dmaengine_terminate_all() on all descriptors that
    haven't completed.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-sh-msiof.c | 71 +++++++++++++++++++++++++---------------------
 1 file changed, 38 insertions(+), 33 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 2a4354dcd661..887c2084130f 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 	dma_cookie_t cookie;
 	int ret;
 
-	if (tx) {
-		ier_bits |= IER_TDREQE | IER_TDMAE;
-		dma_sync_single_for_device(p->master->dma_tx->device->dev,
-					   p->tx_dma_addr, len, DMA_TO_DEVICE);
-		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
-					p->tx_dma_addr, len, DMA_TO_DEVICE,
-					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_tx)
-			return -EAGAIN;
-	}
-
+	/* First prepare and submit the DMA request(s), as this may fail */
 	if (rx) {
 		ier_bits |= IER_RDREQE | IER_RDMAE;
 		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
 					p->rx_dma_addr, len, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx)
-			return -EAGAIN;
-	}
-
-	/* 1 stage FIFO watermarks for DMA */
-	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
-
-	/* setup msiof transfer mode registers (32-bit words) */
-	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
-
-	sh_msiof_write(p, IER, ier_bits);
-
-	reinit_completion(&p->done);
+		if (!desc_rx) {
+			ret = -EAGAIN;
+			goto no_dma_rx;
+		}
 
-	if (rx) {
 		desc_rx->callback = sh_msiof_dma_complete;
 		desc_rx->callback_param = p;
 		cookie = dmaengine_submit(desc_rx);
 		if (dma_submit_error(cookie)) {
 			ret = cookie;
-			goto stop_ier;
+			goto no_dma_rx;
 		}
-		dma_async_issue_pending(p->master->dma_rx);
 	}
 
 	if (tx) {
+		ier_bits |= IER_TDREQE | IER_TDMAE;
+		dma_sync_single_for_device(p->master->dma_tx->device->dev,
+					   p->tx_dma_addr, len, DMA_TO_DEVICE);
+		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
+					p->tx_dma_addr, len, DMA_TO_DEVICE,
+					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+		if (!desc_tx) {
+			ret = -EAGAIN;
+			goto no_dma_tx;
+		}
+
 		if (rx) {
 			/* No callback */
 			desc_tx->callback = NULL;
@@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 		cookie = dmaengine_submit(desc_tx);
 		if (dma_submit_error(cookie)) {
 			ret = cookie;
-			goto stop_rx;
+			goto no_dma_tx;
 		}
-		dma_async_issue_pending(p->master->dma_tx);
 	}
 
+	/* 1 stage FIFO watermarks for DMA */
+	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
+
+	/* setup msiof transfer mode registers (32-bit words) */
+	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
+
+	sh_msiof_write(p, IER, ier_bits);
+
+	reinit_completion(&p->done);
+
+	/* Now start DMA */
+	if (tx)
+		dma_async_issue_pending(p->master->dma_rx);
+	if (rx)
+		dma_async_issue_pending(p->master->dma_tx);
+
 	ret = sh_msiof_spi_start(p, rx);
 	if (ret) {
 		dev_err(&p->pdev->dev, "failed to start hardware\n");
-		goto stop_tx;
+		goto stop_dma;
 	}
 
 	/* wait for tx fifo to be emptied / rx fifo to be filled */
@@ -726,14 +731,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 stop_reset:
 	sh_msiof_reset_str(p);
 	sh_msiof_spi_stop(p, rx);
-stop_tx:
+stop_dma:
 	if (tx)
 		dmaengine_terminate_all(p->master->dma_tx);
-stop_rx:
+no_dma_tx:
 	if (rx)
 		dmaengine_terminate_all(p->master->dma_rx);
-stop_ier:
 	sh_msiof_write(p, IER, 0);
+no_dma_rx:
 	return ret;
 }
 
-- 
1.9.1


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

* [PATCH 07/12] spi: sh-msiof: Configure DMA slave bus width
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
explicit configuration of the DMA slave bus width.
Hardcode the DMA transfer size to 4 bytes, as MSIOF DMA is limited to
32-bit words.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-sh-msiof.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 887c2084130f..b19cbb4cb4a0 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -987,10 +987,13 @@ static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev,
 	memset(&cfg, 0, sizeof(cfg));
 	cfg.slave_id = id;
 	cfg.direction = dir;
-	if (dir = DMA_MEM_TO_DEV)
+	if (dir = DMA_MEM_TO_DEV) {
 		cfg.dst_addr = port_addr;
-	else
+		cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	} else {
 		cfg.src_addr = port_addr;
+		cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	}
 
 	ret = dmaengine_slave_config(chan, &cfg);
 	if (ret) {
-- 
1.9.1


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

* [PATCH 07/12] spi: sh-msiof: Configure DMA slave bus width
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine, Geert Uytterhoeven

The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
explicit configuration of the DMA slave bus width.
Hardcode the DMA transfer size to 4 bytes, as MSIOF DMA is limited to
32-bit words.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi-sh-msiof.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 887c2084130f..b19cbb4cb4a0 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -987,10 +987,13 @@ static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev,
 	memset(&cfg, 0, sizeof(cfg));
 	cfg.slave_id = id;
 	cfg.direction = dir;
-	if (dir == DMA_MEM_TO_DEV)
+	if (dir == DMA_MEM_TO_DEV) {
 		cfg.dst_addr = port_addr;
-	else
+		cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	} else {
 		cfg.src_addr = port_addr;
+		cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	}
 
 	ret = dmaengine_slave_config(chan, &cfg);
 	if (ret) {
-- 
1.9.1


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

* [PATCH 08/12] [v2] spi: sh-msiof: Add DT support to DMA setup
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	Geert Uytterhoeven, devicetree

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
v2:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings
---
 Documentation/devicetree/bindings/spi/sh-msiof.txt | 17 ++++++++++++---
 drivers/spi/spi-sh-msiof.c                         | 25 ++++++++++++++++------
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt b/Documentation/devicetree/bindings/spi/sh-msiof.txt
index f24baf3b6cc1..98e07f1c3dab 100644
--- a/Documentation/devicetree/bindings/spi/sh-msiof.txt
+++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt
@@ -6,8 +6,13 @@ Required properties:
 			 "renesas,sh-mobile-msiof" for SH Mobile series.
 			 Examples with soctypes are:
 			 "renesas,msiof-r8a7790" (R-Car H2)
-			 "renesas,msiof-r8a7791" (R-Car M2)
-- reg                  : Offset and length of the register set for the device
+- reg                  : A list of offsets and lengths of the register sets for
+			 the device.
+			 If only one register set is present, it is to be used
+			 by both the CPU and the DMA engine.
+			 If two register sets are present, the first is to be
+			 used by the CPU, and the second is to be used by the
+			 DMA engine.
 - interrupt-parent     : The phandle for the interrupt controller that
 			 services interrupts for this device
 - interrupts           : Interrupt specifier
@@ -17,6 +22,10 @@ Required properties:
 Optional properties:
 - clocks               : Must contain a reference to the functional clock.
 - num-cs               : Total number of chip-selects (default is 1)
+- dmas                 : Must contain a list of two references to DMA
+			 specifiers, one for transmission, and one for
+			 reception.
+- dma-names            : Must contain a list of two DMA names, "tx" and "rx".
 
 Optional properties, deprecated for soctype-specific bindings:
 - renesas,tx-fifo-size : Overrides the default tx fifo size given in words
@@ -31,9 +40,11 @@ Example:
 
 	msiof0: spi@e6e20000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e20000 0 0x0064>;
+		reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
 		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+		dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index b19cbb4cb4a0..811a42dba92a 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -977,10 +977,11 @@ static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter,
-				  (void *)(unsigned long)id);
+	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				(void *)(unsigned long)id, dev,
+				dir = DMA_MEM_TO_DEV ? "tx" : "rx");
 	if (!chan) {
-		dev_warn(dev, "dma_request_channel failed\n");
+		dev_warn(dev, "dma_request_slave_channel_compat failed\n");
 		return NULL;
 	}
 
@@ -1010,12 +1011,22 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
 	struct platform_device *pdev = p->pdev;
 	struct device *dev = &pdev->dev;
 	const struct sh_msiof_spi_info *info = dev_get_platdata(dev);
+	unsigned int dma_tx_id, dma_rx_id;
 	const struct resource *res;
 	struct spi_master *master;
 	struct device *tx_dev, *rx_dev;
 
-	if (!info || !info->dma_tx_id || !info->dma_rx_id)
-		return 0;	/* The driver assumes no error */
+	if (dev->of_node) {
+		/* In the OF case we will get the slave IDs from the DT */
+		dma_tx_id = 0;
+		dma_rx_id = 0;
+	} else if (info && info->dma_tx_id && info->dma_rx_id) {
+		dma_tx_id = info->dma_tx_id;
+		dma_rx_id = info->dma_rx_id;
+	} else {
+		/* The driver assumes no error */
+		return 0;
+	}
 
 	/* The DMA engine uses the second register set, if present */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -1024,13 +1035,13 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
 
 	master = p->master;
 	master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV,
-						   info->dma_tx_id,
+						   dma_tx_id,
 						   res->start + TFDR);
 	if (!master->dma_tx)
 		return -ENODEV;
 
 	master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM,
-						   info->dma_rx_id,
+						   dma_rx_id,
 						   res->start + RFDR);
 	if (!master->dma_rx)
 		goto free_tx_chan;
-- 
1.9.1


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

* [PATCH 08/12] [v2] spi: sh-msiof: Add DT support to DMA setup
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	Geert Uytterhoeven, devicetree

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
v2:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings
---
 Documentation/devicetree/bindings/spi/sh-msiof.txt | 17 ++++++++++++---
 drivers/spi/spi-sh-msiof.c                         | 25 ++++++++++++++++------
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt b/Documentation/devicetree/bindings/spi/sh-msiof.txt
index f24baf3b6cc1..98e07f1c3dab 100644
--- a/Documentation/devicetree/bindings/spi/sh-msiof.txt
+++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt
@@ -6,8 +6,13 @@ Required properties:
 			 "renesas,sh-mobile-msiof" for SH Mobile series.
 			 Examples with soctypes are:
 			 "renesas,msiof-r8a7790" (R-Car H2)
-			 "renesas,msiof-r8a7791" (R-Car M2)
-- reg                  : Offset and length of the register set for the device
+- reg                  : A list of offsets and lengths of the register sets for
+			 the device.
+			 If only one register set is present, it is to be used
+			 by both the CPU and the DMA engine.
+			 If two register sets are present, the first is to be
+			 used by the CPU, and the second is to be used by the
+			 DMA engine.
 - interrupt-parent     : The phandle for the interrupt controller that
 			 services interrupts for this device
 - interrupts           : Interrupt specifier
@@ -17,6 +22,10 @@ Required properties:
 Optional properties:
 - clocks               : Must contain a reference to the functional clock.
 - num-cs               : Total number of chip-selects (default is 1)
+- dmas                 : Must contain a list of two references to DMA
+			 specifiers, one for transmission, and one for
+			 reception.
+- dma-names            : Must contain a list of two DMA names, "tx" and "rx".
 
 Optional properties, deprecated for soctype-specific bindings:
 - renesas,tx-fifo-size : Overrides the default tx fifo size given in words
@@ -31,9 +40,11 @@ Example:
 
 	msiof0: spi@e6e20000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e20000 0 0x0064>;
+		reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
 		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+		dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index b19cbb4cb4a0..811a42dba92a 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -977,10 +977,11 @@ static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter,
-				  (void *)(unsigned long)id);
+	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				(void *)(unsigned long)id, dev,
+				dir == DMA_MEM_TO_DEV ? "tx" : "rx");
 	if (!chan) {
-		dev_warn(dev, "dma_request_channel failed\n");
+		dev_warn(dev, "dma_request_slave_channel_compat failed\n");
 		return NULL;
 	}
 
@@ -1010,12 +1011,22 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
 	struct platform_device *pdev = p->pdev;
 	struct device *dev = &pdev->dev;
 	const struct sh_msiof_spi_info *info = dev_get_platdata(dev);
+	unsigned int dma_tx_id, dma_rx_id;
 	const struct resource *res;
 	struct spi_master *master;
 	struct device *tx_dev, *rx_dev;
 
-	if (!info || !info->dma_tx_id || !info->dma_rx_id)
-		return 0;	/* The driver assumes no error */
+	if (dev->of_node) {
+		/* In the OF case we will get the slave IDs from the DT */
+		dma_tx_id = 0;
+		dma_rx_id = 0;
+	} else if (info && info->dma_tx_id && info->dma_rx_id) {
+		dma_tx_id = info->dma_tx_id;
+		dma_rx_id = info->dma_rx_id;
+	} else {
+		/* The driver assumes no error */
+		return 0;
+	}
 
 	/* The DMA engine uses the second register set, if present */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -1024,13 +1035,13 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
 
 	master = p->master;
 	master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV,
-						   info->dma_tx_id,
+						   dma_tx_id,
 						   res->start + TFDR);
 	if (!master->dma_tx)
 		return -ENODEV;
 
 	master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM,
-						   info->dma_rx_id,
+						   dma_rx_id,
 						   res->start + RFDR);
 	if (!master->dma_rx)
 		goto free_tx_chan;
-- 
1.9.1


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

* [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add a DMA property to the QSPI node

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".

v2:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings,
v2:
  - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
  - Reorder: TX first, RX second.
---
 arch/arm/boot/dts/r8a7791.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index d59af615e365..8186c9f4a18a 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -1044,6 +1044,8 @@
 		reg = <0 0xe6b10000 0 0x2c>;
 		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
+		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+		dma-names = "tx", "rx";
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
-- 
1.9.1


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

* [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add a DMA property to the QSPI node

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".

v2:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings,
v2:
  - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
  - Reorder: TX first, RX second.
---
 arch/arm/boot/dts/r8a7791.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index d59af615e365..8186c9f4a18a 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -1044,6 +1044,8 @@
 		reg = <0 0xe6b10000 0 0x2c>;
 		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
+		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+		dma-names = "tx", "rx";
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 10/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add register sets used for access by the DMA engine, and DMA properties to
the MSIOF nodes.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".

v3:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings,
v2:
  - Add register sets for DMA,
  - Reorder: TX first, RX second.
---
 arch/arm/boot/dts/r8a7791.dtsi | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index 8186c9f4a18a..152c75ce8534 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -1054,9 +1054,11 @@
 
 	msiof0: spi@e6e20000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e20000 0 0x0064>;
+		reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
 		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+		dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1064,9 +1066,11 @@
 
 	msiof1: spi@e6e10000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e10000 0 0x0064>;
+		reg = <0 0xe6e10000 0 0x0064>, <0 0xe7e10000 0 0x0064>;
 		interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7791_CLK_MSIOF1>;
+		dmas = <&dmac0 0x55>, <&dmac0 0x56>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1074,9 +1078,11 @@
 
 	msiof2: spi@e6e00000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e00000 0 0x0064>;
+		reg = <0 0xe6e00000 0 0x0064>, <0 0xe7e00000 0 0x0064>;
 		interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7791_CLK_MSIOF2>;
+		dmas = <&dmac0 0x41>, <&dmac0 0x42>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
-- 
1.9.1


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

* [PATCH 10/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add register sets used for access by the DMA engine, and DMA properties to
the MSIOF nodes.

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".

v3:
  - Update DMA specifiers to match the renesas,rcar-dmac bindings,
v2:
  - Add register sets for DMA,
  - Reorder: TX first, RX second.
---
 arch/arm/boot/dts/r8a7791.dtsi | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index 8186c9f4a18a..152c75ce8534 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -1054,9 +1054,11 @@
 
 	msiof0: spi@e6e20000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e20000 0 0x0064>;
+		reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
 		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+		dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1064,9 +1066,11 @@
 
 	msiof1: spi@e6e10000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e10000 0 0x0064>;
+		reg = <0 0xe6e10000 0 0x0064>, <0 0xe7e10000 0 0x0064>;
 		interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7791_CLK_MSIOF1>;
+		dmas = <&dmac0 0x55>, <&dmac0 0x56>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1074,9 +1078,11 @@
 
 	msiof2: spi@e6e00000 {
 		compatible = "renesas,msiof-r8a7791";
-		reg = <0 0xe6e00000 0 0x0064>;
+		reg = <0 0xe6e00000 0 0x0064>, <0 0xe7e00000 0 0x0064>;
 		interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7791_CLK_MSIOF2>;
+		dmas = <&dmac0 0x41>, <&dmac0 0x42>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 11/12] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	Geert Uytterhoeven, devicetree

Add a DMA property to the QSPI node

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
This depends on "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
---
 arch/arm/boot/dts/r8a7790.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 4c74f219c824..495771b3cb34 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -978,6 +978,8 @@
 		reg = <0 0xe6b10000 0 0x2c>;
 		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp9_clks R8A7790_CLK_QSPI_MOD>;
+		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+		dma-names = "tx", "rx";
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
-- 
1.9.1


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

* [PATCH 11/12] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI
@ 2014-08-06 12:59   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	Geert Uytterhoeven, devicetree

Add a DMA property to the QSPI node

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
This depends on "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
---
 arch/arm/boot/dts/r8a7790.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 4c74f219c824..495771b3cb34 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -978,6 +978,8 @@
 		reg = <0 0xe6b10000 0 0x2c>;
 		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp9_clks R8A7790_CLK_QSPI_MOD>;
+		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+		dma-names = "tx", "rx";
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
-- 
1.9.1


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

* [PATCH 12/12] ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIOF
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add register sets used for access by the DMA engine, and DMA properties to
the MSIOF nodes.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org
---
This depends on "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
---
 arch/arm/boot/dts/r8a7790.dtsi | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 495771b3cb34..45d6fdd6877b 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -988,9 +988,11 @@
 
 	msiof0: spi@e6e20000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6e20000 0 0x0064>;
+		reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
 		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7790_CLK_MSIOF0>;
+		dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -998,9 +1000,11 @@
 
 	msiof1: spi@e6e10000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6e10000 0 0x0064>;
+		reg = <0 0xe6e10000 0 0x0064>, <0 0xe7e10000 0 0x0064>;
 		interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7790_CLK_MSIOF1>;
+		dmas = <&dmac0 0x55>, <&dmac0 0x56>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1008,9 +1012,11 @@
 
 	msiof2: spi@e6e00000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6e00000 0 0x0064>;
+		reg = <0 0xe6e00000 0 0x0064>, <0 0xe7e00000 0 0x0064>;
 		interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7790_CLK_MSIOF2>;
+		dmas = <&dmac0 0x41>, <&dmac0 0x42>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1018,9 +1024,11 @@
 
 	msiof3: spi@e6c90000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6c90000 0 0x0064>;
+		reg = <0 0xe6c90000 0 0x0064>, <0 0xe7c90000 0 0x0064>;
 		interrupts = <0 159 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7790_CLK_MSIOF3>;
+		dmas = <&dmac0 0x45>, <&dmac0 0x46>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
-- 
1.9.1


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

* [PATCH 12/12] ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIOF
@ 2014-08-06 12:59     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-06 12:59 UTC (permalink / raw)
  To: Mark Brown, Simon Horman
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add register sets used for access by the DMA engine, and DMA properties to
the MSIOF nodes.

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
This depends on "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices
to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
---
 arch/arm/boot/dts/r8a7790.dtsi | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 495771b3cb34..45d6fdd6877b 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -988,9 +988,11 @@
 
 	msiof0: spi@e6e20000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6e20000 0 0x0064>;
+		reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
 		interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7790_CLK_MSIOF0>;
+		dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -998,9 +1000,11 @@
 
 	msiof1: spi@e6e10000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6e10000 0 0x0064>;
+		reg = <0 0xe6e10000 0 0x0064>, <0 0xe7e10000 0 0x0064>;
 		interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7790_CLK_MSIOF1>;
+		dmas = <&dmac0 0x55>, <&dmac0 0x56>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1008,9 +1012,11 @@
 
 	msiof2: spi@e6e00000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6e00000 0 0x0064>;
+		reg = <0 0xe6e00000 0 0x0064>, <0 0xe7e00000 0 0x0064>;
 		interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7790_CLK_MSIOF2>;
+		dmas = <&dmac0 0x41>, <&dmac0 0x42>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
@@ -1018,9 +1024,11 @@
 
 	msiof3: spi@e6c90000 {
 		compatible = "renesas,msiof-r8a7790";
-		reg = <0 0xe6c90000 0 0x0064>;
+		reg = <0 0xe6c90000 0 0x0064>, <0 0xe7c90000 0 0x0064>;
 		interrupts = <0 159 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp2_clks R8A7790_CLK_MSIOF3>;
+		dmas = <&dmac0 0x45>, <&dmac0 0x46>;
+		dma-names = "tx", "rx";
 		#address-cells = <1>;
 		#size-cells = <0>;
 		status = "disabled";
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 01/12] spi: rspi: Fix leaking of unused DMA descriptors
  2014-08-06 12:58   ` Geert Uytterhoeven
@ 2014-08-06 20:11     ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:11 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:58:58PM +0200, Geert Uytterhoeven wrote:
> If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
> unused DMA descriptors.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 01/12] spi: rspi: Fix leaking of unused DMA descriptors
@ 2014-08-06 20:11     ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:11 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:58:58PM +0200, Geert Uytterhoeven wrote:
> If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
> unused DMA descriptors.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 02/12] spi: rspi: Remove unneeded semicolon
  2014-08-06 12:58   ` Geert Uytterhoeven
@ 2014-08-06 20:26     ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:58:59PM +0200, Geert Uytterhoeven wrote:
> Introduced by commit 426ef76dd8a394a0e04d096941cd9acb49539a3e ("spi:
> rspi: Add DT support").

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 02/12] spi: rspi: Remove unneeded semicolon
@ 2014-08-06 20:26     ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:58:59PM +0200, Geert Uytterhoeven wrote:
> Introduced by commit 426ef76dd8a394a0e04d096941cd9acb49539a3e ("spi:
> rspi: Add DT support").

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 03/12] spi: rspi: Use devm_kasprintf()
       [not found]     ` <1407329949-5695-4-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 20:26         ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA

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

On Wed, Aug 06, 2014 at 02:59:00PM +0200, Geert Uytterhoeven wrote:
> Use the devm_kasprintf() helper function instead of open coding
> error-prone buffer handling and string formatting.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 03/12] spi: rspi: Use devm_kasprintf()
@ 2014-08-06 20:26         ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA

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

On Wed, Aug 06, 2014 at 02:59:00PM +0200, Geert Uytterhoeven wrote:
> Use the devm_kasprintf() helper function instead of open coding
> error-prone buffer handling and string formatting.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 04/12] spi: rspi: Configure DMA slave bus width to 8 bit
  2014-08-06 12:59     ` Geert Uytterhoeven
@ 2014-08-06 20:26       ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:59:01PM +0200, Geert Uytterhoeven wrote:
> The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
> explicit configuration of the DMA slave bus width.
> Hardcode the DMA transfer size to 1 byte for both directions, as that's
> the only supported configuration (16-bit DMA support was removed in
> commit 9c5de2c1754c2bb3c69c4d7bf0d0edc0a61d8232 ("spi: rspi: Remove
> unused 16-bit DMA support")).

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 04/12] spi: rspi: Configure DMA slave bus width to 8 bit
@ 2014-08-06 20:26       ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:59:01PM +0200, Geert Uytterhoeven wrote:
> The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
> explicit configuration of the DMA slave bus width.
> Hardcode the DMA transfer size to 1 byte for both directions, as that's
> the only supported configuration (16-bit DMA support was removed in
> commit 9c5de2c1754c2bb3c69c4d7bf0d0edc0a61d8232 ("spi: rspi: Remove
> unused 16-bit DMA support")).

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 05/12] [v2] spi: rspi: Add DT support to DMA setup
  2014-08-06 12:59     ` Geert Uytterhoeven
@ 2014-08-06 20:28       ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:28 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	devicetree

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

On Wed, Aug 06, 2014 at 02:59:02PM +0200, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: devicetree@vger.kernel.org

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 05/12] [v2] spi: rspi: Add DT support to DMA setup
@ 2014-08-06 20:28       ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:28 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	devicetree

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

On Wed, Aug 06, 2014 at 02:59:02PM +0200, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: devicetree@vger.kernel.org

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 00/12] spi: rspi and sh-msiof driver updates
  2014-08-06 12:58 ` Geert Uytterhoeven
@ 2014-08-06 20:29   ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:58:57PM +0200, Geert Uytterhoeven wrote:
> 	Hi Mark, Simon,
> 
> Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
> I grouped them in three parts:
>   - [1-5] are for the rspi driver (Mark),
>   - [6-8] are for the sh-msiof driver (Mark),
>   - [9-12] are for the R-Car Gen2 DTSes (Simon).

Please don't send big jumbo patch serieses for different things in one
fell swoop - for example the two bug fixes here should probably have
been split out, and the rspi and sh-msiof changes have little
interdependency with the rest of the series.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 00/12] spi: rspi and sh-msiof driver updates
@ 2014-08-06 20:29   ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:58:57PM +0200, Geert Uytterhoeven wrote:
> 	Hi Mark, Simon,
> 
> Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
> I grouped them in three parts:
>   - [1-5] are for the rspi driver (Mark),
>   - [6-8] are for the sh-msiof driver (Mark),
>   - [9-12] are for the R-Car Gen2 DTSes (Simon).

Please don't send big jumbo patch serieses for different things in one
fell swoop - for example the two bug fixes here should probably have
been split out, and the rspi and sh-msiof changes have little
interdependency with the rest of the series.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
  2014-08-06 12:59   ` Geert Uytterhoeven
@ 2014-08-06 20:35     ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:35 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:59:03PM +0200, Geert Uytterhoeven wrote:
> If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
> unused DMA descriptors.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
@ 2014-08-06 20:35     ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:35 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine

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

On Wed, Aug 06, 2014 at 02:59:03PM +0200, Geert Uytterhoeven wrote:
> If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
> unused DMA descriptors.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 07/12] spi: sh-msiof: Configure DMA slave bus width
       [not found]   ` <1407329949-5695-8-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-06 20:36       ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA

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

On Wed, Aug 06, 2014 at 02:59:04PM +0200, Geert Uytterhoeven wrote:
> The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
> explicit configuration of the DMA slave bus width.
> Hardcode the DMA transfer size to 4 bytes, as MSIOF DMA is limited to
> 32-bit words.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 07/12] spi: sh-msiof: Configure DMA slave bus width
@ 2014-08-06 20:36       ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA

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

On Wed, Aug 06, 2014 at 02:59:04PM +0200, Geert Uytterhoeven wrote:
> The new Renesas R-Car Gen2 DMA Controller driver (rcar-dmac) requires
> explicit configuration of the DMA slave bus width.
> Hardcode the DMA transfer size to 4 bytes, as MSIOF DMA is limited to
> 32-bit words.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 08/12] [v2] spi: sh-msiof: Add DT support to DMA setup
  2014-08-06 12:59   ` Geert Uytterhoeven
@ 2014-08-06 20:36     ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	devicetree

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

On Wed, Aug 06, 2014 at 02:59:05PM +0200, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 08/12] [v2] spi: sh-msiof: Add DT support to DMA setup
@ 2014-08-06 20:36     ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-06 20:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, linux-spi, linux-sh, dmaengine,
	devicetree

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

On Wed, Aug 06, 2014 at 02:59:05PM +0200, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
  2014-08-06 12:59   ` Geert Uytterhoeven
@ 2014-08-07  0:07     ` Laurent Pinchart
  -1 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07  0:07 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Simon Horman, linux-spi, linux-sh, dmaengine

Hi Geert,

Thank you for the patch.

On Wednesday 06 August 2014 14:59:03 Geert Uytterhoeven wrote:
> If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
> unused DMA descriptors.
> 
> As per Documentation/dmaengine.txt, once a DMA descriptor has been
> obtained, it must be submitted. Hence:
>   - First prepare and submit all DMA descriptors,
>   - Prepare the SPI controller for DMA,
>   - Start DMA by calling dma_async_issue_pending(),
>   - Make sure to call dmaengine_terminate_all() on all descriptors that
>     haven't completed.
> 
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/spi/spi-sh-msiof.c | 71 ++++++++++++++++++++++---------------------
>  1 file changed, 38 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 2a4354dcd661..887c2084130f 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, dma_cookie_t cookie;
>  	int ret;
> 
> -	if (tx) {
> -		ier_bits |= IER_TDREQE | IER_TDMAE;
> -		dma_sync_single_for_device(p->master->dma_tx->device->dev,
> -					   p->tx_dma_addr, len, DMA_TO_DEVICE);
> -		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
> -					p->tx_dma_addr, len, DMA_TO_DEVICE,
> -					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_tx)
> -			return -EAGAIN;
> -	}
> -
> +	/* First prepare and submit the DMA request(s), as this may fail */
>  	if (rx) {
>  		ier_bits |= IER_RDREQE | IER_RDMAE;
>  		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
>  					p->rx_dma_addr, len, DMA_FROM_DEVICE,
>  					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_rx)
> -			return -EAGAIN;
> -	}
> -
> -	/* 1 stage FIFO watermarks for DMA */
> -	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
> -
> -	/* setup msiof transfer mode registers (32-bit words) */
> -	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
> -
> -	sh_msiof_write(p, IER, ier_bits);
> -
> -	reinit_completion(&p->done);
> +		if (!desc_rx) {
> +			ret = -EAGAIN;
> +			goto no_dma_rx;

You could return -EAGAIN directly here.

> +		}
> 
> -	if (rx) {
>  		desc_rx->callback = sh_msiof_dma_complete;
>  		desc_rx->callback_param = p;
>  		cookie = dmaengine_submit(desc_rx);
>  		if (dma_submit_error(cookie)) {
>  			ret = cookie;
> -			goto stop_ier;
> +			goto no_dma_rx;
>  		}
> -		dma_async_issue_pending(p->master->dma_rx);
>  	}
> 
>  	if (tx) {
> +		ier_bits |= IER_TDREQE | IER_TDMAE;
> +		dma_sync_single_for_device(p->master->dma_tx->device->dev,
> +					   p->tx_dma_addr, len, DMA_TO_DEVICE);
> +		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
> +					p->tx_dma_addr, len, DMA_TO_DEVICE,
> +					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> +		if (!desc_tx) {
> +			ret = -EAGAIN;
> +			goto no_dma_tx;
> +		}
> +
>  		if (rx) {
>  			/* No callback */
>  			desc_tx->callback = NULL;
> @@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, cookie = dmaengine_submit(desc_tx);
>  		if (dma_submit_error(cookie)) {
>  			ret = cookie;
> -			goto stop_rx;
> +			goto no_dma_tx;
>  		}
> -		dma_async_issue_pending(p->master->dma_tx);
>  	}
> 
> +	/* 1 stage FIFO watermarks for DMA */
> +	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
> +
> +	/* setup msiof transfer mode registers (32-bit words) */
> +	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
> +
> +	sh_msiof_write(p, IER, ier_bits);
> +
> +	reinit_completion(&p->done);
> +
> +	/* Now start DMA */
> +	if (tx)
> +		dma_async_issue_pending(p->master->dma_rx);

if (tx) issue pending on dma_rx ? Shouldn't is be tx -> tx and rx -> rx below 
? I would also start rx before tx, but that might be an unnecessary 
precaution.

> +	if (rx)
> +		dma_async_issue_pending(p->master->dma_tx);
> +
>  	ret = sh_msiof_spi_start(p, rx);
>  	if (ret) {
>  		dev_err(&p->pdev->dev, "failed to start hardware\n");
> -		goto stop_tx;
> +		goto stop_dma;
>  	}
> 
>  	/* wait for tx fifo to be emptied / rx fifo to be filled */
> @@ -726,14 +731,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, stop_reset:
>  	sh_msiof_reset_str(p);
>  	sh_msiof_spi_stop(p, rx);
> -stop_tx:
> +stop_dma:
>  	if (tx)
>  		dmaengine_terminate_all(p->master->dma_tx);
> -stop_rx:
> +no_dma_tx:
>  	if (rx)
>  		dmaengine_terminate_all(p->master->dma_rx);
> -stop_ier:
>  	sh_msiof_write(p, IER, 0);
> +no_dma_rx:
>  	return ret;
>  }

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
@ 2014-08-07  0:07     ` Laurent Pinchart
  0 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07  0:07 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Simon Horman, linux-spi, linux-sh, dmaengine

Hi Geert,

Thank you for the patch.

On Wednesday 06 August 2014 14:59:03 Geert Uytterhoeven wrote:
> If dmaengine_prep_slave_sg() or dmaengine_submit() fail, we may leak
> unused DMA descriptors.
> 
> As per Documentation/dmaengine.txt, once a DMA descriptor has been
> obtained, it must be submitted. Hence:
>   - First prepare and submit all DMA descriptors,
>   - Prepare the SPI controller for DMA,
>   - Start DMA by calling dma_async_issue_pending(),
>   - Make sure to call dmaengine_terminate_all() on all descriptors that
>     haven't completed.
> 
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/spi/spi-sh-msiof.c | 71 ++++++++++++++++++++++---------------------
>  1 file changed, 38 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 2a4354dcd661..887c2084130f 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, dma_cookie_t cookie;
>  	int ret;
> 
> -	if (tx) {
> -		ier_bits |= IER_TDREQE | IER_TDMAE;
> -		dma_sync_single_for_device(p->master->dma_tx->device->dev,
> -					   p->tx_dma_addr, len, DMA_TO_DEVICE);
> -		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
> -					p->tx_dma_addr, len, DMA_TO_DEVICE,
> -					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_tx)
> -			return -EAGAIN;
> -	}
> -
> +	/* First prepare and submit the DMA request(s), as this may fail */
>  	if (rx) {
>  		ier_bits |= IER_RDREQE | IER_RDMAE;
>  		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
>  					p->rx_dma_addr, len, DMA_FROM_DEVICE,
>  					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_rx)
> -			return -EAGAIN;
> -	}
> -
> -	/* 1 stage FIFO watermarks for DMA */
> -	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
> -
> -	/* setup msiof transfer mode registers (32-bit words) */
> -	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
> -
> -	sh_msiof_write(p, IER, ier_bits);
> -
> -	reinit_completion(&p->done);
> +		if (!desc_rx) {
> +			ret = -EAGAIN;
> +			goto no_dma_rx;

You could return -EAGAIN directly here.

> +		}
> 
> -	if (rx) {
>  		desc_rx->callback = sh_msiof_dma_complete;
>  		desc_rx->callback_param = p;
>  		cookie = dmaengine_submit(desc_rx);
>  		if (dma_submit_error(cookie)) {
>  			ret = cookie;
> -			goto stop_ier;
> +			goto no_dma_rx;
>  		}
> -		dma_async_issue_pending(p->master->dma_rx);
>  	}
> 
>  	if (tx) {
> +		ier_bits |= IER_TDREQE | IER_TDMAE;
> +		dma_sync_single_for_device(p->master->dma_tx->device->dev,
> +					   p->tx_dma_addr, len, DMA_TO_DEVICE);
> +		desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
> +					p->tx_dma_addr, len, DMA_TO_DEVICE,
> +					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> +		if (!desc_tx) {
> +			ret = -EAGAIN;
> +			goto no_dma_tx;
> +		}
> +
>  		if (rx) {
>  			/* No callback */
>  			desc_tx->callback = NULL;
> @@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, cookie = dmaengine_submit(desc_tx);
>  		if (dma_submit_error(cookie)) {
>  			ret = cookie;
> -			goto stop_rx;
> +			goto no_dma_tx;
>  		}
> -		dma_async_issue_pending(p->master->dma_tx);
>  	}
> 
> +	/* 1 stage FIFO watermarks for DMA */
> +	sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
> +
> +	/* setup msiof transfer mode registers (32-bit words) */
> +	sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
> +
> +	sh_msiof_write(p, IER, ier_bits);
> +
> +	reinit_completion(&p->done);
> +
> +	/* Now start DMA */
> +	if (tx)
> +		dma_async_issue_pending(p->master->dma_rx);

if (tx) issue pending on dma_rx ? Shouldn't is be tx -> tx and rx -> rx below 
? I would also start rx before tx, but that might be an unnecessary 
precaution.

> +	if (rx)
> +		dma_async_issue_pending(p->master->dma_tx);
> +
>  	ret = sh_msiof_spi_start(p, rx);
>  	if (ret) {
>  		dev_err(&p->pdev->dev, "failed to start hardware\n");
> -		goto stop_tx;
> +		goto stop_dma;
>  	}
> 
>  	/* wait for tx fifo to be emptied / rx fifo to be filled */
> @@ -726,14 +731,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, stop_reset:
>  	sh_msiof_reset_str(p);
>  	sh_msiof_spi_stop(p, rx);
> -stop_tx:
> +stop_dma:
>  	if (tx)
>  		dmaengine_terminate_all(p->master->dma_tx);
> -stop_rx:
> +no_dma_tx:
>  	if (rx)
>  		dmaengine_terminate_all(p->master->dma_rx);
> -stop_ier:
>  	sh_msiof_write(p, IER, 0);
> +no_dma_rx:
>  	return ret;
>  }

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 00/12] spi: rspi and sh-msiof driver updates
       [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-07  0:16     ` Laurent Pinchart
  2014-08-06 12:59     ` Geert Uytterhoeven
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07  0:16 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Simon Horman, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA

Hi Geert,

Thank you for the patches.

On Wednesday 06 August 2014 14:58:57 Geert Uytterhoeven wrote:
> 	Hi Mark, Simon,
> 
> Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
> I grouped them in three parts:
>   - [1-5] are for the rspi driver (Mark),
>   - [6-8] are for the sh-msiof driver (Mark),
>   - [9-12] are for the R-Car Gen2 DTSes (Simon).

For everything but 06/12,

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Summary of changes:
>   - [1] and [6] are bug fixes I have sent before, but that weren't applied
>     due to dependency confusion,
>   - [2] is a new cosmetic fix,
>   - [3] makes rspi use a new helper function that will be available as of
>     v3.17-rc1,
>   - [4-5] and [7-8] make DMA work with the new R-Car DMAC driver,
>     developed by Laurent Pinchart in the series "[PATCH v2 0/8] R-Car Gen2
>     DMA Controller driver"
>     (http://www.spinics.net/lists/linux-sh/msg33890.html),
>   - [9-12] enable DMA in DT for r8a7791 and r8a7790, and depend on
>     "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices to DT"
>     (http://www.spinics.net/lists/linux-sh/msg33897.html) resp.
>     "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices to DT"
>     (http://www.spinics.net/lists/linux-sh/msg33896.html) of the
>     aforementioned series.
> 
> This has been tested on r8a7791/koelsch.
> 
> Geert Uytterhoeven (12):
>    [1] spi: rspi: Fix leaking of unused DMA descriptors
>    [2] spi: rspi: Remove unneeded semicolon
>    [3] spi: rspi: Use devm_kasprintf()
>    [4] spi: rspi: Configure DMA slave bus width to 8 bit
>    [5] spi: rspi: Add DT support to DMA setup
>    [6] spi: sh-msiof: Fix leaking of unused DMA descriptors
>    [7] spi: sh-msiof: Configure DMA slave bus width
>    [8] spi: sh-msiof: Add DT support to DMA setup
>    [9] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
>   [10] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF
>   [11] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI
>   [12] ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIOF
> 
>  Documentation/devicetree/bindings/spi/sh-msiof.txt |  17 ++-
>  Documentation/devicetree/bindings/spi/spi-rspi.txt |   5 +
>  arch/arm/boot/dts/r8a7790.dtsi                     |  18 ++-
>  arch/arm/boot/dts/r8a7791.dtsi                     |  14 +-
>  drivers/spi/spi-rspi.c                             | 147 +++++++++++-------
>  drivers/spi/spi-sh-msiof.c                         | 103 +++++++++------
>  6 files changed, 195 insertions(+), 109 deletions(-)

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 00/12] spi: rspi and sh-msiof driver updates
@ 2014-08-07  0:16     ` Laurent Pinchart
  0 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07  0:16 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Simon Horman, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA,
	dmaengine-u79uwXL29TY76Z2rM5mHXA

Hi Geert,

Thank you for the patches.

On Wednesday 06 August 2014 14:58:57 Geert Uytterhoeven wrote:
> 	Hi Mark, Simon,
> 
> Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
> I grouped them in three parts:
>   - [1-5] are for the rspi driver (Mark),
>   - [6-8] are for the sh-msiof driver (Mark),
>   - [9-12] are for the R-Car Gen2 DTSes (Simon).

For everything but 06/12,

Acked-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>

> Summary of changes:
>   - [1] and [6] are bug fixes I have sent before, but that weren't applied
>     due to dependency confusion,
>   - [2] is a new cosmetic fix,
>   - [3] makes rspi use a new helper function that will be available as of
>     v3.17-rc1,
>   - [4-5] and [7-8] make DMA work with the new R-Car DMAC driver,
>     developed by Laurent Pinchart in the series "[PATCH v2 0/8] R-Car Gen2
>     DMA Controller driver"
>     (http://www.spinics.net/lists/linux-sh/msg33890.html),
>   - [9-12] enable DMA in DT for r8a7791 and r8a7790, and depend on
>     "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices to DT"
>     (http://www.spinics.net/lists/linux-sh/msg33897.html) resp.
>     "[PATCH v2 7/8] ARM: shmobile: r8a7790: Add DMAC devices to DT"
>     (http://www.spinics.net/lists/linux-sh/msg33896.html) of the
>     aforementioned series.
> 
> This has been tested on r8a7791/koelsch.
> 
> Geert Uytterhoeven (12):
>    [1] spi: rspi: Fix leaking of unused DMA descriptors
>    [2] spi: rspi: Remove unneeded semicolon
>    [3] spi: rspi: Use devm_kasprintf()
>    [4] spi: rspi: Configure DMA slave bus width to 8 bit
>    [5] spi: rspi: Add DT support to DMA setup
>    [6] spi: sh-msiof: Fix leaking of unused DMA descriptors
>    [7] spi: sh-msiof: Configure DMA slave bus width
>    [8] spi: sh-msiof: Add DT support to DMA setup
>    [9] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
>   [10] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF
>   [11] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI
>   [12] ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIOF
> 
>  Documentation/devicetree/bindings/spi/sh-msiof.txt |  17 ++-
>  Documentation/devicetree/bindings/spi/spi-rspi.txt |   5 +
>  arch/arm/boot/dts/r8a7790.dtsi                     |  18 ++-
>  arch/arm/boot/dts/r8a7791.dtsi                     |  14 +-
>  drivers/spi/spi-rspi.c                             | 147 +++++++++++-------
>  drivers/spi/spi-sh-msiof.c                         | 103 +++++++++------
>  6 files changed, 195 insertions(+), 109 deletions(-)

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
  2014-08-06 12:59     ` Geert Uytterhoeven
@ 2014-08-07  0:37       ` Simon Horman
  -1 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-07  0:37 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Laurent Pinchart, linux-spi, linux-sh, dmaengine, devicetree

On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> Add a DMA property to the QSPI node
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: devicetree@vger.kernel.org
> ---
> This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".

Hi Geert, Hi Laurent,

Am I correct in assuming that with this patch applied things
will continue to work the old way until the patch above applied
to the same tree and from there on the user will get the new behaviour?

If so I think that I can take this patch as although the driver hasn't been
merged the relevant bindings were added to the subsystem maintainers tree
by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
available in linux-next.

Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".

> v2:
>   - Update DMA specifiers to match the renesas,rcar-dmac bindings,
> v2:
>   - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
>   - Reorder: TX first, RX second.
> ---
>  arch/arm/boot/dts/r8a7791.dtsi | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> index d59af615e365..8186c9f4a18a 100644
> --- a/arch/arm/boot/dts/r8a7791.dtsi
> +++ b/arch/arm/boot/dts/r8a7791.dtsi
> @@ -1044,6 +1044,8 @@
>  		reg = <0 0xe6b10000 0 0x2c>;
>  		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
>  		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
> +		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
> +		dma-names = "tx", "rx";
>  		num-cs = <1>;
>  		#address-cells = <1>;
>  		#size-cells = <0>;
> -- 
> 1.9.1
> 

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
@ 2014-08-07  0:37       ` Simon Horman
  0 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-07  0:37 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Laurent Pinchart, linux-spi, linux-sh, dmaengine, devicetree

On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> Add a DMA property to the QSPI node
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: devicetree@vger.kernel.org
> ---
> This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".

Hi Geert, Hi Laurent,

Am I correct in assuming that with this patch applied things
will continue to work the old way until the patch above applied
to the same tree and from there on the user will get the new behaviour?

If so I think that I can take this patch as although the driver hasn't been
merged the relevant bindings were added to the subsystem maintainers tree
by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
available in linux-next.

Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".

> v2:
>   - Update DMA specifiers to match the renesas,rcar-dmac bindings,
> v2:
>   - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
>   - Reorder: TX first, RX second.
> ---
>  arch/arm/boot/dts/r8a7791.dtsi | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> index d59af615e365..8186c9f4a18a 100644
> --- a/arch/arm/boot/dts/r8a7791.dtsi
> +++ b/arch/arm/boot/dts/r8a7791.dtsi
> @@ -1044,6 +1044,8 @@
>  		reg = <0 0xe6b10000 0 0x2c>;
>  		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
>  		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
> +		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
> +		dma-names = "tx", "rx";
>  		num-cs = <1>;
>  		#address-cells = <1>;
>  		#size-cells = <0>;
> -- 
> 1.9.1
> 

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
  2014-08-07  0:37       ` Simon Horman
@ 2014-08-07  0:39         ` Simon Horman
  -1 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-07  0:39 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Laurent Pinchart, linux-spi, linux-sh, dmaengine, devicetree

On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
> On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> > Add a DMA property to the QSPI node
> > 
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Cc: devicetree@vger.kernel.org
> > ---
> > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
> 
> Hi Geert, Hi Laurent,
> 
> Am I correct in assuming that with this patch applied things
> will continue to work the old way until the patch above applied
> to the same tree and from there on the user will get the new behaviour?
> 
> If so I think that I can take this patch as although the driver hasn't been
> merged the relevant bindings were added to the subsystem maintainers tree
> by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
> available in linux-next.
> 
> Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".

... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"

> > v2:
> >   - Update DMA specifiers to match the renesas,rcar-dmac bindings,
> > v2:
> >   - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
> >   - Reorder: TX first, RX second.
> > ---
> >  arch/arm/boot/dts/r8a7791.dtsi | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> > index d59af615e365..8186c9f4a18a 100644
> > --- a/arch/arm/boot/dts/r8a7791.dtsi
> > +++ b/arch/arm/boot/dts/r8a7791.dtsi
> > @@ -1044,6 +1044,8 @@
> >  		reg = <0 0xe6b10000 0 0x2c>;
> >  		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
> >  		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
> > +		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
> > +		dma-names = "tx", "rx";
> >  		num-cs = <1>;
> >  		#address-cells = <1>;
> >  		#size-cells = <0>;
> > -- 
> > 1.9.1
> > 

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
@ 2014-08-07  0:39         ` Simon Horman
  0 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-07  0:39 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Laurent Pinchart, linux-spi, linux-sh, dmaengine, devicetree

On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
> On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> > Add a DMA property to the QSPI node
> > 
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Cc: devicetree@vger.kernel.org
> > ---
> > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
> 
> Hi Geert, Hi Laurent,
> 
> Am I correct in assuming that with this patch applied things
> will continue to work the old way until the patch above applied
> to the same tree and from there on the user will get the new behaviour?
> 
> If so I think that I can take this patch as although the driver hasn't been
> merged the relevant bindings were added to the subsystem maintainers tree
> by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
> available in linux-next.
> 
> Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".

... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"

> > v2:
> >   - Update DMA specifiers to match the renesas,rcar-dmac bindings,
> > v2:
> >   - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
> >   - Reorder: TX first, RX second.
> > ---
> >  arch/arm/boot/dts/r8a7791.dtsi | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> > index d59af615e365..8186c9f4a18a 100644
> > --- a/arch/arm/boot/dts/r8a7791.dtsi
> > +++ b/arch/arm/boot/dts/r8a7791.dtsi
> > @@ -1044,6 +1044,8 @@
> >  		reg = <0 0xe6b10000 0 0x2c>;
> >  		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
> >  		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
> > +		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
> > +		dma-names = "tx", "rx";
> >  		num-cs = <1>;
> >  		#address-cells = <1>;
> >  		#size-cells = <0>;
> > -- 
> > 1.9.1
> > 

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
  2014-08-07  0:39         ` Simon Horman
@ 2014-08-07  0:41           ` Simon Horman
  -1 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-07  0:41 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Laurent Pinchart, linux-spi, linux-sh, dmaengine, devicetree

On Thu, Aug 07, 2014 at 09:39:08AM +0900, Simon Horman wrote:
> On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
> > On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> > > Add a DMA property to the QSPI node
> > > 
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > Cc: devicetree@vger.kernel.org
> > > ---
> > > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> > > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
> > 
> > Hi Geert, Hi Laurent,
> > 
> > Am I correct in assuming that with this patch applied things
> > will continue to work the old way until the patch above applied
> > to the same tree and from there on the user will get the new behaviour?
> > 
> > If so I think that I can take this patch as although the driver hasn't been
> > merged the relevant bindings were added to the subsystem maintainers tree
> > by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
> > available in linux-next.
> > 
> > Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".
> 
> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"

... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIO"

and any other similar patches I didn't list above :)

> 
> > > v2:
> > >   - Update DMA specifiers to match the renesas,rcar-dmac bindings,
> > > v2:
> > >   - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
> > >   - Reorder: TX first, RX second.
> > > ---
> > >  arch/arm/boot/dts/r8a7791.dtsi | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> > > index d59af615e365..8186c9f4a18a 100644
> > > --- a/arch/arm/boot/dts/r8a7791.dtsi
> > > +++ b/arch/arm/boot/dts/r8a7791.dtsi
> > > @@ -1044,6 +1044,8 @@
> > >  		reg = <0 0xe6b10000 0 0x2c>;
> > >  		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
> > >  		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
> > > +		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
> > > +		dma-names = "tx", "rx";
> > >  		num-cs = <1>;
> > >  		#address-cells = <1>;
> > >  		#size-cells = <0>;
> > > -- 
> > > 1.9.1
> > > 

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
@ 2014-08-07  0:41           ` Simon Horman
  0 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-07  0:41 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Mark Brown, Laurent Pinchart, linux-spi, linux-sh, dmaengine, devicetree

On Thu, Aug 07, 2014 at 09:39:08AM +0900, Simon Horman wrote:
> On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
> > On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> > > Add a DMA property to the QSPI node
> > > 
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > Cc: devicetree@vger.kernel.org
> > > ---
> > > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> > > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
> > 
> > Hi Geert, Hi Laurent,
> > 
> > Am I correct in assuming that with this patch applied things
> > will continue to work the old way until the patch above applied
> > to the same tree and from there on the user will get the new behaviour?
> > 
> > If so I think that I can take this patch as although the driver hasn't been
> > merged the relevant bindings were added to the subsystem maintainers tree
> > by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
> > available in linux-next.
> > 
> > Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".
> 
> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"

... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIO"

and any other similar patches I didn't list above :)

> 
> > > v2:
> > >   - Update DMA specifiers to match the renesas,rcar-dmac bindings,
> > > v2:
> > >   - QSPI needs to use 8-bit accesses for DMA, not 32-bit,
> > >   - Reorder: TX first, RX second.
> > > ---
> > >  arch/arm/boot/dts/r8a7791.dtsi | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> > > index d59af615e365..8186c9f4a18a 100644
> > > --- a/arch/arm/boot/dts/r8a7791.dtsi
> > > +++ b/arch/arm/boot/dts/r8a7791.dtsi
> > > @@ -1044,6 +1044,8 @@
> > >  		reg = <0 0xe6b10000 0 0x2c>;
> > >  		interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
> > >  		clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
> > > +		dmas = <&dmac0 0x17>, <&dmac0 0x18>;
> > > +		dma-names = "tx", "rx";
> > >  		num-cs = <1>;
> > >  		#address-cells = <1>;
> > >  		#size-cells = <0>;
> > > -- 
> > > 1.9.1
> > > 

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
       [not found]           ` <20140807004107.GB30872-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
@ 2014-08-07  8:27               ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07  8:27 UTC (permalink / raw)
  To: Simon Horman
  Cc: Geert Uytterhoeven, Mark Brown, Laurent Pinchart, linux-spi,
	Linux-sh list, dmaengine-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Hi Simon,

On Thu, Aug 7, 2014 at 2:41 AM, Simon Horman <horms@verge.net.au> wrote:
> On Thu, Aug 07, 2014 at 09:39:08AM +0900, Simon Horman wrote:
>> On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
>> > On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
>> > > Add a DMA property to the QSPI node
>> > >
>> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> > > Cc: devicetree@vger.kernel.org
>> > > ---
>> > > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
>> > > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
>> >
>> > Hi Geert, Hi Laurent,
>> >
>> > Am I correct in assuming that with this patch applied things
>> > will continue to work the old way until the patch above applied
>> > to the same tree and from there on the user will get the new behaviour?
>> >
>> > If so I think that I can take this patch as although the driver hasn't been
>> > merged the relevant bindings were added to the subsystem maintainers tree
>> > by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
>> > available in linux-next.
>> >
>> > Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".
>>
>> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"
>
> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIO"
>
> and any other similar patches I didn't list above :)

Yes[*].

If rcar-dma is not available, drivers fall back to PIO, cfr. for rspi:

-renesas_spi e6b10000.spi: DMA available
+renesas_spi e6b10000.spi: dma_request_slave_channel_compat failed
+renesas_spi e6b10000.spi: DMA not available, using PIO
 renesas_spi e6b10000.spi: registered master spi0
 spi spi0.0: setup mode 0, 8 bits/w, 30000000 Hz max --> 0
 m25p80 spi0.0: s25fl512s (65536 Kbytes)
 3 ofpart partitions found on MTD device spi0.0
 Creating 3 MTD partitions on "spi0.0":
 0x000000000000-0x000000080000 : "loader"
 0x000000080000-0x000000100000 : "bootenv"
 0x000000100000-0x000004000000 : "data"
 renesas_spi e6b10000.spi: registered child spi0.0

and sh-msiof:

-spi_sh_msiof e6e20000.spi: DMA available
+spi_sh_msiof e6e20000.spi: dma_request_slave_channel_compat failed
+spi_sh_msiof e6e20000.spi: DMA not available, using PIO
 spi_sh_msiof e6e20000.spi: registered master spi1
 spi spi1.0: setup mode 3, 8 bits/w, 6000000 Hz max --> 0
 spi_sh_msiof e6e20000.spi: registered child spi1.0

and everything still works, but slower.

[*] If the individual DMA slave drivers properly handle DMA request
    failures. If they don't, they will already fail now, as there is no DMA
    platform configuration without the dmas/dma-names properties
    (ignoring Magnus' DMA prototypes using auxdata, as DT is the way
     forward).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
@ 2014-08-07  8:27               ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07  8:27 UTC (permalink / raw)
  To: Simon Horman
  Cc: Geert Uytterhoeven, Mark Brown, Laurent Pinchart, linux-spi,
	Linux-sh list, dmaengine-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Hi Simon,

On Thu, Aug 7, 2014 at 2:41 AM, Simon Horman <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org> wrote:
> On Thu, Aug 07, 2014 at 09:39:08AM +0900, Simon Horman wrote:
>> On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
>> > On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
>> > > Add a DMA property to the QSPI node
>> > >
>> > > Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
>> > > Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> > > ---
>> > > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
>> > > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
>> >
>> > Hi Geert, Hi Laurent,
>> >
>> > Am I correct in assuming that with this patch applied things
>> > will continue to work the old way until the patch above applied
>> > to the same tree and from there on the user will get the new behaviour?
>> >
>> > If so I think that I can take this patch as although the driver hasn't been
>> > merged the relevant bindings were added to the subsystem maintainers tree
>> > by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
>> > available in linux-next.
>> >
>> > Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".
>>
>> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"
>
> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIO"
>
> and any other similar patches I didn't list above :)

Yes[*].

If rcar-dma is not available, drivers fall back to PIO, cfr. for rspi:

-renesas_spi e6b10000.spi: DMA available
+renesas_spi e6b10000.spi: dma_request_slave_channel_compat failed
+renesas_spi e6b10000.spi: DMA not available, using PIO
 renesas_spi e6b10000.spi: registered master spi0
 spi spi0.0: setup mode 0, 8 bits/w, 30000000 Hz max --> 0
 m25p80 spi0.0: s25fl512s (65536 Kbytes)
 3 ofpart partitions found on MTD device spi0.0
 Creating 3 MTD partitions on "spi0.0":
 0x000000000000-0x000000080000 : "loader"
 0x000000080000-0x000000100000 : "bootenv"
 0x000000100000-0x000004000000 : "data"
 renesas_spi e6b10000.spi: registered child spi0.0

and sh-msiof:

-spi_sh_msiof e6e20000.spi: DMA available
+spi_sh_msiof e6e20000.spi: dma_request_slave_channel_compat failed
+spi_sh_msiof e6e20000.spi: DMA not available, using PIO
 spi_sh_msiof e6e20000.spi: registered master spi1
 spi spi1.0: setup mode 3, 8 bits/w, 6000000 Hz max --> 0
 spi_sh_msiof e6e20000.spi: registered child spi1.0

and everything still works, but slower.

[*] If the individual DMA slave drivers properly handle DMA request
    failures. If they don't, they will already fail now, as there is no DMA
    platform configuration without the dmas/dma-names properties
    (ignoring Magnus' DMA prototypes using auxdata, as DT is the way
     forward).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
  2014-08-07  0:07     ` Laurent Pinchart
@ 2014-08-07  8:55       ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07  8:55 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Geert Uytterhoeven, Mark Brown, Simon Horman, linux-spi,
	Linux-sh list, dmaengine

Hi Laurent,

On Thu, Aug 7, 2014 at 2:07 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Wednesday 06 August 2014 14:59:03 Geert Uytterhoeven wrote:
>> +++ b/drivers/spi/spi-sh-msiof.c
>> @@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
>> *p, const void *tx, dma_cookie_t cookie;
>>       int ret;
>>
>> -     if (tx) {
>> -             ier_bits |= IER_TDREQE | IER_TDMAE;
>> -             dma_sync_single_for_device(p->master->dma_tx->device->dev,
>> -                                        p->tx_dma_addr, len, DMA_TO_DEVICE);
>> -             desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
>> -                                     p->tx_dma_addr, len, DMA_TO_DEVICE,
>> -                                     DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>> -             if (!desc_tx)
>> -                     return -EAGAIN;
>> -     }
>> -
>> +     /* First prepare and submit the DMA request(s), as this may fail */
>>       if (rx) {
>>               ier_bits |= IER_RDREQE | IER_RDMAE;
>>               desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
>>                                       p->rx_dma_addr, len, DMA_FROM_DEVICE,
>>                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>> -             if (!desc_rx)
>> -                     return -EAGAIN;
>> -     }
>> -
>> -     /* 1 stage FIFO watermarks for DMA */
>> -     sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
>> -
>> -     /* setup msiof transfer mode registers (32-bit words) */
>> -     sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
>> -
>> -     sh_msiof_write(p, IER, ier_bits);
>> -
>> -     reinit_completion(&p->done);
>> +             if (!desc_rx) {
>> +                     ret = -EAGAIN;
>> +                     goto no_dma_rx;
>
> You could return -EAGAIN directly here.

Indeed...

>> +             }
>>
>> -     if (rx) {
>>               desc_rx->callback = sh_msiof_dma_complete;
>>               desc_rx->callback_param = p;
>>               cookie = dmaengine_submit(desc_rx);
>>               if (dma_submit_error(cookie)) {
>>                       ret = cookie;
>> -                     goto stop_ier;
>> +                     goto no_dma_rx;

... and here, too. Will do.

>> @@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
>> *p, const void *tx, cookie = dmaengine_submit(desc_tx);
>>               if (dma_submit_error(cookie)) {
>>                       ret = cookie;
>> -                     goto stop_rx;
>> +                     goto no_dma_tx;
>>               }
>> -             dma_async_issue_pending(p->master->dma_tx);
>>       }
>>
>> +     /* 1 stage FIFO watermarks for DMA */
>> +     sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
>> +
>> +     /* setup msiof transfer mode registers (32-bit words) */
>> +     sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
>> +
>> +     sh_msiof_write(p, IER, ier_bits);
>> +
>> +     reinit_completion(&p->done);
>> +
>> +     /* Now start DMA */
>> +     if (tx)
>> +             dma_async_issue_pending(p->master->dma_rx);
>
> if (tx) issue pending on dma_rx ? Shouldn't is be tx -> tx and rx -> rx below
> ? I would also start rx before tx, but that might be an unnecessary
> precaution.

Woops. That check should indeed be "if (rx)", and the one below should
be "if (tx)".

>> +     if (rx)
>> +             dma_async_issue_pending(p->master->dma_tx);
>> +

While I did test transmit-only in the past, usually I tested transmit + receive
only, as the attached PMIC doesn't offer much test potential for large
write-only transfers.

Will send an update soon.

Thanks for your review!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors
@ 2014-08-07  8:55       ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07  8:55 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Geert Uytterhoeven, Mark Brown, Simon Horman, linux-spi,
	Linux-sh list, dmaengine

Hi Laurent,

On Thu, Aug 7, 2014 at 2:07 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Wednesday 06 August 2014 14:59:03 Geert Uytterhoeven wrote:
>> +++ b/drivers/spi/spi-sh-msiof.c
>> @@ -636,48 +636,38 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
>> *p, const void *tx, dma_cookie_t cookie;
>>       int ret;
>>
>> -     if (tx) {
>> -             ier_bits |= IER_TDREQE | IER_TDMAE;
>> -             dma_sync_single_for_device(p->master->dma_tx->device->dev,
>> -                                        p->tx_dma_addr, len, DMA_TO_DEVICE);
>> -             desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
>> -                                     p->tx_dma_addr, len, DMA_TO_DEVICE,
>> -                                     DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>> -             if (!desc_tx)
>> -                     return -EAGAIN;
>> -     }
>> -
>> +     /* First prepare and submit the DMA request(s), as this may fail */
>>       if (rx) {
>>               ier_bits |= IER_RDREQE | IER_RDMAE;
>>               desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
>>                                       p->rx_dma_addr, len, DMA_FROM_DEVICE,
>>                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>> -             if (!desc_rx)
>> -                     return -EAGAIN;
>> -     }
>> -
>> -     /* 1 stage FIFO watermarks for DMA */
>> -     sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
>> -
>> -     /* setup msiof transfer mode registers (32-bit words) */
>> -     sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
>> -
>> -     sh_msiof_write(p, IER, ier_bits);
>> -
>> -     reinit_completion(&p->done);
>> +             if (!desc_rx) {
>> +                     ret = -EAGAIN;
>> +                     goto no_dma_rx;
>
> You could return -EAGAIN directly here.

Indeed...

>> +             }
>>
>> -     if (rx) {
>>               desc_rx->callback = sh_msiof_dma_complete;
>>               desc_rx->callback_param = p;
>>               cookie = dmaengine_submit(desc_rx);
>>               if (dma_submit_error(cookie)) {
>>                       ret = cookie;
>> -                     goto stop_ier;
>> +                     goto no_dma_rx;

... and here, too. Will do.

>> @@ -688,15 +678,30 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
>> *p, const void *tx, cookie = dmaengine_submit(desc_tx);
>>               if (dma_submit_error(cookie)) {
>>                       ret = cookie;
>> -                     goto stop_rx;
>> +                     goto no_dma_tx;
>>               }
>> -             dma_async_issue_pending(p->master->dma_tx);
>>       }
>>
>> +     /* 1 stage FIFO watermarks for DMA */
>> +     sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
>> +
>> +     /* setup msiof transfer mode registers (32-bit words) */
>> +     sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
>> +
>> +     sh_msiof_write(p, IER, ier_bits);
>> +
>> +     reinit_completion(&p->done);
>> +
>> +     /* Now start DMA */
>> +     if (tx)
>> +             dma_async_issue_pending(p->master->dma_rx);
>
> if (tx) issue pending on dma_rx ? Shouldn't is be tx -> tx and rx -> rx below
> ? I would also start rx before tx, but that might be an unnecessary
> precaution.

Woops. That check should indeed be "if (rx)", and the one below should
be "if (tx)".

>> +     if (rx)
>> +             dma_async_issue_pending(p->master->dma_tx);
>> +

While I did test transmit-only in the past, usually I tested transmit + receive
only, as the attached PMIC doesn't offer much test potential for large
write-only transfers.

Will send an update soon.

Thanks for your review!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible
       [not found]       ` <CAMuHMdUd3OKqDwhLSCMW-rEQSnWky+saN5TgC005rkmNPfEL+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-08-07 12:07           ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07 12:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors")
---
 drivers/spi/spi-sh-msiof.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 887c2084130f..0d9ccd0953de 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -642,18 +642,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
 					p->rx_dma_addr, len, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx) {
-			ret = -EAGAIN;
-			goto no_dma_rx;
-		}
+		if (!desc_rx)
+			return -EAGAIN;
 
 		desc_rx->callback = sh_msiof_dma_complete;
 		desc_rx->callback_param = p;
 		cookie = dmaengine_submit(desc_rx);
-		if (dma_submit_error(cookie)) {
-			ret = cookie;
-			goto no_dma_rx;
-		}
+		if (dma_submit_error(cookie))
+			return cookie;
 	}
 
 	if (tx) {
@@ -738,7 +734,6 @@ no_dma_tx:
 	if (rx)
 		dmaengine_terminate_all(p->master->dma_rx);
 	sh_msiof_write(p, IER, 0);
-no_dma_rx:
 	return ret;
 }
 
-- 
1.9.1


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

* [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible
@ 2014-08-07 12:07           ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07 12:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Reported-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors")
---
 drivers/spi/spi-sh-msiof.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 887c2084130f..0d9ccd0953de 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -642,18 +642,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
 					p->rx_dma_addr, len, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx) {
-			ret = -EAGAIN;
-			goto no_dma_rx;
-		}
+		if (!desc_rx)
+			return -EAGAIN;
 
 		desc_rx->callback = sh_msiof_dma_complete;
 		desc_rx->callback_param = p;
 		cookie = dmaengine_submit(desc_rx);
-		if (dma_submit_error(cookie)) {
-			ret = cookie;
-			goto no_dma_rx;
-		}
+		if (dma_submit_error(cookie))
+			return cookie;
 	}
 
 	if (tx) {
@@ -738,7 +734,6 @@ no_dma_tx:
 	if (rx)
 		dmaengine_terminate_all(p->master->dma_rx);
 	sh_msiof_write(p, IER, 0);
-no_dma_rx:
 	return ret;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/2] spi: sh-msiof: Fix transmit-only DMA transfers
       [not found]           ` <1407413263-20177-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-08-07 12:07               ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07 12:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Fix tx/rx mixup, which broke transmit-only transfers.

Introduced by commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors").

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors")
---
 drivers/spi/spi-sh-msiof.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0d9ccd0953de..5ee13a2d93df 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -689,9 +689,9 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 	reinit_completion(&p->done);
 
 	/* Now start DMA */
-	if (tx)
-		dma_async_issue_pending(p->master->dma_rx);
 	if (rx)
+		dma_async_issue_pending(p->master->dma_rx);
+	if (tx)
 		dma_async_issue_pending(p->master->dma_tx);
 
 	ret = sh_msiof_spi_start(p, rx);
-- 
1.9.1


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

* [PATCH 2/2] spi: sh-msiof: Fix transmit-only DMA transfers
@ 2014-08-07 12:07               ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-08-07 12:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Fix tx/rx mixup, which broke transmit-only transfers.

Introduced by commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors").

Reported-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors")
---
 drivers/spi/spi-sh-msiof.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0d9ccd0953de..5ee13a2d93df 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -689,9 +689,9 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 	reinit_completion(&p->done);
 
 	/* Now start DMA */
-	if (tx)
-		dma_async_issue_pending(p->master->dma_rx);
 	if (rx)
+		dma_async_issue_pending(p->master->dma_rx);
+	if (tx)
 		dma_async_issue_pending(p->master->dma_tx);
 
 	ret = sh_msiof_spi_start(p, rx);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] spi: sh-msiof: Fix transmit-only DMA transfers
  2014-08-07 12:07               ` Geert Uytterhoeven
@ 2014-08-07 12:51                 ` Laurent Pinchart
  -1 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07 12:51 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh

Hi Geert,

On Thursday 07 August 2014 14:07:43 Geert Uytterhoeven wrote:
> Fix tx/rx mixup, which broke transmit-only transfers.
> 
> Introduced by commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors").
> 
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors")
> ---
>  drivers/spi/spi-sh-msiof.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 0d9ccd0953de..5ee13a2d93df 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -689,9 +689,9 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, reinit_completion(&p->done);
> 
>  	/* Now start DMA */
> -	if (tx)
> -		dma_async_issue_pending(p->master->dma_rx);
>  	if (rx)
> +		dma_async_issue_pending(p->master->dma_rx);
> +	if (tx)
>  		dma_async_issue_pending(p->master->dma_tx);
> 
>  	ret = sh_msiof_spi_start(p, rx);

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 2/2] spi: sh-msiof: Fix transmit-only DMA transfers
@ 2014-08-07 12:51                 ` Laurent Pinchart
  0 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07 12:51 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh

Hi Geert,

On Thursday 07 August 2014 14:07:43 Geert Uytterhoeven wrote:
> Fix tx/rx mixup, which broke transmit-only transfers.
> 
> Introduced by commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors").
> 
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors")
> ---
>  drivers/spi/spi-sh-msiof.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 0d9ccd0953de..5ee13a2d93df 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -689,9 +689,9 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, reinit_completion(&p->done);
> 
>  	/* Now start DMA */
> -	if (tx)
> -		dma_async_issue_pending(p->master->dma_rx);
>  	if (rx)
> +		dma_async_issue_pending(p->master->dma_rx);
> +	if (tx)
>  		dma_async_issue_pending(p->master->dma_tx);
> 
>  	ret = sh_msiof_spi_start(p, rx);

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible
  2014-08-07 12:07           ` Geert Uytterhoeven
@ 2014-08-07 12:52             ` Laurent Pinchart
  -1 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07 12:52 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh

Hi Geert,

On Thursday 07 August 2014 14:07:42 Geert Uytterhoeven wrote:
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors")
> ---
>  drivers/spi/spi-sh-msiof.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 887c2084130f..0d9ccd0953de 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -642,18 +642,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, desc_rx > dmaengine_prep_slave_single(p->master->dma_rx,
>  					p->rx_dma_addr, len, DMA_FROM_DEVICE,
>  					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_rx) {
> -			ret = -EAGAIN;
> -			goto no_dma_rx;
> -		}
> +		if (!desc_rx)
> +			return -EAGAIN;
> 
>  		desc_rx->callback = sh_msiof_dma_complete;
>  		desc_rx->callback_param = p;
>  		cookie = dmaengine_submit(desc_rx);
> -		if (dma_submit_error(cookie)) {
> -			ret = cookie;
> -			goto no_dma_rx;
> -		}
> +		if (dma_submit_error(cookie))
> +			return cookie;
>  	}
> 
>  	if (tx) {
> @@ -738,7 +734,6 @@ no_dma_tx:
>  	if (rx)
>  		dmaengine_terminate_all(p->master->dma_rx);
>  	sh_msiof_write(p, IER, 0);
> -no_dma_rx:
>  	return ret;
>  }

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible
@ 2014-08-07 12:52             ` Laurent Pinchart
  0 siblings, 0 replies; 70+ messages in thread
From: Laurent Pinchart @ 2014-08-07 12:52 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh

Hi Geert,

On Thursday 07 August 2014 14:07:42 Geert Uytterhoeven wrote:
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors")
> ---
>  drivers/spi/spi-sh-msiof.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 887c2084130f..0d9ccd0953de 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -642,18 +642,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, desc_rx =
> dmaengine_prep_slave_single(p->master->dma_rx,
>  					p->rx_dma_addr, len, DMA_FROM_DEVICE,
>  					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_rx) {
> -			ret = -EAGAIN;
> -			goto no_dma_rx;
> -		}
> +		if (!desc_rx)
> +			return -EAGAIN;
> 
>  		desc_rx->callback = sh_msiof_dma_complete;
>  		desc_rx->callback_param = p;
>  		cookie = dmaengine_submit(desc_rx);
> -		if (dma_submit_error(cookie)) {
> -			ret = cookie;
> -			goto no_dma_rx;
> -		}
> +		if (dma_submit_error(cookie))
> +			return cookie;
>  	}
> 
>  	if (tx) {
> @@ -738,7 +734,6 @@ no_dma_tx:
>  	if (rx)
>  		dmaengine_terminate_all(p->master->dma_rx);
>  	sh_msiof_write(p, IER, 0);
> -no_dma_rx:
>  	return ret;
>  }

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible
  2014-08-07 12:07           ` Geert Uytterhoeven
@ 2014-08-07 17:41             ` Mark Brown
  -1 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-07 17:41 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Laurent Pinchart, linux-spi, linux-sh

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

On Thu, Aug 07, 2014 at 02:07:42PM +0200, Geert Uytterhoeven wrote:
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied both, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible
@ 2014-08-07 17:41             ` Mark Brown
  0 siblings, 0 replies; 70+ messages in thread
From: Mark Brown @ 2014-08-07 17:41 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Laurent Pinchart, linux-spi, linux-sh

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

On Thu, Aug 07, 2014 at 02:07:42PM +0200, Geert Uytterhoeven wrote:
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied both, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
  2014-08-07  8:27               ` Geert Uytterhoeven
@ 2014-08-08  1:38                 ` Simon Horman
  -1 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-08  1:38 UTC (permalink / raw)
  To: Geert Uytterhoeven, Laurent Pinchart
  Cc: Geert Uytterhoeven, Mark Brown, linux-spi, Linux-sh list,
	dmaengine, devicetree

On Thu, Aug 07, 2014 at 10:27:21AM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Thu, Aug 7, 2014 at 2:41 AM, Simon Horman <horms@verge.net.au> wrote:
> > On Thu, Aug 07, 2014 at 09:39:08AM +0900, Simon Horman wrote:
> >> On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
> >> > On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> >> > > Add a DMA property to the QSPI node
> >> > >
> >> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >> > > Cc: devicetree@vger.kernel.org
> >> > > ---
> >> > > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> >> > > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
> >> >
> >> > Hi Geert, Hi Laurent,
> >> >
> >> > Am I correct in assuming that with this patch applied things
> >> > will continue to work the old way until the patch above applied
> >> > to the same tree and from there on the user will get the new behaviour?
> >> >
> >> > If so I think that I can take this patch as although the driver hasn't been
> >> > merged the relevant bindings were added to the subsystem maintainers tree
> >> > by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
> >> > available in linux-next.
> >> >
> >> > Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".
> >>
> >> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"
> >
> > ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIO"
> >
> > and any other similar patches I didn't list above :)
> 
> Yes[*].
> 
> If rcar-dma is not available, drivers fall back to PIO, cfr. for rspi:
> 
> -renesas_spi e6b10000.spi: DMA available
> +renesas_spi e6b10000.spi: dma_request_slave_channel_compat failed
> +renesas_spi e6b10000.spi: DMA not available, using PIO
>  renesas_spi e6b10000.spi: registered master spi0
>  spi spi0.0: setup mode 0, 8 bits/w, 30000000 Hz max --> 0
>  m25p80 spi0.0: s25fl512s (65536 Kbytes)
>  3 ofpart partitions found on MTD device spi0.0
>  Creating 3 MTD partitions on "spi0.0":
>  0x000000000000-0x000000080000 : "loader"
>  0x000000080000-0x000000100000 : "bootenv"
>  0x000000100000-0x000004000000 : "data"
>  renesas_spi e6b10000.spi: registered child spi0.0
> 
> and sh-msiof:
> 
> -spi_sh_msiof e6e20000.spi: DMA available
> +spi_sh_msiof e6e20000.spi: dma_request_slave_channel_compat failed
> +spi_sh_msiof e6e20000.spi: DMA not available, using PIO
>  spi_sh_msiof e6e20000.spi: registered master spi1
>  spi spi1.0: setup mode 3, 8 bits/w, 6000000 Hz max --> 0
>  spi_sh_msiof e6e20000.spi: registered child spi1.0
> 
> and everything still works, but slower.
> 
> [*] If the individual DMA slave drivers properly handle DMA request
>     failures. If they don't, they will already fail now, as there is no DMA
>     platform configuration without the dmas/dma-names properties
>     (ignoring Magnus' DMA prototypes using auxdata, as DT is the way
>      forward).

Thanks, I have queued up the 4 shmobile patches for v3.18 with
Laurent's Ack. They should appear in the devel branch of the renesas tree
some time today.

On Thu, Aug 07, 2014 at 02:16:47AM +0200, Laurent Pinchart wrote:
> Hi Geert,
> 
> Thank you for the patches.
> 
> On Wednesday 06 August 2014 14:58:57 Geert Uytterhoeven wrote:
> > 	Hi Mark, Simon,
> > 
> > Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
> > I grouped them in three parts:
> >   - [1-5] are for the rspi driver (Mark),
> >   - [6-8] are for the sh-msiof driver (Mark),
> >   - [9-12] are for the R-Car Gen2 DTSes (Simon).
> 
> For everything but 06/12,
> 
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

[snip]


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

* Re: [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI
@ 2014-08-08  1:38                 ` Simon Horman
  0 siblings, 0 replies; 70+ messages in thread
From: Simon Horman @ 2014-08-08  1:38 UTC (permalink / raw)
  To: Geert Uytterhoeven, Laurent Pinchart
  Cc: Geert Uytterhoeven, Mark Brown, linux-spi, Linux-sh list,
	dmaengine, devicetree

On Thu, Aug 07, 2014 at 10:27:21AM +0200, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Thu, Aug 7, 2014 at 2:41 AM, Simon Horman <horms@verge.net.au> wrote:
> > On Thu, Aug 07, 2014 at 09:39:08AM +0900, Simon Horman wrote:
> >> On Thu, Aug 07, 2014 at 09:37:56AM +0900, Simon Horman wrote:
> >> > On Wed, Aug 06, 2014 at 02:59:06PM +0200, Geert Uytterhoeven wrote:
> >> > > Add a DMA property to the QSPI node
> >> > >
> >> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >> > > Cc: devicetree@vger.kernel.org
> >> > > ---
> >> > > This depends on "[PATCH v2 8/8] ARM: shmobile: r8a7791: Add DMAC devices
> >> > > to DT" of series "[PATCH v2 0/8] R-Car Gen2 DMA Controller driver".
> >> >
> >> > Hi Geert, Hi Laurent,
> >> >
> >> > Am I correct in assuming that with this patch applied things
> >> > will continue to work the old way until the patch above applied
> >> > to the same tree and from there on the user will get the new behaviour?
> >> >
> >> > If so I think that I can take this patch as although the driver hasn't been
> >> > merged the relevant bindings were added to the subsystem maintainers tree
> >> > by "dmaengine: rcar-dmac: Add device tree bindings documentation" and are
> >> > available in linux-next.
> >> >
> >> > Likewise for "[v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIO".
> >>
> >> ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI"
> >
> > ... and "ARM: shmobile: r8a7790 dtsi: Enable DMA for MSIO"
> >
> > and any other similar patches I didn't list above :)
> 
> Yes[*].
> 
> If rcar-dma is not available, drivers fall back to PIO, cfr. for rspi:
> 
> -renesas_spi e6b10000.spi: DMA available
> +renesas_spi e6b10000.spi: dma_request_slave_channel_compat failed
> +renesas_spi e6b10000.spi: DMA not available, using PIO
>  renesas_spi e6b10000.spi: registered master spi0
>  spi spi0.0: setup mode 0, 8 bits/w, 30000000 Hz max --> 0
>  m25p80 spi0.0: s25fl512s (65536 Kbytes)
>  3 ofpart partitions found on MTD device spi0.0
>  Creating 3 MTD partitions on "spi0.0":
>  0x000000000000-0x000000080000 : "loader"
>  0x000000080000-0x000000100000 : "bootenv"
>  0x000000100000-0x000004000000 : "data"
>  renesas_spi e6b10000.spi: registered child spi0.0
> 
> and sh-msiof:
> 
> -spi_sh_msiof e6e20000.spi: DMA available
> +spi_sh_msiof e6e20000.spi: dma_request_slave_channel_compat failed
> +spi_sh_msiof e6e20000.spi: DMA not available, using PIO
>  spi_sh_msiof e6e20000.spi: registered master spi1
>  spi spi1.0: setup mode 3, 8 bits/w, 6000000 Hz max --> 0
>  spi_sh_msiof e6e20000.spi: registered child spi1.0
> 
> and everything still works, but slower.
> 
> [*] If the individual DMA slave drivers properly handle DMA request
>     failures. If they don't, they will already fail now, as there is no DMA
>     platform configuration without the dmas/dma-names properties
>     (ignoring Magnus' DMA prototypes using auxdata, as DT is the way
>      forward).

Thanks, I have queued up the 4 shmobile patches for v3.18 with
Laurent's Ack. They should appear in the devel branch of the renesas tree
some time today.

On Thu, Aug 07, 2014 at 02:16:47AM +0200, Laurent Pinchart wrote:
> Hi Geert,
> 
> Thank you for the patches.
> 
> On Wednesday 06 August 2014 14:58:57 Geert Uytterhoeven wrote:
> > 	Hi Mark, Simon,
> > 
> > Here's a series of Renesas RSPI/QSPI and SH-MSIOF SPI driver updates.
> > I grouped them in three parts:
> >   - [1-5] are for the rspi driver (Mark),
> >   - [6-8] are for the sh-msiof driver (Mark),
> >   - [9-12] are for the R-Car Gen2 DTSes (Simon).
> 
> For everything but 06/12,
> 
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

[snip]


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

end of thread, other threads:[~2014-08-08  1:38 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06 12:58 [PATCH 00/12] spi: rspi and sh-msiof driver updates Geert Uytterhoeven
2014-08-06 12:58 ` Geert Uytterhoeven
2014-08-06 12:58 ` [PATCH 01/12] spi: rspi: Fix leaking of unused DMA descriptors Geert Uytterhoeven
2014-08-06 12:58   ` Geert Uytterhoeven
2014-08-06 20:11   ` Mark Brown
2014-08-06 20:11     ` Mark Brown
2014-08-06 12:58 ` [PATCH 02/12] spi: rspi: Remove unneeded semicolon Geert Uytterhoeven
2014-08-06 12:58   ` Geert Uytterhoeven
2014-08-06 20:26   ` Mark Brown
2014-08-06 20:26     ` Mark Brown
     [not found] ` <1407329949-5695-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-08-06 12:59   ` [PATCH 03/12] spi: rspi: Use devm_kasprintf() Geert Uytterhoeven
2014-08-06 12:59     ` Geert Uytterhoeven
     [not found]     ` <1407329949-5695-4-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-08-06 20:26       ` Mark Brown
2014-08-06 20:26         ` Mark Brown
2014-08-06 12:59   ` [PATCH 04/12] spi: rspi: Configure DMA slave bus width to 8 bit Geert Uytterhoeven
2014-08-06 12:59     ` Geert Uytterhoeven
2014-08-06 20:26     ` Mark Brown
2014-08-06 20:26       ` Mark Brown
2014-08-06 12:59   ` [PATCH 05/12] [v2] spi: rspi: Add DT support to DMA setup Geert Uytterhoeven
2014-08-06 12:59     ` Geert Uytterhoeven
2014-08-06 20:28     ` Mark Brown
2014-08-06 20:28       ` Mark Brown
2014-08-06 12:59   ` [PATCH 09/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for QSPI Geert Uytterhoeven
2014-08-06 12:59     ` Geert Uytterhoeven
2014-08-07  0:37     ` Simon Horman
2014-08-07  0:37       ` Simon Horman
2014-08-07  0:39       ` Simon Horman
2014-08-07  0:39         ` Simon Horman
2014-08-07  0:41         ` Simon Horman
2014-08-07  0:41           ` Simon Horman
     [not found]           ` <20140807004107.GB30872-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2014-08-07  8:27             ` Geert Uytterhoeven
2014-08-07  8:27               ` Geert Uytterhoeven
2014-08-08  1:38               ` Simon Horman
2014-08-08  1:38                 ` Simon Horman
2014-08-06 12:59   ` [PATCH 10/12] [v3] ARM: shmobile: r8a7791 dtsi: Enable DMA for MSIOF Geert Uytterhoeven
2014-08-06 12:59     ` Geert Uytterhoeven
2014-08-06 12:59   ` [PATCH 12/12] ARM: shmobile: r8a7790 " Geert Uytterhoeven
2014-08-06 12:59     ` Geert Uytterhoeven
2014-08-07  0:16   ` [PATCH 00/12] spi: rspi and sh-msiof driver updates Laurent Pinchart
2014-08-07  0:16     ` Laurent Pinchart
2014-08-06 12:59 ` [PATCH 06/12] spi: sh-msiof: Fix leaking of unused DMA descriptors Geert Uytterhoeven
2014-08-06 12:59   ` Geert Uytterhoeven
2014-08-06 20:35   ` Mark Brown
2014-08-06 20:35     ` Mark Brown
2014-08-07  0:07   ` Laurent Pinchart
2014-08-07  0:07     ` Laurent Pinchart
2014-08-07  8:55     ` Geert Uytterhoeven
2014-08-07  8:55       ` Geert Uytterhoeven
     [not found]       ` <CAMuHMdUd3OKqDwhLSCMW-rEQSnWky+saN5TgC005rkmNPfEL+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-07 12:07         ` [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible Geert Uytterhoeven
2014-08-07 12:07           ` Geert Uytterhoeven
     [not found]           ` <1407413263-20177-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-08-07 12:07             ` [PATCH 2/2] spi: sh-msiof: Fix transmit-only DMA transfers Geert Uytterhoeven
2014-08-07 12:07               ` Geert Uytterhoeven
2014-08-07 12:51               ` Laurent Pinchart
2014-08-07 12:51                 ` Laurent Pinchart
2014-08-07 12:52           ` [PATCH 1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible Laurent Pinchart
2014-08-07 12:52             ` Laurent Pinchart
2014-08-07 17:41           ` Mark Brown
2014-08-07 17:41             ` Mark Brown
2014-08-06 12:59 ` [PATCH 07/12] spi: sh-msiof: Configure DMA slave bus width Geert Uytterhoeven
2014-08-06 12:59   ` Geert Uytterhoeven
     [not found]   ` <1407329949-5695-8-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-08-06 20:36     ` Mark Brown
2014-08-06 20:36       ` Mark Brown
2014-08-06 12:59 ` [PATCH 08/12] [v2] spi: sh-msiof: Add DT support to DMA setup Geert Uytterhoeven
2014-08-06 12:59   ` Geert Uytterhoeven
2014-08-06 20:36   ` Mark Brown
2014-08-06 20:36     ` Mark Brown
2014-08-06 12:59 ` [PATCH 11/12] ARM: shmobile: r8a7790 dtsi: Enable DMA for QSPI Geert Uytterhoeven
2014-08-06 12:59   ` Geert Uytterhoeven
2014-08-06 20:29 ` [PATCH 00/12] spi: rspi and sh-msiof driver updates Mark Brown
2014-08-06 20:29   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.