Changeset 679 for GPL/trunk/include/linux/dma-mapping.h
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/include/linux/dma-mapping.h
r441 r679 1 1 #ifndef _ASM_LINUX_DMA_MAPPING_H 2 2 #define _ASM_LINUX_DMA_MAPPING_H 3 #include <linux/pci.h> 4 #include <linux/errno.h> 5 #include <linux/string.h> 6 #include <linux/err.h> 3 7 4 8 /* These definitions mirror those in pci.h, so they can be used … … 10 14 DMA_NONE = 3, 11 15 }; 16 17 /* 18 * A dma_addr_t can hold any valid DMA or bus address for the platform. 19 * It can be given to a device to use as a DMA source or target. A CPU cannot 20 * reference a dma_addr_t directly because there may be translation between 21 * its physical address space and the bus address space. 22 */ 23 struct dma_map_ops { 24 #if 0 25 void* (*alloc)(struct device *dev, size_t size, 26 dma_addr_t *dma_handle, gfp_t gfp, 27 struct dma_attrs *attrs); 28 void (*free)(struct device *dev, size_t size, 29 void *vaddr, dma_addr_t dma_handle, 30 struct dma_attrs *attrs); 31 int (*mmap)(struct device *, struct vm_area_struct *, 32 void *, dma_addr_t, size_t, struct dma_attrs *attrs); 33 34 int (*get_sgtable)(struct device *dev, struct sg_table *sgt, void *, 35 dma_addr_t, size_t, struct dma_attrs *attrs); 36 37 dma_addr_t (*map_page)(struct device *dev, struct page *page, 38 unsigned long offset, size_t size, 39 enum dma_data_direction dir, 40 struct dma_attrs *attrs); 41 void (*unmap_page)(struct device *dev, dma_addr_t dma_handle, 42 size_t size, enum dma_data_direction dir, 43 struct dma_attrs *attrs); 44 /* 45 * map_sg returns 0 on error and a value > 0 on success. 46 * It should never return a value < 0. 47 */ 48 int (*map_sg)(struct device *dev, struct scatterlist *sg, 49 int nents, enum dma_data_direction dir, 50 struct dma_attrs *attrs); 51 void (*unmap_sg)(struct device *dev, 52 struct scatterlist *sg, int nents, 53 enum dma_data_direction dir, 54 struct dma_attrs *attrs); 55 void (*sync_single_for_cpu)(struct device *dev, 56 dma_addr_t dma_handle, size_t size, 57 enum dma_data_direction dir); 58 void (*sync_single_for_device)(struct device *dev, 59 dma_addr_t dma_handle, size_t size, 60 enum dma_data_direction dir); 61 void (*sync_sg_for_cpu)(struct device *dev, 62 struct scatterlist *sg, int nents, 63 enum dma_data_direction dir); 64 void (*sync_sg_for_device)(struct device *dev, 65 struct scatterlist *sg, int nents, 66 enum dma_data_direction dir); 67 int (*mapping_error)(struct device *dev, dma_addr_t dma_addr); 68 #endif 69 int (*dma_supported)(struct device *dev, u64 mask); 70 int (*set_dma_mask)(struct device *dev, u64 mask); 71 #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK 72 u64 (*get_required_mask)(struct device *dev); 73 #endif 74 int is_phys; 75 }; 76 77 78 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) 79 80 #define DMA_MASK_NONE 0x0ULL 12 81 13 82 #define DMA_64BIT_MASK 0xffffffffffffffffULL … … 30 99 #endif 31 100 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) 101 102 extern struct dma_map_ops *dma_ops; 103 104 static inline struct dma_map_ops *get_dma_ops(struct device *dev) 105 { 106 if (dev->dma_ops) 107 return dev->dma_ops; 108 return NULL; 109 } 110 111 static inline void set_dma_ops(struct device *dev, 112 struct dma_map_ops *dma_ops) 113 { 114 dev->dma_ops = dma_ops; 115 } 116 117 int dma_supported(struct device *dev, u64 mask); 118 int dma_set_mask(struct device *dev, u64 mask); 119 int dma_set_coherent_mask(struct device *dev, u64 mask); 120 121 /* 122 * Set both the DMA mask and the coherent DMA mask to the same thing. 123 * Note that we don't check the return value from dma_set_coherent_mask() 124 * as the DMA API guarantees that the coherent DMA mask can be set to 125 * the same or smaller than the streaming DMA mask. 126 */ 127 static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) 128 { 129 int rc = dma_set_mask(dev, mask); 130 if (rc == 0) 131 dma_set_coherent_mask(dev, mask); 132 return rc; 133 } 134 135 #if 1 136 #define dma_alloc_coherent(dev,size,addr,flags) pci_alloc_consistent((struct pci_dev *)(dev),size,addr) 137 #else 138 extern void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp); 32 139 #endif 33 34 140 #define dma_free_coherent(dev,size,ptr,addr) pci_free_consistent((struct pci_dev *)(dev),size,ptr,addr) 141 static inline bool dma_can_mmap(struct device *dev) 142 { 143 return false; 144 } 145 #define pci_set_consistent_dma_mask(p,x) pci_set_dma_mask(p,x) 146 #endif
Note:
See TracChangeset
for help on using the changeset viewer.