Skip to contentSkip to conversation

mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB

PATCH New Barry Song 2 participants 2 messages Oct 27, 2013

Subsystems (4)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB

From: Bin Shi <[email protected]>

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.

---
 arch/arm/mach-prima2/Kconfig  |  1 +
 drivers/mmc/host/sdhci-sirf.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
arch/arm/mach-prima2/Kconfig +1 -0
index 6988b11..8ecb071 100644
@@ -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
drivers/mmc/host/sdhci-sirf.c +18 -0
index 696122c..11e270f 100644
@@ -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:
Signature · 1 line
1.8.2.3
#1 lore raw

PATCH 1/1 mmc: sdhci-sirf: enable dmabounce since SiRFprimaII MMC DMA only access up to 256MB

drivers/mmc/host/sdhci-sirf.c static int sdhci_sirf_probe(struct platform_device *pdev) · line 109

Quoted 8 lines · Barry Song
drivers/mmc/host/sdhci-sirf.c +4 -0
@@ -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.