dropbear: add option to set receive window size
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.9 / 819-Revert-dmaengine-dmatest-move-callback-wait-queue-to.patch
1 From 8772422ee95b17d87b5cb6cb4318b7ec73f4cfcf Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Mon, 29 Jan 2018 18:04:07 +0800
4 Subject: [PATCH] Revert "dmaengine: dmatest: move callback wait queue to
5 thread context"
6
7 This reverts commit 679dbeac0b6bb551e1f3b95673695b22b2ac953d.
8 ---
9 drivers/dma/dmatest.c | 55 ++++++++++++++++++++++-----------------------------
10 1 file changed, 24 insertions(+), 31 deletions(-)
11
12 --- a/drivers/dma/dmatest.c
13 +++ b/drivers/dma/dmatest.c
14 @@ -158,12 +158,6 @@ MODULE_PARM_DESC(run, "Run the test (def
15 #define PATTERN_OVERWRITE 0x20
16 #define PATTERN_COUNT_MASK 0x1f
17
18 -/* poor man's completion - we want to use wait_event_freezable() on it */
19 -struct dmatest_done {
20 - bool done;
21 - wait_queue_head_t *wait;
22 -};
23 -
24 struct dmatest_thread {
25 struct list_head node;
26 struct dmatest_info *info;
27 @@ -172,8 +166,6 @@ struct dmatest_thread {
28 u8 **srcs;
29 u8 **dsts;
30 enum dma_transaction_type type;
31 - wait_queue_head_t done_wait;
32 - struct dmatest_done test_done;
33 bool done;
34 };
35
36 @@ -334,25 +326,18 @@ static unsigned int dmatest_verify(u8 **
37 return error_count;
38 }
39
40 +/* poor man's completion - we want to use wait_event_freezable() on it */
41 +struct dmatest_done {
42 + bool done;
43 + wait_queue_head_t *wait;
44 +};
45
46 static void dmatest_callback(void *arg)
47 {
48 struct dmatest_done *done = arg;
49 - struct dmatest_thread *thread =
50 - container_of(arg, struct dmatest_thread, done_wait);
51 - if (!thread->done) {
52 - done->done = true;
53 - wake_up_all(done->wait);
54 - } else {
55 - /*
56 - * If thread->done, it means that this callback occurred
57 - * after the parent thread has cleaned up. This can
58 - * happen in the case that driver doesn't implement
59 - * the terminate_all() functionality and a dma operation
60 - * did not occur within the timeout period
61 - */
62 - WARN(1, "dmatest: Kernel memory may be corrupted!!\n");
63 - }
64 +
65 + done->done = true;
66 + wake_up_all(done->wait);
67 }
68
69 static unsigned int min_odd(unsigned int x, unsigned int y)
70 @@ -423,8 +408,9 @@ static unsigned long long dmatest_KBs(s6
71 */
72 static int dmatest_func(void *data)
73 {
74 + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_wait);
75 struct dmatest_thread *thread = data;
76 - struct dmatest_done *done = &thread->test_done;
77 + struct dmatest_done done = { .wait = &done_wait };
78 struct dmatest_info *info;
79 struct dmatest_params *params;
80 struct dma_chan *chan;
81 @@ -651,9 +637,9 @@ static int dmatest_func(void *data)
82 continue;
83 }
84
85 - done->done = false;
86 + done.done = false;
87 tx->callback = dmatest_callback;
88 - tx->callback_param = done;
89 + tx->callback_param = &done;
90 cookie = tx->tx_submit(tx);
91
92 if (dma_submit_error(cookie)) {
93 @@ -666,12 +652,21 @@ static int dmatest_func(void *data)
94 }
95 dma_async_issue_pending(chan);
96
97 - wait_event_freezable_timeout(thread->done_wait, done->done,
98 + wait_event_freezable_timeout(done_wait, done.done,
99 msecs_to_jiffies(params->timeout));
100
101 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
102
103 - if (!done->done) {
104 + if (!done.done) {
105 + /*
106 + * We're leaving the timed out dma operation with
107 + * dangling pointer to done_wait. To make this
108 + * correct, we'll need to allocate wait_done for
109 + * each test iteration and perform "who's gonna
110 + * free it this time?" dancing. For now, just
111 + * leave it dangling.
112 + */
113 + WARN(1, "dmatest: Kernel stack may be corrupted!!\n");
114 dmaengine_unmap_put(um);
115 result("test timed out", total_tests, src_off, dst_off,
116 len, 0);
117 @@ -752,7 +747,7 @@ err_thread_type:
118 dmatest_KBs(runtime, total_len), ret);
119
120 /* terminate all transfers on specified channels */
121 - if (ret || failed_tests)
122 + if (ret)
123 dmaengine_terminate_all(chan);
124
125 thread->done = true;
126 @@ -812,8 +807,6 @@ static int dmatest_add_threads(struct dm
127 thread->info = info;
128 thread->chan = dtc->chan;
129 thread->type = type;
130 - thread->test_done.wait = &thread->done_wait;
131 - init_waitqueue_head(&thread->done_wait);
132 smp_wmb();
133 thread->task = kthread_create(dmatest_func, thread, "%s-%s%u",
134 dma_chan_name(chan), op, i);