Thread (53 messages) 53 messages, 4 authors, 2018-01-12

Re: [PATCH 11/33] dma-mapping: move swiotlb arch helpers to a new header

From: Vladimir Murzin <hidden>
Date: 2018-01-10 09:32:05
Also in: linux-alpha, linux-arch, linux-arm-kernel, linux-iommu, linux-mips, linux-s390, linux-sh, lkml, sparclinux

On 10/01/18 08:00, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
index 9110988b92a1..f00833acb626 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
@@ -61,6 +61,14 @@ static inline void plat_post_dma_flush(struct device *dev)
 {
 }
 
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+	if (!dev->dma_mask)
+		return false;
+
+	return addr + size <= *dev->dma_mask;
+}
+
I know it is copy&paste, but it seems it has off by one error and it should be

return addr + size - 1 <= *dev->dma_mask;

 dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
 phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr);
 
snip...
quoted hunk ↗ jump to hunk
diff --git a/arch/mips/include/asm/mach-loongson64/dma-coherence.h b/arch/mips/include/asm/mach-loongson64/dma-coherence.h
index 1602a9e9e8c2..5cfda8f893e9 100644
--- a/arch/mips/include/asm/mach-loongson64/dma-coherence.h
+++ b/arch/mips/include/asm/mach-loongson64/dma-coherence.h
@@ -17,6 +17,14 @@
 
 struct device;
 
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+	if (!dev->dma_mask)
+		return false;
+
+	return addr + size <= *dev->dma_mask;

ditto

Cheers
Vladimir
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help