bcm27xx: update to latest patches from RPi foundation
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0448-dma-direct-unify-the-dma_capable-definitions.patch
1 From 203e0c39b262fc1da6f976495c32ec38ea93a137 Mon Sep 17 00:00:00 2001
2 From: Christoph Hellwig <hch@lst.de>
3 Date: Tue, 12 Nov 2019 17:06:04 +0100
4 Subject: [PATCH] dma-direct: unify the dma_capable definitions
5
6 commit 130c1ccbf55330b55e82612a6e54eebb82c9d746 upstream.
7
8 Currently each architectures that wants to override dma_to_phys and
9 phys_to_dma also has to provide dma_capable. But there isn't really
10 any good reason for that. powerpc and mips just have copies of the
11 generic one minus the latests fix, and the arm one was the inspiration
12 for said fix, but misses the bus_dma_mask handling.
13 Make all architectures use the generic version instead.
14
15 Signed-off-by: Christoph Hellwig <hch@lst.de>
16 Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
17 Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
18 ---
19 arch/arm/include/asm/dma-direct.h | 19 -------------------
20 arch/mips/include/asm/dma-direct.h | 8 --------
21 arch/powerpc/include/asm/dma-direct.h | 9 ---------
22 include/linux/dma-direct.h | 2 +-
23 4 files changed, 1 insertion(+), 37 deletions(-)
24
25 --- a/arch/arm/include/asm/dma-direct.h
26 +++ b/arch/arm/include/asm/dma-direct.h
27 @@ -14,23 +14,4 @@ static inline phys_addr_t __dma_to_phys(
28 return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset;
29 }
30
31 -static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
32 -{
33 - u64 limit, mask;
34 -
35 - if (!dev->dma_mask)
36 - return 0;
37 -
38 - mask = *dev->dma_mask;
39 -
40 - limit = (mask + 1) & ~mask;
41 - if (limit && size > limit)
42 - return 0;
43 -
44 - if ((addr | (addr + size - 1)) & ~mask)
45 - return 0;
46 -
47 - return 1;
48 -}
49 -
50 #endif /* ASM_ARM_DMA_DIRECT_H */
51 --- a/arch/mips/include/asm/dma-direct.h
52 +++ b/arch/mips/include/asm/dma-direct.h
53 @@ -2,14 +2,6 @@
54 #ifndef _MIPS_DMA_DIRECT_H
55 #define _MIPS_DMA_DIRECT_H 1
56
57 -static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
58 -{
59 - if (!dev->dma_mask)
60 - return false;
61 -
62 - return addr + size - 1 <= *dev->dma_mask;
63 -}
64 -
65 dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr);
66 phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr);
67
68 --- a/arch/powerpc/include/asm/dma-direct.h
69 +++ b/arch/powerpc/include/asm/dma-direct.h
70 @@ -2,15 +2,6 @@
71 #ifndef ASM_POWERPC_DMA_DIRECT_H
72 #define ASM_POWERPC_DMA_DIRECT_H 1
73
74 -static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
75 -{
76 - if (!dev->dma_mask)
77 - return false;
78 -
79 - return addr + size - 1 <=
80 - min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
81 -}
82 -
83 static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
84 {
85 if (!dev)
86 --- a/include/linux/dma-direct.h
87 +++ b/include/linux/dma-direct.h
88 @@ -26,6 +26,7 @@ static inline phys_addr_t __dma_to_phys(
89
90 return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
91 }
92 +#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
93
94 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
95 {
96 @@ -40,7 +41,6 @@ static inline bool dma_capable(struct de
97
98 return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
99 }
100 -#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
101
102 #ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED
103 bool force_dma_unencrypted(struct device *dev);