From f5ad14f487f445134eb59b400519f17e42a93ee7 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Fri, 22 Mar 2013 15:04:49 -0700 Subject: [PATCH] --- yaml --- r: 361674 b: refs/heads/master c: 96e7d7a1e0fc7780b4c1981c787e42473aa91a95 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/lib/dma-debug.c | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 26e1856925d8..a6c59c5ee085 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8d640a51ec9e9cdefa680b67ad55f933eefc5923 +refs/heads/master: 96e7d7a1e0fc7780b4c1981c787e42473aa91a95 diff --git a/trunk/lib/dma-debug.c b/trunk/lib/dma-debug.c index d3e06a5e981e..d87a17a819d0 100644 --- a/trunk/lib/dma-debug.c +++ b/trunk/lib/dma-debug.c @@ -1085,13 +1085,27 @@ void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) ref.dev = dev; ref.dev_addr = dma_addr; bucket = get_hash_bucket(&ref, &flags); - entry = bucket_find_exact(bucket, &ref); - if (!entry) - goto out; + list_for_each_entry(entry, &bucket->list, list) { + if (!exact_match(&ref, entry)) + continue; + + /* + * The same physical address can be mapped multiple + * times. Without a hardware IOMMU this results in the + * same device addresses being put into the dma-debug + * hash multiple times too. This can result in false + * positives being reported. Therefore we implement a + * best-fit algorithm here which updates the first entry + * from the hash which fits the reference value and is + * not currently listed as being checked. + */ + if (entry->map_err_type == MAP_ERR_NOT_CHECKED) { + entry->map_err_type = MAP_ERR_CHECKED; + break; + } + } - entry->map_err_type = MAP_ERR_CHECKED; -out: put_hash_bucket(bucket, &flags); } EXPORT_SYMBOL(debug_dma_mapping_error);