linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hein Tibosch <hein_tibosch@yahoo.es>
To: Andrew Morton <akpm@linux-foundation.org>,
	viresh kumar <viresh.kumar@linaro.org>,
	Hans-Christian Egtvedt <egtvedt@samfundet.no>,
	Arnd Bergmann <arnd.bergmann@linaro.org>
Cc: spear-devel <spear-devel@list.st.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"ludovic.desroches" <ludovic.desroches@atmel.com>,
	Havard Skinnemoen <havard@skinnemoen.net>,
	Nicolas Ferre <nicolas.ferre@atmel.com>
Subject: [PATCH v4 2/3] dw_dmac: max_mem_width limits value for SRC/DST_TR_WID register
Date: Mon, 03 Sep 2012 01:54:12 +0800	[thread overview]
Message-ID: <50439D44.3080100@yahoo.es> (raw)

From: Hein Tibosch <hein_tibosch@yahoo.es>

v4: now based and tested on 3.6-rc4

The dw_dmac driver was earlier adapted to do 64-bit transfers on the memory
side (see https://lkml.org/lkml/2012/1/18/52)
This works on ARM platforms but for AVR32 (AP700x) the maximum allowed transfer
size is 32-bits.
This patch allows the arch code to set a new slave property max_mem_width to
limit the size.

Allowable values are:

#define	DW_MEM_WIDTH_64		0	/* default */
#define	DW_MEM_WIDTH_32		1	/* e.g. for avr32 */

Signed-off-by: Hein Tibosch <hein_tibosch@yahoo.es>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/dma/dw_dmac.c   |   13 +++++++------
 include/linux/dw_dmac.h |    3 +++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index d3c5a5a..311953c 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -190,14 +190,14 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
 }
 
 /*----------------------------------------------------------------------*/
-
-static inline unsigned int dwc_fast_fls(unsigned long long v)
+static inline unsigned int dwc_fast_fls(unsigned long long v,
+	struct dw_dma_slave *dws)
 {
 	/*
 	 * We can be a lot more clever here, but this should take care
 	 * of the most common optimization.
 	 */
-	if (!(v & 7))
+	if (dws->max_mem_width == DW_MEM_WIDTH_64 && !(v & 7))
 		return 3;
 	else if (!(v & 3))
 		return 2;
@@ -636,6 +636,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
 		size_t len, unsigned long flags)
 {
 	struct dw_dma_chan	*dwc = to_dw_dma_chan(chan);
+	struct dw_dma_slave	*dws = chan->private;
 	struct dw_desc		*desc;
 	struct dw_desc		*first;
 	struct dw_desc		*prev;
@@ -655,7 +656,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
 		return NULL;
 	}
 
-	src_width = dst_width = dwc_fast_fls(src | dest | len);
+	src_width = dst_width = dwc_fast_fls(src | dest | len, dws);
 
 	ctllo = DWC_DEFAULT_CTLLO(chan)
 			| DWC_CTLL_DST_WIDTH(dst_width)
@@ -755,7 +756,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
 			mem = sg_dma_address(sg);
 			len = sg_dma_len(sg);
 
-			mem_width = dwc_fast_fls(mem | len);
+			mem_width = dwc_fast_fls(mem | len, dws);
 
 slave_sg_todev_fill_desc:
 			desc = dwc_desc_get(dwc);
@@ -815,7 +816,7 @@ slave_sg_todev_fill_desc:
 			mem = sg_dma_address(sg);
 			len = sg_dma_len(sg);
 
-			mem_width = dwc_fast_fls(mem | len);
+			mem_width = dwc_fast_fls(mem | len, dws);
 
 slave_sg_fromdev_fill_desc:
 			desc = dwc_desc_get(dwc);
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
index 2412e02..330afb2 100644
--- a/include/linux/dw_dmac.h
+++ b/include/linux/dw_dmac.h
@@ -58,6 +58,9 @@ struct dw_dma_slave {
 	u32			cfg_lo;
 	u8			src_master;
 	u8			dst_master;
+#define	DW_MEM_WIDTH_64		0
+#define	DW_MEM_WIDTH_32		1	/* e.g. for avr32 */
+	u8			max_mem_width;
 };
 
 /* Platform-configurable bits in CFG_HI */
-- 
1.7.8.0

             reply	other threads:[~2012-09-02 18:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-02 17:54 Hein Tibosch [this message]
2012-09-03  8:25 ` Andy Shevchenko
2012-09-03  8:30   ` Viresh Kumar
2012-09-03  8:49     ` Andy Shevchenko
2012-09-03  8:59       ` Viresh Kumar
2012-09-03 13:06         ` Hein Tibosch
2012-09-04  6:38           ` Andy Shevchenko

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=50439D44.3080100@yahoo.es \
    --to=hein_tibosch@yahoo.es \
    --cc=akpm@linux-foundation.org \
    --cc=arnd.bergmann@linaro.org \
    --cc=egtvedt@samfundet.no \
    --cc=havard@skinnemoen.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=spear-devel@list.st.com \
    --cc=viresh.kumar@linaro.org \
    --subject='Re: [PATCH v4 2/3] dw_dmac: max_mem_width limits value for SRC/DST_TR_WID register' \
    /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

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