|
39 | 39 | dma_debug_sg, |
40 | 40 | dma_debug_coherent, |
41 | 41 | dma_debug_resource, |
| 42 | + dma_debug_noncoherent, |
42 | 43 | }; |
43 | 44 |
|
44 | 45 | enum map_err_types { |
@@ -141,6 +142,7 @@ static const char *type2name[] = { |
141 | 142 | [dma_debug_sg] = "scatter-gather", |
142 | 143 | [dma_debug_coherent] = "coherent", |
143 | 144 | [dma_debug_resource] = "resource", |
| 145 | + [dma_debug_noncoherent] = "noncoherent", |
144 | 146 | }; |
145 | 147 |
|
146 | 148 | static const char *dir2name[] = { |
@@ -993,7 +995,8 @@ static void check_unmap(struct dma_debug_entry *ref) |
993 | 995 | "[mapped as %s] [unmapped as %s]\n", |
994 | 996 | ref->dev_addr, ref->size, |
995 | 997 | type2name[entry->type], type2name[ref->type]); |
996 | | - } else if (entry->type == dma_debug_coherent && |
| 998 | + } else if ((entry->type == dma_debug_coherent || |
| 999 | + entry->type == dma_debug_noncoherent) && |
997 | 1000 | ref->paddr != entry->paddr) { |
998 | 1001 | err_printk(ref->dev, entry, "device driver frees " |
999 | 1002 | "DMA memory with different CPU address " |
@@ -1581,6 +1584,49 @@ void debug_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, |
1581 | 1584 | } |
1582 | 1585 | } |
1583 | 1586 |
|
| 1587 | +void debug_dma_alloc_pages(struct device *dev, struct page *page, |
| 1588 | + size_t size, int direction, |
| 1589 | + dma_addr_t dma_addr, |
| 1590 | + unsigned long attrs) |
| 1591 | +{ |
| 1592 | + struct dma_debug_entry *entry; |
| 1593 | + |
| 1594 | + if (unlikely(dma_debug_disabled())) |
| 1595 | + return; |
| 1596 | + |
| 1597 | + entry = dma_entry_alloc(); |
| 1598 | + if (!entry) |
| 1599 | + return; |
| 1600 | + |
| 1601 | + entry->type = dma_debug_noncoherent; |
| 1602 | + entry->dev = dev; |
| 1603 | + entry->paddr = page_to_phys(page); |
| 1604 | + entry->size = size; |
| 1605 | + entry->dev_addr = dma_addr; |
| 1606 | + entry->direction = direction; |
| 1607 | + |
| 1608 | + add_dma_entry(entry, attrs); |
| 1609 | +} |
| 1610 | + |
| 1611 | +void debug_dma_free_pages(struct device *dev, struct page *page, |
| 1612 | + size_t size, int direction, |
| 1613 | + dma_addr_t dma_addr) |
| 1614 | +{ |
| 1615 | + struct dma_debug_entry ref = { |
| 1616 | + .type = dma_debug_noncoherent, |
| 1617 | + .dev = dev, |
| 1618 | + .paddr = page_to_phys(page), |
| 1619 | + .dev_addr = dma_addr, |
| 1620 | + .size = size, |
| 1621 | + .direction = direction, |
| 1622 | + }; |
| 1623 | + |
| 1624 | + if (unlikely(dma_debug_disabled())) |
| 1625 | + return; |
| 1626 | + |
| 1627 | + check_unmap(&ref); |
| 1628 | +} |
| 1629 | + |
1584 | 1630 | static int __init dma_debug_driver_setup(char *str) |
1585 | 1631 | { |
1586 | 1632 | int i; |
|
0 commit comments