Skip to content

Commit 3e5ccd8

Browse files
andy-shevVinod Koul
authored andcommitted
dmatest: return actual state in 'run' file
The following command should return actual state of the test. % cat /sys/kernel/debug/dmatest/run To wait for test done the user may perform a busy loop that checks the state. % while [ $(cat /sys/kernel/debug/dmatest/run) = "Y" ] > do > echo -n "." > sleep 1 > done > echo Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 851b7e1 commit 3e5ccd8

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

Documentation/dmatest.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ in the original code.
3636

3737
Note that running a new test will stop any in progress test.
3838

39+
The following command should return actual state of the test.
40+
% cat /sys/kernel/debug/dmatest/run
41+
42+
To wait for test done the user may perform a busy loop that checks the state.
43+
44+
% while [ $(cat /sys/kernel/debug/dmatest/run) = "Y" ]
45+
> do
46+
> echo -n "."
47+
> sleep 1
48+
> done
49+
> echo
50+
3951
Part 3 - When built-in in the kernel...
4052

4153
The module parameters that is supplied to the kernel command line will be used

drivers/dma/dmatest.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct dmatest_thread {
9393
u8 **srcs;
9494
u8 **dsts;
9595
enum dma_transaction_type type;
96+
bool done;
9697
};
9798

9899
struct dmatest_chan {
@@ -603,6 +604,8 @@ static int dmatest_func(void *data)
603604
if (ret)
604605
dmaengine_terminate_all(chan);
605606

607+
thread->done = true;
608+
606609
if (params->iterations > 0)
607610
while (!kthread_should_stop()) {
608611
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait_dmatest_exit);
@@ -884,12 +887,28 @@ static ssize_t dtf_read_run(struct file *file, char __user *user_buf,
884887
{
885888
struct dmatest_info *info = file->private_data;
886889
char buf[3];
890+
struct dmatest_chan *dtc;
891+
bool alive = false;
887892

888893
mutex_lock(&info->lock);
889-
if (info->nr_channels)
894+
list_for_each_entry(dtc, &info->channels, node) {
895+
struct dmatest_thread *thread;
896+
897+
list_for_each_entry(thread, &dtc->threads, node) {
898+
if (!thread->done) {
899+
alive = true;
900+
break;
901+
}
902+
}
903+
}
904+
905+
if (alive) {
890906
buf[0] = 'Y';
891-
else
907+
} else {
908+
__stop_threaded_test(info);
892909
buf[0] = 'N';
910+
}
911+
893912
mutex_unlock(&info->lock);
894913
buf[1] = '\n';
895914
buf[2] = 0x00;

0 commit comments

Comments
 (0)