Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 280383
b: refs/heads/master
c: adfa543
h: refs/heads/master
i:
  280381: 123b2a9
  280379: ba692ce
  280375: faaaea9
  280367: e956e13
  280351: 07083be
  280319: 3f3315a
v: v3
  • Loading branch information
Tejun Heo committed Nov 23, 2011
1 parent 25ee524 commit 01d975b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ec012476af73a1a8a82565a915e9b48c2e337878
refs/heads/master: adfa543e7314b36ac55a40019977de6e47946dd7
46 changes: 27 additions & 19 deletions trunk/drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,18 @@ static unsigned int dmatest_verify(u8 **bufs, unsigned int start,
return error_count;
}

static void dmatest_callback(void *completion)
/* poor man's completion - we want to use wait_event_freezable() on it */
struct dmatest_done {
bool done;
wait_queue_head_t *wait;
};

static void dmatest_callback(void *arg)
{
complete(completion);
struct dmatest_done *done = arg;

done->done = true;
wake_up_all(done->wait);
}

/*
Expand All @@ -235,7 +244,9 @@ static void dmatest_callback(void *completion)
*/
static int dmatest_func(void *data)
{
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_wait);
struct dmatest_thread *thread = data;
struct dmatest_done done = { .wait = &done_wait };
struct dma_chan *chan;
const char *thread_name;
unsigned int src_off, dst_off, len;
Expand All @@ -252,7 +263,7 @@ static int dmatest_func(void *data)
int i;

thread_name = current->comm;
set_freezable_with_signal();
set_freezable();

ret = -ENOMEM;

Expand Down Expand Up @@ -306,9 +317,6 @@ static int dmatest_func(void *data)
struct dma_async_tx_descriptor *tx = NULL;
dma_addr_t dma_srcs[src_cnt];
dma_addr_t dma_dsts[dst_cnt];
struct completion cmp;
unsigned long start, tmo, end = 0 /* compiler... */;
bool reload = true;
u8 align = 0;

total_tests++;
Expand Down Expand Up @@ -391,9 +399,9 @@ static int dmatest_func(void *data)
continue;
}

init_completion(&cmp);
done.done = false;
tx->callback = dmatest_callback;
tx->callback_param = &cmp;
tx->callback_param = &done;
cookie = tx->tx_submit(tx);

if (dma_submit_error(cookie)) {
Expand All @@ -407,20 +415,20 @@ static int dmatest_func(void *data)
}
dma_async_issue_pending(chan);

do {
start = jiffies;
if (reload)
end = start + msecs_to_jiffies(timeout);
else if (end <= start)
end = start + 1;
tmo = wait_for_completion_interruptible_timeout(&cmp,
end - start);
reload = try_to_freeze();
} while (tmo == -ERESTARTSYS);
wait_event_freezable_timeout(done_wait, done.done,
msecs_to_jiffies(timeout));

status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);

if (tmo == 0) {
if (!done.done) {
/*
* We're leaving the timed out dma operation with
* dangling pointer to done_wait. To make this
* correct, we'll need to allocate wait_done for
* each test iteration and perform "who's gonna
* free it this time?" dancing. For now, just
* leave it dangling.
*/
pr_warning("%s: #%u: test timed out\n",
thread_name, total_tests - 1);
failed_tests++;
Expand Down

0 comments on commit 01d975b

Please sign in to comment.