linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series
@ 2016-12-13 13:40 M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 1/9] dmaengine: stm32-dma: Set correct args number for DMA request from DT M'boumba Cedric Madianga
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

This patchset adds bug fixes reported by devices using STM32 DMA and some
improvements mainly linked to dmaengine framework evolution.

M'boumba Cedric Madianga (9):
  dmaengine: stm32-dma: Set correct args number for DMA request from DT
  dmaengine: stm32-dma: Fix typo in Kconfig
  dt-bindings: stm32-dma: Fix typo regarding DMA client binding
  dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status
  dmaengine: stm32-dma: Rework starting transfer management
  dmaengine: stm32-dma: Fix residue computation issue in cyclic mode
  dmaengine: stm32-dma: Add error messages if xlate fails
  dmaengine: stm32-dma: Add synchronization support
  dmaengine: stm32-dma: Add max_burst support

 .../devicetree/bindings/dma/stm32-dma.txt          |   5 +-
 drivers/dma/Kconfig                                |   2 +-
 drivers/dma/stm32-dma.c                            | 103 +++++++++++++--------
 3 files changed, 66 insertions(+), 44 deletions(-)

-- 
1.9.1

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

* [PATCH 1/9] dmaengine: stm32-dma: Set correct args number for DMA request from DT
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 2/9] dmaengine: stm32-dma: Fix typo in Kconfig M'boumba Cedric Madianga
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

This patch sets the right number of arguments to be used for DMA clients
which request channels from DT.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 drivers/dma/stm32-dma.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 3688d08..a884b85 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -972,21 +972,18 @@ static struct dma_chan *stm32_dma_of_xlate(struct of_phandle_args *dma_spec,
 	struct stm32_dma_chan *chan;
 	struct dma_chan *c;
 
-	if (dma_spec->args_count < 3)
+	if (dma_spec->args_count < 4)
 		return NULL;
 
 	cfg.channel_id = dma_spec->args[0];
 	cfg.request_line = dma_spec->args[1];
 	cfg.stream_config = dma_spec->args[2];
-	cfg.threshold = 0;
+	cfg.threshold = dma_spec->args[3];
 
 	if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) || (cfg.request_line >=
 				STM32_DMA_MAX_REQUEST_ID))
 		return NULL;
 
-	if (dma_spec->args_count > 3)
-		cfg.threshold = dma_spec->args[3];
-
 	chan = &dmadev->chan[cfg.channel_id];
 
 	c = dma_get_slave_channel(&chan->vchan.chan);
-- 
1.9.1

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

* [PATCH 2/9] dmaengine: stm32-dma: Fix typo in Kconfig
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 1/9] dmaengine: stm32-dma: Set correct args number for DMA request from DT M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 3/9] dt-bindings: stm32-dma: Fix typo regarding DMA client binding M'boumba Cedric Madianga
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

As STM32 DMA driver is only used as buit-in driver, it couldn't be used as
module.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 drivers/dma/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 263495d..96da57a 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -458,7 +458,7 @@ config STM32_DMA
 	help
 	  Enable support for the on-chip DMA controller on STMicroelectronics
 	  STM32 MCUs.
-	  If you have a board based on such a MCU and wish to use DMA say Y or M
+	  If you have a board based on such a MCU and wish to use DMA say Y
 	  here.
 
 config S3C24XX_DMAC
-- 
1.9.1

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

* [PATCH 3/9] dt-bindings: stm32-dma: Fix typo regarding DMA client binding
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 1/9] dmaengine: stm32-dma: Set correct args number for DMA request from DT M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 2/9] dmaengine: stm32-dma: Fix typo in Kconfig M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 20:09   ` Rob Herring
  2016-12-13 13:40 ` [PATCH 4/9] dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status M'boumba Cedric Madianga
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

Only four cells are required for dma client binding not five.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 Documentation/devicetree/bindings/dma/stm32-dma.txt | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/stm32-dma.txt b/Documentation/devicetree/bindings/dma/stm32-dma.txt
index 70cd13f..4408af6 100644
--- a/Documentation/devicetree/bindings/dma/stm32-dma.txt
+++ b/Documentation/devicetree/bindings/dma/stm32-dma.txt
@@ -40,8 +40,7 @@ Example:
 
 DMA clients connected to the STM32 DMA controller must use the format
 described in the dma.txt file, using a five-cell specifier for each
