aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/dma-mapping.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-01-03 06:29:28 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-01-06 17:31:11 -0500
commit24056f525051a9e186af28904b396320e18bf9a0 (patch)
treea8580f24820e21ad48333fce6b5f03be55edd561 /arch/arm/mm/dma-mapping.c
parent9eedd96301cad8ab58ee8c1e579677d0a75c2ba1 (diff)
ARM: DMA: add support for DMA debugging
Add ARM support for the DMA debug infrastructure, which allows the DMA API usage to be debugged. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/dma-mapping.c')
-rw-r--r--arch/arm/mm/dma-mapping.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 44e72108d7a7..85f9361f3e02 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -554,17 +554,20 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
554 struct scatterlist *s; 554 struct scatterlist *s;
555 int i, j; 555 int i, j;
556 556
557 BUG_ON(!valid_dma_direction(dir));
558
557 for_each_sg(sg, s, nents, i) { 559 for_each_sg(sg, s, nents, i) {
558 s->dma_address = dma_map_page(dev, sg_page(s), s->offset, 560 s->dma_address = __dma_map_page(dev, sg_page(s), s->offset,
559 s->length, dir); 561 s->length, dir);
560 if (dma_mapping_error(dev, s->dma_address)) 562 if (dma_mapping_error(dev, s->dma_address))
561 goto bad_mapping; 563 goto bad_mapping;
562 } 564 }
565 debug_dma_map_sg(dev, sg, nents, nents, dir);
563 return nents; 566 return nents;
564 567
565 bad_mapping: 568 bad_mapping:
566 for_each_sg(sg, s, i, j) 569 for_each_sg(sg, s, i, j)
567 dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir); 570 __dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
568 return 0; 571 return 0;
569} 572}
570EXPORT_SYMBOL(dma_map_sg); 573EXPORT_SYMBOL(dma_map_sg);
@@ -585,8 +588,10 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
585 struct scatterlist *s; 588 struct scatterlist *s;
586 int i; 589 int i;
587 590
591 debug_dma_unmap_sg(dev, sg, nents, dir);
592
588 for_each_sg(sg, s, nents, i) 593 for_each_sg(sg, s, nents, i)
589 dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir); 594 __dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
590} 595}
591EXPORT_SYMBOL(dma_unmap_sg); 596EXPORT_SYMBOL(dma_unmap_sg);
592 597
@@ -611,6 +616,8 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
611 __dma_page_dev_to_cpu(sg_page(s), s->offset, 616 __dma_page_dev_to_cpu(sg_page(s), s->offset,
612 s->length, dir); 617 s->length, dir);
613 } 618 }
619
620 debug_dma_sync_sg_for_cpu(dev, sg, nents, dir);
614} 621}
615EXPORT_SYMBOL(dma_sync_sg_for_cpu); 622EXPORT_SYMBOL(dma_sync_sg_for_cpu);
616 623
@@ -635,5 +642,16 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
635 __dma_page_cpu_to_dev(sg_page(s), s->offset, 642 __dma_page_cpu_to_dev(sg_page(s), s->offset,
636 s->length, dir); 643 s->length, dir);
637 } 644 }
645
646 debug_dma_sync_sg_for_device(dev, sg, nents, dir);
638} 647}
639EXPORT_SYMBOL(dma_sync_sg_for_device); 648EXPORT_SYMBOL(dma_sync_sg_for_device);
649
650#define PREALLOC_DMA_DEBUG_ENTRIES 4096
651
652static int __init dma_debug_do_init(void)
653{
654 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
655 return 0;
656}
657fs_initcall(dma_debug_do_init);