~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/dma-direct.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/dma-direct.h (Version linux-6.11.5) and /include/linux/dma-direct.h (Version linux-5.7.19)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                             << 
  3  * Internals of the DMA direct mapping impleme << 
  4  * DMA mapping code and IOMMU drivers.         << 
  5  */                                            << 
  6 #ifndef _LINUX_DMA_DIRECT_H                         2 #ifndef _LINUX_DMA_DIRECT_H
  7 #define _LINUX_DMA_DIRECT_H 1                       3 #define _LINUX_DMA_DIRECT_H 1
  8                                                     4 
  9 #include <linux/dma-mapping.h>                      5 #include <linux/dma-mapping.h>
 10 #include <linux/dma-map-ops.h>                 << 
 11 #include <linux/memblock.h> /* for min_low_pfn      6 #include <linux/memblock.h> /* for min_low_pfn */
 12 #include <linux/mem_encrypt.h>                      7 #include <linux/mem_encrypt.h>
 13 #include <linux/swiotlb.h>                     << 
 14                                                     8 
 15 extern unsigned int zone_dma_bits;                  9 extern unsigned int zone_dma_bits;
 16                                                    10 
 17 /*                                             !!  11 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
 18  * Record the mapping of CPU physical to DMA a !!  12 #include <asm/dma-direct.h>
 19  */                                            !!  13 #else
 20 struct bus_dma_region {                        !!  14 static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
 21         phys_addr_t     cpu_start;             << 
 22         dma_addr_t      dma_start;             << 
 23         u64             size;                  << 
 24 };                                             << 
 25                                                << 
 26 static inline dma_addr_t translate_phys_to_dma << 
 27                 phys_addr_t paddr)             << 
 28 {                                              << 
 29         const struct bus_dma_region *m;        << 
 30                                                << 
 31         for (m = dev->dma_range_map; m->size;  << 
 32                 u64 offset = paddr - m->cpu_st << 
 33                                                << 
 34                 if (paddr >= m->cpu_start && o << 
 35                         return m->dma_start +  << 
 36         }                                      << 
 37                                                << 
 38         /* make sure dma_capable fails when no << 
 39         return DMA_MAPPING_ERROR;              << 
 40 }                                              << 
 41                                                << 
 42 static inline phys_addr_t translate_dma_to_phy << 
 43                 dma_addr_t dma_addr)           << 
 44 {                                              << 
 45         const struct bus_dma_region *m;        << 
 46                                                << 
 47         for (m = dev->dma_range_map; m->size;  << 
 48                 u64 offset = dma_addr - m->dma << 
 49                                                << 
 50                 if (dma_addr >= m->dma_start & << 
 51                         return m->cpu_start +  << 
 52         }                                      << 
 53                                                << 
 54         return (phys_addr_t)-1;                << 
 55 }                                              << 
 56                                                << 
 57 static inline dma_addr_t dma_range_map_min(con << 
 58 {                                                  15 {
 59         dma_addr_t ret = (dma_addr_t)U64_MAX;  !!  16         dma_addr_t dev_addr = (dma_addr_t)paddr;
 60                                                    17 
 61         for (; map->size; map++)               !!  18         return dev_addr - ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
 62                 ret = min(ret, map->dma_start) << 
 63         return ret;                            << 
 64 }                                                  19 }
 65                                                    20 
 66 static inline dma_addr_t dma_range_map_max(con !!  21 static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
 67 {                                                  22 {
 68         dma_addr_t ret = 0;                    !!  23         phys_addr_t paddr = (phys_addr_t)dev_addr;
 69                                                    24 
 70         for (; map->size; map++)               !!  25         return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
 71                 ret = max(ret, map->dma_start  << 
 72         return ret;                            << 
 73 }                                                  26 }
                                                   >>  27 #endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
 74                                                    28 
 75 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA             !!  29 #ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED
 76 #include <asm/dma-direct.h>                    !!  30 bool force_dma_unencrypted(struct device *dev);
 77 #ifndef phys_to_dma_unencrypted                << 
 78 #define phys_to_dma_unencrypted         phys_t << 
 79 #endif                                         << 
 80 #else                                              31 #else
 81 static inline dma_addr_t phys_to_dma_unencrypt !!  32 static inline bool force_dma_unencrypted(struct device *dev)
 82                 phys_addr_t paddr)             << 
 83 {                                                  33 {
 84         if (dev->dma_range_map)                !!  34         return false;
 85                 return translate_phys_to_dma(d << 
 86         return paddr;                          << 
 87 }                                                  35 }
                                                   >>  36 #endif /* CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED */
 88                                                    37 
 89 /*                                                 38 /*
 90  * If memory encryption is supported, phys_to_     39  * If memory encryption is supported, phys_to_dma will set the memory encryption
 91  * bit in the DMA address, and dma_to_phys wil !!  40  * bit in the DMA address, and dma_to_phys will clear it.  The raw __phys_to_dma
 92  * phys_to_dma_unencrypted is for use on speci !!  41  * and __dma_to_phys versions should only be used on non-encrypted memory for
 93  * buffers.                                    !!  42  * special occasions like DMA coherent buffers.
 94  */                                                43  */
 95 static inline dma_addr_t phys_to_dma(struct de     44 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
 96 {                                                  45 {
 97         return __sme_set(phys_to_dma_unencrypt !!  46         return __sme_set(__phys_to_dma(dev, paddr));
 98 }                                              << 
 99                                                << 
100 static inline phys_addr_t dma_to_phys(struct d << 
101 {                                              << 
102         phys_addr_t paddr;                     << 
103                                                << 
104         if (dev->dma_range_map)                << 
105                 paddr = translate_dma_to_phys( << 
106         else                                   << 
107                 paddr = dma_addr;              << 
108                                                << 
109         return __sme_clr(paddr);               << 
110 }                                                  47 }
111 #endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */      << 
112                                                    48 
113 #ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED   !!  49 static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
114 bool force_dma_unencrypted(struct device *dev) << 
115 #else                                          << 
116 static inline bool force_dma_unencrypted(struc << 
117 {                                                  50 {
118         return false;                          !!  51         return __sme_clr(__dma_to_phys(dev, daddr));
119 }                                                  52 }
120 #endif /* CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTE << 
121                                                    53 
122 static inline bool dma_capable(struct device *     54 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
123                 bool is_ram)                       55                 bool is_ram)
124 {                                                  56 {
125         dma_addr_t end = addr + size - 1;          57         dma_addr_t end = addr + size - 1;
126                                                    58 
127         if (addr == DMA_MAPPING_ERROR)         !!  59         if (!dev->dma_mask)
128                 return false;                      60                 return false;
                                                   >>  61 
129         if (is_ram && !IS_ENABLED(CONFIG_ARCH_     62         if (is_ram && !IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
130             min(addr, end) < phys_to_dma(dev,      63             min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
131                 return false;                      64                 return false;
132                                                    65 
133         return end <= min_not_zero(*dev->dma_m     66         return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_limit);
134 }                                                  67 }
135                                                    68 
136 u64 dma_direct_get_required_mask(struct device     69 u64 dma_direct_get_required_mask(struct device *dev);
137 void *dma_direct_alloc(struct device *dev, siz     70 void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
138                 gfp_t gfp, unsigned long attrs     71                 gfp_t gfp, unsigned long attrs);
139 void dma_direct_free(struct device *dev, size_     72 void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,
140                 dma_addr_t dma_addr, unsigned      73                 dma_addr_t dma_addr, unsigned long attrs);
141 struct page *dma_direct_alloc_pages(struct dev !!  74 void *dma_direct_alloc_pages(struct device *dev, size_t size,
142                 dma_addr_t *dma_handle, enum d !!  75                 dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs);
143 void dma_direct_free_pages(struct device *dev, !!  76 void dma_direct_free_pages(struct device *dev, size_t size, void *cpu_addr,
144                 struct page *page, dma_addr_t  !!  77                 dma_addr_t dma_addr, unsigned long attrs);
145                 enum dma_data_direction dir);  !!  78 struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
                                                   >>  79                 gfp_t gfp, unsigned long attrs);
                                                   >>  80 int dma_direct_get_sgtable(struct device *dev, struct sg_table *sgt,
                                                   >>  81                 void *cpu_addr, dma_addr_t dma_addr, size_t size,
                                                   >>  82                 unsigned long attrs);
                                                   >>  83 bool dma_direct_can_mmap(struct device *dev);
                                                   >>  84 int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
                                                   >>  85                 void *cpu_addr, dma_addr_t dma_addr, size_t size,
                                                   >>  86                 unsigned long attrs);
146 int dma_direct_supported(struct device *dev, u     87 int dma_direct_supported(struct device *dev, u64 mask);
147 dma_addr_t dma_direct_map_resource(struct devi << 
148                 size_t size, enum dma_data_dir << 
149                                                << 
150 #endif /* _LINUX_DMA_DIRECT_H */                   88 #endif /* _LINUX_DMA_DIRECT_H */
151                                                    89 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php