-channel: a phandle plus four integer cells.
-The four cells in order are:
+channel: a phandle to the DMA controller plus the following four integer cells:
 
 1. The channel id
 2. The request line number
@@ -61,7 +60,7 @@ The four cells in order are:
 	0x1: medium
 	0x2: high
 	0x3: very high
-5. A 32bit mask specifying the DMA FIFO threshold configuration which are device
+4. A 32bit mask specifying the DMA FIFO threshold configuration which are device
    dependent:
  -bit 0-1: Fifo threshold
 	0x0: 1/4 full FIFO
-- 
1.9.1

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

* [PATCH 4/9] dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (2 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 3/9] dt-bindings: stm32-dma: Fix typo regarding DMA client binding M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 5/9] dmaengine: stm32-dma: Rework starting transfer management M'boumba Cedric Madianga
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

chan->desc is always set to NULL when a DMA transfer is complete.
As a DMA transfer could be complete during the call of stm32_dma_tx_status,
we need to be sure that chan->desc is not NULL before using this variable
to avoid a null pointer deference issue.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 drivers/dma/stm32-dma.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index a884b85..3056ce7 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -880,7 +880,7 @@ static enum dma_status stm32_dma_tx_status(struct dma_chan *c,
 	struct virt_dma_desc *vdesc;
 	enum dma_status status;
 	unsigned long flags;
-	u32 residue;
+	u32 residue = 0;
 
 	status = dma_cookie_status(c, cookie, state);
 	if ((status == DMA_COMPLETE) || (!state))
@@ -888,16 +888,12 @@ static enum dma_status stm32_dma_tx_status(struct dma_chan *c,
 
 	spin_lock_irqsave(&chan->vchan.lock, flags);
 	vdesc = vchan_find_desc(&chan->vchan, cookie);
-	if (cookie == chan->desc->vdesc.tx.cookie) {
+	if (chan->desc && cookie == chan->desc->vdesc.tx.cookie)
 		residue = stm32_dma_desc_residue(chan, chan->desc,
 						 chan->next_sg);
-	} else if (vdesc) {
+	else if (vdesc)
 		residue = stm32_dma_desc_residue(chan,
 						 to_stm32_dma_desc(vdesc), 0);
-	} else {
-		residue = 0;
-	}
-
 	dma_set_residue(state, residue);
 
 	spin_unlock_irqrestore(&chan->vchan.lock, flags);
-- 
1.9.1

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

* [PATCH 5/9] dmaengine: stm32-dma: Rework starting transfer management
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (3 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 4/9] dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 6/9] dmaengine: stm32-dma: Fix residue computation issue in cyclic mode M'boumba Cedric Madianga
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

This patch reworks the way to manage transfer starting.
Now, starting DMA is only allowed when the channel is not busy.
Then, stm32_dma_start_transfer is declared as void.
At least, after each transfer completion, we start the next transfer if a
new descriptor as been queued in the issued list during an ongoing
transfer.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 drivers/dma/stm32-dma.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 3056ce7..adb846c 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -421,7 +421,7 @@ static void stm32_dma_dump_reg(struct stm32_dma_chan *chan)
 	dev_dbg(chan2dev(chan), "SFCR:  0x%08x\n", sfcr);
 }
 
-static int stm32_dma_start_transfer(struct stm32_dma_chan *chan)
+static void stm32_dma_start_transfer(struct stm32_dma_chan *chan)
 {
 	struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan);
 	struct virt_dma_desc *vdesc;
@@ -432,12 +432,12 @@ static int stm32_dma_start_transfer(struct stm32_dma_chan *chan)
 
 	ret = stm32_dma_disable_chan(chan);
 	if (ret < 0)
-		return ret;
+		return;
 
 	if (!chan->desc) {
 		vdesc = vchan_next_desc(&chan->vchan);
 		if (!vdesc)
-			return -EPERM;
+			return;
 
 		chan->desc = to_stm32_dma_desc(vdesc);
 		chan->next_sg = 0;
@@ -471,7 +471,7 @@ static int stm32_dma_start_transfer(struct stm32_dma_chan *chan)
 
 	chan->busy = true;
 
-	return 0;
+	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
 }
 
 static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan)
