]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
dmatest: return actual state in 'run' file
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 4 Mar 2013 09:09:31 +0000 (11:09 +0200)
committerVinod Koul <vinod.koul@intel.com>
Mon, 15 Apr 2013 04:21:17 +0000 (09:51 +0530)
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>
Documentation/dmatest.txt
drivers/dma/dmatest.c

index 9a90729bdee6536e030220107a5660425830b4cb..3e17b55a8ba3f697aa1f23ad863d02c69033bcde 100644 (file)
@@ -36,6 +36,18 @@ in the original code.
 
 Note that running a new test will stop any in progress test.
 
+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
+
        Part 3 - When built-in in the kernel...
 
 The module parameters that is supplied to the kernel command line will be used
index fc31542e7200c399c8c1e209cdc20984fa2f79f9..d19234b0834275f3a34914f9cf2444c0e2a341a6 100644 (file)
@@ -93,6 +93,7 @@ struct dmatest_thread {
        u8                      **srcs;
        u8                      **dsts;
        enum dma_transaction_type type;
+       bool                    done;
 };
 
 struct dmatest_chan {
@@ -603,6 +604,8 @@ err_thread_type:
        if (ret)
                dmaengine_terminate_all(chan);
 
+       thread->done = true;
+
        if (params->iterations > 0)
                while (!kthread_should_stop()) {
                        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,
 {
        struct dmatest_info *info = file->private_data;
        char buf[3];
+       struct dmatest_chan *dtc;
+       bool alive = false;
 
        mutex_lock(&info->lock);
-       if (info->nr_channels)
+       list_for_each_entry(dtc, &info->channels, node) {
+               struct dmatest_thread *thread;
+
+               list_for_each_entry(thread, &dtc->threads, node) {
+                       if (!thread->done) {
+                               alive = true;
+                               break;
+                       }
+               }
+       }
+
+       if (alive) {
                buf[0] = 'Y';
-       else
+       } else {
+               __stop_threaded_test(info);
                buf[0] = 'N';
+       }
+
        mutex_unlock(&info->lock);
        buf[1] = '\n';
        buf[2] = 0x00;