Re: [PATCH] dmaengine: dmatest: Remove use of VLAs
From: kbuild test robot
Date: Tue Apr 10 2018 - 00:00:59 EST
Hi Laura,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v4.16 next-20180409]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Laura-Abbott/dmaengine-dmatest-Remove-use-of-VLAs/20180410-094633
config: i386-randconfig-x076-201814 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_write
Cyclomatic Complexity 2 arch/x86/include/asm/bitops.h:set_bit
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls
Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u32
Cyclomatic Complexity 3 include/linux/log2.h:is_power_of_2
Cyclomatic Complexity 1 include/linux/list.h:INIT_LIST_HEAD
Cyclomatic Complexity 1 include/linux/list.h:__list_add_valid
Cyclomatic Complexity 1 include/linux/list.h:__list_del_entry_valid
Cyclomatic Complexity 2 include/linux/list.h:__list_add
Cyclomatic Complexity 1 include/linux/list.h:list_add_tail
Cyclomatic Complexity 1 include/linux/list.h:__list_del
Cyclomatic Complexity 2 include/linux/list.h:__list_del_entry
Cyclomatic Complexity 1 include/linux/list.h:list_del
Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
Cyclomatic Complexity 1 arch/x86/include/asm/current.h:get_current
Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_read
Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_inc
Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_dec_and_test
Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_read
Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_inc
Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_dec_and_test
Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
Cyclomatic Complexity 3 include/linux/bitmap.h:bitmap_zero
Cyclomatic Complexity 1 include/linux/jiffies.h:_msecs_to_jiffies
Cyclomatic Complexity 3 include/linux/jiffies.h:msecs_to_jiffies
Cyclomatic Complexity 70 include/linux/ktime.h:ktime_divns
Cyclomatic Complexity 1 include/linux/ktime.h:ktime_to_us
Cyclomatic Complexity 1 include/linux/mmzone.h:pfn_to_section_nr
Cyclomatic Complexity 2 include/linux/mmzone.h:__nr_to_section
Cyclomatic Complexity 1 include/linux/mmzone.h:__section_mem_map_addr
Cyclomatic Complexity 1 include/linux/mmzone.h:__pfn_to_section
Cyclomatic Complexity 1 include/linux/kobject.h:kobject_name
Cyclomatic Complexity 2 include/linux/device.h:dev_name
Cyclomatic Complexity 1 include/linux/dma-debug.h:debug_dma_map_page
Cyclomatic Complexity 1 include/linux/dma-debug.h:debug_dma_mapping_error
Cyclomatic Complexity 1 include/linux/dma-mapping.h:valid_dma_direction
Cyclomatic Complexity 1 arch/x86/include/asm/dma-mapping.h:get_arch_dma_ops
Cyclomatic Complexity 4 include/linux/dma-mapping.h:get_dma_ops
Cyclomatic Complexity 1 include/linux/dma-mapping.h:dma_map_page_attrs
Cyclomatic Complexity 2 include/linux/dma-mapping.h:dma_mapping_error
Cyclomatic Complexity 1 include/linux/dmaengine.h:dma_submit_error
Cyclomatic Complexity 1 include/linux/dmaengine.h:dma_chan_name
Cyclomatic Complexity 2 include/linux/dmaengine.h:dmaengine_terminate_all
Cyclomatic Complexity 1 include/linux/dmaengine.h:dmaf_continue
Cyclomatic Complexity 1 include/linux/dmaengine.h:dmaf_p_disabled_continue
Cyclomatic Complexity 1 include/linux/dmaengine.h:dma_dev_has_pq_continue
Cyclomatic Complexity 1 include/linux/dmaengine.h:dma_dev_to_maxpq
Cyclomatic Complexity 4 include/linux/dmaengine.h:dma_maxpq
Cyclomatic Complexity 1 include/linux/dmaengine.h:__dma_cap_set
Cyclomatic Complexity 1 include/linux/dmaengine.h:__dma_cap_zero
Cyclomatic Complexity 2 include/linux/dmaengine.h:__dma_has_cap
Cyclomatic Complexity 1 include/linux/dmaengine.h:dma_async_issue_pending
Cyclomatic Complexity 3 include/linux/dmaengine.h:dma_async_is_tx_complete
Cyclomatic Complexity 2 include/linux/freezer.h:freezing
Cyclomatic Complexity 2 include/linux/freezer.h:try_to_freeze_unsafe
Cyclomatic Complexity 2 include/linux/freezer.h:try_to_freeze
Cyclomatic Complexity 1 include/linux/kasan.h:kasan_kmalloc
Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
Cyclomatic Complexity 1 include/linux/slab.h:kmem_cache_alloc_trace
Cyclomatic Complexity 1 include/linux/slab.h:kmalloc_order_trace
Cyclomatic Complexity 67 include/linux/slab.h:kmalloc_large
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc_array
Cyclomatic Complexity 1 include/linux/slab.h:kcalloc
Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
Cyclomatic Complexity 2 include/linux/sched/task.h:put_task_struct
Cyclomatic Complexity 2 drivers/dma/dmatest.c:gen_inv_idx
Cyclomatic Complexity 1 drivers/dma/dmatest.c:gen_src_value
Cyclomatic Complexity 1 drivers/dma/dmatest.c:gen_dst_value
Cyclomatic Complexity 5 drivers/dma/dmatest.c:dmatest_init_srcs
Cyclomatic Complexity 5 drivers/dma/dmatest.c:dmatest_init_dsts
Cyclomatic Complexity 2 drivers/dma/dmatest.c:min_odd
Cyclomatic Complexity 8 drivers/dma/dmatest.c:is_threaded_test_run
Cyclomatic Complexity 5 drivers/dma/dmatest.c:dmatest_mismatch
Cyclomatic Complexity 6 drivers/dma/dmatest.c:dmatest_verify
Cyclomatic Complexity 1 drivers/dma/dmatest.c:result
Cyclomatic Complexity 1 drivers/dma/dmatest.c:dbg_result
Cyclomatic Complexity 5 drivers/dma/dmatest.c:dmatest_cleanup_channel
Cyclomatic Complexity 5 drivers/dma/dmatest.c:stop_threaded_test
Cyclomatic Complexity 2 drivers/dma/dmatest.c:dmatest_run_get
Cyclomatic Complexity 1 drivers/dma/dmatest.c:dmatest_exit
Cyclomatic Complexity 2 drivers/dma/dmatest.c:dmatest_match_channel
Cyclomatic Complexity 2 drivers/dma/dmatest.c:dmatest_match_device
Cyclomatic Complexity 3 drivers/dma/dmatest.c:filter
Cyclomatic Complexity 69 drivers/dma/dmatest.c:dmatest_persec
Cyclomatic Complexity 1 drivers/dma/dmatest.c:dmatest_KBs
Cyclomatic Complexity 8 drivers/dma/dmatest.c:dmatest_add_threads
Cyclomatic Complexity 8 drivers/dma/dmatest.c:dmatest_add_channel
Cyclomatic Complexity 5 drivers/dma/dmatest.c:request_channels
Cyclomatic Complexity 1 drivers/dma/dmatest.c:run_threaded_test
Cyclomatic Complexity 2 drivers/dma/dmatest.c:restart_threaded_test
Cyclomatic Complexity 4 drivers/dma/dmatest.c:dmatest_run_set
Cyclomatic Complexity 4 drivers/dma/dmatest.c:dmatest_callback
Cyclomatic Complexity 1 drivers/dma/dmatest.c:dmatest_random
Cyclomatic Complexity 52 drivers/dma/dmatest.c:dmatest_func
Cyclomatic Complexity 4 drivers/dma/dmatest.c:dmatest_wait_get
Cyclomatic Complexity 6 drivers/dma/dmatest.c:dmatest_init
drivers/dma/dmatest.c: In function 'dmatest_func':
>> drivers/dma/dmatest.c:806:1: warning: the frame size of 4264 bytes is larger than 2048 bytes [-Wframe-larger-than=]
}
^
vim +806 drivers/dma/dmatest.c
95019c8c5 Andy Shevchenko 2013-03-04 425
4a776f0aa Haavard Skinnemoen 2008-07-08 426 /*
4a776f0aa Haavard Skinnemoen 2008-07-08 427 * This function repeatedly tests DMA transfers of various lengths and
b54d5cb91 Dan Williams 2009-03-25 428 * offsets for a given operation type until it is told to exit by
b54d5cb91 Dan Williams 2009-03-25 429 * kthread_stop(). There may be multiple threads running this function
b54d5cb91 Dan Williams 2009-03-25 430 * in parallel for a single channel, and there may be multiple channels
b54d5cb91 Dan Williams 2009-03-25 431 * being tested in parallel.
4a776f0aa Haavard Skinnemoen 2008-07-08 432 *
4a776f0aa Haavard Skinnemoen 2008-07-08 433 * Before each test, the source and destination buffer is initialized
4a776f0aa Haavard Skinnemoen 2008-07-08 434 * with a known pattern. This pattern is different depending on
4a776f0aa Haavard Skinnemoen 2008-07-08 435 * whether it's in an area which is supposed to be copied or
4a776f0aa Haavard Skinnemoen 2008-07-08 436 * overwritten, and different in the source and destination buffers.
4a776f0aa Haavard Skinnemoen 2008-07-08 437 * So if the DMA engine doesn't copy exactly what we tell it to copy,
4a776f0aa Haavard Skinnemoen 2008-07-08 438 * we'll notice.
4a776f0aa Haavard Skinnemoen 2008-07-08 439 */
4a776f0aa Haavard Skinnemoen 2008-07-08 440 static int dmatest_func(void *data)
4a776f0aa Haavard Skinnemoen 2008-07-08 441 {
4a776f0aa Haavard Skinnemoen 2008-07-08 442 struct dmatest_thread *thread = data;
6f6a23a21 Adam Wallis 2017-11-27 443 struct dmatest_done *done = &thread->test_done;
e03e93a97 Andy Shevchenko 2013-03-04 444 struct dmatest_info *info;
15b8a8ea1 Andy Shevchenko 2013-03-04 445 struct dmatest_params *params;
4a776f0aa Haavard Skinnemoen 2008-07-08 446 struct dma_chan *chan;
8be9e32b3 Akinobu Mita 2012-10-28 447 struct dma_device *dev;
4a776f0aa Haavard Skinnemoen 2008-07-08 448 unsigned int error_count;
4a776f0aa Haavard Skinnemoen 2008-07-08 449 unsigned int failed_tests = 0;
4a776f0aa Haavard Skinnemoen 2008-07-08 450 unsigned int total_tests = 0;
4a776f0aa Haavard Skinnemoen 2008-07-08 451 dma_cookie_t cookie;
4a776f0aa Haavard Skinnemoen 2008-07-08 452 enum dma_status status;
b54d5cb91 Dan Williams 2009-03-25 453 enum dma_ctrl_flags flags;
945b5af3c Andy Shevchenko 2013-03-04 454 u8 *pq_coefs = NULL;
4a776f0aa Haavard Skinnemoen 2008-07-08 455 int ret;
b54d5cb91 Dan Williams 2009-03-25 456 int src_cnt;
b54d5cb91 Dan Williams 2009-03-25 457 int dst_cnt;
b54d5cb91 Dan Williams 2009-03-25 458 int i;
e9405ef08 Sinan Kaya 2016-09-01 459 ktime_t ktime, start, diff;
8b0e19531 Thomas Gleixner 2016-12-25 460 ktime_t filltime = 0;
8b0e19531 Thomas Gleixner 2016-12-25 461 ktime_t comparetime = 0;
86727443a Dan Williams 2013-11-06 462 s64 runtime = 0;
86727443a Dan Williams 2013-11-06 463 unsigned long long total_len = 0;
d64816086 Dave Jiang 2016-11-29 464 u8 align = 0;
61b5f54d8 Sinan Kaya 2017-06-29 465 bool is_memset = false;
4a776f0aa Haavard Skinnemoen 2008-07-08 466
adfa543e7 Tejun Heo 2011-11-23 467 set_freezable();
4a776f0aa Haavard Skinnemoen 2008-07-08 468
4a776f0aa Haavard Skinnemoen 2008-07-08 469 ret = -ENOMEM;
4a776f0aa Haavard Skinnemoen 2008-07-08 470
4a776f0aa Haavard Skinnemoen 2008-07-08 471 smp_rmb();
e03e93a97 Andy Shevchenko 2013-03-04 472 info = thread->info;
15b8a8ea1 Andy Shevchenko 2013-03-04 473 params = &info->params;
4a776f0aa Haavard Skinnemoen 2008-07-08 474 chan = thread->chan;
8be9e32b3 Akinobu Mita 2012-10-28 475 dev = chan->device;
d64816086 Dave Jiang 2016-11-29 476 if (thread->type == DMA_MEMCPY) {
d64816086 Dave Jiang 2016-11-29 477 align = dev->copy_align;
b54d5cb91 Dan Williams 2009-03-25 478 src_cnt = dst_cnt = 1;
61b5f54d8 Sinan Kaya 2017-06-29 479 } else if (thread->type == DMA_MEMSET) {
61b5f54d8 Sinan Kaya 2017-06-29 480 align = dev->fill_align;
61b5f54d8 Sinan Kaya 2017-06-29 481 src_cnt = dst_cnt = 1;
61b5f54d8 Sinan Kaya 2017-06-29 482 is_memset = true;
d64816086 Dave Jiang 2016-11-29 483 } else if (thread->type == DMA_XOR) {
8be9e32b3 Akinobu Mita 2012-10-28 484 /* force odd to ensure dst = src */
15b8a8ea1 Andy Shevchenko 2013-03-04 485 src_cnt = min_odd(params->xor_sources | 1, dev->max_xor);
b54d5cb91 Dan Williams 2009-03-25 486 dst_cnt = 1;
d64816086 Dave Jiang 2016-11-29 487 align = dev->xor_align;
58691d64c Dan Williams 2009-08-29 488 } else if (thread->type == DMA_PQ) {
8be9e32b3 Akinobu Mita 2012-10-28 489 /* force odd to ensure dst = src */
15b8a8ea1 Andy Shevchenko 2013-03-04 490 src_cnt = min_odd(params->pq_sources | 1, dma_maxpq(dev, 0));
58691d64c Dan Williams 2009-08-29 491 dst_cnt = 2;
d64816086 Dave Jiang 2016-11-29 492 align = dev->pq_align;
945b5af3c Andy Shevchenko 2013-03-04 493
15b8a8ea1 Andy Shevchenko 2013-03-04 494 pq_coefs = kmalloc(params->pq_sources + 1, GFP_KERNEL);
945b5af3c Andy Shevchenko 2013-03-04 495 if (!pq_coefs)
945b5af3c Andy Shevchenko 2013-03-04 496 goto err_thread_type;
945b5af3c Andy Shevchenko 2013-03-04 497
94de648d7 Anatolij Gustschin 2010-02-15 498 for (i = 0; i < src_cnt; i++)
58691d64c Dan Williams 2009-08-29 499 pq_coefs[i] = 1;
b54d5cb91 Dan Williams 2009-03-25 500 } else
945b5af3c Andy Shevchenko 2013-03-04 501 goto err_thread_type;
b54d5cb91 Dan Williams 2009-03-25 502
b54d5cb91 Dan Williams 2009-03-25 503 thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL);
b54d5cb91 Dan Williams 2009-03-25 504 if (!thread->srcs)
b54d5cb91 Dan Williams 2009-03-25 505 goto err_srcs;
d64816086 Dave Jiang 2016-11-29 506
d64816086 Dave Jiang 2016-11-29 507 thread->usrcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL);
d64816086 Dave Jiang 2016-11-29 508 if (!thread->usrcs)
d64816086 Dave Jiang 2016-11-29 509 goto err_usrcs;
d64816086 Dave Jiang 2016-11-29 510
b54d5cb91 Dan Williams 2009-03-25 511 for (i = 0; i < src_cnt; i++) {
d64816086 Dave Jiang 2016-11-29 512 thread->usrcs[i] = kmalloc(params->buf_size + align,
d64816086 Dave Jiang 2016-11-29 513 GFP_KERNEL);
d64816086 Dave Jiang 2016-11-29 514 if (!thread->usrcs[i])
b54d5cb91 Dan Williams 2009-03-25 515 goto err_srcbuf;
d64816086 Dave Jiang 2016-11-29 516
d64816086 Dave Jiang 2016-11-29 517 /* align srcs to alignment restriction */
d64816086 Dave Jiang 2016-11-29 518 if (align)
d64816086 Dave Jiang 2016-11-29 519 thread->srcs[i] = PTR_ALIGN(thread->usrcs[i], align);
d64816086 Dave Jiang 2016-11-29 520 else
d64816086 Dave Jiang 2016-11-29 521 thread->srcs[i] = thread->usrcs[i];
b54d5cb91 Dan Williams 2009-03-25 522 }
b54d5cb91 Dan Williams 2009-03-25 523 thread->srcs[i] = NULL;
b54d5cb91 Dan Williams 2009-03-25 524
b54d5cb91 Dan Williams 2009-03-25 525 thread->dsts = kcalloc(dst_cnt + 1, sizeof(u8 *), GFP_KERNEL);
b54d5cb91 Dan Williams 2009-03-25 526 if (!thread->dsts)
b54d5cb91 Dan Williams 2009-03-25 527 goto err_dsts;
d64816086 Dave Jiang 2016-11-29 528
d64816086 Dave Jiang 2016-11-29 529 thread->udsts = kcalloc(dst_cnt + 1, sizeof(u8 *), GFP_KERNEL);
d64816086 Dave Jiang 2016-11-29 530 if (!thread->udsts)
d64816086 Dave Jiang 2016-11-29 531 goto err_udsts;
d64816086 Dave Jiang 2016-11-29 532
b54d5cb91 Dan Williams 2009-03-25 533 for (i = 0; i < dst_cnt; i++) {
d64816086 Dave Jiang 2016-11-29 534 thread->udsts[i] = kmalloc(params->buf_size + align,
d64816086 Dave Jiang 2016-11-29 535 GFP_KERNEL);
d64816086 Dave Jiang 2016-11-29 536 if (!thread->udsts[i])
b54d5cb91 Dan Williams 2009-03-25 537 goto err_dstbuf;
d64816086 Dave Jiang 2016-11-29 538
d64816086 Dave Jiang 2016-11-29 539 /* align dsts to alignment restriction */
d64816086 Dave Jiang 2016-11-29 540 if (align)
d64816086 Dave Jiang 2016-11-29 541 thread->dsts[i] = PTR_ALIGN(thread->udsts[i], align);
d64816086 Dave Jiang 2016-11-29 542 else
d64816086 Dave Jiang 2016-11-29 543 thread->dsts[i] = thread->udsts[i];
b54d5cb91 Dan Williams 2009-03-25 544 }
b54d5cb91 Dan Williams 2009-03-25 545 thread->dsts[i] = NULL;
b54d5cb91 Dan Williams 2009-03-25 546
e44e0aa3c Dan Williams 2009-03-25 547 set_user_nice(current, 10);
e44e0aa3c Dan Williams 2009-03-25 548
b203bd3f6 Ira Snyder 2011-03-03 549 /*
d1cab34c0 Bartlomiej Zolnierkiewicz 2013-10-18 550 * src and dst buffers are freed by ourselves below
b203bd3f6 Ira Snyder 2011-03-03 551 */
0776ae7b8 Bartlomiej Zolnierkiewicz 2013-10-18 552 flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
4a776f0aa Haavard Skinnemoen 2008-07-08 553
86727443a Dan Williams 2013-11-06 554 ktime = ktime_get();
0a2ff57d6 Nicolas Ferre 2009-07-03 555 while (!kthread_should_stop()
15b8a8ea1 Andy Shevchenko 2013-03-04 556 && !(params->iterations && total_tests >= params->iterations)) {
b54d5cb91 Dan Williams 2009-03-25 557 struct dma_async_tx_descriptor *tx = NULL;
4076e755d Dan Williams 2013-11-06 558 struct dmaengine_unmap_data *um;
e9fe1e34b Laura Abbott 2018-04-09 559 /* total buffer count must fit into u8 */
e9fe1e34b Laura Abbott 2018-04-09 560 dma_addr_t srcs[255];
4076e755d Dan Williams 2013-11-06 561 dma_addr_t *dsts;
ede23a586 Andy Shevchenko 2014-10-22 562 unsigned int src_off, dst_off, len;
d86be86e9 Atsushi Nemoto 2009-01-13 563
4a776f0aa Haavard Skinnemoen 2008-07-08 564 total_tests++;
4a776f0aa Haavard Skinnemoen 2008-07-08 565
fbfb8e1dc Stefan Roese 2017-04-27 566 /* Check if buffer count fits into map count variable (u8) */
fbfb8e1dc Stefan Roese 2017-04-27 567 if ((src_cnt + dst_cnt) >= 255) {
fbfb8e1dc Stefan Roese 2017-04-27 568 pr_err("too many buffers (%d of 255 supported)\n",
fbfb8e1dc Stefan Roese 2017-04-27 569 src_cnt + dst_cnt);
fbfb8e1dc Stefan Roese 2017-04-27 570 break;
fbfb8e1dc Stefan Roese 2017-04-27 571 }
fbfb8e1dc Stefan Roese 2017-04-27 572
15b8a8ea1 Andy Shevchenko 2013-03-04 573 if (1 << align > params->buf_size) {
cfe4f2751 Guennadi Liakhovetski 2009-12-04 574 pr_err("%u-byte buffer too small for %d-byte alignment\n",
15b8a8ea1 Andy Shevchenko 2013-03-04 575 params->buf_size, 1 << align);
cfe4f2751 Guennadi Liakhovetski 2009-12-04 576 break;
cfe4f2751 Guennadi Liakhovetski 2009-12-04 577 }
cfe4f2751 Guennadi Liakhovetski 2009-12-04 578
ede23a586 Andy Shevchenko 2014-10-22 579 if (params->noverify)
e3b9c3473 Dan Williams 2013-11-06 580 len = params->buf_size;
ede23a586 Andy Shevchenko 2014-10-22 581 else
15b8a8ea1 Andy Shevchenko 2013-03-04 582 len = dmatest_random() % params->buf_size + 1;
ede23a586 Andy Shevchenko 2014-10-22 583
83544ae9f Dan Williams 2009-09-08 584 len = (len >> align) << align;
cfe4f2751 Guennadi Liakhovetski 2009-12-04 585 if (!len)
cfe4f2751 Guennadi Liakhovetski 2009-12-04 586 len = 1 << align;
ede23a586 Andy Shevchenko 2014-10-22 587
ede23a586 Andy Shevchenko 2014-10-22 588 total_len += len;
ede23a586 Andy Shevchenko 2014-10-22 589
ede23a586 Andy Shevchenko 2014-10-22 590 if (params->noverify) {
ede23a586 Andy Shevchenko 2014-10-22 591 src_off = 0;
ede23a586 Andy Shevchenko 2014-10-22 592 dst_off = 0;
ede23a586 Andy Shevchenko 2014-10-22 593 } else {
e9405ef08 Sinan Kaya 2016-09-01 594 start = ktime_get();
15b8a8ea1 Andy Shevchenko 2013-03-04 595 src_off = dmatest_random() % (params->buf_size - len + 1);
15b8a8ea1 Andy Shevchenko 2013-03-04 596 dst_off = dmatest_random() % (params->buf_size - len + 1);
cfe4f2751 Guennadi Liakhovetski 2009-12-04 597
83544ae9f Dan Williams 2009-09-08 598 src_off = (src_off >> align) << align;
83544ae9f Dan Williams 2009-09-08 599 dst_off = (dst_off >> align) << align;
83544ae9f Dan Williams 2009-09-08 600
e3b9c3473 Dan Williams 2013-11-06 601 dmatest_init_srcs(thread->srcs, src_off, len,
61b5f54d8 Sinan Kaya 2017-06-29 602 params->buf_size, is_memset);
e3b9c3473 Dan Williams 2013-11-06 603 dmatest_init_dsts(thread->dsts, dst_off, len,
61b5f54d8 Sinan Kaya 2017-06-29 604 params->buf_size, is_memset);
e9405ef08 Sinan Kaya 2016-09-01 605
e9405ef08 Sinan Kaya 2016-09-01 606 diff = ktime_sub(ktime_get(), start);
e9405ef08 Sinan Kaya 2016-09-01 607 filltime = ktime_add(filltime, diff);
e3b9c3473 Dan Williams 2013-11-06 608 }
b54d5cb91 Dan Williams 2009-03-25 609
4076e755d Dan Williams 2013-11-06 610 um = dmaengine_get_unmap_data(dev->dev, src_cnt + dst_cnt,
4076e755d Dan Williams 2013-11-06 611 GFP_KERNEL);
4076e755d Dan Williams 2013-11-06 612 if (!um) {
4076e755d Dan Williams 2013-11-06 613 failed_tests++;
4076e755d Dan Williams 2013-11-06 614 result("unmap data NULL", total_tests,
4076e755d Dan Williams 2013-11-06 615 src_off, dst_off, len, ret);
4076e755d Dan Williams 2013-11-06 616 continue;
4076e755d Dan Williams 2013-11-06 617 }
4a776f0aa Haavard Skinnemoen 2008-07-08 618
4076e755d Dan Williams 2013-11-06 619 um->len = params->buf_size;
4076e755d Dan Williams 2013-11-06 620 for (i = 0; i < src_cnt; i++) {
745c00daf Dan Williams 2013-12-09 621 void *buf = thread->srcs[i];
4076e755d Dan Williams 2013-11-06 622 struct page *pg = virt_to_page(buf);
f62e5f613 Geliang Tang 2017-04-22 623 unsigned long pg_off = offset_in_page(buf);
4076e755d Dan Williams 2013-11-06 624
4076e755d Dan Williams 2013-11-06 625 um->addr[i] = dma_map_page(dev->dev, pg, pg_off,
4076e755d Dan Williams 2013-11-06 626 um->len, DMA_TO_DEVICE);
4076e755d Dan Williams 2013-11-06 627 srcs[i] = um->addr[i] + src_off;
4076e755d Dan Williams 2013-11-06 628 ret = dma_mapping_error(dev->dev, um->addr[i]);
afde3be12 Andy Shevchenko 2012-12-17 629 if (ret) {
4076e755d Dan Williams 2013-11-06 630 dmaengine_unmap_put(um);
872f05c6e Dan Williams 2013-11-06 631 result("src mapping error", total_tests,
872f05c6e Dan Williams 2013-11-06 632 src_off, dst_off, len, ret);
afde3be12 Andy Shevchenko 2012-12-17 633 failed_tests++;
afde3be12 Andy Shevchenko 2012-12-17 634 continue;
afde3be12 Andy Shevchenko 2012-12-17 635 }
4076e755d Dan Williams 2013-11-06 636 um->to_cnt++;
b54d5cb91 Dan Williams 2009-03-25 637 }
d86be86e9 Atsushi Nemoto 2009-01-13 638 /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
4076e755d Dan Williams 2013-11-06 639 dsts = &um->addr[src_cnt];
b54d5cb91 Dan Williams 2009-03-25 640 for (i = 0; i < dst_cnt; i++) {
745c00daf Dan Williams 2013-12-09 641 void *buf = thread->dsts[i];
4076e755d Dan Williams 2013-11-06 642 struct page *pg = virt_to_page(buf);
f62e5f613 Geliang Tang 2017-04-22 643 unsigned long pg_off = offset_in_page(buf);
4076e755d Dan Williams 2013-11-06 644
4076e755d Dan Williams 2013-11-06 645 dsts[i] = dma_map_page(dev->dev, pg, pg_off, um->len,
b54d5cb91 Dan Williams 2009-03-25 646 DMA_BIDIRECTIONAL);
4076e755d Dan Williams 2013-11-06 647 ret = dma_mapping_error(dev->dev, dsts[i]);
afde3be12 Andy Shevchenko 2012-12-17 648 if (ret) {
4076e755d Dan Williams 2013-11-06 649 dmaengine_unmap_put(um);
872f05c6e Dan Williams 2013-11-06 650 result("dst mapping error", total_tests,
872f05c6e Dan Williams 2013-11-06 651 src_off, dst_off, len, ret);
afde3be12 Andy Shevchenko 2012-12-17 652 failed_tests++;
afde3be12 Andy Shevchenko 2012-12-17 653 continue;
afde3be12 Andy Shevchenko 2012-12-17 654 }
4076e755d Dan Williams 2013-11-06 655 um->bidi_cnt++;
b54d5cb91 Dan Williams 2009-03-25 656 }
83544ae9f Dan Williams 2009-09-08 657
b54d5cb91 Dan Williams 2009-03-25 658 if (thread->type == DMA_MEMCPY)
b54d5cb91 Dan Williams 2009-03-25 659 tx = dev->device_prep_dma_memcpy(chan,
4076e755d Dan Williams 2013-11-06 660 dsts[0] + dst_off,
4076e755d Dan Williams 2013-11-06 661 srcs[0], len, flags);
61b5f54d8 Sinan Kaya 2017-06-29 662 else if (thread->type == DMA_MEMSET)
61b5f54d8 Sinan Kaya 2017-06-29 663 tx = dev->device_prep_dma_memset(chan,
61b5f54d8 Sinan Kaya 2017-06-29 664 dsts[0] + dst_off,
61b5f54d8 Sinan Kaya 2017-06-29 665 *(thread->srcs[0] + src_off),
61b5f54d8 Sinan Kaya 2017-06-29 666 len, flags);
b54d5cb91 Dan Williams 2009-03-25 667 else if (thread->type == DMA_XOR)
b54d5cb91 Dan Williams 2009-03-25 668 tx = dev->device_prep_dma_xor(chan,
4076e755d Dan Williams 2013-11-06 669 dsts[0] + dst_off,
4076e755d Dan Williams 2013-11-06 670 srcs, src_cnt,
b54d5cb91 Dan Williams 2009-03-25 671 len, flags);
58691d64c Dan Williams 2009-08-29 672 else if (thread->type == DMA_PQ) {
e9fe1e34b Laura Abbott 2018-04-09 673 /* dst_cnt can't be more than u8 */
e9fe1e34b Laura Abbott 2018-04-09 674 dma_addr_t dma_pq[255];
58691d64c Dan Williams 2009-08-29 675
58691d64c Dan Williams 2009-08-29 676 for (i = 0; i < dst_cnt; i++)
4076e755d Dan Williams 2013-11-06 677 dma_pq[i] = dsts[i] + dst_off;
4076e755d Dan Williams 2013-11-06 678 tx = dev->device_prep_dma_pq(chan, dma_pq, srcs,
94de648d7 Anatolij Gustschin 2010-02-15 679 src_cnt, pq_coefs,
58691d64c Dan Williams 2009-08-29 680 len, flags);
58691d64c Dan Williams 2009-08-29 681 }
d86be86e9 Atsushi Nemoto 2009-01-13 682
d86be86e9 Atsushi Nemoto 2009-01-13 683 if (!tx) {
4076e755d Dan Williams 2013-11-06 684 dmaengine_unmap_put(um);
872f05c6e Dan Williams 2013-11-06 685 result("prep error", total_tests, src_off,
872f05c6e Dan Williams 2013-11-06 686 dst_off, len, ret);
d86be86e9 Atsushi Nemoto 2009-01-13 687 msleep(100);
d86be86e9 Atsushi Nemoto 2009-01-13 688 failed_tests++;
d86be86e9 Atsushi Nemoto 2009-01-13 689 continue;
d86be86e9 Atsushi Nemoto 2009-01-13 690 }
e44e0aa3c Dan Williams 2009-03-25 691
6f6a23a21 Adam Wallis 2017-11-27 692 done->done = false;
e44e0aa3c Dan Williams 2009-03-25 693 tx->callback = dmatest_callback;
6f6a23a21 Adam Wallis 2017-11-27 694 tx->callback_param = done;
d86be86e9 Atsushi Nemoto 2009-01-13 695 cookie = tx->tx_submit(tx);
d86be86e9 Atsushi Nemoto 2009-01-13 696
4a776f0aa Haavard Skinnemoen 2008-07-08 697 if (dma_submit_error(cookie)) {
4076e755d Dan Williams 2013-11-06 698 dmaengine_unmap_put(um);
872f05c6e Dan Williams 2013-11-06 699 result("submit error", total_tests, src_off,
872f05c6e Dan Williams 2013-11-06 700 dst_off, len, ret);
4a776f0aa Haavard Skinnemoen 2008-07-08 701 msleep(100);
4a776f0aa Haavard Skinnemoen 2008-07-08 702 failed_tests++;
4a776f0aa Haavard Skinnemoen 2008-07-08 703 continue;
4a776f0aa Haavard Skinnemoen 2008-07-08 704 }
b54d5cb91 Dan Williams 2009-03-25 705 dma_async_issue_pending(chan);
4a776f0aa Haavard Skinnemoen 2008-07-08 706
6f6a23a21 Adam Wallis 2017-11-27 707 wait_event_freezable_timeout(thread->done_wait, done->done,
15b8a8ea1 Andy Shevchenko 2013-03-04 708 msecs_to_jiffies(params->timeout));
981ed70d8 Guennadi Liakhovetski 2011-08-18 709
e44e0aa3c Dan Williams 2009-03-25 710 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
4a776f0aa Haavard Skinnemoen 2008-07-08 711
6f6a23a21 Adam Wallis 2017-11-27 712 if (!done->done) {
4076e755d Dan Williams 2013-11-06 713 dmaengine_unmap_put(um);
872f05c6e Dan Williams 2013-11-06 714 result("test timed out", total_tests, src_off, dst_off,
95019c8c5 Andy Shevchenko 2013-03-04 715 len, 0);
4a776f0aa Haavard Skinnemoen 2008-07-08 716 failed_tests++;
4a776f0aa Haavard Skinnemoen 2008-07-08 717 continue;
19e9f99f2 Vinod Koul 2013-10-16 718 } else if (status != DMA_COMPLETE) {
4076e755d Dan Williams 2013-11-06 719 dmaengine_unmap_put(um);
872f05c6e Dan Williams 2013-11-06 720 result(status == DMA_ERROR ?
872f05c6e Dan Williams 2013-11-06 721 "completion error status" :
872f05c6e Dan Williams 2013-11-06 722 "completion busy status", total_tests, src_off,
872f05c6e Dan Williams 2013-11-06 723 dst_off, len, ret);
e44e0aa3c Dan Williams 2009-03-25 724 failed_tests++;
e44e0aa3c Dan Williams 2009-03-25 725 continue;
4a776f0aa Haavard Skinnemoen 2008-07-08 726 }
e44e0aa3c Dan Williams 2009-03-25 727
4076e755d Dan Williams 2013-11-06 728 dmaengine_unmap_put(um);
4a776f0aa Haavard Skinnemoen 2008-07-08 729
e3b9c3473 Dan Williams 2013-11-06 730 if (params->noverify) {
50137a7df Dan Williams 2013-11-08 731 verbose_result("test passed", total_tests, src_off,
50137a7df Dan Williams 2013-11-08 732 dst_off, len, 0);
e3b9c3473 Dan Williams 2013-11-06 733 continue;
e3b9c3473 Dan Williams 2013-11-06 734 }
4a776f0aa Haavard Skinnemoen 2008-07-08 735
e9405ef08 Sinan Kaya 2016-09-01 736 start = ktime_get();
872f05c6e Dan Williams 2013-11-06 737 pr_debug("%s: verifying source buffer...\n", current->comm);
e3b9c3473 Dan Williams 2013-11-06 738 error_count = dmatest_verify(thread->srcs, 0, src_off,
61b5f54d8 Sinan Kaya 2017-06-29 739 0, PATTERN_SRC, true, is_memset);
7b6101782 Dan Williams 2013-11-06 740 error_count += dmatest_verify(thread->srcs, src_off,
7b6101782 Dan Williams 2013-11-06 741 src_off + len, src_off,
61b5f54d8 Sinan Kaya 2017-06-29 742 PATTERN_SRC | PATTERN_COPY, true, is_memset);
7b6101782 Dan Williams 2013-11-06 743 error_count += dmatest_verify(thread->srcs, src_off + len,
7b6101782 Dan Williams 2013-11-06 744 params->buf_size, src_off + len,
61b5f54d8 Sinan Kaya 2017-06-29 745 PATTERN_SRC, true, is_memset);
7b6101782 Dan Williams 2013-11-06 746
872f05c6e Dan Williams 2013-11-06 747 pr_debug("%s: verifying dest buffer...\n", current->comm);
7b6101782 Dan Williams 2013-11-06 748 error_count += dmatest_verify(thread->dsts, 0, dst_off,
61b5f54d8 Sinan Kaya 2017-06-29 749 0, PATTERN_DST, false, is_memset);
61b5f54d8 Sinan Kaya 2017-06-29 750
7b6101782 Dan Williams 2013-11-06 751 error_count += dmatest_verify(thread->dsts, dst_off,
7b6101782 Dan Williams 2013-11-06 752 dst_off + len, src_off,
61b5f54d8 Sinan Kaya 2017-06-29 753 PATTERN_SRC | PATTERN_COPY, false, is_memset);
61b5f54d8 Sinan Kaya 2017-06-29 754
7b6101782 Dan Williams 2013-11-06 755 error_count += dmatest_verify(thread->dsts, dst_off + len,
7b6101782 Dan Williams 2013-11-06 756 params->buf_size, dst_off + len,
61b5f54d8 Sinan Kaya 2017-06-29 757 PATTERN_DST, false, is_memset);
4a776f0aa Haavard Skinnemoen 2008-07-08 758
e9405ef08 Sinan Kaya 2016-09-01 759 diff = ktime_sub(ktime_get(), start);
e9405ef08 Sinan Kaya 2016-09-01 760 comparetime = ktime_add(comparetime, diff);
e9405ef08 Sinan Kaya 2016-09-01 761
4a776f0aa Haavard Skinnemoen 2008-07-08 762 if (error_count) {
872f05c6e Dan Williams 2013-11-06 763 result("data error", total_tests, src_off, dst_off,
95019c8c5 Andy Shevchenko 2013-03-04 764 len, error_count);
4a776f0aa Haavard Skinnemoen 2008-07-08 765 failed_tests++;
4a776f0aa Haavard Skinnemoen 2008-07-08 766 } else {
50137a7df Dan Williams 2013-11-08 767 verbose_result("test passed", total_tests, src_off,
50137a7df Dan Williams 2013-11-08 768 dst_off, len, 0);
4a776f0aa Haavard Skinnemoen 2008-07-08 769 }
4a776f0aa Haavard Skinnemoen 2008-07-08 770 }
e9405ef08 Sinan Kaya 2016-09-01 771 ktime = ktime_sub(ktime_get(), ktime);
e9405ef08 Sinan Kaya 2016-09-01 772 ktime = ktime_sub(ktime, comparetime);
e9405ef08 Sinan Kaya 2016-09-01 773 ktime = ktime_sub(ktime, filltime);
e9405ef08 Sinan Kaya 2016-09-01 774 runtime = ktime_to_us(ktime);
4a776f0aa Haavard Skinnemoen 2008-07-08 775
4a776f0aa Haavard Skinnemoen 2008-07-08 776 ret = 0;
8e1f50d74 Andy Shevchenko 2014-08-22 777 err_dstbuf:
d64816086 Dave Jiang 2016-11-29 778 for (i = 0; thread->udsts[i]; i++)
d64816086 Dave Jiang 2016-11-29 779 kfree(thread->udsts[i]);
d64816086 Dave Jiang 2016-11-29 780 kfree(thread->udsts);
d64816086 Dave Jiang 2016-11-29 781 err_udsts:
b54d5cb91 Dan Williams 2009-03-25 782 kfree(thread->dsts);
b54d5cb91 Dan Williams 2009-03-25 783 err_dsts:
8e1f50d74 Andy Shevchenko 2014-08-22 784 err_srcbuf:
d64816086 Dave Jiang 2016-11-29 785 for (i = 0; thread->usrcs[i]; i++)
d64816086 Dave Jiang 2016-11-29 786 kfree(thread->usrcs[i]);
d64816086 Dave Jiang 2016-11-29 787 kfree(thread->usrcs);
d64816086 Dave Jiang 2016-11-29 788 err_usrcs:
b54d5cb91 Dan Williams 2009-03-25 789 kfree(thread->srcs);
b54d5cb91 Dan Williams 2009-03-25 790 err_srcs:
945b5af3c Andy Shevchenko 2013-03-04 791 kfree(pq_coefs);
945b5af3c Andy Shevchenko 2013-03-04 792 err_thread_type:
86727443a Dan Williams 2013-11-06 793 pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
86727443a Dan Williams 2013-11-06 794 current->comm, total_tests, failed_tests,
86727443a Dan Williams 2013-11-06 795 dmatest_persec(runtime, total_tests),
86727443a Dan Williams 2013-11-06 796 dmatest_KBs(runtime, total_len), ret);
0a2ff57d6 Nicolas Ferre 2009-07-03 797
9704efaa5 Viresh Kumar 2011-07-29 798 /* terminate all transfers on specified channels */
6f6a23a21 Adam Wallis 2017-11-27 799 if (ret || failed_tests)
944ea4dd3 Jon Mason 2012-11-11 800 dmaengine_terminate_all(chan);
5e034f7b6 Shiraz Hashim 2012-11-09 801
3e5ccd866 Andy Shevchenko 2013-03-04 802 thread->done = true;
2d88ce76e Dan Williams 2013-11-06 803 wake_up(&thread_wait);
0a2ff57d6 Nicolas Ferre 2009-07-03 804
4a776f0aa Haavard Skinnemoen 2008-07-08 805 return ret;
4a776f0aa Haavard Skinnemoen 2008-07-08 @806 }
4a776f0aa Haavard Skinnemoen 2008-07-08 807
:::::: The code at line 806 was first introduced by commit
:::::: 4a776f0aa922a552460192c07b56f4fe9cd82632 dmatest: Simple DMA memcpy test client
:::::: TO: Haavard Skinnemoen <hskinnemoen@xxxxxxxxx>
:::::: CC: Dan Williams <dan.j.williams@xxxxxxxxx>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip