* [PATCH] mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB
@ 2013-10-27 21:23 Barry Song
2013-10-27 22:12 ` Russell King - ARM Linux
0 siblings, 1 reply; 2+ messages in thread
From: Barry Song @ 2013-10-27 21:23 UTC (permalink / raw)
To: linux-arm-kernel
From: Bin Shi <Bin.Shi@csr.com>
on SiRFprimaII, sdhci is after pci-iobg bus, the bus bridge has a hardware
limitation. DMA operations after this bridge can not access memory address
higher than 256MB.
this patch enables dmabounce for SiRFprimaII to fix DMA of primaII. for other
SiRF SoCs, there is no this problem.
Signed-off-by: Bin Shi <Bin.Shi@csr.com>
Signed-off-by: Binghua Duan <Binghua.Duan@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
arch/arm/mach-prima2/Kconfig | 1 +
drivers/mmc/host/sdhci-sirf.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/arch/arm/mach-prima2/Kconfig b/arch/arm/mach-prima2/Kconfig
index 6988b11..8ecb071 100644
--- a/arch/arm/mach-prima2/Kconfig
+++ b/arch/arm/mach-prima2/Kconfig
@@ -26,6 +26,7 @@ config ARCH_PRIMA2
bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
default y
select CPU_V7
+ select DMABOUNCE
select SIRF_IRQ
select ZONE_DMA
help
diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c
index 696122c..11e270f 100644
--- a/drivers/mmc/host/sdhci-sirf.c
+++ b/drivers/mmc/host/sdhci-sirf.c
@@ -13,6 +13,7 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/mmc/slot-gpio.h>
+#include <linux/dma-mapping.h>
#include "sdhci-pltfm.h"
struct sdhci_sirf_priv {
@@ -40,6 +41,16 @@ static struct sdhci_pltfm_data sdhci_sirf_pdata = {
SDHCI_QUIRK_DELAY_AFTER_POWER,
};
+/*
+ * The following functions are needed for DMA bouncing because SiRFprimaII SD
+ * controller can address up to 256MByte
+ */
+static int sdhci_sirf_needs_bounce(struct device *dev, dma_addr_t dma_addr,
+ size_t size)
+{
+ return (dma_addr + size) >= SZ_256M;
+}
+
static int sdhci_sirf_probe(struct platform_device *pdev)
{
struct sdhci_host *host;
@@ -92,6 +103,13 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
}
}
+ if (of_machine_is_compatible("sirf,prima2")) {
+ if (pdev->dev.dma_mask)
+ *(pdev->dev.dma_mask) = SZ_256M - 1;
+ pdev->dev.coherent_dma_mask = SZ_256M - 1;
+ dmabounce_register_dev(&pdev->dev, 1024, 2048, sdhci_sirf_needs_bounce);
+ }
+
return 0;
err_request_cd:
--
1.8.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB
2013-10-27 21:23 [PATCH] mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB Barry Song
@ 2013-10-27 22:12 ` Russell King - ARM Linux
0 siblings, 0 replies; 2+ messages in thread
From: Russell King - ARM Linux @ 2013-10-27 22:12 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Oct 28, 2013 at 05:23:50AM +0800, Barry Song wrote:
> @@ -92,6 +103,13 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
> }
> }
>
> + if (of_machine_is_compatible("sirf,prima2")) {
> + if (pdev->dev.dma_mask)
> + *(pdev->dev.dma_mask) = SZ_256M - 1;
> + pdev->dev.coherent_dma_mask = SZ_256M - 1;
NAK. Please do not directly write to the DMA mask; this is not how DMA
masks should be setup. Please read up on the DMA API and specifically
in this case the dma_set_mask() / dma_set_coherent_mask() functions.
Also note that after the next merge window, those two calls should be
collapsed to dma_set_mask_and_coherent().
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-27 22:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-27 21:23 [PATCH] mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB Barry Song
2013-10-27 22:12 ` Russell King - ARM Linux
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).