All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-sh@vger.kernel.org
Subject: [PATCH/RFC 3/5] dmaengine: rcar-dmac: Compute maximum chunk size at runtime
Date: Tue, 22 Jul 2014 12:33:49 +0000	[thread overview]
Message-ID: <1406032431-3807-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)

The DMAC expressed DMA request lengths as a number of transfers, limited
to 16777216 by the hardware. As a single transfer transfers a
configurable number of bytes (from 1 to 64), the chunk size limit isn't
fixed and must be computed at runtime by multiplying the transfers
number limit by the transfer size.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/dma/sh/rcar-dmac.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 09df914..371cca3 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -242,7 +242,6 @@ struct rcar_dmac {
 
 /* Hardcode the MEMCPY transfer size to 4 bytes. */
 #define RCAR_DMAC_MEMCPY_XFER_SIZE	4
-#define RCAR_DMAC_MAX_XFER_LEN		(RCAR_DMATCR_MASK + 1)
 
 /* -----------------------------------------------------------------------------
  * Device access
@@ -701,6 +700,7 @@ rcar_dmac_chan_prep_sg(struct rcar_dmac_chan *chan, struct scatterlist *sgl,
 	struct rcar_dmac_xfer_chunk *chunk;
 	struct rcar_dmac_desc *desc;
 	struct scatterlist *sg = sgl;
+	size_t max_chunk_size;
 	size_t full_size = 0;
 	unsigned int i;
 
@@ -716,6 +716,8 @@ rcar_dmac_chan_prep_sg(struct rcar_dmac_chan *chan, struct scatterlist *sgl,
 
 	rcar_dmac_chan_configure_desc(chan, desc);
 
+	max_chunk_size = (RCAR_DMATCR_MASK + 1) << desc->xfer_shift;
+
 	/*
 	 * Allocate and fill the transfer chunk descriptors. We own the only
 	 * reference to the DMA descriptor, there's no need for locking.
@@ -727,7 +729,7 @@ rcar_dmac_chan_prep_sg(struct rcar_dmac_chan *chan, struct scatterlist *sgl,
 		full_size += len;
 
 		while (len) {
-			size_t size = min_t(size_t, len, RCAR_DMAC_MAX_XFER_LEN);
+			size_t size = min_t(size_t, len, max_chunk_size);
 
 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
 			/*
-- 
1.8.5.5


                 reply	other threads:[~2014-07-22 12:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1406032431-3807-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-sh@vger.kernel.org \
    /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.