History

dma-mapping: remove the default map_resource implementation

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

Christoph Hellwig committed 7 years ago

Commit cfced781 parent f17b5f05 files · +25 −5Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/dma-mapping.h+7−5
@@ -208,6 +208,8 @@ dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, · 207 unmodified lines
208208 unsigned long attrs);
209209 int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
210210 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);
211213
212214 #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
213215 defined(CONFIG_SWIOTLB)
@@ -346,19 +348,19 @@ static inline dma_addr_t dma_map_resource(struct device *dev, · 132 unmodified lines
346348 unsigned long attrs)
347349 {
348350 const struct dma_map_ops *ops = get_dma_ops(dev);
349− dma_addr_t addr;
351+ dma_addr_t addr = DMA_MAPPING_ERROR;
350352
351353 BUG_ON(!valid_dma_direction(dir));
352354
353355 /* Don't allow RAM to be mapped */
354356 BUG_ON(pfn_valid(PHYS_PFN(phys_addr)));
355357
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)
358361 addr = ops->map_resource(dev, phys_addr, size, dir, attrs);
359362
360363 debug_dma_map_resource(dev, phys_addr, size, dir, addr);
361−
362364 return addr;
363365 }
364366
@@ -369,7 +371,7 @@ static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr, · 4 unmodified lines
369371 const struct dma_map_ops *ops = get_dma_ops(dev);
370372
371373 BUG_ON(!valid_dma_direction(dir));
372− if (ops && ops->unmap_resource)
374+ if (!dma_is_direct(ops) && ops->unmap_resource)
373375 ops->unmap_resource(dev, addr, size, dir, attrs);
374376 debug_dma_unmap_resource(dev, addr, size, dir);
375377 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t