linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linus.walleij@linaro.org (Linus Walleij)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mmci: restrict DMA usage to large, even multiblock transfers
Date: Tue,  1 Feb 2011 11:41:13 +0100	[thread overview]
Message-ID: <1296556873-2730-1-git-send-email-linus.walleij@linaro.org> (raw)

This will restrict the use of DMA to only cover multi-block
transfers of blocks that are evenly divisible with the FIFO
halfsize (8 4-byte words, 32 bytes). This will be true for any
normal, large MMC file transfer, falling back to PIO mode for
any smallish reads.

Cc: Ulf Hansson <ulf.hansson@stericsson.com>
Cc: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
With this and the previous DMA end sync code the latest MMCI
patches work fine on U8500. On external cards the first read
is an 8-byte single block, which would fail otherwise.

I believe the earlier 1-byte-burst code would circumvent this
restriction, this solution is more elegant. Whether it is also
more efficient to avoid DMA on small packets needs to be
confirmed by measurements but I suspect it is.
---
 drivers/mmc/host/mmci.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index bac15a3..9ba24fd 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -484,10 +484,14 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
 		datactrl |= MCI_DPSM_DIRECTION;
 
 	/*
-	 * Attempt to use DMA operation mode, if this
-	 * should fail, fall back to PIO mode
+	 * If the transfer is more than one block, and the block size is
+	 * evenly dividable by the half FIFO so it can be chopped into
+	 * burst packets, then attempt to use DMA operation mode, if this
+	 * should fail, fall back to PIO mode.
 	 */
-	if (!mmci_dma_start_data(host, datactrl))
+	if (data->blocks > 1 &&
+	    (data->blksz % variant->fifohalfsize == 0) &&
+	    !mmci_dma_start_data(host, datactrl))
 		return;
 
 	/* IRQ mode, map the SG list for CPU reading/writing */
-- 
1.7.3.2

             reply	other threads:[~2011-02-01 10:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01 10:41 Linus Walleij [this message]
2011-02-01 10:54 ` [PATCH] mmci: restrict DMA usage to large, even multiblock transfers Russell King - ARM Linux
2011-02-01 11:34   ` Ulf Hansson
2011-02-01 11:45     ` Russell King - ARM Linux
2011-02-01 11:56       ` Ulf Hansson
2011-02-01 11:58       ` Russell King - ARM Linux
2011-02-01 14:07         ` Linus Walleij
2011-02-01 14:44           ` Russell King - ARM Linux
2011-02-02  9:39             ` Linus Walleij
2011-02-01 15:05           ` Russell King - ARM Linux
2011-02-02  9:34             ` Linus Walleij

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=1296556873-2730-1-git-send-email-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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 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).