aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-01-30 14:48:44 -0500
committerVinod Koul <vkoul@kernel.org>2019-02-04 04:04:22 -0500
commit6454368a804c4955ccd116236037536f81e5b1f1 (patch)
treede4d7bb2475c62f66a10ddfd403c78e4d4607902
parent6d66c8d1a034eeb1bbf4a0a8dd99fa6f33a8db5d (diff)
dmaengine: dmatest: Abort test in case of mapping error
In case of mapping error the DMA addresses are invalid and continuing will screw system memory or potentially something else. [ 222.480310] dmatest: dma0chan7-copy0: summary 1 tests, 3 failures 6 iops 349 KB/s (0) ... [ 240.912725] check: Corrupted low memory at 00000000c7c75ac9 (2940 phys) = 5656000000000000 [ 240.921998] check: Corrupted low memory at 000000005715a1cd (2948 phys) = 279f2aca5595ab2b [ 240.931280] check: Corrupted low memory at 000000002f4024c0 (2950 phys) = 5e5624f349e793cf ... Abort any test if mapping failed. Fixes: 4076e755dbec ("dmatest: convert to dmaengine_unmap_data") Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r--drivers/dma/dmatest.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 2eea4ef72915..6511928b4cdf 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -711,11 +711,9 @@ static int dmatest_func(void *data)
711 srcs[i] = um->addr[i] + src_off; 711 srcs[i] = um->addr[i] + src_off;
712 ret = dma_mapping_error(dev->dev, um->addr[i]); 712 ret = dma_mapping_error(dev->dev, um->addr[i]);
713 if (ret) { 713 if (ret) {
714 dmaengine_unmap_put(um);
715 result("src mapping error", total_tests, 714 result("src mapping error", total_tests,
716 src_off, dst_off, len, ret); 715 src_off, dst_off, len, ret);
717 failed_tests++; 716 goto error_unmap_continue;
718 continue;
719 } 717 }
720 um->to_cnt++; 718 um->to_cnt++;
721 } 719 }
@@ -730,11 +728,9 @@ static int dmatest_func(void *data)
730 DMA_BIDIRECTIONAL); 728 DMA_BIDIRECTIONAL);
731 ret = dma_mapping_error(dev->dev, dsts[i]); 729 ret = dma_mapping_error(dev->dev, dsts[i]);
732 if (ret) { 730 if (ret) {
733 dmaengine_unmap_put(um);
734 result("dst mapping error", total_tests, 731 result("dst mapping error", total_tests,
735 src_off, dst_off, len, ret); 732 src_off, dst_off, len, ret);
736 failed_tests++; 733 goto error_unmap_continue;
737 continue;
738 } 734 }
739 um->bidi_cnt++; 735 um->bidi_cnt++;
740 } 736 }
@@ -762,12 +758,10 @@ static int dmatest_func(void *data)
762 } 758 }
763 759
764 if (!tx) { 760 if (!tx) {
765 dmaengine_unmap_put(um);
766 result("prep error", total_tests, src_off, 761 result("prep error", total_tests, src_off,
767 dst_off, len, ret); 762 dst_off, len, ret);
768 msleep(100); 763 msleep(100);
769 failed_tests++; 764 goto error_unmap_continue;
770 continue;
771 } 765 }
772 766
773 done->done = false; 767 done->done = false;
@@ -776,12 +770,10 @@ static int dmatest_func(void *data)
776 cookie = tx->tx_submit(tx); 770 cookie = tx->tx_submit(tx);
777 771
778 if (dma_submit_error(cookie)) { 772 if (dma_submit_error(cookie)) {
779 dmaengine_unmap_put(um);
780 result("submit error", total_tests, src_off, 773 result("submit error", total_tests, src_off,
781 dst_off, len, ret); 774 dst_off, len, ret);
782 msleep(100); 775 msleep(100);
783 failed_tests++; 776 goto error_unmap_continue;
784 continue;
785 } 777 }
786 dma_async_issue_pending(chan); 778 dma_async_issue_pending(chan);
787 779
@@ -790,22 +782,20 @@ static int dmatest_func(void *data)
790 782
791 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL); 783 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
792 784
793 dmaengine_unmap_put(um);
794
795 if (!done->done) { 785 if (!done->done) {
796 result("test timed out", total_tests, src_off, dst_off, 786 result("test timed out", total_tests, src_off, dst_off,
797 len, 0); 787 len, 0);
798 failed_tests++; 788 goto error_unmap_continue;
799 continue;
800 } else if (status != DMA_COMPLETE) { 789 } else if (status != DMA_COMPLETE) {
801 result(status == DMA_ERROR ? 790 result(status == DMA_ERROR ?
802 "completion error status" : 791 "completion error status" :
803 "completion busy status", total_tests, src_off, 792 "completion busy status", total_tests, src_off,
804 dst_off, len, ret); 793 dst_off, len, ret);
805 failed_tests++; 794 goto error_unmap_continue;
806 continue;
807 } 795 }
808 796
797 dmaengine_unmap_put(um);
798
809 if (params->noverify) { 799 if (params->noverify) {
810 verbose_result("test passed", total_tests, src_off, 800 verbose_result("test passed", total_tests, src_off,
811 dst_off, len, 0); 801 dst_off, len, 0);
@@ -846,6 +836,12 @@ static int dmatest_func(void *data)
846 verbose_result("test passed", total_tests, src_off, 836 verbose_result("test passed", total_tests, src_off,
847 dst_off, len, 0); 837 dst_off, len, 0);
848 } 838 }
839
840 continue;
841
842error_unmap_continue:
843 dmaengine_unmap_put(um);
844 failed_tests++;
849 } 845 }
850 ktime = ktime_sub(ktime_get(), ktime); 846 ktime = ktime_sub(ktime_get(), ktime);
851 ktime = ktime_sub(ktime, comparetime); 847 ktime = ktime_sub(ktime, comparetime);