@@ -552,15 +552,13 @@ static void stm32_dma_issue_pending(struct dma_chan *c)
 {
 	struct stm32_dma_chan *chan = to_stm32_dma_chan(c);
 	unsigned long flags;
-	int ret;
 
 	spin_lock_irqsave(&chan->vchan.lock, flags);
-	if (!chan->busy) {
-		if (vchan_issue_pending(&chan->vchan) && !chan->desc) {
-			ret = stm32_dma_start_transfer(chan);
-			if ((!ret) && (chan->desc->cyclic))
-				stm32_dma_configure_next_sg(chan);
-		}
+	if (vchan_issue_pending(&chan->vchan) && !chan->desc && !chan->busy) {
+		dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
+		stm32_dma_start_transfer(chan);
+		if (chan->desc->cyclic)
+			stm32_dma_configure_next_sg(chan);
 	}
 	spin_unlock_irqrestore(&chan->vchan.lock, flags);
 }
-- 
1.9.1

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

* [PATCH 6/9] dmaengine: stm32-dma: Fix residue computation issue in cyclic mode
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (4 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 5/9] dmaengine: stm32-dma: Rework starting transfer management M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 7/9] dmaengine: stm32-dma: Add error messages if xlate fails M'boumba Cedric Madianga
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

This patch resolves the residue computation issue detected in cyclic mode.
Now, in cyclic mode, we increment next_sg variable as soon as a period is
transferred instead of after pushing a new sg request.
Then, we take into account that after transferring a complete buffer,
the next_sg variable is equal to 0.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 drivers/dma/stm32-dma.c | 39 ++++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index adb846c..ba929a9 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -500,8 +500,6 @@ static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan)
 			dev_dbg(chan2dev(chan), "CT=0 <=> SM1AR: 0x%08x\n",
 				stm32_dma_read(dmadev, STM32_DMA_SM1AR(id)));
 		}
-
-		chan->next_sg++;
 	}
 }
 
@@ -510,6 +508,7 @@ static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan)
 	if (chan->desc) {
 		if (chan->desc->cyclic) {
 			vchan_cyclic_callback(&chan->desc->vdesc);
+			chan->next_sg++;
 			stm32_dma_configure_next_sg(chan);
 		} else {
 			chan->busy = false;
@@ -846,26 +845,40 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_memcpy(
 	return vchan_tx_prep(&chan->vchan, &desc->vdesc, flags);
 }
 
+static u32 stm32_dma_get_remaining_bytes(struct stm32_dma_chan *chan)
+{
+	u32 dma_scr, width, ndtr;
+	struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan);
+
+	dma_scr = stm32_dma_read(dmadev, STM32_DMA_SCR(chan->id));
+	width = STM32_DMA_SCR_PSIZE_GET(dma_scr);
+	ndtr = stm32_dma_read(dmadev, STM32_DMA_SNDTR(chan->id));
+
+	return ndtr << width;
+}
+
 static size_t stm32_dma_desc_residue(struct stm32_dma_chan *chan,
 				     struct stm32_dma_desc *desc,
 				     u32 next_sg)
 {
-	struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan);
-	u32 dma_scr, width, residue, count;
+	u32 residue = 0;
 	int i;
 
-	residue = 0;
+	/*
+	 * In cyclic mode, for the last period, residue = remaining bytes from
+	 * NDTR
+	 */
+	if (chan->desc->cyclic && next_sg == 0)
+		return stm32_dma_get_remaining_bytes(chan);
 
+	/*
+	 * For all other periods in cyclic mode, and in sg mode,
+	 * residue = remaining bytes from NDTR + remaining periods/sg to be
+	 * transferred
+	 */
 	for (i = next_sg; i < desc->num_sgs; i++)
 		residue += desc->sg_req[i].len;
-
-	if (next_sg != 0) {
-		dma_scr = stm32_dma_read(dmadev, STM32_DMA_SCR(chan->id));
-		width = STM32_DMA_SCR_PSIZE_GET(dma_scr);
-		count = stm32_dma_read(dmadev, STM32_DMA_SNDTR(chan->id));
-
-		residue += count << width;
-	}
+	residue += stm32_dma_get_remaining_bytes(chan);
 
 	return residue;
 }
-- 
1.9.1

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

* [PATCH 7/9] dmaengine: stm32-dma: Add error messages if xlate fails
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (5 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 6/9] dmaengine: stm32-dma: Fix residue computation issue in cyclic mode M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 8/9] dmaengine: stm32-dma: Add synchronization support M'boumba Cedric Madianga
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

