All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@st.com>
To: <linus.walleij@linaro.org>
Cc: <vinod.koul@intel.com>, <dan.j.williams@intel.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <linux@arm.linux.org.uk>,
	<armando.visconti@st.com>, <shiraz.hashim@st.com>,
	<vipin.kumar@st.com>, <rajeev-dlh.kumar@st.com>,
	<deepak.sikri@st.com>, <vipulkumar.samar@st.com>,
	<amit.virdi@st.com>, <viresh.kumar@st.com>,
	<pratyush.anand@st.com>, <bhupesh.sharma@st.com>,
	<viresh.linux@gmail.com>
Subject: [PATCH V2 17/20] dmaengine/amba-pl08x: Pass flow controller information with slave channel data
Date: Mon, 1 Aug 2011 15:07:27 +0530	[thread overview]
Message-ID: <75eeef2d64881c9ef21065e2b15188876a13a4ed.1312190881.git.viresh.kumar@st.com> (raw)
In-Reply-To: <cover.1312190881.git.viresh.kumar@st.com>

At least, on SPEAr platforms there is one peripheral, JPEG, which can be flow
controller for DMA transfer. Currently DMA controller driver didn't support
peripheral flow controller configurations.

This patch adds device_fc field in struct pl08x_channel_data, which will be used
only for slave transfers and is not used in case of mem2mem transfers.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/amba-pl08x.c   |   61 ++++++++++++++++++++++++++++++++++++++------
 include/linux/amba/pl08x.h |    4 +++
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index c969309..d573dc2 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -66,11 +66,6 @@
  *    after the final transfer signalled by LBREQ or LSREQ.  The DMAC
  *    will then move to the next LLI entry.
  *
- * Only the former works sanely with scatter lists, so we only implement
- * the DMAC flow control method.  However, peripherals which use the LBREQ
- * and LSREQ signals (eg, MMCI) are unable to use this mode, which through
- * these hardware restrictions prevents them from using scatter DMA.
- *
  * Global TODO:
  * - Break out common code from arch/arm/mach-s3c64xx and share
  */
