@@ -97,7 +97,7 @@ struct dmatest_chan {
9797};
9898
9999/**
100- * struct dmatest_info - test information .
100+ * struct dmatest_params - test parameters .
101101 * @buf_size: size of the memcpy test buffer
102102 * @channel: bus ID of the channel to test
103103 * @device: bus ID of the DMA Engine to test
@@ -108,8 +108,7 @@ struct dmatest_chan {
108108 * @pq_sources: number of p+q source buffers
109109 * @timeout: transfer timeout in msec, -1 for infinite timeout
110110 */
111- struct dmatest_info {
112- /* Test parameters */
111+ struct dmatest_params {
113112 unsigned int buf_size ;
114113 char channel [20 ];
115114 char device [20 ];
@@ -119,6 +118,15 @@ struct dmatest_info {
119118 unsigned int xor_sources ;
120119 unsigned int pq_sources ;
121120 int timeout ;
121+ };
122+
123+ /**
124+ * struct dmatest_info - test information.
125+ * @params: test parameters
126+ */
127+ struct dmatest_info {
128+ /* Test parameters */
129+ struct dmatest_params params ;
122130
123131 /* Internal state */
124132 struct list_head channels ;
@@ -127,20 +135,20 @@ struct dmatest_info {
127135
128136static struct dmatest_info test_info ;
129137
130- static bool dmatest_match_channel (struct dmatest_info * info ,
138+ static bool dmatest_match_channel (struct dmatest_params * params ,
131139 struct dma_chan * chan )
132140{
133- if (info -> channel [0 ] == '\0' )
141+ if (params -> channel [0 ] == '\0' )
134142 return true;
135- return strcmp (dma_chan_name (chan ), info -> channel ) == 0 ;
143+ return strcmp (dma_chan_name (chan ), params -> channel ) == 0 ;
136144}
137145
138- static bool dmatest_match_device (struct dmatest_info * info ,
146+ static bool dmatest_match_device (struct dmatest_params * params ,
139147 struct dma_device * device )
140148{
141- if (info -> device [0 ] == '\0' )
149+ if (params -> device [0 ] == '\0' )
142150 return true;
143- return strcmp (dev_name (device -> dev ), info -> device ) == 0 ;
151+ return strcmp (dev_name (device -> dev ), params -> device ) == 0 ;
144152}
145153
146154static unsigned long dmatest_random (void )
@@ -300,6 +308,7 @@ static int dmatest_func(void *data)
300308 struct dmatest_thread * thread = data ;
301309 struct dmatest_done done = { .wait = & done_wait };
302310 struct dmatest_info * info ;
311+ struct dmatest_params * params ;
303312 struct dma_chan * chan ;
304313 struct dma_device * dev ;
305314 const char * thread_name ;
@@ -323,20 +332,21 @@ static int dmatest_func(void *data)
323332
324333 smp_rmb ();
325334 info = thread -> info ;
335+ params = & info -> params ;
326336 chan = thread -> chan ;
327337 dev = chan -> device ;
328338 if (thread -> type == DMA_MEMCPY )
329339 src_cnt = dst_cnt = 1 ;
330340 else if (thread -> type == DMA_XOR ) {
331341 /* force odd to ensure dst = src */
332- src_cnt = min_odd (info -> xor_sources | 1 , dev -> max_xor );
342+ src_cnt = min_odd (params -> xor_sources | 1 , dev -> max_xor );
333343 dst_cnt = 1 ;
334344 } else if (thread -> type == DMA_PQ ) {
335345 /* force odd to ensure dst = src */
336- src_cnt = min_odd (info -> pq_sources | 1 , dma_maxpq (dev , 0 ));
346+ src_cnt = min_odd (params -> pq_sources | 1 , dma_maxpq (dev , 0 ));
337347 dst_cnt = 2 ;
338348
339- pq_coefs = kmalloc (info -> pq_sources + 1 , GFP_KERNEL );
349+ pq_coefs = kmalloc (params -> pq_sources + 1 , GFP_KERNEL );
340350 if (!pq_coefs )
341351 goto err_thread_type ;
342352
@@ -349,7 +359,7 @@ static int dmatest_func(void *data)
349359 if (!thread -> srcs )
350360 goto err_srcs ;
351361 for (i = 0 ; i < src_cnt ; i ++ ) {
352- thread -> srcs [i ] = kmalloc (info -> buf_size , GFP_KERNEL );
362+ thread -> srcs [i ] = kmalloc (params -> buf_size , GFP_KERNEL );
353363 if (!thread -> srcs [i ])
354364 goto err_srcbuf ;
355365 }
@@ -359,7 +369,7 @@ static int dmatest_func(void *data)
359369 if (!thread -> dsts )
360370 goto err_dsts ;
361371 for (i = 0 ; i < dst_cnt ; i ++ ) {
362- thread -> dsts [i ] = kmalloc (info -> buf_size , GFP_KERNEL );
372+ thread -> dsts [i ] = kmalloc (params -> buf_size , GFP_KERNEL );
363373 if (!thread -> dsts [i ])
364374 goto err_dstbuf ;
365375 }
@@ -375,7 +385,7 @@ static int dmatest_func(void *data)
375385 | DMA_COMPL_SKIP_DEST_UNMAP | DMA_COMPL_SRC_UNMAP_SINGLE ;
376386
377387 while (!kthread_should_stop ()
378- && !(info -> iterations && total_tests >= info -> iterations )) {
388+ && !(params -> iterations && total_tests >= params -> iterations )) {
379389 struct dma_async_tx_descriptor * tx = NULL ;
380390 dma_addr_t dma_srcs [src_cnt ];
381391 dma_addr_t dma_dsts [dst_cnt ];
@@ -391,24 +401,24 @@ static int dmatest_func(void *data)
391401 else if (thread -> type == DMA_PQ )
392402 align = dev -> pq_align ;
393403
394- if (1 << align > info -> buf_size ) {
404+ if (1 << align > params -> buf_size ) {
395405 pr_err ("%u-byte buffer too small for %d-byte alignment\n" ,
396- info -> buf_size , 1 << align );
406+ params -> buf_size , 1 << align );
397407 break ;
398408 }
399409
400- len = dmatest_random () % info -> buf_size + 1 ;
410+ len = dmatest_random () % params -> buf_size + 1 ;
401411 len = (len >> align ) << align ;
402412 if (!len )
403413 len = 1 << align ;
404- src_off = dmatest_random () % (info -> buf_size - len + 1 );
405- dst_off = dmatest_random () % (info -> buf_size - len + 1 );
414+ src_off = dmatest_random () % (params -> buf_size - len + 1 );
415+ dst_off = dmatest_random () % (params -> buf_size - len + 1 );
406416
407417 src_off = (src_off >> align ) << align ;
408418 dst_off = (dst_off >> align ) << align ;
409419
410- dmatest_init_srcs (thread -> srcs , src_off , len , info -> buf_size );
411- dmatest_init_dsts (thread -> dsts , dst_off , len , info -> buf_size );
420+ dmatest_init_srcs (thread -> srcs , src_off , len , params -> buf_size );
421+ dmatest_init_dsts (thread -> dsts , dst_off , len , params -> buf_size );
412422
413423 for (i = 0 ; i < src_cnt ; i ++ ) {
414424 u8 * buf = thread -> srcs [i ] + src_off ;
@@ -429,16 +439,17 @@ static int dmatest_func(void *data)
429439 /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
430440 for (i = 0 ; i < dst_cnt ; i ++ ) {
431441 dma_dsts [i ] = dma_map_single (dev -> dev , thread -> dsts [i ],
432- info -> buf_size ,
442+ params -> buf_size ,
433443 DMA_BIDIRECTIONAL );
434444 ret = dma_mapping_error (dev -> dev , dma_dsts [i ]);
435445 if (ret ) {
436446 unmap_src (dev -> dev , dma_srcs , len , src_cnt );
437- unmap_dst (dev -> dev , dma_dsts , info -> buf_size , i );
447+ unmap_dst (dev -> dev , dma_dsts , params -> buf_size ,
448+ i );
438449 pr_warn ("%s: #%u: mapping error %d with "
439450 "dst_off=0x%x len=0x%x\n" ,
440451 thread_name , total_tests - 1 , ret ,
441- dst_off , info -> buf_size );
452+ dst_off , params -> buf_size );
442453 failed_tests ++ ;
443454 continue ;
444455 }
@@ -466,7 +477,8 @@ static int dmatest_func(void *data)
466477
467478 if (!tx ) {
468479 unmap_src (dev -> dev , dma_srcs , len , src_cnt );
469- unmap_dst (dev -> dev , dma_dsts , info -> buf_size , dst_cnt );
480+ unmap_dst (dev -> dev , dma_dsts , params -> buf_size ,
481+ dst_cnt );
470482 pr_warning ("%s: #%u: prep error with src_off=0x%x "
471483 "dst_off=0x%x len=0x%x\n" ,
472484 thread_name , total_tests - 1 ,
@@ -494,7 +506,7 @@ static int dmatest_func(void *data)
494506
495507 wait_event_freezable_timeout (done_wait ,
496508 done .done || kthread_should_stop (),
497- msecs_to_jiffies (info -> timeout ));
509+ msecs_to_jiffies (params -> timeout ));
498510
499511 status = dma_async_is_tx_complete (chan , cookie , NULL , NULL );
500512
@@ -521,7 +533,7 @@ static int dmatest_func(void *data)
521533 }
522534
523535 /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */
524- unmap_dst (dev -> dev , dma_dsts , info -> buf_size , dst_cnt );
536+ unmap_dst (dev -> dev , dma_dsts , params -> buf_size , dst_cnt );
525537
526538 error_count = 0 ;
527539
@@ -532,7 +544,7 @@ static int dmatest_func(void *data)
532544 src_off + len , src_off ,
533545 PATTERN_SRC | PATTERN_COPY , true);
534546 error_count += dmatest_verify (thread -> srcs , src_off + len ,
535- info -> buf_size , src_off + len ,
547+ params -> buf_size , src_off + len ,
536548 PATTERN_SRC , true);
537549
538550 pr_debug ("%s: verifying dest buffer...\n" ,
@@ -543,7 +555,7 @@ static int dmatest_func(void *data)
543555 dst_off + len , src_off ,
544556 PATTERN_SRC | PATTERN_COPY , false);
545557 error_count += dmatest_verify (thread -> dsts , dst_off + len ,
546- info -> buf_size , dst_off + len ,
558+ params -> buf_size , dst_off + len ,
547559 PATTERN_DST , false);
548560
549561 if (error_count ) {
@@ -580,7 +592,7 @@ static int dmatest_func(void *data)
580592 if (ret )
581593 dmaengine_terminate_all (chan );
582594
583- if (info -> iterations > 0 )
595+ if (params -> iterations > 0 )
584596 while (!kthread_should_stop ()) {
585597 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (wait_dmatest_exit );
586598 interruptible_sleep_on (& wait_dmatest_exit );
@@ -612,6 +624,7 @@ static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
612624static int dmatest_add_threads (struct dmatest_info * info ,
613625 struct dmatest_chan * dtc , enum dma_transaction_type type )
614626{
627+ struct dmatest_params * params = & info -> params ;
615628 struct dmatest_thread * thread ;
616629 struct dma_chan * chan = dtc -> chan ;
617630 char * op ;
@@ -626,7 +639,7 @@ static int dmatest_add_threads(struct dmatest_info *info,
626639 else
627640 return - EINVAL ;
628641
629- for (i = 0 ; i < info -> threads_per_chan ; i ++ ) {
642+ for (i = 0 ; i < params -> threads_per_chan ; i ++ ) {
630643 thread = kzalloc (sizeof (struct dmatest_thread ), GFP_KERNEL );
631644 if (!thread ) {
632645 pr_warning ("dmatest: No memory for %s-%s%u\n" ,
@@ -696,10 +709,10 @@ static int dmatest_add_channel(struct dmatest_info *info,
696709
697710static bool filter (struct dma_chan * chan , void * param )
698711{
699- struct dmatest_info * info = param ;
712+ struct dmatest_params * params = param ;
700713
701- if (!dmatest_match_channel (info , chan ) ||
702- !dmatest_match_device (info , chan -> device ))
714+ if (!dmatest_match_channel (params , chan ) ||
715+ !dmatest_match_device (params , chan -> device ))
703716 return false;
704717 else
705718 return true;
@@ -709,12 +722,13 @@ static int run_threaded_test(struct dmatest_info *info)
709722{
710723 dma_cap_mask_t mask ;
711724 struct dma_chan * chan ;
725+ struct dmatest_params * params = & info -> params ;
712726 int err = 0 ;
713727
714728 dma_cap_zero (mask );
715729 dma_cap_set (DMA_MEMCPY , mask );
716730 for (;;) {
717- chan = dma_request_channel (mask , filter , info );
731+ chan = dma_request_channel (mask , filter , params );
718732 if (chan ) {
719733 err = dmatest_add_channel (info , chan );
720734 if (err ) {
@@ -723,8 +737,8 @@ static int run_threaded_test(struct dmatest_info *info)
723737 }
724738 } else
725739 break ; /* no more channels available */
726- if (info -> max_channels &&
727- info -> nr_channels >= info -> max_channels )
740+ if (params -> max_channels &&
741+ info -> nr_channels >= params -> max_channels )
728742 break ; /* we have all we need */
729743 }
730744 return err ;
@@ -749,21 +763,22 @@ static void stop_threaded_test(struct dmatest_info *info)
749763static int __init dmatest_init (void )
750764{
751765 struct dmatest_info * info = & test_info ;
766+ struct dmatest_params * params = & info -> params ;
752767
753768 memset (info , 0 , sizeof (* info ));
754769
755770 INIT_LIST_HEAD (& info -> channels );
756771
757772 /* Set default parameters */
758- info -> buf_size = test_buf_size ;
759- strlcpy (info -> channel , test_channel , sizeof (info -> channel ));
760- strlcpy (info -> device , test_device , sizeof (info -> device ));
761- info -> threads_per_chan = threads_per_chan ;
762- info -> max_channels = max_channels ;
763- info -> iterations = iterations ;
764- info -> xor_sources = xor_sources ;
765- info -> pq_sources = pq_sources ;
766- info -> timeout = timeout ;
773+ params -> buf_size = test_buf_size ;
774+ strlcpy (params -> channel , test_channel , sizeof (params -> channel ));
775+ strlcpy (params -> device , test_device , sizeof (params -> device ));
776+ params -> threads_per_chan = threads_per_chan ;
777+ params -> max_channels = max_channels ;
778+ params -> iterations = iterations ;
779+ params -> xor_sources = xor_sources ;
780+ params -> pq_sources = pq_sources ;
781+ params -> timeout = timeout ;
767782
768783 return run_threaded_test (info );
769784}
0 commit comments