Skip to contentSkip to conversation

SWIOTLB support for Netlogic XLP

PATCH New Jayachandran C 1 participant 3 messages Jun 10, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

cover SWIOTLB support for Netlogic XLP

Two patches for using the SWIOTLB lib in Netlogic XLP code.

The first one adds support for SWIOTLB in generic MIPS operations. Without this platforms cannot use generic MIPS dma ops when SWIOTLB is enabled. The second adds SWIOTLB based dma ops for Netlogic XLP, which will be used by a few drivers which cannot do 64-bit DMA.

Comments welcome.

Regards,
JC.

Ganesan Ramalingam (1):
MIPS: Netlogic: SWIOTLB dma ops for 32-bit DMA

Jayachandran C (1):
MIPS: Support SWIOTLB in default dma operations

 arch/mips/include/asm/mach-generic/dma-coherence.h |   12 +++
 arch/mips/include/asm/netlogic/common.h            |    3 +
 arch/mips/mm/dma-default.c                         |    3 +
 arch/mips/netlogic/Kconfig                         |   11 ++
 arch/mips/netlogic/common/Makefile                 |    1 +
 arch/mips/netlogic/common/nlm-dma.c                |  107 ++++++++++++++++++++
 6 files changed, 137 insertions(+)
 create mode 100644 arch/mips/netlogic/common/nlm-dma.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 MIPS: Support SWIOTLB in default dma operations

Provide a default implementation of phys_to_dma and dma_to_phys in mach-generic/dma_coherence.h.

If CONFIG_NEED_SG_DMA_LENGTH is defined, the dma_length field in struct scatterlist is used. Set this up in mips_dma_map_sg so that the default mips DMA ops can be used when SWIOTLB is enabled.

---
 arch/mips/include/asm/mach-generic/dma-coherence.h |   12 ++++++++++++
 arch/mips/mm/dma-default.c                         |    3 +++
 2 files changed, 15 insertions(+)
arch/mips/include/asm/mach-generic/dma-coherence.h +12 -0
index fe23034..74cb992 100644
@@ -66,4 +66,16 @@ static inline int plat_device_is_coherent(struct device *dev)
 #endif
 }
 
+#ifdef CONFIG_SWIOTLB
+static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return paddr;
+}
+
+static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+	return daddr;
+}
+#endif
+
 #endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
arch/mips/mm/dma-default.c +3 -0
index caf92ec..aaccf1c 100644
@@ -246,6 +246,9 @@ static int mips_dma_map_sg(struct device *dev, struct scatterlist *sg,
 		if (!plat_device_is_coherent(dev))
 			__dma_sync(sg_page(sg), sg->offset, sg->length,
 				   direction);
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+		sg->dma_length = sg->length;
+#endif
 		sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) +
 				  sg->offset;
 	}
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 MIPS: Netlogic: SWIOTLB dma ops for 32-bit DMA

In reply to Jayachandran C

From: Ganesan Ramalingam <[email protected]>

Add SWIOTLB config option and related files to Netlogic platform.

Some XLP SoC components like the SD/MMC interface cannot do DMA beyond 32-bit physical address. The SD/MMC driver can use memory outside this range for IO, to support this we have to add bounce buffers implemented by SWIOTLB.

---
 arch/mips/include/asm/netlogic/common.h |    3 +
 arch/mips/netlogic/Kconfig              |   11 ++++
 arch/mips/netlogic/common/Makefile      |    1 +
 arch/mips/netlogic/common/nlm-dma.c     |  107 +++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+)
 create mode 100644 arch/mips/netlogic/common/nlm-dma.c
arch/mips/include/asm/netlogic/common.h +3 -0
index aef560a..70351b9 100644
@@ -76,6 +76,9 @@ void nlm_node_init(int node);
 extern struct plat_smp_ops nlm_smp_ops;
 extern char nlm_reset_entry[], nlm_reset_entry_end[];
 
+/* SWIOTLB */
+extern struct dma_map_ops nlm_swiotlb_dma_ops;
+
 extern unsigned int nlm_threads_per_core;
 extern cpumask_t nlm_cpumask;
 
arch/mips/netlogic/Kconfig +11 -0
index e0873a3..2447bf9 100644
@@ -51,4 +51,15 @@ endif
 config NLM_COMMON
 	bool
 
+config IOMMU_HELPER
+	bool
+
+config NEED_SG_DMA_LENGTH
+	bool
+
+config SWIOTLB
+	def_bool y
+	select NEED_SG_DMA_LENGTH
+	select IOMMU_HELPER
+
 endif
arch/mips/netlogic/common/Makefile +1 -0
index 291372a..b295497 100644
@@ -1,3 +1,4 @@
 obj-y				+= irq.o time.o
+obj-y				+= nlm-dma.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o
 obj-$(CONFIG_EARLY_PRINTK)	+= earlycons.o
arch/mips/netlogic/common/nlm-dma.c new file +107 -0

107 lines not on this page · raw message

Signature · 1 line
1.7.9.5