@@ -615,6 +610,49 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
 		 sbus == &bd.srcbus ? "src" : "dst");
 
 	/*
+	 * Zero length is only allowed if all these requirements are met:
+	 * - flow controller is peripheral.
+	 * - src.addr is aligned to src.width
+	 * - dst.addr is aligned to dst.width
+	 *
+	 * sg_len == 1 should be true, as there can be two cases here:
+	 * - Memory addresses are contiguous and are not scattered. Here, Only
+	 * one sg will be passed by user driver, with memory address and zero
+	 * length. We pass this to controller and after the transfer it will
+	 * receive the last burst request from peripheral and so transfer
+	 * finishes.
+	 *
+	 * - Memory addresses are scattered and are not contiguous. Here,
+	 * Obviously as DMA controller doesn't know when a lli's transfer gets
+	 * over, it can't load next lli. So in this case, there has to be an
+	 * assumption that only one lli is supported. Thus, we can't have
+	 * scattered addresses.
+	 */
+	if (!bd.remainder) {
+		u32 fc = (txd->ccfg & PL080_CONFIG_FLOW_CONTROL_MASK) >>
+			PL080_CONFIG_FLOW_CONTROL_SHIFT;
+		if (!((fc >= PL080_FLOW_SRC2DST_DST) &&
+					(fc <= PL080_FLOW_SRC2DST_SRC))) {
+			dev_err(&pl08x->adev->dev, "%s sg len can't be zero",
+				__func__);
+			return 0;
+		}
+
+		if ((bd.srcbus.addr % bd.srcbus.buswidth) ||
+				(bd.srcbus.addr % bd.srcbus.buswidth)) {
+			dev_err(&pl08x->adev->dev,
+				"%s src & dst address must be aligned to src"
+				" & dst width if peripheral is flow controller",
+				__func__);
+			return 0;
+		}
+
+		cctl = pl08x_cctl_bits(cctl, bd.srcbus.buswidth,
+				bd.dstbus.buswidth, 0);
+		pl08x_fill_lli_for_desc(&bd, num_llis++, 0, cctl);
+	}
+
+	/*
 	 * Send byte by byte for following cases
 	 * - Less than a bus width available
 	 * - until master bus is aligned
@@ -1255,7 +1293,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 	struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
 	struct pl08x_driver_data *pl08x = plchan->host;
 	struct pl08x_txd *txd;
-	int ret;
+	int ret, tmp;
 
 	/*
 	 * Current implementation ASSUMES only one sg
@@ -1289,12 +1327,10 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 	txd->len = sgl->length;
 
 	if (direction == DMA_TO_DEVICE) {
-		txd->ccfg |= PL080_FLOW_MEM2PER << PL080_CONFIG_FLOW_CONTROL_SHIFT;
 		txd->cctl = plchan->dst_cctl;
 		txd->src_addr = sgl->dma_address;
 		txd->dst_addr = plchan->dst_addr;
 	} else if (direction == DMA_FROM_DEVICE) {
-		txd->ccfg |= PL080_FLOW_PER2MEM << PL080_CONFIG_FLOW_CONTROL_SHIFT;
 		txd->cctl = plchan->src_cctl;
 		txd->src_addr = plchan->src_addr;
 		txd->dst_addr = sgl->dma_address;
@@ -1304,6 +1340,15 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 		return NULL;
 	}
 
+	if (plchan->cd->device_fc)
+		tmp = (direction == DMA_TO_DEVICE) ? PL080_FLOW_MEM2PER_PER :
+			PL080_FLOW_PER2MEM_PER;
+	else
+		tmp = (direction == DMA_TO_DEVICE) ? PL080_FLOW_MEM2PER :
+			PL080_FLOW_PER2MEM;
+
+	txd->ccfg |= tmp << PL080_CONFIG_FLOW_CONTROL_SHIFT;
+
 	ret = pl08x_prep_channel_resources(plchan, txd);
 	if (ret)
 		return NULL;
diff --git a/include/linux/amba/pl08x.h b/include/linux/amba/pl08x.h
index ecd17f5..a22662c 100644
--- a/include/linux/amba/pl08x.h
+++ b/include/linux/amba/pl08x.h
@@ -47,6 +47,9 @@ enum {
  * @muxval: a number usually used to poke into some mux regiser to
  * mux in the signal to this channel
  * @cctl_opt: default options for the channel control register
+ * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
+ * channels. Fill with 'true' if peripheral should be flow controller. Direction
+ * will be selected at Runtime.
  * @addr: source/target address in physical memory for this DMA channel,
  * can be the address of a FIFO register for burst requests for example.
  * This can be left undefined if the PrimeCell API is used for configuring
@@ -65,6 +68,7 @@ struct pl08x_channel_data {
 	int max_signal;
 	u32 muxval;
 	u32 cctl;
+	bool device_fc;
 	dma_addr_t addr;
 	bool circular_buffer;
 	bool single;
-- 
1.7.2.2


WARNING: multiple messages have this Message-ID (diff)
From: viresh.kumar@st.com (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 17/20] dmaengine/amba-pl08x: Pass flow controller information with slave channel data
Date: Mon, 1 Aug 2011 15:07:27 +0530	[thread overview]
Message-ID: <75eeef2d64881c9ef21065e2b15188876a13a4ed.1312190881.git.viresh.kumar@st.com> (raw)
In-Reply-To: <cover.1312190881.git.viresh.kumar@st.com>

At least, on SPEAr platforms there is one peripheral, JPEG, which can be flow
controller for DMA transfer. Currently DMA controller driver didn't support
peripheral flow controller configurations.

This patch adds device_fc field in struct pl08x_channel_data, which will be used
only for slave transfers and is not used in case of mem2mem transfers.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/dma/amba-pl08x.c   |   61 ++++++++++++++++++++++++++++++++++++++------
 include/linux/amba/pl08x.h |    4 +++
 2 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index c969309..d573dc2 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -66,11 +66,6 @@
  *    after the final transfer signalled by LBREQ or LSREQ.  The DMAC
  *    will then move to the next LLI entry.
  *
- * Only the former works sanely with scatter lists, so we only implement
- * the DMAC flow control method.  However, peripherals which use the LBREQ
- * and LSREQ signals (eg, MMCI) are unable to use this mode, which through
- * these hardware restrictions prevents them from using scatter DMA.
- *
  * Global TODO:
  * - Break out common code from arch/arm/mach-s3c64xx and share
  */
