summaryrefslogtreecommitdiffstats
path: root/lib/dma-debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dma-debug.c')
-rw-r--r--lib/dma-debug.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index ea4cc3dde4f1..1b34d210452c 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -1495,14 +1495,22 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
1495 if (!entry) 1495 if (!entry)
1496 return; 1496 return;
1497 1497
1498 /* handle vmalloc and linear addresses */
1499 if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
1500 return;
1501
1498 entry->type = dma_debug_coherent; 1502 entry->type = dma_debug_coherent;
1499 entry->dev = dev; 1503 entry->dev = dev;
1500 entry->pfn = page_to_pfn(virt_to_page(virt));
1501 entry->offset = offset_in_page(virt); 1504 entry->offset = offset_in_page(virt);
1502 entry->size = size; 1505 entry->size = size;
1503 entry->dev_addr = dma_addr; 1506 entry->dev_addr = dma_addr;
1504 entry->direction = DMA_BIDIRECTIONAL; 1507 entry->direction = DMA_BIDIRECTIONAL;
1505 1508
1509 if (is_vmalloc_addr(virt))
1510 entry->pfn = vmalloc_to_pfn(virt);
1511 else
1512 entry->pfn = page_to_pfn(virt_to_page(virt));
1513
1506 add_dma_entry(entry); 1514 add_dma_entry(entry);
1507} 1515}
1508EXPORT_SYMBOL(debug_dma_alloc_coherent); 1516EXPORT_SYMBOL(debug_dma_alloc_coherent);
@@ -1513,13 +1521,21 @@ void debug_dma_free_coherent(struct device *dev, size_t size,
1513 struct dma_debug_entry ref = { 1521 struct dma_debug_entry ref = {
1514 .type = dma_debug_coherent, 1522 .type = dma_debug_coherent,
1515 .dev = dev, 1523 .dev = dev,
1516 .pfn = page_to_pfn(virt_to_page(virt)),
1517 .offset = offset_in_page(virt), 1524 .offset = offset_in_page(virt),
1518 .dev_addr = addr, 1525 .dev_addr = addr,
1519 .size = size, 1526 .size = size,
1520 .direction = DMA_BIDIRECTIONAL, 1527 .direction = DMA_BIDIRECTIONAL,
1521 }; 1528 };
1522 1529
1530 /* handle vmalloc and linear addresses */
1531 if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
1532 return;
1533
1534 if (is_vmalloc_addr(virt))
1535 ref.pfn = vmalloc_to_pfn(virt);
1536 else
1537 ref.pfn = page_to_pfn(virt_to_page(virt));
1538
1523 if (unlikely(dma_debug_disabled())) 1539 if (unlikely(dma_debug_disabled()))
1524 return; 1540 return;
1525 1541