This patch adds some error messages when a slave device fails to request a
channel.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
---
 drivers/dma/stm32-dma.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index ba929a9..35639f6 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -975,27 +975,36 @@ static struct dma_chan *stm32_dma_of_xlate(struct of_phandle_args *dma_spec,
 					   struct of_dma *ofdma)
 {
 	struct stm32_dma_device *dmadev = ofdma->of_dma_data;
+	struct device *dev = dmadev->ddev.dev;
 	struct stm32_dma_cfg cfg;
 	struct stm32_dma_chan *chan;
 	struct dma_chan *c;
 
-	if (dma_spec->args_count < 4)
+	if (dma_spec->args_count < 4) {
+		dev_err(dev, "Bad number of cells\n");
 		return NULL;
+	}
 
 	cfg.channel_id = dma_spec->args[0];
 	cfg.request_line = dma_spec->args[1];
 	cfg.stream_config = dma_spec->args[2];
 	cfg.threshold = dma_spec->args[3];
 
-	if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) || (cfg.request_line >=
-				STM32_DMA_MAX_REQUEST_ID))
+	if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) ||
+	    (cfg.request_line >= STM32_DMA_MAX_REQUEST_ID)) {
+		dev_err(dev, "Bad channel and/or request id\n");
 		return NULL;
+	}
 
 	chan = &dmadev->chan[cfg.channel_id];
 
 	c = dma_get_slave_channel(&chan->vchan.chan);
-	if (c)
-		stm32_dma_set_config(chan, &cfg);
+	if (!c) {
+		dev_err(dev, "No more channel avalaible\n");
+		return NULL;
+	}
+
+	stm32_dma_set_config(chan, &cfg);
 
 	return c;
 }
-- 
1.9.1

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

* [PATCH 8/9] dmaengine: stm32-dma: Add synchronization support
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (6 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 7/9] dmaengine: stm32-dma: Add error messages if xlate fails M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2016-12-13 13:40 ` [PATCH 9/9] dmaengine: stm32-dma: Add max_burst support M'boumba Cedric Madianga
  2017-01-02  4:14 ` [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series Vinod Koul
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

Implement the new device_synchronize() callback to allow proper
synchronization when stopping a channel.

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
---
 drivers/dma/stm32-dma.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 35639f6..b7be43a 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -403,6 +403,13 @@ static int stm32_dma_terminate_all(struct dma_chan *c)
 	return 0;
 }
 
+static void stm32_dma_synchronize(struct dma_chan *c)
+{
+	struct stm32_dma_chan *chan = to_stm32_dma_chan(c);
+
+	vchan_synchronize(&chan->vchan);
+}
+
 static void stm32_dma_dump_reg(struct stm32_dma_chan *chan)
 {
 	struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan);
@@ -1068,6 +1075,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
 	dd->device_prep_dma_cyclic = stm32_dma_prep_dma_cyclic;
 	dd->device_config = stm32_dma_slave_config;
 	dd->device_terminate_all = stm32_dma_terminate_all;
+	dd->device_synchronize = stm32_dma_synchronize;
 	dd->src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
 		BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
 		BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
-- 
1.9.1

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

