diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-04-25 07:58:29 -0400 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-05-22 07:26:29 -0400 |
commit | de0b65a786ae83c8f6dfb712f65b9a36af70a981 (patch) | |
tree | 5e806a20e51bafdb7a42e209239b98ab0620ceb6 | |
parent | 0718e59ae259f7c48155b4e852d8b0632d59028e (diff) |
mmc: sdhci: avoid sync'ing the SG if there's no misalignment
On read, we don't need to sync the whole scatterlist and then check
whether any segments need copying - if we check first, we avoid
potentially expensive cache handling.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Markus Pargmann <mpa@pengutronix.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r-- | drivers/mmc/host/sdhci.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 074157e8e73d..4f878bcfaa2d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -602,6 +602,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host, | |||
602 | u8 *align; | 602 | u8 *align; |
603 | char *buffer; | 603 | char *buffer; |
604 | unsigned long flags; | 604 | unsigned long flags; |
605 | bool has_unaligned; | ||
605 | 606 | ||
606 | if (data->flags & MMC_DATA_READ) | 607 | if (data->flags & MMC_DATA_READ) |
607 | direction = DMA_FROM_DEVICE; | 608 | direction = DMA_FROM_DEVICE; |
@@ -614,7 +615,15 @@ static void sdhci_adma_table_post(struct sdhci_host *host, | |||
614 | dma_unmap_single(mmc_dev(host->mmc), host->align_addr, | 615 | dma_unmap_single(mmc_dev(host->mmc), host->align_addr, |
615 | 128 * 4, direction); | 616 | 128 * 4, direction); |
616 | 617 | ||
617 | if (data->flags & MMC_DATA_READ) { | 618 | /* Do a quick scan of the SG list for any unaligned mappings */ |
619 | has_unaligned = false; | ||
620 | for_each_sg(data->sg, sg, host->sg_count, i) | ||
621 | if (sg_dma_address(sg) & 3) { | ||
622 | has_unaligned = true; | ||
623 | break; | ||
624 | } | ||
625 | |||
626 | if (has_unaligned && data->flags & MMC_DATA_READ) { | ||
618 | dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg, | 627 | dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg, |
619 | data->sg_len, direction); | 628 | data->sg_len, direction); |
620 | 629 | ||