@@ -120,114 +120,8 @@ struct page *dma_direct_alloc_pages(struct device *dev, size_t size,
120
120
void dma_direct_free_pages (struct device * dev , size_t size ,
121
121
struct page * page , dma_addr_t dma_addr ,
122
122
enum dma_data_direction dir );
123
- int dma_direct_get_sgtable (struct device * dev , struct sg_table * sgt ,
124
- void * cpu_addr , dma_addr_t dma_addr , size_t size ,
125
- unsigned long attrs );
126
- bool dma_direct_can_mmap (struct device * dev );
127
- int dma_direct_mmap (struct device * dev , struct vm_area_struct * vma ,
128
- void * cpu_addr , dma_addr_t dma_addr , size_t size ,
129
- unsigned long attrs );
130
123
int dma_direct_supported (struct device * dev , u64 mask );
131
- bool dma_direct_need_sync (struct device * dev , dma_addr_t dma_addr );
132
- int dma_direct_map_sg (struct device * dev , struct scatterlist * sgl , int nents ,
133
- enum dma_data_direction dir , unsigned long attrs );
134
124
dma_addr_t dma_direct_map_resource (struct device * dev , phys_addr_t paddr ,
135
125
size_t size , enum dma_data_direction dir , unsigned long attrs );
136
- size_t dma_direct_max_mapping_size (struct device * dev );
137
126
138
- #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE ) || \
139
- defined(CONFIG_SWIOTLB )
140
- void dma_direct_sync_sg_for_device (struct device * dev , struct scatterlist * sgl ,
141
- int nents , enum dma_data_direction dir );
142
- #else
143
- static inline void dma_direct_sync_sg_for_device (struct device * dev ,
144
- struct scatterlist * sgl , int nents , enum dma_data_direction dir )
145
- {
146
- }
147
- #endif
148
-
149
- #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU ) || \
150
- defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL ) || \
151
- defined(CONFIG_SWIOTLB )
152
- void dma_direct_unmap_sg (struct device * dev , struct scatterlist * sgl ,
153
- int nents , enum dma_data_direction dir , unsigned long attrs );
154
- void dma_direct_sync_sg_for_cpu (struct device * dev ,
155
- struct scatterlist * sgl , int nents , enum dma_data_direction dir );
156
- #else
157
- static inline void dma_direct_unmap_sg (struct device * dev ,
158
- struct scatterlist * sgl , int nents , enum dma_data_direction dir ,
159
- unsigned long attrs )
160
- {
161
- }
162
- static inline void dma_direct_sync_sg_for_cpu (struct device * dev ,
163
- struct scatterlist * sgl , int nents , enum dma_data_direction dir )
164
- {
165
- }
166
- #endif
167
-
168
- static inline void dma_direct_sync_single_for_device (struct device * dev ,
169
- dma_addr_t addr , size_t size , enum dma_data_direction dir )
170
- {
171
- phys_addr_t paddr = dma_to_phys (dev , addr );
172
-
173
- if (unlikely (is_swiotlb_buffer (paddr )))
174
- swiotlb_tbl_sync_single (dev , paddr , size , dir , SYNC_FOR_DEVICE );
175
-
176
- if (!dev_is_dma_coherent (dev ))
177
- arch_sync_dma_for_device (paddr , size , dir );
178
- }
179
-
180
- static inline void dma_direct_sync_single_for_cpu (struct device * dev ,
181
- dma_addr_t addr , size_t size , enum dma_data_direction dir )
182
- {
183
- phys_addr_t paddr = dma_to_phys (dev , addr );
184
-
185
- if (!dev_is_dma_coherent (dev )) {
186
- arch_sync_dma_for_cpu (paddr , size , dir );
187
- arch_sync_dma_for_cpu_all ();
188
- }
189
-
190
- if (unlikely (is_swiotlb_buffer (paddr )))
191
- swiotlb_tbl_sync_single (dev , paddr , size , dir , SYNC_FOR_CPU );
192
-
193
- if (dir == DMA_FROM_DEVICE )
194
- arch_dma_mark_clean (paddr , size );
195
- }
196
-
197
- static inline dma_addr_t dma_direct_map_page (struct device * dev ,
198
- struct page * page , unsigned long offset , size_t size ,
199
- enum dma_data_direction dir , unsigned long attrs )
200
- {
201
- phys_addr_t phys = page_to_phys (page ) + offset ;
202
- dma_addr_t dma_addr = phys_to_dma (dev , phys );
203
-
204
- if (unlikely (swiotlb_force == SWIOTLB_FORCE ))
205
- return swiotlb_map (dev , phys , size , dir , attrs );
206
-
207
- if (unlikely (!dma_capable (dev , dma_addr , size , true))) {
208
- if (swiotlb_force != SWIOTLB_NO_FORCE )
209
- return swiotlb_map (dev , phys , size , dir , attrs );
210
-
211
- dev_WARN_ONCE (dev , 1 ,
212
- "DMA addr %pad+%zu overflow (mask %llx, bus limit %llx).\n" ,
213
- & dma_addr , size , * dev -> dma_mask , dev -> bus_dma_limit );
214
- return DMA_MAPPING_ERROR ;
215
- }
216
-
217
- if (!dev_is_dma_coherent (dev ) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC ))
218
- arch_sync_dma_for_device (phys , size , dir );
219
- return dma_addr ;
220
- }
221
-
222
- static inline void dma_direct_unmap_page (struct device * dev , dma_addr_t addr ,
223
- size_t size , enum dma_data_direction dir , unsigned long attrs )
224
- {
225
- phys_addr_t phys = dma_to_phys (dev , addr );
226
-
227
- if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC ))
228
- dma_direct_sync_single_for_cpu (dev , addr , size , dir );
229
-
230
- if (unlikely (is_swiotlb_buffer (phys )))
231
- swiotlb_tbl_unmap_single (dev , phys , size , size , dir , attrs );
232
- }
233
127
#endif /* _LINUX_DMA_DIRECT_H */
0 commit comments