* [PATCH 9/9] dmaengine: stm32-dma: Add max_burst support
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (7 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 8/9] dmaengine: stm32-dma: Add synchronization support M'boumba Cedric Madianga
@ 2016-12-13 13:40 ` M'boumba Cedric Madianga
  2017-01-02  4:14 ` [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series Vinod Koul
  9 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2016-12-13 13:40 UTC (permalink / raw)
  To: vinod.koul, robh+dt, mark.rutland, mcoquelin.stm32,
	alexandre.torgue, dan.j.williams, dmaengine, devicetree,
	linux-arm-kernel, linux-kernel
  Cc: M'boumba Cedric Madianga

This patch sets the max_burst value supported by the STM32 DMA

Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
---
 drivers/dma/stm32-dma.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index b7be43a..49f86ca 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -114,6 +114,7 @@
 #define STM32_DMA_MAX_CHANNELS		0x08
 #define STM32_DMA_MAX_REQUEST_ID	0x08
 #define STM32_DMA_MAX_DATA_PARAM	0x03
+#define STM32_DMA_MAX_BURST		16
 
 enum stm32_dma_width {
 	STM32_DMA_BYTE,
@@ -1084,6 +1085,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
 		BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
 	dd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
 	dd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+	dd->max_burst = STM32_DMA_MAX_BURST;
 	dd->dev = &pdev->dev;
 	INIT_LIST_HEAD(&dd->channels);
 
-- 
1.9.1

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

* Re: [PATCH 3/9] dt-bindings: stm32-dma: Fix typo regarding DMA client binding
  2016-12-13 13:40 ` [PATCH 3/9] dt-bindings: stm32-dma: Fix typo regarding DMA client binding M'boumba Cedric Madianga
@ 2016-12-13 20:09   ` Rob Herring
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2016-12-13 20:09 UTC (permalink / raw)
  To: M'boumba Cedric Madianga
  Cc: vinod.koul, mark.rutland, mcoquelin.stm32, alexandre.torgue,
	dan.j.williams, dmaengine, devicetree, linux-arm-kernel,
	linux-kernel

On Tue, Dec 13, 2016 at 02:40:45PM +0100, M'boumba Cedric Madianga wrote:
> Only four cells are required for dma client binding not five.
> 
> Signed-off-by: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
> Reviewed-by: Ludovic BARRE <ludovic.barre@st.com>
> ---
>  Documentation/devicetree/bindings/dma/stm32-dma.txt | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series
  2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
                   ` (8 preceding siblings ...)
  2016-12-13 13:40 ` [PATCH 9/9] dmaengine: stm32-dma: Add max_burst support M'boumba Cedric Madianga
@ 2017-01-02  4:14 ` Vinod Koul
  2017-01-02  9:26   ` M'boumba Cedric Madianga
  9 siblings, 1 reply; 13+ messages in thread
From: Vinod Koul @ 2017-01-02  4:14 UTC (permalink / raw)
  To: M'boumba Cedric Madianga
  Cc: robh+dt, mark.rutland, mcoquelin.stm32, alexandre.torgue,
	dan.j.williams, dmaengine, devicetree, linux-arm-kernel,
	linux-kernel

On Tue, Dec 13, 2016 at 02:40:42PM +0100, M'boumba Cedric Madianga wrote:
> This patchset adds bug fixes reported by devices using STM32 DMA and some
> improvements mainly linked to dmaengine framework evolution.

So you should order fixes first and then new additions.

Fixes go in for current release whereas the rest for next one.

I have applied two to fixes and rest to updated, patch 5 didn't apply, please
resend that one.

-- 
~Vinod

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

* Re: [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series
  2017-01-02  4:14 ` [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series Vinod Koul
@ 2017-01-02  9:26   ` M'boumba Cedric Madianga
  0 siblings, 0 replies; 13+ messages in thread
From: M'boumba Cedric Madianga @ 2017-01-02  9:26 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	dan.j.williams, dmaengine, devicetree, linux-arm-kernel,
	linux-kernel

Hi Vinod,

> So you should order fixes first and then new additions.
> Fixes go in for current release whereas the rest for next one.
Ok thanks for the info.

> I have applied two to fixes and rest to updated, patch 5 didn't apply, please
> resend that one.
I have tried to apply patch 5 on top of slave-dma/fixes branch but I
don't have any issue.
So, I am going to resend this patch in order to be sure that there is no diff.

Best regards,

Cedric

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

end of thread, other threads:[~2017-01-02  9:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 13:40 [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 1/9] dmaengine: stm32-dma: Set correct args number for DMA request from DT M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 2/9] dmaengine: stm32-dma: Fix typo in Kconfig M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 3/9] dt-bindings: stm32-dma: Fix typo regarding DMA client binding M'boumba Cedric Madianga
2016-12-13 20:09   ` Rob Herring
2016-12-13 13:40 ` [PATCH 4/9] dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 5/9] dmaengine: stm32-dma: Rework starting transfer management M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 6/9] dmaengine: stm32-dma: Fix residue computation issue in cyclic mode M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 7/9] dmaengine: stm32-dma: Add error messages if xlate fails M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 8/9] dmaengine: stm32-dma: Add synchronization support M'boumba Cedric Madianga
2016-12-13 13:40 ` [PATCH 9/9] dmaengine: stm32-dma: Add max_burst support M'boumba Cedric Madianga
2017-01-02  4:14 ` [PATCH 0/9] dmaengine: stm32-dma: Bug fixes and improvements series Vinod Koul
2017-01-02  9:26   ` M'boumba Cedric Madianga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).