History

dma-mapping: implement dma_map_single_attrs using dma_map_page_attrs

And also switch the way we implement the unmap side around to stay consistent. This ensures dma-debug works again because it records which function we used for mapping to ensure it is also used for unmapping, and also reduces further code duplication. Last but not least this also officially allows calling dma_sync_single_* for mappings created using dma_map_page, which is perfectly fine given that the sync calls only take a dma_addr_t, but not a virtual address or struct page.

Christoph Hellwig committed 7 years ago

Commit 2e05ea51 parent 96d4f263 files · +32 −62Browse files

Showing the changes to kernel (1 of 3 files). Show all

Unified · Split

kernel/dma/debug.c+4−13
@@ -49,7 +49,6 @@ · 48 unmodified lines
4949
5050 enum {
5151 dma_debug_single,
52− dma_debug_page,
5352 dma_debug_sg,
5453 dma_debug_coherent,
5554 dma_debug_resource,
@@ -1300,8 +1299,7 @@ void debug_dma_map_single(struct device *dev, const void *addr, · 1244 unmodified lines
13001299 EXPORT_SYMBOL(debug_dma_map_single);
13011300
13021301 void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
1303− size_t size, int direction, dma_addr_t dma_addr,
1304− bool map_single)
1302+ size_t size, int direction, dma_addr_t dma_addr)
13051303 {
13061304 struct dma_debug_entry *entry;
13071305
@@ -1316,7 +1314,7 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset, · 8 unmodified lines
13161314 return;
13171315
13181316 entry->dev = dev;
1319− entry->type = dma_debug_page;
1317+ entry->type = dma_debug_single;
13201318 entry->pfn = page_to_pfn(page);
13211319 entry->offset = offset,
13221320 entry->dev_addr = dma_addr;
@@ -1324,9 +1322,6 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset, · 1 unmodified line
13241322 entry->direction = direction;
13251323 entry->map_err_type = MAP_ERR_NOT_CHECKED;
13261324
1327− if (map_single)
1328− entry->type = dma_debug_single;
1329−
13301325 check_for_stack(dev, page, offset);
13311326
13321327 if (!PageHighMem(page)) {
@@ -1378,10 +1373,10 @@ void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) · 45 unmodified lines
13781373 EXPORT_SYMBOL(debug_dma_mapping_error);
13791374
13801375 void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
1381− size_t size, int direction, bool map_single)
1376+ size_t size, int direction)
13821377 {
13831378 struct dma_debug_entry ref = {
1384− .type = dma_debug_page,
1379+ .type = dma_debug_single,
13851380 .dev = dev,
13861381 .dev_addr = addr,
13871382 .size = size,
@@ -1390,10 +1385,6 @@ void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, · 2 unmodified lines
13901385
13911386 if (unlikely(dma_debug_disabled()))
13921387 return;
1393−
1394− if (map_single)
1395− ref.type = dma_debug_single;
1396−
13971388 check_unmap(&ref);
13981389 }
13991390 EXPORT_SYMBOL(debug_dma_unmap_page);