aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dma-debug.c
diff options
context:
space:
mode:
authorShuah Khan <shuah.khan@hp.com>2012-11-03 19:00:07 -0400
committerJoerg Roedel <joro@8bytes.org>2012-11-17 07:06:41 -0500
commitbfe0fb0f1a570ae72680d6d48655c98d1f4733f5 (patch)
tree8da2d888a5c38bcc4389e0fbd7cf9bf624ca59c2 /lib/dma-debug.c
parent8d7f62e6a7aa0bfd7163d3c4a5fb59280f6a6eb5 (diff)
dma-debug: fix to not have dependency on get_dma_ops() interface
dma-debug depends on get_dma_ops() interface. Several architectures do not define dma_ops and get_dma_ops(). When dma debug interfaces are used on an architecture (e.g: c6x) that doesn't define get_dmap_ops(), compilation fails. Changing dma-debug to call dma_mapping_error() instead of defining its own that calls get_dma_ops(), such that the internal use of dma_mapping_error() doesn't interfere with the debug_dma_mapping_error() interface's mapping error checks. Moving dma_mapping_error() checks in check_unmap() under the dma debug entry not found is sufficient to fix the problem. Reference: https://lkml.org/lkml/2012/10/26/367 Signed-off-by: Shuah Khan <shuah.khan@hp.com> Reported-by: Mark Salter <msalter@redhat.com> Signed-off-by: Joerg Roedel <joro@8bytes.org>
Diffstat (limited to 'lib/dma-debug.c')
-rw-r--r--lib/dma-debug.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 59f4a1a8187d..5e396accd3d0 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -852,37 +852,22 @@ static __init int dma_debug_entries_cmdline(char *str)
852__setup("dma_debug=", dma_debug_cmdline); 852__setup("dma_debug=", dma_debug_cmdline);
853__setup("dma_debug_entries=", dma_debug_entries_cmdline); 853__setup("dma_debug_entries=", dma_debug_entries_cmdline);
854 854
855/* Calling dma_mapping_error() from dma-debug api will result in calling
856 debug_dma_mapping_error() - need internal mapping error routine to
857 avoid debug checks */
858#ifndef DMA_ERROR_CODE
859#define DMA_ERROR_CODE 0
860#endif
861static inline int has_mapping_error(struct device *dev, dma_addr_t dma_addr)
862{
863 const struct dma_map_ops *ops = get_dma_ops(dev);
864 if (ops->mapping_error)
865 return ops->mapping_error(dev, dma_addr);
866
867 return (dma_addr == DMA_ERROR_CODE);
868}
869
870static void check_unmap(struct dma_debug_entry *ref) 855static void check_unmap(struct dma_debug_entry *ref)
871{ 856{
872 struct dma_debug_entry *entry; 857 struct dma_debug_entry *entry;
873 struct hash_bucket *bucket; 858 struct hash_bucket *bucket;
874 unsigned long flags; 859 unsigned long flags;
875 860
876 if (unlikely(has_mapping_error(ref->dev, ref->dev_addr))) {
877 err_printk(ref->dev, NULL, "DMA-API: device driver tries "
878 "to free an invalid DMA memory address\n");
879 return;
880 }
881
882 bucket = get_hash_bucket(ref, &flags); 861 bucket = get_hash_bucket(ref, &flags);
883 entry = bucket_find_exact(bucket, ref); 862 entry = bucket_find_exact(bucket, ref);
884 863
885 if (!entry) { 864 if (!entry) {
865 if (dma_mapping_error(ref->dev, ref->dev_addr)) {
866 err_printk(ref->dev, NULL,
867 "DMA-API: device driver tries "
868 "to free an invalid DMA memory address\n");
869 return;
870 }
886 err_printk(ref->dev, NULL, "DMA-API: device driver tries " 871 err_printk(ref->dev, NULL, "DMA-API: device driver tries "
887 "to free DMA memory it has not allocated " 872 "to free DMA memory it has not allocated "
888 "[device address=0x%016llx] [size=%llu bytes]\n", 873 "[device address=0x%016llx] [size=%llu bytes]\n",
@@ -1055,7 +1040,7 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
1055 if (unlikely(global_disable)) 1040 if (unlikely(global_disable))
1056 return; 1041 return;
1057 1042
1058 if (unlikely(has_mapping_error(dev, dma_addr))) 1043 if (dma_mapping_error(dev, dma_addr))
1059 return; 1044 return;
1060 1045
1061 entry = dma_entry_alloc(); 1046 entry = dma_entry_alloc();