Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dmatest: do not allow to interrupt ongoing tests

When user interrupts ongoing transfers the dmatest may end up with console
lockup, oops, or data mismatch. This patch prevents user to abort any ongoing
test.

Documentation is updated accordingly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Will Deacon <will.deacon@arm.com>
Tested-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Andy Shevchenko and committed by
Vinod Koul
bcc567e3 9ecb41bd

+26 -25
+3 -3
Documentation/dmatest.txt
··· 34 34 After a while you will start to get messages about current status or error like 35 35 in the original code. 36 36 37 - Note that running a new test will stop any in progress test. 37 + Note that running a new test will not stop any in progress test. 38 38 39 39 The following command should return actual state of the test. 40 40 % cat /sys/kernel/debug/dmatest/run ··· 52 52 53 53 The module parameters that is supplied to the kernel command line will be used 54 54 for the first performed test. After user gets a control, the test could be 55 - interrupted or re-run with same or different parameters. For the details see 56 - the above section "Part 2 - When dmatest is built as a module..." 55 + re-run with the same or different parameters. For the details see the above 56 + section "Part 2 - When dmatest is built as a module..." 57 57 58 58 In both cases the module parameters are used as initial values for the test case. 59 59 You always could check them at run-time by running
+23 -22
drivers/dma/dmatest.c
··· 716 716 } 717 717 dma_async_issue_pending(chan); 718 718 719 - wait_event_freezable_timeout(done_wait, 720 - done.done || kthread_should_stop(), 719 + wait_event_freezable_timeout(done_wait, done.done, 721 720 msecs_to_jiffies(params->timeout)); 722 721 723 722 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL); ··· 996 997 static int __restart_threaded_test(struct dmatest_info *info, bool run) 997 998 { 998 999 struct dmatest_params *params = &info->params; 999 - int ret; 1000 1000 1001 1001 /* Stop any running test first */ 1002 1002 __stop_threaded_test(info); ··· 1010 1012 memcpy(params, &info->dbgfs_params, sizeof(*params)); 1011 1013 1012 1014 /* Run test with new parameters */ 1013 - ret = __run_threaded_test(info); 1014 - if (ret) { 1015 - __stop_threaded_test(info); 1016 - pr_err("dmatest: Can't run test\n"); 1015 + return __run_threaded_test(info); 1016 + } 1017 + 1018 + static bool __is_threaded_test_run(struct dmatest_info *info) 1019 + { 1020 + struct dmatest_chan *dtc; 1021 + 1022 + list_for_each_entry(dtc, &info->channels, node) { 1023 + struct dmatest_thread *thread; 1024 + 1025 + list_for_each_entry(thread, &dtc->threads, node) { 1026 + if (!thread->done) 1027 + return true; 1028 + } 1017 1029 } 1018 1030 1019 - return ret; 1031 + return false; 1020 1032 } 1021 1033 1022 1034 static ssize_t dtf_write_string(void *to, size_t available, loff_t *ppos, ··· 1099 1091 { 1100 1092 struct dmatest_info *info = file->private_data; 1101 1093 char buf[3]; 1102 - struct dmatest_chan *dtc; 1103 - bool alive = false; 1104 1094 1105 1095 mutex_lock(&info->lock); 1106 - list_for_each_entry(dtc, &info->channels, node) { 1107 - struct dmatest_thread *thread; 1108 1096 1109 - list_for_each_entry(thread, &dtc->threads, node) { 1110 - if (!thread->done) { 1111 - alive = true; 1112 - break; 1113 - } 1114 - } 1115 - } 1116 - 1117 - if (alive) { 1097 + if (__is_threaded_test_run(info)) { 1118 1098 buf[0] = 'Y'; 1119 1099 } else { 1120 1100 __stop_threaded_test(info); ··· 1128 1132 1129 1133 if (strtobool(buf, &bv) == 0) { 1130 1134 mutex_lock(&info->lock); 1131 - ret = __restart_threaded_test(info, bv); 1135 + 1136 + if (__is_threaded_test_run(info)) 1137 + ret = -EBUSY; 1138 + else 1139 + ret = __restart_threaded_test(info, bv); 1140 + 1132 1141 mutex_unlock(&info->lock); 1133 1142 } 1134 1143