]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Mon, 3 Feb 2020 23:32:07 +0000 (18:32 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 3 Feb 2020 23:32:07 +0000 (18:32 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/dma-direct-unify-the-dma_capable-definitions.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/dma-direct-unify-the-dma_capable-definitions.patch b/queue-5.4/dma-direct-unify-the-dma_capable-definitions.patch
new file mode 100644 (file)
index 0000000..6ce1380
--- /dev/null
@@ -0,0 +1,117 @@
+From 182e83b42c1adbbde6c22f0cf1a0a00c79c49e26 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 12 Nov 2019 17:06:04 +0100
+Subject: dma-direct: unify the dma_capable definitions
+
+From: Christoph Hellwig <hch@lst.de>
+
+[ Upstream commit 130c1ccbf55330b55e82612a6e54eebb82c9d746 ]
+
+Currently each architectures that wants to override dma_to_phys and
+phys_to_dma also has to provide dma_capable.  But there isn't really
+any good reason for that.  powerpc and mips just have copies of the
+generic one minus the latests fix, and the arm one was the inspiration
+for said fix, but misses the bus_dma_mask handling.
+Make all architectures use the generic version instead.
+
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
+Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/include/asm/dma-direct.h     | 19 -------------------
+ arch/mips/include/asm/dma-direct.h    |  8 --------
+ arch/powerpc/include/asm/dma-direct.h |  9 ---------
+ include/linux/dma-direct.h            |  2 +-
+ 4 files changed, 1 insertion(+), 37 deletions(-)
+
+diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
+index b67e5fc1fe436..7c3001a6a775b 100644
+--- a/arch/arm/include/asm/dma-direct.h
++++ b/arch/arm/include/asm/dma-direct.h
+@@ -14,23 +14,4 @@ static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+       return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset;
+ }
+-static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+-{
+-      u64 limit, mask;
+-
+-      if (!dev->dma_mask)
+-              return 0;
+-
+-      mask = *dev->dma_mask;
+-
+-      limit = (mask + 1) & ~mask;
+-      if (limit && size > limit)
+-              return 0;
+-
+-      if ((addr | (addr + size - 1)) & ~mask)
+-              return 0;
+-
+-      return 1;
+-}
+-
+ #endif /* ASM_ARM_DMA_DIRECT_H */
+diff --git a/arch/mips/include/asm/dma-direct.h b/arch/mips/include/asm/dma-direct.h
+index b5c240806e1bb..14e352651ce94 100644
+--- a/arch/mips/include/asm/dma-direct.h
++++ b/arch/mips/include/asm/dma-direct.h
+@@ -2,14 +2,6 @@
+ #ifndef _MIPS_DMA_DIRECT_H
+ #define _MIPS_DMA_DIRECT_H 1
+-static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+-{
+-      if (!dev->dma_mask)
+-              return false;
+-
+-      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);
+diff --git a/arch/powerpc/include/asm/dma-direct.h b/arch/powerpc/include/asm/dma-direct.h
+index a2912b47102cf..e29e8a236b8df 100644
+--- a/arch/powerpc/include/asm/dma-direct.h
++++ b/arch/powerpc/include/asm/dma-direct.h
+@@ -2,15 +2,6 @@
+ #ifndef ASM_POWERPC_DMA_DIRECT_H
+ #define ASM_POWERPC_DMA_DIRECT_H 1
+-static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+-{
+-      if (!dev->dma_mask)
+-              return false;
+-
+-      return addr + size - 1 <=
+-              min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
+-}
+-
+ static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
+ {
+       if (!dev)
+diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
+index 076c2ecb7fa06..9e764a798c819 100644
+--- a/include/linux/dma-direct.h
++++ b/include/linux/dma-direct.h
+@@ -24,6 +24,7 @@ static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+       return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+ }
++#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
+ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
+               bool is_ram)
+@@ -39,7 +40,6 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
+       return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
+ }
+-#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
+ #ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED
+ bool force_dma_unencrypted(struct device *dev);
+-- 
+2.20.1
+
index e7bd55ca354ded36d45f250da8d4281bb1b84692..c10a1ffcfc86885f3ba8d487ad0f7d7ad000b5fa 100644 (file)
@@ -98,3 +98,4 @@ mm-migrate.c-also-overwrite-error-when-it-is-bigger-.patch
 asoc-topology-fix-soc_tplg_fe_link_create-link-dobj-.patch
 revert-rsi-fix-potential-null-dereference-in-rsi_pro.patch
 tracing-uprobe-fix-to-make-trace_uprobe_filter-align.patch
+dma-direct-unify-the-dma_capable-definitions.patch