aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dma-debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dma-debug.c')
-rw-r--r--lib/dma-debug.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index c38083871f11..2defd1308b04 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -463,7 +463,7 @@ static int active_pfn_set_overlap(unsigned long pfn, int overlap)
463 int i; 463 int i;
464 464
465 if (overlap > ACTIVE_PFN_MAX_OVERLAP || overlap < 0) 465 if (overlap > ACTIVE_PFN_MAX_OVERLAP || overlap < 0)
466 return 0; 466 return overlap;
467 467
468 for (i = RADIX_TREE_MAX_TAGS - 1; i >= 0; i--) 468 for (i = RADIX_TREE_MAX_TAGS - 1; i >= 0; i--)
469 if (overlap & 1 << i) 469 if (overlap & 1 << i)
@@ -486,7 +486,7 @@ static void active_pfn_inc_overlap(unsigned long pfn)
486 * debug_dma_assert_idle() as the pfn may be marked idle 486 * debug_dma_assert_idle() as the pfn may be marked idle
487 * prematurely. 487 * prematurely.
488 */ 488 */
489 WARN_ONCE(overlap == 0, 489 WARN_ONCE(overlap > ACTIVE_PFN_MAX_OVERLAP,
490 "DMA-API: exceeded %d overlapping mappings of pfn %lx\n", 490 "DMA-API: exceeded %d overlapping mappings of pfn %lx\n",
491 ACTIVE_PFN_MAX_OVERLAP, pfn); 491 ACTIVE_PFN_MAX_OVERLAP, pfn);
492} 492}
@@ -517,7 +517,11 @@ static void active_pfn_remove(struct dma_debug_entry *entry)
517 unsigned long flags; 517 unsigned long flags;
518 518
519 spin_lock_irqsave(&radix_lock, flags); 519 spin_lock_irqsave(&radix_lock, flags);
520 if (active_pfn_dec_overlap(entry->pfn) == 0) 520 /* since we are counting overlaps the final put of the
521 * entry->pfn will occur when the overlap count is 0.
522 * active_pfn_dec_overlap() returns -1 in that case
523 */
524 if (active_pfn_dec_overlap(entry->pfn) < 0)
521 radix_tree_delete(&dma_active_pfn, entry->pfn); 525 radix_tree_delete(&dma_active_pfn, entry->pfn);
522 spin_unlock_irqrestore(&radix_lock, flags); 526 spin_unlock_irqrestore(&radix_lock, flags);
523} 527}