@@ -615,6 +610,49 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
 		 sbus == &bd.srcbus ? "src" : "dst");
 
 	/*
+	 * Zero length is only allowed if all these requirements are met:
+	 * - flow controller is peripheral.
+	 * - src.addr is aligned to src.width
+	 * - dst.addr is aligned to dst.width
+	 *
+	 * sg_len == 1 should be true, as there can be two cases here:
+	 * - Memory addresses are contiguous and are not scattered. Here, Only
+	 * one sg will be passed by user driver, with memory address and zero
+	 * length. We pass this to controller and after the transfer it will
+	 * receive the last burst request from peripheral and so transfer
+	 * finishes.
+	 *
+	 * - Memory addresses are scattered and are not contiguous. Here,
+	 * Obviously as DMA controller doesn't know when a lli's transfer gets
+	 * over, it can't load next lli. So in this case, there has to be an
+	 * assumption that only one lli is supported. Thus, we can't have
+	 * scattered addresses.
+	 */
+	if (!bd.remainder) {
+		u32 fc = (txd->ccfg & PL080_CONFIG_FLOW_CONTROL_MASK) >>
+			PL080_CONFIG_FLOW_CONTROL_SHIFT;
+		if (!((fc >= PL080_FLOW_SRC2DST_DST) &&
+					(fc <= PL080_FLOW_SRC2DST_SRC))) {
+			dev_err(&pl08x->adev->dev, "%s sg len can't be zero",
+				__func__);
+			return 0;
+		}
+
+		if ((bd.srcbus.addr % bd.srcbus.buswidth) ||
+				(bd.srcbus.addr % bd.srcbus.buswidth)) {
+			dev_err(&pl08x->adev->dev,
+				"%s src & dst address must be aligned to src"
+				" & dst width if peripheral is flow controller",
+				__func__);
+			return 0;
+		}
+
+		cctl = pl08x_cctl_bits(cctl, bd.srcbus.buswidth,
+				bd.dstbus.buswidth, 0);
+		pl08x_fill_lli_for_desc(&bd, num_llis++, 0, cctl);
+	}
+
+	/*
 	 * Send byte by byte for following cases
 	 * - Less than a bus width available
 	 * - until master bus is aligned
@@ -1255,7 +1293,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 	struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
 	struct pl08x_driver_data *pl08x = plchan->host;
 	struct pl08x_txd *txd;
-	int ret;
+	int ret, tmp;
 
 	/*
 	 * Current implementation ASSUMES only one sg
@@ -1289,12 +1327,10 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 	txd->len = sgl->length;
 
 	if (direction == DMA_TO_DEVICE) {
-		txd->ccfg |= PL080_FLOW_MEM2PER << PL080_CONFIG_FLOW_CONTROL_SHIFT;
 		txd->cctl = plchan->dst_cctl;
 		txd->src_addr = sgl->dma_address;
 		txd->dst_addr = plchan->dst_addr;
 	} else if (direction == DMA_FROM_DEVICE) {
-		txd->ccfg |= PL080_FLOW_PER2MEM << PL080_CONFIG_FLOW_CONTROL_SHIFT;
 		txd->cctl = plchan->src_cctl;
 		txd->src_addr = plchan->src_addr;
 		txd->dst_addr = sgl->dma_address;
@@ -1304,6 +1340,15 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 		return NULL;
 	}
 
+	if (plchan->cd->device_fc)
+		tmp = (direction == DMA_TO_DEVICE) ? PL080_FLOW_MEM2PER_PER :
+			PL080_FLOW_PER2MEM_PER;
+	else
+		tmp = (direction == DMA_TO_DEVICE) ? PL080_FLOW_MEM2PER :
+			PL080_FLOW_PER2MEM;
+
+	txd->ccfg |= tmp << PL080_CONFIG_FLOW_CONTROL_SHIFT;
+
 	ret = pl08x_prep_channel_resources(plchan, txd);
 	if (ret)
 		return NULL;
diff --git a/include/linux/amba/pl08x.h b/include/linux/amba/pl08x.h
index ecd17f5..a22662c 100644
--- a/include/linux/amba/pl08x.h
+++ b/include/linux/amba/pl08x.h
@@ -47,6 +47,9 @@ enum {
  * @muxval: a number usually used to poke into some mux regiser to
  * mux in the signal to this channel
  * @cctl_opt: default options for the channel control register
+ * @device_fc: Flow Controller Settings for ccfg register. Only valid for slave
+ * channels. Fill with 'true' if peripheral should be flow controller. Direction
+ * will be selected@Runtime.
  * @addr: source/target address in physical memory for this DMA channel,
  * can be the address of a FIFO register for burst requests for example.
  * This can be left undefined if the PrimeCell API is used for configuring
@@ -65,6 +68,7 @@ struct pl08x_channel_data {
 	int max_signal;
 	u32 muxval;
 	u32 cctl;
+	bool device_fc;
 	dma_addr_t addr;
 	bool circular_buffer;
 	bool single;
-- 
1.7.2.2

  parent reply	other threads:[~2011-08-01  9:40 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01  9:37 [PATCH V2 00/20] dmaengine/amba-pl08x updates Viresh Kumar
2011-08-01  9:37 ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 01/20] ARM: asm/pl080.h: Protect against multiple inclusion of header file Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 02/20] dmaengine/amba-pl08x: Resolve formatting issues Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 03/20] dmaengine/amba-pl08x: Rearrange inclusion of header files in ascending order Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:52   ` Sergei Shtylyov
2011-08-01  9:52     ` Sergei Shtylyov
2011-08-01 10:34     ` viresh kumar
2011-08-01 10:34       ` viresh kumar
2011-08-01  9:37 ` [PATCH V2 04/20] dmaengine/amba-pl08x: pass (*ptr) to sizeof() instead of (struct xyz) Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 05/20] dmaengine/amba-pl08x: Complete doc comment for struct pl08x_txd Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 06/20] dmaengine/amba-pl08x: Remove redundant comment and rewrite original Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 07/20] dmaengine/amba-pl08x: Changing few prints to dev_dbg from dev_info Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-04  8:28   ` Koul, Vinod
2011-08-04  8:28     ` Koul, Vinod
2011-08-04  9:25     ` viresh kumar
2011-08-04  9:25       ` viresh kumar
2011-08-04  8:53       ` Koul, Vinod
2011-08-04  8:53         ` Koul, Vinod
2011-08-01  9:37 ` [PATCH V2 08/20] dmaengine/amba-pl08x: support runtime PM Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01 10:26   ` Russell King - ARM Linux
2011-08-01 10:26     ` Russell King - ARM Linux
2011-08-01 11:55     ` viresh kumar
2011-08-01 11:55       ` viresh kumar
2011-08-03 12:39   ` Russell King - ARM Linux
2011-08-03 12:39     ` Russell King - ARM Linux
2011-08-04  5:19     ` viresh kumar
2011-08-04  5:19       ` viresh kumar
2011-08-04  5:36       ` Koul, Vinod
2011-08-04  5:36         ` Koul, Vinod
2011-08-04  6:31         ` viresh kumar
2011-08-04  6:31           ` viresh kumar
2011-08-04  7:28           ` Koul, Vinod
2011-08-04  7:28             ` Koul, Vinod
2011-08-04  8:42             ` viresh kumar
2011-08-04  8:42               ` viresh kumar
2011-08-01  9:37 ` [PATCH V2 09/20] dmaengine/amba-pl08x: Simplify pl08x_ensure_on() Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 10/20] dmaengine/amba-pl08x: No need to check "ch->signal < 0" Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 11/20] dmaengine/amba-pl08x: Schedule tasklet in case of error interrupt Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 12/20] dmaengine/amba-pl08x: Get rid of pl08x_pre_boundary() Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 13/20] dmaengine/amba-pl08x: max_bytes_per_lli is TRANSFER_SIZE * src_width (not MIN(width)) Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 14/20] dmaengine/amba-pl08x: Add prep_single_byte_llis() routine Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 15/20] dmaengine/amba-pl08x: Align lli_len to max(src.width, dst.width) Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 16/20] dmaengine/amba-pl08x: Choose peripheral bus as master bus Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` Viresh Kumar [this message]
2011-08-01  9:37   ` [PATCH V2 17/20] dmaengine/amba-pl08x: Pass flow controller information with slave channel data Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 18/20] dmaengine/amba-pl08x: Add support for sg len greater than one for slave transfers Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-04 10:27   ` viresh kumar
2011-08-04 10:27     ` viresh kumar
2011-08-01  9:37 ` [PATCH V2 19/20] dmaengine/amba-pl08x: Check txd->llis_va before freeing dma_pool Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01  9:37 ` [PATCH V2 20/20] dmaengine/amba-pl08x: Call pl08x_free_txd() instead of calling kfree() directly Viresh Kumar
2011-08-01  9:37   ` Viresh Kumar
2011-08-01 11:56 ` [PATCH V3 08/20] dmaengine/amba-pl08x: support runtime PM Viresh Kumar
2011-08-01 11:56   ` Viresh Kumar
2011-08-04  8:52   ` Koul, Vinod
2011-08-04  8:52     ` Koul, Vinod
2011-08-04  9:41     ` viresh kumar
2011-08-04  9:41       ` viresh kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75eeef2d64881c9ef21065e2b15188876a13a4ed.1312190881.git.viresh.kumar@st.com \
    --to=viresh.kumar@st.com \
    --cc=amit.virdi@st.com \
    --cc=armando.visconti@st.com \
    --cc=bhupesh.sharma@st.com \
    --cc=dan.j.williams@intel.com \
    --cc=deepak.sikri@st.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=pratyush.anand@st.com \
    --cc=rajeev-dlh.kumar@st.com \
    --cc=shiraz.hashim@st.com \
    --cc=vinod.koul@intel.com \
    --cc=vipin.kumar@st.com \
    --cc=vipulkumar.samar@st.com \
    --cc=viresh.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.