dmatest.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * DMA Engine test module
  3. *
  4. * Copyright (C) 2007 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/delay.h>
  11. #include <linux/dmaengine.h>
  12. #include <linux/init.h>
  13. #include <linux/kthread.h>
  14. #include <linux/module.h>
  15. #include <linux/moduleparam.h>
  16. #include <linux/random.h>
  17. #include <linux/slab.h>
  18. #include <linux/wait.h>
  19. static unsigned int test_buf_size = 16384;
  20. module_param(test_buf_size, uint, S_IRUGO);
  21. MODULE_PARM_DESC(test_buf_size, "Size of the memcpy test buffer");
  22. static char test_channel[20];
  23. module_param_string(channel, test_channel, sizeof(test_channel), S_IRUGO);
  24. MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)");
  25. static char test_device[20];
  26. module_param_string(device, test_device, sizeof(test_device), S_IRUGO);
  27. MODULE_PARM_DESC(device, "Bus ID of the DMA Engine to test (default: any)");
  28. static unsigned int threads_per_chan = 1;
  29. module_param(threads_per_chan, uint, S_IRUGO);
  30. MODULE_PARM_DESC(threads_per_chan,
  31. "Number of threads to start per channel (default: 1)");
  32. static unsigned int max_channels;
  33. module_param(max_channels, uint, S_IRUGO);
  34. MODULE_PARM_DESC(max_channels,
  35. "Maximum number of channels to use (default: all)");
  36. static unsigned int iterations;
  37. module_param(iterations, uint, S_IRUGO);
  38. MODULE_PARM_DESC(iterations,
  39. "Iterations before stopping test (default: infinite)");
  40. static unsigned int xor_sources = 3;
  41. module_param(xor_sources, uint, S_IRUGO);
  42. MODULE_PARM_DESC(xor_sources,
  43. "Number of xor source buffers (default: 3)");
  44. static unsigned int pq_sources = 3;
  45. module_param(pq_sources, uint, S_IRUGO);
  46. MODULE_PARM_DESC(pq_sources,
  47. "Number of p+q source buffers (default: 3)");
  48. static int timeout = 3000;
  49. module_param(timeout, uint, S_IRUGO);
  50. MODULE_PARM_DESC(timeout, "Transfer Timeout in msec (default: 3000), "
  51. "Pass -1 for infinite timeout");
  52. /*
  53. * Initialization patterns. All bytes in the source buffer has bit 7
  54. * set, all bytes in the destination buffer has bit 7 cleared.
  55. *
  56. * Bit 6 is set for all bytes which are to be copied by the DMA
  57. * engine. Bit 5 is set for all bytes which are to be overwritten by
  58. * the DMA engine.
  59. *
  60. * The remaining bits are the inverse of a counter which increments by
  61. * one for each byte address.
  62. */
  63. #define PATTERN_SRC 0x80
  64. #define PATTERN_DST 0x00
  65. #define PATTERN_COPY 0x40
  66. #define PATTERN_OVERWRITE 0x20
  67. #define PATTERN_COUNT_MASK 0x1f
  68. struct dmatest_thread {
  69. struct list_head node;
  70. struct task_struct *task;
  71. struct dma_chan *chan;
  72. u8 **srcs;
  73. u8 **dsts;
  74. enum dma_transaction_type type;
  75. };
  76. struct dmatest_chan {
  77. struct list_head node;
  78. struct dma_chan *chan;
  79. struct list_head threads;
  80. };
  81. /*
  82. * These are protected by dma_list_mutex since they're only used by
  83. * the DMA filter function callback
  84. */
  85. static LIST_HEAD(dmatest_channels);
  86. static unsigned int nr_channels;
  87. static bool dmatest_match_channel(struct dma_chan *chan)
  88. {
  89. if (test_channel[0] == '\0')
  90. return true;
  91. return strcmp(dma_chan_name(chan), test_channel) == 0;
  92. }
  93. static bool dmatest_match_device(struct dma_device *device)
  94. {
  95. if (test_device[0] == '\0')
  96. return true;
  97. return strcmp(dev_name(device->dev), test_device) == 0;
  98. }
  99. static unsigned long dmatest_random(void)
  100. {
  101. unsigned long buf;
  102. get_random_bytes(&buf, sizeof(buf));
  103. return buf;
  104. }
  105. static void dmatest_init_srcs(u8 **bufs, unsigned int start, unsigned int len)
  106. {
  107. unsigned int i;
  108. u8 *buf;
  109. for (; (buf = *bufs); bufs++) {
  110. for (i = 0; i < start; i++)
  111. buf[i] = PATTERN_SRC | (~i & PATTERN_COUNT_MASK);
  112. for ( ; i < start + len; i++)
  113. buf[i] = PATTERN_SRC | PATTERN_COPY
  114. | (~i & PATTERN_COUNT_MASK);
  115. for ( ; i < test_buf_size; i++)
  116. buf[i] = PATTERN_SRC | (~i & PATTERN_COUNT_MASK);
  117. buf++;
  118. }
  119. }
  120. static void dmatest_init_dsts(u8 **bufs, unsigned int start, unsigned int len)
  121. {
  122. unsigned int i;
  123. u8 *buf;
  124. for (; (buf = *bufs); bufs++) {
  125. for (i = 0; i < start; i++)
  126. buf[i] = PATTERN_DST | (~i & PATTERN_COUNT_MASK);
  127. for ( ; i < start + len; i++)
  128. buf[i] = PATTERN_DST | PATTERN_OVERWRITE
  129. | (~i & PATTERN_COUNT_MASK);
  130. for ( ; i < test_buf_size; i++)
  131. buf[i] = PATTERN_DST | (~i & PATTERN_COUNT_MASK);
  132. }
  133. }
  134. static void dmatest_mismatch(u8 actual, u8 pattern, unsigned int index,
  135. unsigned int counter, bool is_srcbuf)
  136. {
  137. u8 diff = actual ^ pattern;
  138. u8 expected = pattern | (~counter & PATTERN_COUNT_MASK);
  139. const char *thread_name = current->comm;
  140. if (is_srcbuf)
  141. pr_warning("%s: srcbuf[0x%x] overwritten!"
  142. " Expected %02x, got %02x\n",
  143. thread_name, index, expected, actual);
  144. else if ((pattern & PATTERN_COPY)
  145. && (diff & (PATTERN_COPY | PATTERN_OVERWRITE)))
  146. pr_warning("%s: dstbuf[0x%x] not copied!"
  147. " Expected %02x, got %02x\n",
  148. thread_name, index, expected, actual);
  149. else if (diff & PATTERN_SRC)
  150. pr_warning("%s: dstbuf[0x%x] was copied!"
  151. " Expected %02x, got %02x\n",
  152. thread_name, index, expected, actual);
  153. else
  154. pr_warning("%s: dstbuf[0x%x] mismatch!"
  155. " Expected %02x, got %02x\n",
  156. thread_name, index, expected, actual);
  157. }
  158. static unsigned int dmatest_verify(u8 **bufs, unsigned int start,
  159. unsigned int end, unsigned int counter, u8 pattern,
  160. bool is_srcbuf)
  161. {
  162. unsigned int i;
  163. unsigned int error_count = 0;
  164. u8 actual;
  165. u8 expected;
  166. u8 *buf;
  167. unsigned int counter_orig = counter;
  168. for (; (buf = *bufs); bufs++) {
  169. counter = counter_orig;
  170. for (i = start; i < end; i++) {
  171. actual = buf[i];
  172. expected = pattern | (~counter & PATTERN_COUNT_MASK);
  173. if (actual != expected) {
  174. if (error_count < 32)
  175. dmatest_mismatch(actual, pattern, i,
  176. counter, is_srcbuf);
  177. error_count++;
  178. }
  179. counter++;
  180. }
  181. }
  182. if (error_count > 32)
  183. pr_warning("%s: %u errors suppressed\n",
  184. current->comm, error_count - 32);
  185. return error_count;
  186. }
  187. static void dmatest_callback(void *completion)
  188. {
  189. complete(completion);
  190. }
  191. /*
  192. * This function repeatedly tests DMA transfers of various lengths and
  193. * offsets for a given operation type until it is told to exit by
  194. * kthread_stop(). There may be multiple threads running this function
  195. * in parallel for a single channel, and there may be multiple channels
  196. * being tested in parallel.
  197. *
  198. * Before each test, the source and destination buffer is initialized
  199. * with a known pattern. This pattern is different depending on
  200. * whether it's in an area which is supposed to be copied or
  201. * overwritten, and different in the source and destination buffers.
  202. * So if the DMA engine doesn't copy exactly what we tell it to copy,
  203. * we'll notice.
  204. */
  205. static int dmatest_func(void *data)
  206. {
  207. struct dmatest_thread *thread = data;
  208. struct dma_chan *chan;
  209. const char *thread_name;
  210. unsigned int src_off, dst_off, len;
  211. unsigned int error_count;
  212. unsigned int failed_tests = 0;
  213. unsigned int total_tests = 0;
  214. dma_cookie_t cookie;
  215. enum dma_status status;
  216. enum dma_ctrl_flags flags;
  217. u8 pq_coefs[pq_sources + 1];
  218. int ret;
  219. int src_cnt;
  220. int dst_cnt;
  221. int i;
  222. thread_name = current->comm;
  223. ret = -ENOMEM;
  224. smp_rmb();
  225. chan = thread->chan;
  226. if (thread->type == DMA_MEMCPY)
  227. src_cnt = dst_cnt = 1;
  228. else if (thread->type == DMA_XOR) {
  229. src_cnt = xor_sources | 1; /* force odd to ensure dst = src */
  230. dst_cnt = 1;
  231. } else if (thread->type == DMA_PQ) {
  232. src_cnt = pq_sources | 1; /* force odd to ensure dst = src */
  233. dst_cnt = 2;
  234. for (i = 0; i < src_cnt; i++)
  235. pq_coefs[i] = 1;
  236. } else
  237. goto err_srcs;
  238. thread->srcs = kcalloc(src_cnt+1, sizeof(u8 *), GFP_KERNEL);
  239. if (!thread->srcs)
  240. goto err_srcs;
  241. for (i = 0; i < src_cnt; i++) {
  242. thread->srcs[i] = kmalloc(test_buf_size, GFP_KERNEL);
  243. if (!thread->srcs[i])
  244. goto err_srcbuf;
  245. }
  246. thread->srcs[i] = NULL;
  247. thread->dsts = kcalloc(dst_cnt+1, sizeof(u8 *), GFP_KERNEL);
  248. if (!thread->dsts)
  249. goto err_dsts;
  250. for (i = 0; i < dst_cnt; i++) {
  251. thread->dsts[i] = kmalloc(test_buf_size, GFP_KERNEL);
  252. if (!thread->dsts[i])
  253. goto err_dstbuf;
  254. }
  255. thread->dsts[i] = NULL;
  256. set_user_nice(current, 10);
  257. /*
  258. * src buffers are freed by the DMAEngine code with dma_unmap_single()
  259. * dst buffers are freed by ourselves below
  260. */
  261. flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT
  262. | DMA_COMPL_SKIP_DEST_UNMAP | DMA_COMPL_SRC_UNMAP_SINGLE;
  263. while (!kthread_should_stop()
  264. && !(iterations && total_tests >= iterations)) {
  265. struct dma_device *dev = chan->device;
  266. struct dma_async_tx_descriptor *tx = NULL;
  267. dma_addr_t dma_srcs[src_cnt];
  268. dma_addr_t dma_dsts[dst_cnt];
  269. struct completion cmp;
  270. unsigned long tmo = msecs_to_jiffies(timeout);
  271. u8 align = 0;
  272. total_tests++;
  273. /* honor alignment restrictions */
  274. if (thread->type == DMA_MEMCPY)
  275. align = dev->copy_align;
  276. else if (thread->type == DMA_XOR)
  277. align = dev->xor_align;
  278. else if (thread->type == DMA_PQ)
  279. align = dev->pq_align;
  280. if (1 << align > test_buf_size) {
  281. pr_err("%u-byte buffer too small for %d-byte alignment\n",
  282. test_buf_size, 1 << align);
  283. break;
  284. }
  285. len = dmatest_random() % test_buf_size + 1;
  286. len = (len >> align) << align;
  287. if (!len)
  288. len = 1 << align;
  289. src_off = dmatest_random() % (test_buf_size - len + 1);
  290. dst_off = dmatest_random() % (test_buf_size - len + 1);
  291. src_off = (src_off >> align) << align;
  292. dst_off = (dst_off >> align) << align;
  293. dmatest_init_srcs(thread->srcs, src_off, len);
  294. dmatest_init_dsts(thread->dsts, dst_off, len);
  295. for (i = 0; i < src_cnt; i++) {
  296. u8 *buf = thread->srcs[i] + src_off;
  297. dma_srcs[i] = dma_map_single(dev->dev, buf, len,
  298. DMA_TO_DEVICE);
  299. }
  300. /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
  301. for (i = 0; i < dst_cnt; i++) {
  302. dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i],
  303. test_buf_size,
  304. DMA_BIDIRECTIONAL);
  305. }
  306. if (thread->type == DMA_MEMCPY)
  307. tx = dev->device_prep_dma_memcpy(chan,
  308. dma_dsts[0] + dst_off,
  309. dma_srcs[0], len,
  310. flags);
  311. else if (thread->type == DMA_XOR)
  312. tx = dev->device_prep_dma_xor(chan,
  313. dma_dsts[0] + dst_off,
  314. dma_srcs, src_cnt,
  315. len, flags);
  316. else if (thread->type == DMA_PQ) {
  317. dma_addr_t dma_pq[dst_cnt];
  318. for (i = 0; i < dst_cnt; i++)
  319. dma_pq[i] = dma_dsts[i] + dst_off;
  320. tx = dev->device_prep_dma_pq(chan, dma_pq, dma_srcs,
  321. src_cnt, pq_coefs,
  322. len, flags);
  323. }
  324. if (!tx) {
  325. for (i = 0; i < src_cnt; i++)
  326. dma_unmap_single(dev->dev, dma_srcs[i], len,
  327. DMA_TO_DEVICE);
  328. for (i = 0; i < dst_cnt; i++)
  329. dma_unmap_single(dev->dev, dma_dsts[i],
  330. test_buf_size,
  331. DMA_BIDIRECTIONAL);
  332. pr_warning("%s: #%u: prep error with src_off=0x%x "
  333. "dst_off=0x%x len=0x%x\n",
  334. thread_name, total_tests - 1,
  335. src_off, dst_off, len);
  336. msleep(100);
  337. failed_tests++;
  338. continue;
  339. }
  340. init_completion(&cmp);
  341. tx->callback = dmatest_callback;
  342. tx->callback_param = &cmp;
  343. cookie = tx->tx_submit(tx);
  344. if (dma_submit_error(cookie)) {
  345. pr_warning("%s: #%u: submit error %d with src_off=0x%x "
  346. "dst_off=0x%x len=0x%x\n",
  347. thread_name, total_tests - 1, cookie,
  348. src_off, dst_off, len);
  349. msleep(100);
  350. failed_tests++;
  351. continue;
  352. }
  353. dma_async_issue_pending(chan);
  354. tmo = wait_for_completion_timeout(&cmp, tmo);
  355. status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
  356. if (tmo == 0) {
  357. pr_warning("%s: #%u: test timed out\n",
  358. thread_name, total_tests - 1);
  359. failed_tests++;
  360. continue;
  361. } else if (status != DMA_SUCCESS) {
  362. pr_warning("%s: #%u: got completion callback,"
  363. " but status is \'%s\'\n",
  364. thread_name, total_tests - 1,
  365. status == DMA_ERROR ? "error" : "in progress");
  366. failed_tests++;
  367. continue;
  368. }
  369. /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */
  370. for (i = 0; i < dst_cnt; i++)
  371. dma_unmap_single(dev->dev, dma_dsts[i], test_buf_size,
  372. DMA_BIDIRECTIONAL);
  373. error_count = 0;
  374. pr_debug("%s: verifying source buffer...\n", thread_name);
  375. error_count += dmatest_verify(thread->srcs, 0, src_off,
  376. 0, PATTERN_SRC, true);
  377. error_count += dmatest_verify(thread->srcs, src_off,
  378. src_off + len, src_off,
  379. PATTERN_SRC | PATTERN_COPY, true);
  380. error_count += dmatest_verify(thread->srcs, src_off + len,
  381. test_buf_size, src_off + len,
  382. PATTERN_SRC, true);
  383. pr_debug("%s: verifying dest buffer...\n",
  384. thread->task->comm);
  385. error_count += dmatest_verify(thread->dsts, 0, dst_off,
  386. 0, PATTERN_DST, false);
  387. error_count += dmatest_verify(thread->dsts, dst_off,
  388. dst_off + len, src_off,
  389. PATTERN_SRC | PATTERN_COPY, false);
  390. error_count += dmatest_verify(thread->dsts, dst_off + len,
  391. test_buf_size, dst_off + len,
  392. PATTERN_DST, false);
  393. if (error_count) {
  394. pr_warning("%s: #%u: %u errors with "
  395. "src_off=0x%x dst_off=0x%x len=0x%x\n",
  396. thread_name, total_tests - 1, error_count,
  397. src_off, dst_off, len);
  398. failed_tests++;
  399. } else {
  400. pr_debug("%s: #%u: No errors with "
  401. "src_off=0x%x dst_off=0x%x len=0x%x\n",
  402. thread_name, total_tests - 1,
  403. src_off, dst_off, len);
  404. }
  405. }
  406. ret = 0;
  407. for (i = 0; thread->dsts[i]; i++)
  408. kfree(thread->dsts[i]);
  409. err_dstbuf:
  410. kfree(thread->dsts);
  411. err_dsts:
  412. for (i = 0; thread->srcs[i]; i++)
  413. kfree(thread->srcs[i]);
  414. err_srcbuf:
  415. kfree(thread->srcs);
  416. err_srcs:
  417. pr_notice("%s: terminating after %u tests, %u failures (status %d)\n",
  418. thread_name, total_tests, failed_tests, ret);
  419. if (iterations > 0)
  420. while (!kthread_should_stop()) {
  421. DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait_dmatest_exit);
  422. interruptible_sleep_on(&wait_dmatest_exit);
  423. }
  424. return ret;
  425. }
  426. static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
  427. {
  428. struct dmatest_thread *thread;
  429. struct dmatest_thread *_thread;
  430. int ret;
  431. list_for_each_entry_safe(thread, _thread, &dtc->threads, node) {
  432. ret = kthread_stop(thread->task);
  433. pr_debug("dmatest: thread %s exited with status %d\n",
  434. thread->task->comm, ret);
  435. list_del(&thread->node);
  436. kfree(thread);
  437. }
  438. kfree(dtc);
  439. }
  440. static int dmatest_add_threads(struct dmatest_chan *dtc, enum dma_transaction_type type)
  441. {
  442. struct dmatest_thread *thread;
  443. struct dma_chan *chan = dtc->chan;
  444. char *op;
  445. unsigned int i;
  446. if (type == DMA_MEMCPY)
  447. op = "copy";
  448. else if (type == DMA_XOR)
  449. op = "xor";
  450. else if (type == DMA_PQ)
  451. op = "pq";
  452. else
  453. return -EINVAL;
  454. for (i = 0; i < threads_per_chan; i++) {
  455. thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL);
  456. if (!thread) {
  457. pr_warning("dmatest: No memory for %s-%s%u\n",
  458. dma_chan_name(chan), op, i);
  459. break;
  460. }
  461. thread->chan = dtc->chan;
  462. thread->type = type;
  463. smp_wmb();
  464. thread->task = kthread_run(dmatest_func, thread, "%s-%s%u",
  465. dma_chan_name(chan), op, i);
  466. if (IS_ERR(thread->task)) {
  467. pr_warning("dmatest: Failed to run thread %s-%s%u\n",
  468. dma_chan_name(chan), op, i);
  469. kfree(thread);
  470. break;
  471. }
  472. /* srcbuf and dstbuf are allocated by the thread itself */
  473. list_add_tail(&thread->node, &dtc->threads);
  474. }
  475. return i;
  476. }
  477. static int dmatest_add_channel(struct dma_chan *chan)
  478. {
  479. struct dmatest_chan *dtc;
  480. struct dma_device *dma_dev = chan->device;
  481. unsigned int thread_count = 0;
  482. int cnt;
  483. dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL);
  484. if (!dtc) {
  485. pr_warning("dmatest: No memory for %s\n", dma_chan_name(chan));
  486. return -ENOMEM;
  487. }
  488. dtc->chan = chan;
  489. INIT_LIST_HEAD(&dtc->threads);
  490. if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) {
  491. cnt = dmatest_add_threads(dtc, DMA_MEMCPY);
  492. thread_count += cnt > 0 ? cnt : 0;
  493. }
  494. if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
  495. cnt = dmatest_add_threads(dtc, DMA_XOR);
  496. thread_count += cnt > 0 ? cnt : 0;
  497. }
  498. if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) {
  499. cnt = dmatest_add_threads(dtc, DMA_PQ);
  500. thread_count += cnt > 0 ?: 0;
  501. }
  502. pr_info("dmatest: Started %u threads using %s\n",
  503. thread_count, dma_chan_name(chan));
  504. list_add_tail(&dtc->node, &dmatest_channels);
  505. nr_channels++;
  506. return 0;
  507. }
  508. static bool filter(struct dma_chan *chan, void *param)
  509. {
  510. if (!dmatest_match_channel(chan) || !dmatest_match_device(chan->device))
  511. return false;
  512. else
  513. return true;
  514. }
  515. static int __init dmatest_init(void)
  516. {
  517. dma_cap_mask_t mask;
  518. struct dma_chan *chan;
  519. int err = 0;
  520. dma_cap_zero(mask);
  521. dma_cap_set(DMA_MEMCPY, mask);
  522. for (;;) {
  523. chan = dma_request_channel(mask, filter, NULL);
  524. if (chan) {
  525. err = dmatest_add_channel(chan);
  526. if (err) {
  527. dma_release_channel(chan);
  528. break; /* add_channel failed, punt */
  529. }
  530. } else
  531. break; /* no more channels available */
  532. if (max_channels && nr_channels >= max_channels)
  533. break; /* we have all we need */
  534. }
  535. return err;
  536. }
  537. /* when compiled-in wait for drivers to load first */
  538. late_initcall(dmatest_init);
  539. static void __exit dmatest_exit(void)
  540. {
  541. struct dmatest_chan *dtc, *_dtc;
  542. struct dma_chan *chan;
  543. list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) {
  544. list_del(&dtc->node);
  545. chan = dtc->chan;
  546. dmatest_cleanup_channel(dtc);
  547. pr_debug("dmatest: dropped channel %s\n",
  548. dma_chan_name(chan));
  549. dma_release_channel(chan);
  550. }
  551. }
  552. module_exit(dmatest_exit);
  553. MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
  554. MODULE_LICENSE("GPL v2");