All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmci: restrict DMA usage to large, even multiblock transfers
@ 2011-02-01 10:41 Linus Walleij
  2011-02-01 10:54 ` Russell King - ARM Linux
  0 siblings, 1 reply; 11+ messages in thread
From: Linus Walleij @ 2011-02-01 10:41 UTC (permalink / raw)
  To: linux-arm-kernel

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

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

end of thread, other threads:[~2011-02-02  9:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 10:41 [PATCH] mmci: restrict DMA usage to large, even multiblock transfers Linus Walleij
2011-02-01 10:54 ` 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

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.