a98f1d38527e6233cc38482dd3f8faa39428c86b
[openwrt/staging/ldir.git] /
1 From a3794022e928547de664abd03b61280163c7f13a Mon Sep 17 00:00:00 2001
2 From: Christoph Hellwig <hch@lst.de>
3 Date: Tue, 12 Nov 2019 17:07:43 +0100
4 Subject: [PATCH] dma-direct: avoid a forward declaration for
5 phys_to_dma
6
7 Move dma_capable down a bit so that we don't need a forward declaration
8 for phys_to_dma.
9
10 Signed-off-by: Christoph Hellwig <hch@lst.de>
11 Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
12 (cherry picked from commit c7345159f7db6fb69ec1c3b3f8f28cd05c731be2)
13 ---
14 include/linux/dma-direct.h | 30 ++++++++++++++----------------
15 1 file changed, 14 insertions(+), 16 deletions(-)
16
17 --- a/include/linux/dma-direct.h
18 +++ b/include/linux/dma-direct.h
19 @@ -6,8 +6,6 @@
20 #include <linux/memblock.h> /* for min_low_pfn */
21 #include <linux/mem_encrypt.h>
22
23 -static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
24 -
25 extern unsigned int zone_dma_bits;
26
27 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
28 @@ -28,20 +26,6 @@ static inline phys_addr_t __dma_to_phys(
29 }
30 #endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
31
32 -static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
33 -{
34 - dma_addr_t end = addr + size - 1;
35 -
36 - if (!dev->dma_mask)
37 - return false;
38 -
39 - if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
40 - min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
41 - return false;
42 -
43 - return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
44 -}
45 -
46 #ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED
47 bool force_dma_unencrypted(struct device *dev);
48 #else
49 @@ -67,6 +51,20 @@ static inline phys_addr_t dma_to_phys(st
50 return __sme_clr(__dma_to_phys(dev, daddr));
51 }
52
53 +static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
54 +{
55 + dma_addr_t end = addr + size - 1;
56 +
57 + if (!dev->dma_mask)
58 + return false;
59 +
60 + if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
61 + min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
62 + return false;
63 +
64 + return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
65 +}
66 +
67 u64 dma_direct_get_required_mask(struct device *dev);
68 void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
69 gfp_t gfp, unsigned long attrs);