diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-01-09 08:38:50 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-03-05 14:35:19 -0500 |
commit | 6bfd4498764d6201399849d2e80fda95db7742c0 (patch) | |
tree | 71675d02878324a82036e75d3bd0e0457a33e12b | |
parent | 972aa45ceaf65376f33aa75958fcaefc9e752fa4 (diff) |
dma-debug: add checking for [alloc|free]_coherent
Impact: add debug callbacks for dma_[alloc|free]_coherent
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
-rw-r--r-- | include/linux/dma-debug.h | 16 | ||||
-rw-r--r-- | lib/dma-debug.c | 45 |
2 files changed, 61 insertions, 0 deletions
diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h index ee9fdb328549..cb72dfd87326 100644 --- a/include/linux/dma-debug.h +++ b/include/linux/dma-debug.h | |||
@@ -43,6 +43,12 @@ extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, | |||
43 | extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, | 43 | extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, |
44 | int nelems, int dir); | 44 | int nelems, int dir); |
45 | 45 | ||
46 | extern void debug_dma_alloc_coherent(struct device *dev, size_t size, | ||
47 | dma_addr_t dma_addr, void *virt); | ||
48 | |||
49 | extern void debug_dma_free_coherent(struct device *dev, size_t size, | ||
50 | void *virt, dma_addr_t addr); | ||
51 | |||
46 | #else /* CONFIG_DMA_API_DEBUG */ | 52 | #else /* CONFIG_DMA_API_DEBUG */ |
47 | 53 | ||
48 | static inline void dma_debug_init(u32 num_entries) | 54 | static inline void dma_debug_init(u32 num_entries) |
@@ -73,6 +79,16 @@ static inline void debug_dma_unmap_sg(struct device *dev, | |||
73 | { | 79 | { |
74 | } | 80 | } |
75 | 81 | ||
82 | static inline void debug_dma_alloc_coherent(struct device *dev, size_t size, | ||
83 | dma_addr_t dma_addr, void *virt) | ||
84 | { | ||
85 | } | ||
86 | |||
87 | static inline void debug_dma_free_coherent(struct device *dev, size_t size, | ||
88 | void *virt, dma_addr_t addr) | ||
89 | { | ||
90 | } | ||
91 | |||
76 | #endif /* CONFIG_DMA_API_DEBUG */ | 92 | #endif /* CONFIG_DMA_API_DEBUG */ |
77 | 93 | ||
78 | #endif /* __DMA_DEBUG_H */ | 94 | #endif /* __DMA_DEBUG_H */ |
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 26e40e93e0f2..44af837f68ef 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
@@ -692,3 +692,48 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, | |||
692 | } | 692 | } |
693 | EXPORT_SYMBOL(debug_dma_unmap_sg); | 693 | EXPORT_SYMBOL(debug_dma_unmap_sg); |
694 | 694 | ||
695 | void debug_dma_alloc_coherent(struct device *dev, size_t size, | ||
696 | dma_addr_t dma_addr, void *virt) | ||
697 | { | ||
698 | struct dma_debug_entry *entry; | ||
699 | |||
700 | if (unlikely(global_disable)) | ||
701 | return; | ||
702 | |||
703 | if (unlikely(virt == NULL)) | ||
704 | return; | ||
705 | |||
706 | entry = dma_entry_alloc(); | ||
707 | if (!entry) | ||
708 | return; | ||
709 | |||
710 | entry->type = dma_debug_coherent; | ||
711 | entry->dev = dev; | ||
712 | entry->paddr = virt_to_phys(virt); | ||
713 | entry->size = size; | ||
714 | entry->dev_addr = dma_addr; | ||
715 | entry->direction = DMA_BIDIRECTIONAL; | ||
716 | |||
717 | add_dma_entry(entry); | ||
718 | } | ||
719 | EXPORT_SYMBOL(debug_dma_alloc_coherent); | ||
720 | |||
721 | void debug_dma_free_coherent(struct device *dev, size_t size, | ||
722 | void *virt, dma_addr_t addr) | ||
723 | { | ||
724 | struct dma_debug_entry ref = { | ||
725 | .type = dma_debug_coherent, | ||
726 | .dev = dev, | ||
727 | .paddr = virt_to_phys(virt), | ||
728 | .dev_addr = addr, | ||
729 | .size = size, | ||
730 | .direction = DMA_BIDIRECTIONAL, | ||
731 | }; | ||
732 | |||
733 | if (unlikely(global_disable)) | ||
734 | return; | ||
735 | |||
736 | check_unmap(&ref); | ||
737 | } | ||
738 | EXPORT_SYMBOL(debug_dma_free_coherent); | ||
739 | |||