blob: ec5f9d2bc8202f340c615cbe43731016d316d547 [file] [log] [blame]
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -07001/*
2 * DMA Engine test module
3 *
4 * Copyright (C) 2007 Atmel Corporation
Andy Shevchenko851b7e12013-03-04 11:09:30 +02005 * Copyright (C) 2013 Intel Corporation
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
Dan Williams872f05c2013-11-06 16:29:58 -080011#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070013#include <linux/delay.h>
Alexey Dobriyanb7f080c2011-06-16 11:01:34 +000014#include <linux/dma-mapping.h>
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070015#include <linux/dmaengine.h>
Guennadi Liakhovetski981ed702011-08-18 16:50:51 +020016#include <linux/freezer.h>
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070017#include <linux/init.h>
18#include <linux/kthread.h>
Ingo Molnar0881e7b2017-02-05 15:30:50 +010019#include <linux/sched/task.h>
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070020#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/random.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090023#include <linux/slab.h>
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070024#include <linux/wait.h>
25
26static unsigned int test_buf_size = 16384;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030027module_param(test_buf_size, uint, S_IRUGO | S_IWUSR);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070028MODULE_PARM_DESC(test_buf_size, "Size of the memcpy test buffer");
29
Kay Sievers06190d82008-11-11 13:12:33 -070030static char test_channel[20];
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030031module_param_string(channel, test_channel, sizeof(test_channel),
32 S_IRUGO | S_IWUSR);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070033MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)");
34
Guennadi Liakhovetskia85159f2013-12-30 14:58:04 +010035static char test_device[32];
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030036module_param_string(device, test_device, sizeof(test_device),
37 S_IRUGO | S_IWUSR);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070038MODULE_PARM_DESC(device, "Bus ID of the DMA Engine to test (default: any)");
39
40static unsigned int threads_per_chan = 1;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030041module_param(threads_per_chan, uint, S_IRUGO | S_IWUSR);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070042MODULE_PARM_DESC(threads_per_chan,
43 "Number of threads to start per channel (default: 1)");
44
45static unsigned int max_channels;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030046module_param(max_channels, uint, S_IRUGO | S_IWUSR);
Dan Williams33df8ca2009-01-06 11:38:15 -070047MODULE_PARM_DESC(max_channels,
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070048 "Maximum number of channels to use (default: all)");
49
Nicolas Ferre0a2ff57d2009-07-03 19:26:51 +020050static unsigned int iterations;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030051module_param(iterations, uint, S_IRUGO | S_IWUSR);
Nicolas Ferre0a2ff57d2009-07-03 19:26:51 +020052MODULE_PARM_DESC(iterations,
53 "Iterations before stopping test (default: infinite)");
54
Eugeniy Paltsevd8646722016-09-14 20:40:38 +030055static unsigned int dmatest;
Kedareswara rao Appanaa0d4cb42016-06-09 21:10:14 +053056module_param(dmatest, uint, S_IRUGO | S_IWUSR);
57MODULE_PARM_DESC(dmatest,
Dave Jiangc678fa62017-08-21 10:23:13 -070058 "dmatest 0-memcpy 1-memset (default: 0)");
Kedareswara rao Appanaa0d4cb42016-06-09 21:10:14 +053059
Dan Williamsb54d5cb2009-03-25 09:13:25 -070060static unsigned int xor_sources = 3;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030061module_param(xor_sources, uint, S_IRUGO | S_IWUSR);
Dan Williamsb54d5cb2009-03-25 09:13:25 -070062MODULE_PARM_DESC(xor_sources,
63 "Number of xor source buffers (default: 3)");
64
Dan Williams58691d62009-08-29 19:09:27 -070065static unsigned int pq_sources = 3;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030066module_param(pq_sources, uint, S_IRUGO | S_IWUSR);
Dan Williams58691d62009-08-29 19:09:27 -070067MODULE_PARM_DESC(pq_sources,
68 "Number of p+q source buffers (default: 3)");
69
Viresh Kumard42efe62011-03-22 17:27:25 +053070static int timeout = 3000;
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +030071module_param(timeout, uint, S_IRUGO | S_IWUSR);
Joe Perches85ee7a12011-04-23 20:38:19 -070072MODULE_PARM_DESC(timeout, "Transfer Timeout in msec (default: 3000), "
73 "Pass -1 for infinite timeout");
Viresh Kumard42efe62011-03-22 17:27:25 +053074
Dan Williamse3b9c342013-11-06 16:30:05 -080075static bool noverify;
76module_param(noverify, bool, S_IRUGO | S_IWUSR);
77MODULE_PARM_DESC(noverify, "Disable random data setup and verification");
Andy Shevchenko74b5c072013-03-04 11:09:32 +020078
Dan Williams50137a72013-11-08 12:26:26 -080079static bool verbose;
80module_param(verbose, bool, S_IRUGO | S_IWUSR);
81MODULE_PARM_DESC(verbose, "Enable \"success\" result messages (default: off)");
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -070082
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +020083/**
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +020084 * struct dmatest_params - test parameters.
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +020085 * @buf_size: size of the memcpy test buffer
86 * @channel: bus ID of the channel to test
87 * @device: bus ID of the DMA Engine to test
88 * @threads_per_chan: number of threads to start per channel
89 * @max_channels: maximum number of channels to use
90 * @iterations: iterations before stopping test
91 * @xor_sources: number of xor source buffers
92 * @pq_sources: number of p+q source buffers
93 * @timeout: transfer timeout in msec, -1 for infinite timeout
94 */
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +020095struct dmatest_params {
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +020096 unsigned int buf_size;
97 char channel[20];
Guennadi Liakhovetskia85159f2013-12-30 14:58:04 +010098 char device[32];
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +020099 unsigned int threads_per_chan;
100 unsigned int max_channels;
101 unsigned int iterations;
102 unsigned int xor_sources;
103 unsigned int pq_sources;
104 int timeout;
Dan Williamse3b9c342013-11-06 16:30:05 -0800105 bool noverify;
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200106};
107
108/**
109 * struct dmatest_info - test information.
110 * @params: test parameters
Andy Shevchenko851b7e12013-03-04 11:09:30 +0200111 * @lock: access protection to the fields of this structure
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200112 */
Dan Williamsa310d032013-11-06 16:30:01 -0800113static struct dmatest_info {
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200114 /* Test parameters */
115 struct dmatest_params params;
Andy Shevchenko838cc702013-03-04 11:09:28 +0200116
117 /* Internal state */
118 struct list_head channels;
119 unsigned int nr_channels;
Andy Shevchenko851b7e12013-03-04 11:09:30 +0200120 struct mutex lock;
Dan Williamsa310d032013-11-06 16:30:01 -0800121 bool did_init;
122} test_info = {
123 .channels = LIST_HEAD_INIT(test_info.channels),
124 .lock = __MUTEX_INITIALIZER(test_info.lock),
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200125};
126
Dan Williamsa310d032013-11-06 16:30:01 -0800127static int dmatest_run_set(const char *val, const struct kernel_param *kp);
128static int dmatest_run_get(char *val, const struct kernel_param *kp);
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930129static const struct kernel_param_ops run_ops = {
Dan Williamsa310d032013-11-06 16:30:01 -0800130 .set = dmatest_run_set,
131 .get = dmatest_run_get,
132};
133static bool dmatest_run;
134module_param_cb(run, &run_ops, &dmatest_run, S_IRUGO | S_IWUSR);
135MODULE_PARM_DESC(run, "Run the test (default: false)");
136
137/* Maximum amount of mismatched bytes in buffer to print */
138#define MAX_ERROR_COUNT 32
139
140/*
141 * Initialization patterns. All bytes in the source buffer has bit 7
142 * set, all bytes in the destination buffer has bit 7 cleared.
143 *
144 * Bit 6 is set for all bytes which are to be copied by the DMA
145 * engine. Bit 5 is set for all bytes which are to be overwritten by
146 * the DMA engine.
147 *
148 * The remaining bits are the inverse of a counter which increments by
149 * one for each byte address.
150 */
151#define PATTERN_SRC 0x80
152#define PATTERN_DST 0x00
153#define PATTERN_COPY 0x40
154#define PATTERN_OVERWRITE 0x20
155#define PATTERN_COUNT_MASK 0x1f
Sinan Kaya61b5f542017-06-29 22:30:58 -0400156#define PATTERN_MEMSET_IDX 0x01
Dan Williamsa310d032013-11-06 16:30:01 -0800157
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500158/* poor man's completion - we want to use wait_event_freezable() on it */
159struct dmatest_done {
160 bool done;
161 wait_queue_head_t *wait;
162};
163
Dan Williamsa310d032013-11-06 16:30:01 -0800164struct dmatest_thread {
165 struct list_head node;
166 struct dmatest_info *info;
167 struct task_struct *task;
168 struct dma_chan *chan;
169 u8 **srcs;
Dave Jiangd6481602016-11-29 13:22:20 -0700170 u8 **usrcs;
Dan Williamsa310d032013-11-06 16:30:01 -0800171 u8 **dsts;
Dave Jiangd6481602016-11-29 13:22:20 -0700172 u8 **udsts;
Dan Williamsa310d032013-11-06 16:30:01 -0800173 enum dma_transaction_type type;
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500174 wait_queue_head_t done_wait;
175 struct dmatest_done test_done;
Dan Williamsa310d032013-11-06 16:30:01 -0800176 bool done;
177};
178
179struct dmatest_chan {
180 struct list_head node;
181 struct dma_chan *chan;
182 struct list_head threads;
183};
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200184
Dan Williams2d88ce72013-11-06 16:30:09 -0800185static DECLARE_WAIT_QUEUE_HEAD(thread_wait);
186static bool wait;
187
188static bool is_threaded_test_run(struct dmatest_info *info)
189{
190 struct dmatest_chan *dtc;
191
192 list_for_each_entry(dtc, &info->channels, node) {
193 struct dmatest_thread *thread;
194
195 list_for_each_entry(thread, &dtc->threads, node) {
196 if (!thread->done)
197 return true;
198 }
199 }
200
201 return false;
202}
203
204static int dmatest_wait_get(char *val, const struct kernel_param *kp)
205{
206 struct dmatest_info *info = &test_info;
207 struct dmatest_params *params = &info->params;
208
209 if (params->iterations)
210 wait_event(thread_wait, !is_threaded_test_run(info));
211 wait = true;
212 return param_get_bool(val, kp);
213}
214
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930215static const struct kernel_param_ops wait_ops = {
Dan Williams2d88ce72013-11-06 16:30:09 -0800216 .get = dmatest_wait_get,
217 .set = param_set_bool,
218};
219module_param_cb(wait, &wait_ops, &wait, S_IRUGO);
220MODULE_PARM_DESC(wait, "Wait for tests to complete (default: false)");
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700221
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200222static bool dmatest_match_channel(struct dmatest_params *params,
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200223 struct dma_chan *chan)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700224{
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200225 if (params->channel[0] == '\0')
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700226 return true;
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200227 return strcmp(dma_chan_name(chan), params->channel) == 0;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700228}
229
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200230static bool dmatest_match_device(struct dmatest_params *params,
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200231 struct dma_device *device)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700232{
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200233 if (params->device[0] == '\0')
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700234 return true;
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200235 return strcmp(dev_name(device->dev), params->device) == 0;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700236}
237
238static unsigned long dmatest_random(void)
239{
240 unsigned long buf;
241
Dan Williamsbe9fa5a2013-11-06 16:30:03 -0800242 prandom_bytes(&buf, sizeof(buf));
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700243 return buf;
244}
245
Sinan Kaya61b5f542017-06-29 22:30:58 -0400246static inline u8 gen_inv_idx(u8 index, bool is_memset)
247{
248 u8 val = is_memset ? PATTERN_MEMSET_IDX : index;
249
250 return ~val & PATTERN_COUNT_MASK;
251}
252
253static inline u8 gen_src_value(u8 index, bool is_memset)
254{
255 return PATTERN_SRC | gen_inv_idx(index, is_memset);
256}
257
258static inline u8 gen_dst_value(u8 index, bool is_memset)
259{
260 return PATTERN_DST | gen_inv_idx(index, is_memset);
261}
262
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200263static void dmatest_init_srcs(u8 **bufs, unsigned int start, unsigned int len,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400264 unsigned int buf_size, bool is_memset)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700265{
266 unsigned int i;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700267 u8 *buf;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700268
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700269 for (; (buf = *bufs); bufs++) {
270 for (i = 0; i < start; i++)
Sinan Kaya61b5f542017-06-29 22:30:58 -0400271 buf[i] = gen_src_value(i, is_memset);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700272 for ( ; i < start + len; i++)
Sinan Kaya61b5f542017-06-29 22:30:58 -0400273 buf[i] = gen_src_value(i, is_memset) | PATTERN_COPY;
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200274 for ( ; i < buf_size; i++)
Sinan Kaya61b5f542017-06-29 22:30:58 -0400275 buf[i] = gen_src_value(i, is_memset);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700276 buf++;
277 }
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700278}
279
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200280static void dmatest_init_dsts(u8 **bufs, unsigned int start, unsigned int len,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400281 unsigned int buf_size, bool is_memset)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700282{
283 unsigned int i;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700284 u8 *buf;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700285
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700286 for (; (buf = *bufs); bufs++) {
287 for (i = 0; i < start; i++)
Sinan Kaya61b5f542017-06-29 22:30:58 -0400288 buf[i] = gen_dst_value(i, is_memset);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700289 for ( ; i < start + len; i++)
Sinan Kaya61b5f542017-06-29 22:30:58 -0400290 buf[i] = gen_dst_value(i, is_memset) |
291 PATTERN_OVERWRITE;
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200292 for ( ; i < buf_size; i++)
Sinan Kaya61b5f542017-06-29 22:30:58 -0400293 buf[i] = gen_dst_value(i, is_memset);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700294 }
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700295}
296
Dan Williams7b610172013-11-06 16:29:57 -0800297static void dmatest_mismatch(u8 actual, u8 pattern, unsigned int index,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400298 unsigned int counter, bool is_srcbuf, bool is_memset)
Dan Williams7b610172013-11-06 16:29:57 -0800299{
300 u8 diff = actual ^ pattern;
Sinan Kaya61b5f542017-06-29 22:30:58 -0400301 u8 expected = pattern | gen_inv_idx(counter, is_memset);
Dan Williams7b610172013-11-06 16:29:57 -0800302 const char *thread_name = current->comm;
303
304 if (is_srcbuf)
305 pr_warn("%s: srcbuf[0x%x] overwritten! Expected %02x, got %02x\n",
306 thread_name, index, expected, actual);
307 else if ((pattern & PATTERN_COPY)
308 && (diff & (PATTERN_COPY | PATTERN_OVERWRITE)))
309 pr_warn("%s: dstbuf[0x%x] not copied! Expected %02x, got %02x\n",
310 thread_name, index, expected, actual);
311 else if (diff & PATTERN_SRC)
312 pr_warn("%s: dstbuf[0x%x] was copied! Expected %02x, got %02x\n",
313 thread_name, index, expected, actual);
314 else
315 pr_warn("%s: dstbuf[0x%x] mismatch! Expected %02x, got %02x\n",
316 thread_name, index, expected, actual);
317}
318
319static unsigned int dmatest_verify(u8 **bufs, unsigned int start,
320 unsigned int end, unsigned int counter, u8 pattern,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400321 bool is_srcbuf, bool is_memset)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700322{
323 unsigned int i;
324 unsigned int error_count = 0;
325 u8 actual;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700326 u8 expected;
327 u8 *buf;
328 unsigned int counter_orig = counter;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700329
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700330 for (; (buf = *bufs); bufs++) {
331 counter = counter_orig;
332 for (i = start; i < end; i++) {
333 actual = buf[i];
Sinan Kaya61b5f542017-06-29 22:30:58 -0400334 expected = pattern | gen_inv_idx(counter, is_memset);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700335 if (actual != expected) {
Dan Williams7b610172013-11-06 16:29:57 -0800336 if (error_count < MAX_ERROR_COUNT)
337 dmatest_mismatch(actual, pattern, i,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400338 counter, is_srcbuf,
339 is_memset);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700340 error_count++;
341 }
342 counter++;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700343 }
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700344 }
345
Andy Shevchenko74b5c072013-03-04 11:09:32 +0200346 if (error_count > MAX_ERROR_COUNT)
Dan Williams7b610172013-11-06 16:29:57 -0800347 pr_warn("%s: %u errors suppressed\n",
Andy Shevchenko74b5c072013-03-04 11:09:32 +0200348 current->comm, error_count - MAX_ERROR_COUNT);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700349
350 return error_count;
351}
352
Tejun Heoadfa5432011-11-23 09:28:16 -0800353
354static void dmatest_callback(void *arg)
Dan Williamse44e0aa2009-03-25 09:13:25 -0700355{
Tejun Heoadfa5432011-11-23 09:28:16 -0800356 struct dmatest_done *done = arg;
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500357 struct dmatest_thread *thread =
358 container_of(arg, struct dmatest_thread, done_wait);
359 if (!thread->done) {
360 done->done = true;
361 wake_up_all(done->wait);
362 } else {
363 /*
364 * If thread->done, it means that this callback occurred
365 * after the parent thread has cleaned up. This can
366 * happen in the case that driver doesn't implement
367 * the terminate_all() functionality and a dma operation
368 * did not occur within the timeout period
369 */
370 WARN(1, "dmatest: Kernel memory may be corrupted!!\n");
371 }
Dan Williamse44e0aa2009-03-25 09:13:25 -0700372}
373
Akinobu Mita8be9e32b2012-10-28 00:49:32 +0900374static unsigned int min_odd(unsigned int x, unsigned int y)
375{
376 unsigned int val = min(x, y);
377
378 return val % 2 ? val : val - 1;
379}
380
Dan Williams872f05c2013-11-06 16:29:58 -0800381static void result(const char *err, unsigned int n, unsigned int src_off,
382 unsigned int dst_off, unsigned int len, unsigned long data)
Andy Shevchenkod86b2f22013-03-04 11:09:34 +0200383{
Jerome Blin2acec152014-03-04 10:38:55 +0100384 pr_info("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)\n",
Dan Williams872f05c2013-11-06 16:29:58 -0800385 current->comm, n, err, src_off, dst_off, len, data);
Andy Shevchenkod86b2f22013-03-04 11:09:34 +0200386}
387
Dan Williams872f05c2013-11-06 16:29:58 -0800388static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
389 unsigned int dst_off, unsigned int len,
390 unsigned long data)
Andy Shevchenko95019c82013-03-04 11:09:33 +0200391{
Jerome Blin2acec152014-03-04 10:38:55 +0100392 pr_debug("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)\n",
Andy Shevchenkoa835bb82014-10-22 16:16:42 +0300393 current->comm, n, err, src_off, dst_off, len, data);
Andy Shevchenko95019c82013-03-04 11:09:33 +0200394}
395
Andy Shevchenkoa835bb82014-10-22 16:16:42 +0300396#define verbose_result(err, n, src_off, dst_off, len, data) ({ \
397 if (verbose) \
398 result(err, n, src_off, dst_off, len, data); \
399 else \
400 dbg_result(err, n, src_off, dst_off, len, data);\
Dan Williams50137a72013-11-08 12:26:26 -0800401})
402
Dan Williams86727442013-11-06 16:30:07 -0800403static unsigned long long dmatest_persec(s64 runtime, unsigned int val)
Andy Shevchenko95019c82013-03-04 11:09:33 +0200404{
Dan Williams86727442013-11-06 16:30:07 -0800405 unsigned long long per_sec = 1000000;
Andy Shevchenko95019c82013-03-04 11:09:33 +0200406
Dan Williams86727442013-11-06 16:30:07 -0800407 if (runtime <= 0)
408 return 0;
Andy Shevchenko95019c82013-03-04 11:09:33 +0200409
Dan Williams86727442013-11-06 16:30:07 -0800410 /* drop precision until runtime is 32-bits */
411 while (runtime > UINT_MAX) {
412 runtime >>= 1;
413 per_sec <<= 1;
414 }
Andy Shevchenko95019c82013-03-04 11:09:33 +0200415
Dan Williams86727442013-11-06 16:30:07 -0800416 per_sec *= val;
417 do_div(per_sec, runtime);
418 return per_sec;
Andy Shevchenko95019c82013-03-04 11:09:33 +0200419}
420
Dan Williams86727442013-11-06 16:30:07 -0800421static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)
Andy Shevchenkod86b2f22013-03-04 11:09:34 +0200422{
Dan Williams86727442013-11-06 16:30:07 -0800423 return dmatest_persec(runtime, len >> 10);
Andy Shevchenko95019c82013-03-04 11:09:33 +0200424}
425
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700426/*
427 * This function repeatedly tests DMA transfers of various lengths and
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700428 * offsets for a given operation type until it is told to exit by
429 * kthread_stop(). There may be multiple threads running this function
430 * in parallel for a single channel, and there may be multiple channels
431 * being tested in parallel.
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700432 *
433 * Before each test, the source and destination buffer is initialized
434 * with a known pattern. This pattern is different depending on
435 * whether it's in an area which is supposed to be copied or
436 * overwritten, and different in the source and destination buffers.
437 * So if the DMA engine doesn't copy exactly what we tell it to copy,
438 * we'll notice.
439 */
440static int dmatest_func(void *data)
441{
442 struct dmatest_thread *thread = data;
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500443 struct dmatest_done *done = &thread->test_done;
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200444 struct dmatest_info *info;
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200445 struct dmatest_params *params;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700446 struct dma_chan *chan;
Akinobu Mita8be9e32b2012-10-28 00:49:32 +0900447 struct dma_device *dev;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700448 unsigned int error_count;
449 unsigned int failed_tests = 0;
450 unsigned int total_tests = 0;
451 dma_cookie_t cookie;
452 enum dma_status status;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700453 enum dma_ctrl_flags flags;
Andy Shevchenko945b5af2013-03-04 11:09:26 +0200454 u8 *pq_coefs = NULL;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700455 int ret;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700456 int src_cnt;
457 int dst_cnt;
458 int i;
Sinan Kayae9405ef2016-09-01 10:02:55 -0400459 ktime_t ktime, start, diff;
Thomas Gleixner8b0e1952016-12-25 12:30:41 +0100460 ktime_t filltime = 0;
461 ktime_t comparetime = 0;
Dan Williams86727442013-11-06 16:30:07 -0800462 s64 runtime = 0;
463 unsigned long long total_len = 0;
Dave Jiangd6481602016-11-29 13:22:20 -0700464 u8 align = 0;
Sinan Kaya61b5f542017-06-29 22:30:58 -0400465 bool is_memset = false;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700466
Tejun Heoadfa5432011-11-23 09:28:16 -0800467 set_freezable();
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700468
469 ret = -ENOMEM;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700470
471 smp_rmb();
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200472 info = thread->info;
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200473 params = &info->params;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700474 chan = thread->chan;
Akinobu Mita8be9e32b2012-10-28 00:49:32 +0900475 dev = chan->device;
Dave Jiangd6481602016-11-29 13:22:20 -0700476 if (thread->type == DMA_MEMCPY) {
477 align = dev->copy_align;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700478 src_cnt = dst_cnt = 1;
Sinan Kaya61b5f542017-06-29 22:30:58 -0400479 } else if (thread->type == DMA_MEMSET) {
480 align = dev->fill_align;
481 src_cnt = dst_cnt = 1;
482 is_memset = true;
Dave Jiangd6481602016-11-29 13:22:20 -0700483 } else if (thread->type == DMA_XOR) {
Akinobu Mita8be9e32b2012-10-28 00:49:32 +0900484 /* force odd to ensure dst = src */
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200485 src_cnt = min_odd(params->xor_sources | 1, dev->max_xor);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700486 dst_cnt = 1;
Dave Jiangd6481602016-11-29 13:22:20 -0700487 align = dev->xor_align;
Dan Williams58691d62009-08-29 19:09:27 -0700488 } else if (thread->type == DMA_PQ) {
Akinobu Mita8be9e32b2012-10-28 00:49:32 +0900489 /* force odd to ensure dst = src */
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200490 src_cnt = min_odd(params->pq_sources | 1, dma_maxpq(dev, 0));
Dan Williams58691d62009-08-29 19:09:27 -0700491 dst_cnt = 2;
Dave Jiangd6481602016-11-29 13:22:20 -0700492 align = dev->pq_align;
Andy Shevchenko945b5af2013-03-04 11:09:26 +0200493
Dave Jiang31d18252016-11-29 13:22:01 -0700494 pq_coefs = kmalloc(params->pq_sources + 1, GFP_KERNEL);
Andy Shevchenko945b5af2013-03-04 11:09:26 +0200495 if (!pq_coefs)
496 goto err_thread_type;
497
Anatolij Gustschin94de6482010-02-15 22:35:23 +0100498 for (i = 0; i < src_cnt; i++)
Dan Williams58691d62009-08-29 19:09:27 -0700499 pq_coefs[i] = 1;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700500 } else
Andy Shevchenko945b5af2013-03-04 11:09:26 +0200501 goto err_thread_type;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700502
Dave Jiang31d18252016-11-29 13:22:01 -0700503 thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700504 if (!thread->srcs)
505 goto err_srcs;
Dave Jiangd6481602016-11-29 13:22:20 -0700506
507 thread->usrcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL);
508 if (!thread->usrcs)
509 goto err_usrcs;
510
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700511 for (i = 0; i < src_cnt; i++) {
Dave Jiangd6481602016-11-29 13:22:20 -0700512 thread->usrcs[i] = kmalloc(params->buf_size + align,
513 GFP_KERNEL);
514 if (!thread->usrcs[i])
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700515 goto err_srcbuf;
Dave Jiangd6481602016-11-29 13:22:20 -0700516
517 /* align srcs to alignment restriction */
518 if (align)
519 thread->srcs[i] = PTR_ALIGN(thread->usrcs[i], align);
520 else
521 thread->srcs[i] = thread->usrcs[i];
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700522 }
523 thread->srcs[i] = NULL;
524
Dave Jiang31d18252016-11-29 13:22:01 -0700525 thread->dsts = kcalloc(dst_cnt + 1, sizeof(u8 *), GFP_KERNEL);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700526 if (!thread->dsts)
527 goto err_dsts;
Dave Jiangd6481602016-11-29 13:22:20 -0700528
529 thread->udsts = kcalloc(dst_cnt + 1, sizeof(u8 *), GFP_KERNEL);
530 if (!thread->udsts)
531 goto err_udsts;
532
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700533 for (i = 0; i < dst_cnt; i++) {
Dave Jiangd6481602016-11-29 13:22:20 -0700534 thread->udsts[i] = kmalloc(params->buf_size + align,
535 GFP_KERNEL);
536 if (!thread->udsts[i])
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700537 goto err_dstbuf;
Dave Jiangd6481602016-11-29 13:22:20 -0700538
539 /* align dsts to alignment restriction */
540 if (align)
541 thread->dsts[i] = PTR_ALIGN(thread->udsts[i], align);
542 else
543 thread->dsts[i] = thread->udsts[i];
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700544 }
545 thread->dsts[i] = NULL;
546
Dan Williamse44e0aa2009-03-25 09:13:25 -0700547 set_user_nice(current, 10);
548
Ira Snyderb203bd32011-03-03 07:54:53 +0000549 /*
Bartlomiej Zolnierkiewiczd1cab342013-10-18 19:35:21 +0200550 * src and dst buffers are freed by ourselves below
Ira Snyderb203bd32011-03-03 07:54:53 +0000551 */
Bartlomiej Zolnierkiewicz0776ae72013-10-18 19:35:33 +0200552 flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700553
Dan Williams86727442013-11-06 16:30:07 -0800554 ktime = ktime_get();
Nicolas Ferre0a2ff57d2009-07-03 19:26:51 +0200555 while (!kthread_should_stop()
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200556 && !(params->iterations && total_tests >= params->iterations)) {
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700557 struct dma_async_tx_descriptor *tx = NULL;
Dan Williams4076e752013-11-06 16:30:10 -0800558 struct dmaengine_unmap_data *um;
559 dma_addr_t srcs[src_cnt];
560 dma_addr_t *dsts;
Andy Shevchenkoede23a52014-10-22 16:16:43 +0300561 unsigned int src_off, dst_off, len;
Atsushi Nemotod86be86e2009-01-13 09:22:20 -0700562
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700563 total_tests++;
564
Stefan Roesefbfb8e12017-04-27 14:21:41 +0200565 /* Check if buffer count fits into map count variable (u8) */
566 if ((src_cnt + dst_cnt) >= 255) {
567 pr_err("too many buffers (%d of 255 supported)\n",
568 src_cnt + dst_cnt);
569 break;
570 }
571
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200572 if (1 << align > params->buf_size) {
Guennadi Liakhovetskicfe4f272009-12-04 19:44:48 +0100573 pr_err("%u-byte buffer too small for %d-byte alignment\n",
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200574 params->buf_size, 1 << align);
Guennadi Liakhovetskicfe4f272009-12-04 19:44:48 +0100575 break;
576 }
577
Andy Shevchenkoede23a52014-10-22 16:16:43 +0300578 if (params->noverify)
Dan Williamse3b9c342013-11-06 16:30:05 -0800579 len = params->buf_size;
Andy Shevchenkoede23a52014-10-22 16:16:43 +0300580 else
581 len = dmatest_random() % params->buf_size + 1;
582
583 len = (len >> align) << align;
584 if (!len)
585 len = 1 << align;
586
587 total_len += len;
588
589 if (params->noverify) {
Dan Williamse3b9c342013-11-06 16:30:05 -0800590 src_off = 0;
591 dst_off = 0;
592 } else {
Sinan Kayae9405ef2016-09-01 10:02:55 -0400593 start = ktime_get();
Dan Williamse3b9c342013-11-06 16:30:05 -0800594 src_off = dmatest_random() % (params->buf_size - len + 1);
595 dst_off = dmatest_random() % (params->buf_size - len + 1);
596
597 src_off = (src_off >> align) << align;
598 dst_off = (dst_off >> align) << align;
599
600 dmatest_init_srcs(thread->srcs, src_off, len,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400601 params->buf_size, is_memset);
Dan Williamse3b9c342013-11-06 16:30:05 -0800602 dmatest_init_dsts(thread->dsts, dst_off, len,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400603 params->buf_size, is_memset);
Sinan Kayae9405ef2016-09-01 10:02:55 -0400604
605 diff = ktime_sub(ktime_get(), start);
606 filltime = ktime_add(filltime, diff);
Dan Williamse3b9c342013-11-06 16:30:05 -0800607 }
608
Dave Jiang31d18252016-11-29 13:22:01 -0700609 um = dmaengine_get_unmap_data(dev->dev, src_cnt + dst_cnt,
Dan Williams4076e752013-11-06 16:30:10 -0800610 GFP_KERNEL);
611 if (!um) {
612 failed_tests++;
613 result("unmap data NULL", total_tests,
614 src_off, dst_off, len, ret);
615 continue;
616 }
Dan Williams83544ae2009-09-08 17:42:53 -0700617
Dan Williams4076e752013-11-06 16:30:10 -0800618 um->len = params->buf_size;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700619 for (i = 0; i < src_cnt; i++) {
Dan Williams745c00d2013-12-09 11:16:01 -0800620 void *buf = thread->srcs[i];
Dan Williams4076e752013-11-06 16:30:10 -0800621 struct page *pg = virt_to_page(buf);
Geliang Tangf62e5f62017-04-22 09:18:03 +0800622 unsigned long pg_off = offset_in_page(buf);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700623
Dan Williams4076e752013-11-06 16:30:10 -0800624 um->addr[i] = dma_map_page(dev->dev, pg, pg_off,
625 um->len, DMA_TO_DEVICE);
626 srcs[i] = um->addr[i] + src_off;
627 ret = dma_mapping_error(dev->dev, um->addr[i]);
Andy Shevchenkoafde3be2012-12-17 15:59:53 -0800628 if (ret) {
Dan Williams4076e752013-11-06 16:30:10 -0800629 dmaengine_unmap_put(um);
Dan Williams872f05c2013-11-06 16:29:58 -0800630 result("src mapping error", total_tests,
631 src_off, dst_off, len, ret);
Andy Shevchenkoafde3be2012-12-17 15:59:53 -0800632 failed_tests++;
633 continue;
634 }
Dan Williams4076e752013-11-06 16:30:10 -0800635 um->to_cnt++;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700636 }
Atsushi Nemotod86be86e2009-01-13 09:22:20 -0700637 /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
Dan Williams4076e752013-11-06 16:30:10 -0800638 dsts = &um->addr[src_cnt];
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700639 for (i = 0; i < dst_cnt; i++) {
Dan Williams745c00d2013-12-09 11:16:01 -0800640 void *buf = thread->dsts[i];
Dan Williams4076e752013-11-06 16:30:10 -0800641 struct page *pg = virt_to_page(buf);
Geliang Tangf62e5f62017-04-22 09:18:03 +0800642 unsigned long pg_off = offset_in_page(buf);
Dan Williams4076e752013-11-06 16:30:10 -0800643
644 dsts[i] = dma_map_page(dev->dev, pg, pg_off, um->len,
645 DMA_BIDIRECTIONAL);
646 ret = dma_mapping_error(dev->dev, dsts[i]);
Andy Shevchenkoafde3be2012-12-17 15:59:53 -0800647 if (ret) {
Dan Williams4076e752013-11-06 16:30:10 -0800648 dmaengine_unmap_put(um);
Dan Williams872f05c2013-11-06 16:29:58 -0800649 result("dst mapping error", total_tests,
650 src_off, dst_off, len, ret);
Andy Shevchenkoafde3be2012-12-17 15:59:53 -0800651 failed_tests++;
652 continue;
653 }
Dan Williams4076e752013-11-06 16:30:10 -0800654 um->bidi_cnt++;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700655 }
Atsushi Nemotod86be86e2009-01-13 09:22:20 -0700656
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700657 if (thread->type == DMA_MEMCPY)
658 tx = dev->device_prep_dma_memcpy(chan,
Dan Williams4076e752013-11-06 16:30:10 -0800659 dsts[0] + dst_off,
660 srcs[0], len, flags);
Sinan Kaya61b5f542017-06-29 22:30:58 -0400661 else if (thread->type == DMA_MEMSET)
662 tx = dev->device_prep_dma_memset(chan,
663 dsts[0] + dst_off,
664 *(thread->srcs[0] + src_off),
665 len, flags);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700666 else if (thread->type == DMA_XOR)
667 tx = dev->device_prep_dma_xor(chan,
Dan Williams4076e752013-11-06 16:30:10 -0800668 dsts[0] + dst_off,
669 srcs, src_cnt,
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700670 len, flags);
Dan Williams58691d62009-08-29 19:09:27 -0700671 else if (thread->type == DMA_PQ) {
672 dma_addr_t dma_pq[dst_cnt];
673
674 for (i = 0; i < dst_cnt; i++)
Dan Williams4076e752013-11-06 16:30:10 -0800675 dma_pq[i] = dsts[i] + dst_off;
676 tx = dev->device_prep_dma_pq(chan, dma_pq, srcs,
Anatolij Gustschin94de6482010-02-15 22:35:23 +0100677 src_cnt, pq_coefs,
Dan Williams58691d62009-08-29 19:09:27 -0700678 len, flags);
679 }
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700680
Atsushi Nemotod86be86e2009-01-13 09:22:20 -0700681 if (!tx) {
Dan Williams4076e752013-11-06 16:30:10 -0800682 dmaengine_unmap_put(um);
Dan Williams872f05c2013-11-06 16:29:58 -0800683 result("prep error", total_tests, src_off,
684 dst_off, len, ret);
Atsushi Nemotod86be86e2009-01-13 09:22:20 -0700685 msleep(100);
686 failed_tests++;
687 continue;
688 }
Dan Williamse44e0aa2009-03-25 09:13:25 -0700689
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500690 done->done = false;
Dan Williamse44e0aa2009-03-25 09:13:25 -0700691 tx->callback = dmatest_callback;
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500692 tx->callback_param = done;
Atsushi Nemotod86be86e2009-01-13 09:22:20 -0700693 cookie = tx->tx_submit(tx);
694
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700695 if (dma_submit_error(cookie)) {
Dan Williams4076e752013-11-06 16:30:10 -0800696 dmaengine_unmap_put(um);
Dan Williams872f05c2013-11-06 16:29:58 -0800697 result("submit error", total_tests, src_off,
698 dst_off, len, ret);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700699 msleep(100);
700 failed_tests++;
701 continue;
702 }
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700703 dma_async_issue_pending(chan);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700704
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500705 wait_event_freezable_timeout(thread->done_wait, done->done,
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200706 msecs_to_jiffies(params->timeout));
Guennadi Liakhovetski981ed702011-08-18 16:50:51 +0200707
Dan Williamse44e0aa2009-03-25 09:13:25 -0700708 status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700709
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500710 if (!done->done) {
Dan Williams4076e752013-11-06 16:30:10 -0800711 dmaengine_unmap_put(um);
Dan Williams872f05c2013-11-06 16:29:58 -0800712 result("test timed out", total_tests, src_off, dst_off,
713 len, 0);
Dan Williamse44e0aa2009-03-25 09:13:25 -0700714 failed_tests++;
715 continue;
Vinod Koul19e9f992013-10-16 13:37:27 +0530716 } else if (status != DMA_COMPLETE) {
Dan Williams4076e752013-11-06 16:30:10 -0800717 dmaengine_unmap_put(um);
Dan Williams872f05c2013-11-06 16:29:58 -0800718 result(status == DMA_ERROR ?
719 "completion error status" :
720 "completion busy status", total_tests, src_off,
721 dst_off, len, ret);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700722 failed_tests++;
723 continue;
724 }
Dan Williamse44e0aa2009-03-25 09:13:25 -0700725
Dan Williams4076e752013-11-06 16:30:10 -0800726 dmaengine_unmap_put(um);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700727
Dan Williamse3b9c342013-11-06 16:30:05 -0800728 if (params->noverify) {
Dan Williams50137a72013-11-08 12:26:26 -0800729 verbose_result("test passed", total_tests, src_off,
730 dst_off, len, 0);
Dan Williamse3b9c342013-11-06 16:30:05 -0800731 continue;
732 }
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700733
Sinan Kayae9405ef2016-09-01 10:02:55 -0400734 start = ktime_get();
Dan Williams872f05c2013-11-06 16:29:58 -0800735 pr_debug("%s: verifying source buffer...\n", current->comm);
Dan Williamse3b9c342013-11-06 16:30:05 -0800736 error_count = dmatest_verify(thread->srcs, 0, src_off,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400737 0, PATTERN_SRC, true, is_memset);
Dan Williams7b610172013-11-06 16:29:57 -0800738 error_count += dmatest_verify(thread->srcs, src_off,
739 src_off + len, src_off,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400740 PATTERN_SRC | PATTERN_COPY, true, is_memset);
Dan Williams7b610172013-11-06 16:29:57 -0800741 error_count += dmatest_verify(thread->srcs, src_off + len,
742 params->buf_size, src_off + len,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400743 PATTERN_SRC, true, is_memset);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700744
Dan Williams872f05c2013-11-06 16:29:58 -0800745 pr_debug("%s: verifying dest buffer...\n", current->comm);
Dan Williams7b610172013-11-06 16:29:57 -0800746 error_count += dmatest_verify(thread->dsts, 0, dst_off,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400747 0, PATTERN_DST, false, is_memset);
748
Dan Williams7b610172013-11-06 16:29:57 -0800749 error_count += dmatest_verify(thread->dsts, dst_off,
750 dst_off + len, src_off,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400751 PATTERN_SRC | PATTERN_COPY, false, is_memset);
752
Dan Williams7b610172013-11-06 16:29:57 -0800753 error_count += dmatest_verify(thread->dsts, dst_off + len,
754 params->buf_size, dst_off + len,
Sinan Kaya61b5f542017-06-29 22:30:58 -0400755 PATTERN_DST, false, is_memset);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700756
Sinan Kayae9405ef2016-09-01 10:02:55 -0400757 diff = ktime_sub(ktime_get(), start);
758 comparetime = ktime_add(comparetime, diff);
759
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700760 if (error_count) {
Dan Williams872f05c2013-11-06 16:29:58 -0800761 result("data error", total_tests, src_off, dst_off,
762 len, error_count);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700763 failed_tests++;
764 } else {
Dan Williams50137a72013-11-08 12:26:26 -0800765 verbose_result("test passed", total_tests, src_off,
766 dst_off, len, 0);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700767 }
768 }
Sinan Kayae9405ef2016-09-01 10:02:55 -0400769 ktime = ktime_sub(ktime_get(), ktime);
770 ktime = ktime_sub(ktime, comparetime);
771 ktime = ktime_sub(ktime, filltime);
772 runtime = ktime_to_us(ktime);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700773
774 ret = 0;
Andy Shevchenko8e1f50d2014-08-22 15:19:44 +0300775err_dstbuf:
Dave Jiangd6481602016-11-29 13:22:20 -0700776 for (i = 0; thread->udsts[i]; i++)
777 kfree(thread->udsts[i]);
778 kfree(thread->udsts);
779err_udsts:
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700780 kfree(thread->dsts);
781err_dsts:
Andy Shevchenko8e1f50d2014-08-22 15:19:44 +0300782err_srcbuf:
Dave Jiangd6481602016-11-29 13:22:20 -0700783 for (i = 0; thread->usrcs[i]; i++)
784 kfree(thread->usrcs[i]);
785 kfree(thread->usrcs);
786err_usrcs:
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700787 kfree(thread->srcs);
788err_srcs:
Andy Shevchenko945b5af2013-03-04 11:09:26 +0200789 kfree(pq_coefs);
790err_thread_type:
Dan Williams86727442013-11-06 16:30:07 -0800791 pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
792 current->comm, total_tests, failed_tests,
793 dmatest_persec(runtime, total_tests),
794 dmatest_KBs(runtime, total_len), ret);
Nicolas Ferre0a2ff57d2009-07-03 19:26:51 +0200795
Viresh Kumar9704efa2011-07-29 16:21:57 +0530796 /* terminate all transfers on specified channels */
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500797 if (ret || failed_tests)
Shiraz Hashim5e034f72012-11-09 15:26:29 +0000798 dmaengine_terminate_all(chan);
799
Andy Shevchenko3e5ccd82013-03-04 11:09:31 +0200800 thread->done = true;
Dan Williams2d88ce72013-11-06 16:30:09 -0800801 wake_up(&thread_wait);
Nicolas Ferre0a2ff57d2009-07-03 19:26:51 +0200802
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700803 return ret;
804}
805
806static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
807{
808 struct dmatest_thread *thread;
809 struct dmatest_thread *_thread;
810 int ret;
811
812 list_for_each_entry_safe(thread, _thread, &dtc->threads, node) {
813 ret = kthread_stop(thread->task);
Dan Williams0adff802013-11-06 16:30:00 -0800814 pr_debug("thread %s exited with status %d\n",
815 thread->task->comm, ret);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700816 list_del(&thread->node);
Dan Williams2d88ce72013-11-06 16:30:09 -0800817 put_task_struct(thread->task);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700818 kfree(thread);
819 }
Viresh Kumar9704efa2011-07-29 16:21:57 +0530820
821 /* terminate all transfers on specified channels */
Jon Mason944ea4d2012-11-11 23:03:20 +0000822 dmaengine_terminate_all(dtc->chan);
Viresh Kumar9704efa2011-07-29 16:21:57 +0530823
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700824 kfree(dtc);
825}
826
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200827static int dmatest_add_threads(struct dmatest_info *info,
828 struct dmatest_chan *dtc, enum dma_transaction_type type)
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700829{
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200830 struct dmatest_params *params = &info->params;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700831 struct dmatest_thread *thread;
832 struct dma_chan *chan = dtc->chan;
833 char *op;
834 unsigned int i;
835
836 if (type == DMA_MEMCPY)
837 op = "copy";
Sinan Kaya61b5f542017-06-29 22:30:58 -0400838 else if (type == DMA_MEMSET)
839 op = "set";
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700840 else if (type == DMA_XOR)
841 op = "xor";
Dan Williams58691d62009-08-29 19:09:27 -0700842 else if (type == DMA_PQ)
843 op = "pq";
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700844 else
845 return -EINVAL;
846
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200847 for (i = 0; i < params->threads_per_chan; i++) {
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700848 thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL);
849 if (!thread) {
Dan Williams0adff802013-11-06 16:30:00 -0800850 pr_warn("No memory for %s-%s%u\n",
851 dma_chan_name(chan), op, i);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700852 break;
853 }
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200854 thread->info = info;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700855 thread->chan = dtc->chan;
856 thread->type = type;
Adam Wallis6f6a23a2017-11-27 10:45:01 -0500857 thread->test_done.wait = &thread->done_wait;
858 init_waitqueue_head(&thread->done_wait);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700859 smp_wmb();
Dan Williams2d88ce72013-11-06 16:30:09 -0800860 thread->task = kthread_create(dmatest_func, thread, "%s-%s%u",
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700861 dma_chan_name(chan), op, i);
862 if (IS_ERR(thread->task)) {
Dan Williams2d88ce72013-11-06 16:30:09 -0800863 pr_warn("Failed to create thread %s-%s%u\n",
Dan Williams0adff802013-11-06 16:30:00 -0800864 dma_chan_name(chan), op, i);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700865 kfree(thread);
866 break;
867 }
868
869 /* srcbuf and dstbuf are allocated by the thread itself */
Dan Williams2d88ce72013-11-06 16:30:09 -0800870 get_task_struct(thread->task);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700871 list_add_tail(&thread->node, &dtc->threads);
Dan Williams2d88ce72013-11-06 16:30:09 -0800872 wake_up_process(thread->task);
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700873 }
874
875 return i;
876}
877
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200878static int dmatest_add_channel(struct dmatest_info *info,
879 struct dma_chan *chan)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700880{
881 struct dmatest_chan *dtc;
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700882 struct dma_device *dma_dev = chan->device;
883 unsigned int thread_count = 0;
Kulikov Vasiliyb9033e62010-07-17 19:19:48 +0400884 int cnt;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700885
Andrew Morton6fdb8bd2008-09-19 04:16:23 -0700886 dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700887 if (!dtc) {
Dan Williams0adff802013-11-06 16:30:00 -0800888 pr_warn("No memory for %s\n", dma_chan_name(chan));
Dan Williams33df8ca2009-01-06 11:38:15 -0700889 return -ENOMEM;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700890 }
891
892 dtc->chan = chan;
893 INIT_LIST_HEAD(&dtc->threads);
894
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700895 if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) {
Kedareswara rao Appanaa0d4cb42016-06-09 21:10:14 +0530896 if (dmatest == 0) {
897 cnt = dmatest_add_threads(info, dtc, DMA_MEMCPY);
898 thread_count += cnt > 0 ? cnt : 0;
899 }
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700900 }
Kedareswara rao Appanaa0d4cb42016-06-09 21:10:14 +0530901
Sinan Kaya61b5f542017-06-29 22:30:58 -0400902 if (dma_has_cap(DMA_MEMSET, dma_dev->cap_mask)) {
Kedareswara rao Appanaa0d4cb42016-06-09 21:10:14 +0530903 if (dmatest == 1) {
Dave Jiangc678fa62017-08-21 10:23:13 -0700904 cnt = dmatest_add_threads(info, dtc, DMA_MEMSET);
Kedareswara rao Appanaa0d4cb42016-06-09 21:10:14 +0530905 thread_count += cnt > 0 ? cnt : 0;
906 }
907 }
908
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700909 if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200910 cnt = dmatest_add_threads(info, dtc, DMA_XOR);
Nicolas Ferref1aef8b2009-07-06 18:19:44 +0200911 thread_count += cnt > 0 ? cnt : 0;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700912 }
Dan Williams58691d62009-08-29 19:09:27 -0700913 if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) {
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200914 cnt = dmatest_add_threads(info, dtc, DMA_PQ);
Dr. David Alan Gilbertd07a74a2011-08-25 16:13:55 -0700915 thread_count += cnt > 0 ? cnt : 0;
Dan Williams58691d62009-08-29 19:09:27 -0700916 }
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700917
Dan Williams0adff802013-11-06 16:30:00 -0800918 pr_info("Started %u threads using %s\n",
Dan Williamsb54d5cb2009-03-25 09:13:25 -0700919 thread_count, dma_chan_name(chan));
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700920
Andy Shevchenko838cc702013-03-04 11:09:28 +0200921 list_add_tail(&dtc->node, &info->channels);
922 info->nr_channels++;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700923
Dan Williams33df8ca2009-01-06 11:38:15 -0700924 return 0;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700925}
926
Dan Williams7dd60252009-01-06 11:38:19 -0700927static bool filter(struct dma_chan *chan, void *param)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700928{
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200929 struct dmatest_params *params = param;
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200930
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200931 if (!dmatest_match_channel(params, chan) ||
932 !dmatest_match_device(params, chan->device))
Dan Williams7dd60252009-01-06 11:38:19 -0700933 return false;
Dan Williams33df8ca2009-01-06 11:38:15 -0700934 else
Dan Williams7dd60252009-01-06 11:38:19 -0700935 return true;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700936}
937
Dan Williamsa9e55492013-11-06 16:30:02 -0800938static void request_channels(struct dmatest_info *info,
939 enum dma_transaction_type type)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700940{
Dan Williams33df8ca2009-01-06 11:38:15 -0700941 dma_cap_mask_t mask;
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700942
Dan Williams33df8ca2009-01-06 11:38:15 -0700943 dma_cap_zero(mask);
Dan Williamsa9e55492013-11-06 16:30:02 -0800944 dma_cap_set(type, mask);
Dan Williams33df8ca2009-01-06 11:38:15 -0700945 for (;;) {
Dan Williamsa9e55492013-11-06 16:30:02 -0800946 struct dmatest_params *params = &info->params;
947 struct dma_chan *chan;
948
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200949 chan = dma_request_channel(mask, filter, params);
Dan Williams33df8ca2009-01-06 11:38:15 -0700950 if (chan) {
Dan Williamsa9e55492013-11-06 16:30:02 -0800951 if (dmatest_add_channel(info, chan)) {
Dan Williams33df8ca2009-01-06 11:38:15 -0700952 dma_release_channel(chan);
953 break; /* add_channel failed, punt */
954 }
955 } else
956 break; /* no more channels available */
Andy Shevchenko15b8a8e2013-03-04 11:09:29 +0200957 if (params->max_channels &&
958 info->nr_channels >= params->max_channels)
Dan Williams33df8ca2009-01-06 11:38:15 -0700959 break; /* we have all we need */
960 }
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700961}
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700962
Dan Williamsa9e55492013-11-06 16:30:02 -0800963static void run_threaded_test(struct dmatest_info *info)
Andy Shevchenko851b7e12013-03-04 11:09:30 +0200964{
965 struct dmatest_params *params = &info->params;
Andy Shevchenko851b7e12013-03-04 11:09:30 +0200966
Andy Shevchenko851b7e12013-03-04 11:09:30 +0200967 /* Copy test parameters */
Andy Shevchenkoa6c268d2013-07-23 18:36:46 +0300968 params->buf_size = test_buf_size;
969 strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
970 strlcpy(params->device, strim(test_device), sizeof(params->device));
971 params->threads_per_chan = threads_per_chan;
972 params->max_channels = max_channels;
973 params->iterations = iterations;
974 params->xor_sources = xor_sources;
975 params->pq_sources = pq_sources;
976 params->timeout = timeout;
Dan Williamse3b9c342013-11-06 16:30:05 -0800977 params->noverify = noverify;
Dan Williamsa310d032013-11-06 16:30:01 -0800978
Dan Williamsa9e55492013-11-06 16:30:02 -0800979 request_channels(info, DMA_MEMCPY);
Sinan Kaya61b5f542017-06-29 22:30:58 -0400980 request_channels(info, DMA_MEMSET);
Dan Williamsa9e55492013-11-06 16:30:02 -0800981 request_channels(info, DMA_XOR);
982 request_channels(info, DMA_PQ);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700983}
984
Dan Williamsa310d032013-11-06 16:30:01 -0800985static void stop_threaded_test(struct dmatest_info *info)
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700986{
987 struct dmatest_chan *dtc, *_dtc;
988 struct dma_chan *chan;
989
990 list_for_each_entry_safe(dtc, _dtc, &info->channels, node) {
991 list_del(&dtc->node);
992 chan = dtc->chan;
993 dmatest_cleanup_channel(dtc);
Dan Williams0adff802013-11-06 16:30:00 -0800994 pr_debug("dropped channel %s\n", dma_chan_name(chan));
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +0200995 dma_release_channel(chan);
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -0700996 }
Dan Williams33df8ca2009-01-06 11:38:15 -0700997
Dan Williams7cbd4872009-03-04 16:06:03 -0700998 info->nr_channels = 0;
Dan Williams33df8ca2009-01-06 11:38:15 -0700999}
Andy Shevchenko838cc702013-03-04 11:09:28 +02001000
Dan Williamsa9e55492013-11-06 16:30:02 -08001001static void restart_threaded_test(struct dmatest_info *info, bool run)
Dan Williams7cbd4872009-03-04 16:06:03 -07001002{
Dan Williamsa310d032013-11-06 16:30:01 -08001003 /* we might be called early to set run=, defer running until all
1004 * parameters have been evaluated
1005 */
1006 if (!info->did_init)
Dan Williamsa9e55492013-11-06 16:30:02 -08001007 return;
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001008
Dan Williamsa310d032013-11-06 16:30:01 -08001009 /* Stop any running test first */
1010 stop_threaded_test(info);
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001011
1012 /* Run test with new parameters */
Dan Williamsa9e55492013-11-06 16:30:02 -08001013 run_threaded_test(info);
Andy Shevchenkobcc567e2013-05-23 14:29:53 +03001014}
1015
Dan Williamsa310d032013-11-06 16:30:01 -08001016static int dmatest_run_get(char *val, const struct kernel_param *kp)
Andy Shevchenkobcc567e2013-05-23 14:29:53 +03001017{
Dan Williamsa310d032013-11-06 16:30:01 -08001018 struct dmatest_info *info = &test_info;
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001019
1020 mutex_lock(&info->lock);
Dan Williamsa310d032013-11-06 16:30:01 -08001021 if (is_threaded_test_run(info)) {
1022 dmatest_run = true;
Andy Shevchenko3e5ccd82013-03-04 11:09:31 +02001023 } else {
Dan Williamsa310d032013-11-06 16:30:01 -08001024 stop_threaded_test(info);
1025 dmatest_run = false;
Andy Shevchenko3e5ccd82013-03-04 11:09:31 +02001026 }
Dan Williamsa310d032013-11-06 16:30:01 -08001027 mutex_unlock(&info->lock);
1028
1029 return param_get_bool(val, kp);
1030}
1031
1032static int dmatest_run_set(const char *val, const struct kernel_param *kp)
1033{
1034 struct dmatest_info *info = &test_info;
1035 int ret;
1036
1037 mutex_lock(&info->lock);
1038 ret = param_set_bool(val, kp);
1039 if (ret) {
1040 mutex_unlock(&info->lock);
1041 return ret;
1042 }
1043
1044 if (is_threaded_test_run(info))
1045 ret = -EBUSY;
1046 else if (dmatest_run)
Dan Williamsa9e55492013-11-06 16:30:02 -08001047 restart_threaded_test(info, dmatest_run);
Andy Shevchenko3e5ccd82013-03-04 11:09:31 +02001048
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001049 mutex_unlock(&info->lock);
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001050
Dan Williamsa310d032013-11-06 16:30:01 -08001051 return ret;
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001052}
1053
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +02001054static int __init dmatest_init(void)
1055{
1056 struct dmatest_info *info = &test_info;
Dan Williams2d88ce72013-11-06 16:30:09 -08001057 struct dmatest_params *params = &info->params;
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +02001058
Dan Williamsa310d032013-11-06 16:30:01 -08001059 if (dmatest_run) {
1060 mutex_lock(&info->lock);
Dan Williamsa9e55492013-11-06 16:30:02 -08001061 run_threaded_test(info);
Dan Williamsa310d032013-11-06 16:30:01 -08001062 mutex_unlock(&info->lock);
1063 }
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +02001064
Dan Williams2d88ce72013-11-06 16:30:09 -08001065 if (params->iterations && wait)
1066 wait_event(thread_wait, !is_threaded_test_run(info));
Andy Shevchenko838cc702013-03-04 11:09:28 +02001067
Dan Williamsa310d032013-11-06 16:30:01 -08001068 /* module parameters are stable, inittime tests are started,
1069 * let userspace take over 'run' control
1070 */
1071 info->did_init = true;
Andy Shevchenko95019c82013-03-04 11:09:33 +02001072
Andy Shevchenko851b7e12013-03-04 11:09:30 +02001073 return 0;
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +02001074}
1075/* when compiled-in wait for drivers to load first */
1076late_initcall(dmatest_init);
1077
1078static void __exit dmatest_exit(void)
1079{
1080 struct dmatest_info *info = &test_info;
1081
Dan Williamsa310d032013-11-06 16:30:01 -08001082 mutex_lock(&info->lock);
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +02001083 stop_threaded_test(info);
Dan Williamsa310d032013-11-06 16:30:01 -08001084 mutex_unlock(&info->lock);
Andy Shevchenkoe03e93a2013-03-04 11:09:27 +02001085}
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -07001086module_exit(dmatest_exit);
1087
Jean Delvaree05503e2011-05-18 16:49:24 +02001088MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
Haavard Skinnemoen4a776f02008-07-08 11:58:45 -07001089MODULE_LICENSE("GPL v2");