Instead provide a proper implementation in the direct mapping code, and also wire it up for arm and powerpc, leaving an error return for all the IOMMU or virtual mapping instances for which we'd have to wire up an actual implementation
Showing the changes to include/linux (1 of 5 files). Show all
Unified · Split
| @@ -208,6 +208,8 @@ dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, · 207 unmodified lines | ||
| 208 | 208 | unsigned long attrs); |
| 209 | 209 | int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, |
| 210 | 210 | enum dma_data_direction dir, unsigned long attrs); |
| 211 | +dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr, | |
| 212 | + size_t size, enum dma_data_direction dir, unsigned long attrs); | |
| 211 | 213 | |
| 212 | 214 | #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ |
| 213 | 215 | defined(CONFIG_SWIOTLB) |
| @@ -346,19 +348,19 @@ static inline dma_addr_t dma_map_resource(struct device *dev, · 132 unmodified lines | ||
| 346 | 348 | unsigned long attrs) |
| 347 | 349 | { |
| 348 | 350 | const struct dma_map_ops *ops = get_dma_ops(dev); |
| 349 | − dma_addr_t addr; | |
| 351 | + dma_addr_t addr = DMA_MAPPING_ERROR; | |
| 350 | 352 | |
| 351 | 353 | BUG_ON(!valid_dma_direction(dir)); |
| 352 | 354 | |
| 353 | 355 | /* Don't allow RAM to be mapped */ |
| 354 | 356 | BUG_ON(pfn_valid(PHYS_PFN(phys_addr))); |
| 355 | 357 | |
| 356 | − addr = phys_addr; | |
| 357 | − if (ops && ops->map_resource) | |
| 358 | + if (dma_is_direct(ops)) | |
| 359 | + addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs); | |
| 360 | + else if (ops->map_resource) | |
| 358 | 361 | addr = ops->map_resource(dev, phys_addr, size, dir, attrs); |
| 359 | 362 | |
| 360 | 363 | debug_dma_map_resource(dev, phys_addr, size, dir, addr); |
| 361 | − | |
| 362 | 364 | return addr; |
| 363 | 365 | } |
| 364 | 366 | |
| @@ -369,7 +371,7 @@ static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr, · 4 unmodified lines | ||
| 369 | 371 | const struct dma_map_ops *ops = get_dma_ops(dev); |
| 370 | 372 | |
| 371 | 373 | BUG_ON(!valid_dma_direction(dir)); |
| 372 | − if (ops && ops->unmap_resource) | |
| 374 | + if (!dma_is_direct(ops) && ops->unmap_resource) | |
| 373 | 375 | ops->unmap_resource(dev, addr, size, dir, attrs); |
| 374 | 376 | debug_dma_unmap_resource(dev, addr, size, dir); |
| 375 | 377 | } |