@@ -734,31 +734,20 @@ static bool filter(struct dma_chan *chan, void *param)
734
734
return true;
735
735
}
736
736
737
- static int run_threaded_test (struct dmatest_info * info )
737
+ static void request_channels (struct dmatest_info * info ,
738
+ enum dma_transaction_type type )
738
739
{
739
740
dma_cap_mask_t mask ;
740
- struct dma_chan * chan ;
741
- struct dmatest_params * params = & info -> params ;
742
- int err = 0 ;
743
-
744
- /* Copy test parameters */
745
- params -> buf_size = test_buf_size ;
746
- strlcpy (params -> channel , strim (test_channel ), sizeof (params -> channel ));
747
- strlcpy (params -> device , strim (test_device ), sizeof (params -> device ));
748
- params -> threads_per_chan = threads_per_chan ;
749
- params -> max_channels = max_channels ;
750
- params -> iterations = iterations ;
751
- params -> xor_sources = xor_sources ;
752
- params -> pq_sources = pq_sources ;
753
- params -> timeout = timeout ;
754
741
755
742
dma_cap_zero (mask );
756
- dma_cap_set (DMA_MEMCPY , mask );
743
+ dma_cap_set (type , mask );
757
744
for (;;) {
745
+ struct dmatest_params * params = & info -> params ;
746
+ struct dma_chan * chan ;
747
+
758
748
chan = dma_request_channel (mask , filter , params );
759
749
if (chan ) {
760
- err = dmatest_add_channel (info , chan );
761
- if (err ) {
750
+ if (dmatest_add_channel (info , chan )) {
762
751
dma_release_channel (chan );
763
752
break ; /* add_channel failed, punt */
764
753
}
@@ -768,9 +757,27 @@ static int run_threaded_test(struct dmatest_info *info)
768
757
info -> nr_channels >= params -> max_channels )
769
758
break ; /* we have all we need */
770
759
}
771
- return err ;
772
760
}
773
761
762
+ static void run_threaded_test (struct dmatest_info * info )
763
+ {
764
+ struct dmatest_params * params = & info -> params ;
765
+
766
+ /* Copy test parameters */
767
+ params -> buf_size = test_buf_size ;
768
+ strlcpy (params -> channel , strim (test_channel ), sizeof (params -> channel ));
769
+ strlcpy (params -> device , strim (test_device ), sizeof (params -> device ));
770
+ params -> threads_per_chan = threads_per_chan ;
771
+ params -> max_channels = max_channels ;
772
+ params -> iterations = iterations ;
773
+ params -> xor_sources = xor_sources ;
774
+ params -> pq_sources = pq_sources ;
775
+ params -> timeout = timeout ;
776
+
777
+ request_channels (info , DMA_MEMCPY );
778
+ request_channels (info , DMA_XOR );
779
+ request_channels (info , DMA_PQ );
780
+ }
774
781
775
782
static void stop_threaded_test (struct dmatest_info * info )
776
783
{
@@ -788,19 +795,19 @@ static void stop_threaded_test(struct dmatest_info *info)
788
795
info -> nr_channels = 0 ;
789
796
}
790
797
791
- static int restart_threaded_test (struct dmatest_info * info , bool run )
798
+ static void restart_threaded_test (struct dmatest_info * info , bool run )
792
799
{
793
800
/* we might be called early to set run=, defer running until all
794
801
* parameters have been evaluated
795
802
*/
796
803
if (!info -> did_init )
797
- return 0 ;
804
+ return ;
798
805
799
806
/* Stop any running test first */
800
807
stop_threaded_test (info );
801
808
802
809
/* Run test with new parameters */
803
- return run_threaded_test (info );
810
+ run_threaded_test (info );
804
811
}
805
812
806
813
static bool is_threaded_test_run (struct dmatest_info * info )
@@ -850,7 +857,7 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
850
857
if (is_threaded_test_run (info ))
851
858
ret = - EBUSY ;
852
859
else if (dmatest_run )
853
- ret = restart_threaded_test (info , dmatest_run );
860
+ restart_threaded_test (info , dmatest_run );
854
861
855
862
mutex_unlock (& info -> lock );
856
863
@@ -860,11 +867,10 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
860
867
static int __init dmatest_init (void )
861
868
{
862
869
struct dmatest_info * info = & test_info ;
863
- int ret = 0 ;
864
870
865
871
if (dmatest_run ) {
866
872
mutex_lock (& info -> lock );
867
- ret = run_threaded_test (info );
873
+ run_threaded_test (info );
868
874
mutex_unlock (& info -> lock );
869
875
}
870
876
@@ -873,7 +879,7 @@ static int __init dmatest_init(void)
873
879
*/
874
880
info -> did_init = true;
875
881
876
- return ret ;
882
+ return 0 ;
877
883
}
878
884
/* when compiled-in wait for drivers to load first */
879
885
late_initcall (dmatest_init );
0 commit comments