iop-adma.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662
  1. /*
  2. * offload engine driver for the Intel Xscale series of i/o processors
  3. * Copyright © 2006, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. /*
  20. * This driver supports the asynchrounous DMA copy and RAID engines available
  21. * on the Intel Xscale(R) family of I/O Processors (IOP 32x, 33x, 134x)
  22. */
  23. #include <linux/init.h>
  24. #include <linux/module.h>
  25. #include <linux/delay.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/spinlock.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/memory.h>
  31. #include <linux/ioport.h>
  32. #include <linux/raid/pq.h>
  33. #include <linux/slab.h>
  34. #include <mach/adma.h>
  35. #include "dmaengine.h"
  36. #define to_iop_adma_chan(chan) container_of(chan, struct iop_adma_chan, common)
  37. #define to_iop_adma_device(dev) \
  38. container_of(dev, struct iop_adma_device, common)
  39. #define tx_to_iop_adma_slot(tx) \
  40. container_of(tx, struct iop_adma_desc_slot, async_tx)
  41. /**
  42. * iop_adma_free_slots - flags descriptor slots for reuse
  43. * @slot: Slot to free
  44. * Caller must hold &iop_chan->lock while calling this function
  45. */
  46. static void iop_adma_free_slots(struct iop_adma_desc_slot *slot)
  47. {
  48. int stride = slot->slots_per_op;
  49. while (stride--) {
  50. slot->slots_per_op = 0;
  51. slot = list_entry(slot->slot_node.next,
  52. struct iop_adma_desc_slot,
  53. slot_node);
  54. }
  55. }
  56. static void
  57. iop_desc_unmap(struct iop_adma_chan *iop_chan, struct iop_adma_desc_slot *desc)
  58. {
  59. struct dma_async_tx_descriptor *tx = &desc->async_tx;
  60. struct iop_adma_desc_slot *unmap = desc->group_head;
  61. struct device *dev = &iop_chan->device->pdev->dev;
  62. u32 len = unmap->unmap_len;
  63. enum dma_ctrl_flags flags = tx->flags;
  64. u32 src_cnt;
  65. dma_addr_t addr;
  66. dma_addr_t dest;
  67. src_cnt = unmap->unmap_src_cnt;
  68. dest = iop_desc_get_dest_addr(unmap, iop_chan);
  69. if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
  70. enum dma_data_direction dir;
  71. if (src_cnt > 1) /* is xor? */
  72. dir = DMA_BIDIRECTIONAL;
  73. else
  74. dir = DMA_FROM_DEVICE;
  75. dma_unmap_page(dev, dest, len, dir);
  76. }
  77. if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
  78. while (src_cnt--) {
  79. addr = iop_desc_get_src_addr(unmap, iop_chan, src_cnt);
  80. if (addr == dest)
  81. continue;
  82. dma_unmap_page(dev, addr, len, DMA_TO_DEVICE);
  83. }
  84. }
  85. desc->group_head = NULL;
  86. }
  87. static void
  88. iop_desc_unmap_pq(struct iop_adma_chan *iop_chan, struct iop_adma_desc_slot *desc)
  89. {
  90. struct dma_async_tx_descriptor *tx = &desc->async_tx;
  91. struct iop_adma_desc_slot *unmap = desc->group_head;
  92. struct device *dev = &iop_chan->device->pdev->dev;
  93. u32 len = unmap->unmap_len;
  94. enum dma_ctrl_flags flags = tx->flags;
  95. u32 src_cnt = unmap->unmap_src_cnt;
  96. dma_addr_t pdest = iop_desc_get_dest_addr(unmap, iop_chan);
  97. dma_addr_t qdest = iop_desc_get_qdest_addr(unmap, iop_chan);
  98. int i;
  99. if (tx->flags & DMA_PREP_CONTINUE)
  100. src_cnt -= 3;
  101. if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP) && !desc->pq_check_result) {
  102. dma_unmap_page(dev, pdest, len, DMA_BIDIRECTIONAL);
  103. dma_unmap_page(dev, qdest, len, DMA_BIDIRECTIONAL);
  104. }
  105. if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
  106. dma_addr_t addr;
  107. for (i = 0; i < src_cnt; i++) {
  108. addr = iop_desc_get_src_addr(unmap, iop_chan, i);
  109. dma_unmap_page(dev, addr, len, DMA_TO_DEVICE);
  110. }
  111. if (desc->pq_check_result) {
  112. dma_unmap_page(dev, pdest, len, DMA_TO_DEVICE);
  113. dma_unmap_page(dev, qdest, len, DMA_TO_DEVICE);
  114. }
  115. }
  116. desc->group_head = NULL;
  117. }
  118. static dma_cookie_t
  119. iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,
  120. struct iop_adma_chan *iop_chan, dma_cookie_t cookie)
  121. {
  122. struct dma_async_tx_descriptor *tx = &desc->async_tx;
  123. BUG_ON(tx->cookie < 0);
  124. if (tx->cookie > 0) {
  125. cookie = tx->cookie;
  126. tx->cookie = 0;
  127. /* call the callback (must not sleep or submit new
  128. * operations to this channel)
  129. */
  130. if (tx->callback)
  131. tx->callback(tx->callback_param);
  132. dma_descriptor_unmap(tx);
  133. /* unmap dma addresses
  134. * (unmap_single vs unmap_page?)
  135. */
  136. if (desc->group_head && desc->unmap_len) {
  137. if (iop_desc_is_pq(desc))
  138. iop_desc_unmap_pq(iop_chan, desc);
  139. else
  140. iop_desc_unmap(iop_chan, desc);
  141. }
  142. }
  143. /* run dependent operations */
  144. dma_run_dependencies(tx);
  145. return cookie;
  146. }
  147. static int
  148. iop_adma_clean_slot(struct iop_adma_desc_slot *desc,
  149. struct iop_adma_chan *iop_chan)
  150. {
  151. /* the client is allowed to attach dependent operations
  152. * until 'ack' is set
  153. */
  154. if (!async_tx_test_ack(&desc->async_tx))
  155. return 0;
  156. /* leave the last descriptor in the chain
  157. * so we can append to it
  158. */
  159. if (desc->chain_node.next == &iop_chan->chain)
  160. return 1;
  161. dev_dbg(iop_chan->device->common.dev,
  162. "\tfree slot: %d slots_per_op: %d\n",
  163. desc->idx, desc->slots_per_op);
  164. list_del(&desc->chain_node);
  165. iop_adma_free_slots(desc);
  166. return 0;
  167. }
  168. static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan)
  169. {
  170. struct iop_adma_desc_slot *iter, *_iter, *grp_start = NULL;
  171. dma_cookie_t cookie = 0;
  172. u32 current_desc = iop_chan_get_current_descriptor(iop_chan);
  173. int busy = iop_chan_is_busy(iop_chan);
  174. int seen_current = 0, slot_cnt = 0, slots_per_op = 0;
  175. dev_dbg(iop_chan->device->common.dev, "%s\n", __func__);
  176. /* free completed slots from the chain starting with
  177. * the oldest descriptor
  178. */
  179. list_for_each_entry_safe(iter, _iter, &iop_chan->chain,
  180. chain_node) {
  181. pr_debug("\tcookie: %d slot: %d busy: %d "
  182. "this_desc: %#x next_desc: %#x ack: %d\n",
  183. iter->async_tx.cookie, iter->idx, busy,
  184. iter->async_tx.phys, iop_desc_get_next_desc(iter),
  185. async_tx_test_ack(&iter->async_tx));
  186. prefetch(_iter);
  187. prefetch(&_iter->async_tx);
  188. /* do not advance past the current descriptor loaded into the
  189. * hardware channel, subsequent descriptors are either in
  190. * process or have not been submitted
  191. */
  192. if (seen_current)
  193. break;
  194. /* stop the search if we reach the current descriptor and the
  195. * channel is busy, or if it appears that the current descriptor
  196. * needs to be re-read (i.e. has been appended to)
  197. */
  198. if (iter->async_tx.phys == current_desc) {
  199. BUG_ON(seen_current++);
  200. if (busy || iop_desc_get_next_desc(iter))
  201. break;
  202. }
  203. /* detect the start of a group transaction */
  204. if (!slot_cnt && !slots_per_op) {
  205. slot_cnt = iter->slot_cnt;
  206. slots_per_op = iter->slots_per_op;
  207. if (slot_cnt <= slots_per_op) {
  208. slot_cnt = 0;
  209. slots_per_op = 0;
  210. }
  211. }
  212. if (slot_cnt) {
  213. pr_debug("\tgroup++\n");
  214. if (!grp_start)
  215. grp_start = iter;
  216. slot_cnt -= slots_per_op;
  217. }
  218. /* all the members of a group are complete */
  219. if (slots_per_op != 0 && slot_cnt == 0) {
  220. struct iop_adma_desc_slot *grp_iter, *_grp_iter;
  221. int end_of_chain = 0;
  222. pr_debug("\tgroup end\n");
  223. /* collect the total results */
  224. if (grp_start->xor_check_result) {
  225. u32 zero_sum_result = 0;
  226. slot_cnt = grp_start->slot_cnt;
  227. grp_iter = grp_start;
  228. list_for_each_entry_from(grp_iter,
  229. &iop_chan->chain, chain_node) {
  230. zero_sum_result |=
  231. iop_desc_get_zero_result(grp_iter);
  232. pr_debug("\titer%d result: %d\n",
  233. grp_iter->idx, zero_sum_result);
  234. slot_cnt -= slots_per_op;
  235. if (slot_cnt == 0)
  236. break;
  237. }
  238. pr_debug("\tgrp_start->xor_check_result: %p\n",
  239. grp_start->xor_check_result);
  240. *grp_start->xor_check_result = zero_sum_result;
  241. }
  242. /* clean up the group */
  243. slot_cnt = grp_start->slot_cnt;
  244. grp_iter = grp_start;
  245. list_for_each_entry_safe_from(grp_iter, _grp_iter,
  246. &iop_chan->chain, chain_node) {
  247. cookie = iop_adma_run_tx_complete_actions(
  248. grp_iter, iop_chan, cookie);
  249. slot_cnt -= slots_per_op;
  250. end_of_chain = iop_adma_clean_slot(grp_iter,
  251. iop_chan);
  252. if (slot_cnt == 0 || end_of_chain)
  253. break;
  254. }
  255. /* the group should be complete at this point */
  256. BUG_ON(slot_cnt);
  257. slots_per_op = 0;
  258. grp_start = NULL;
  259. if (end_of_chain)
  260. break;
  261. else
  262. continue;
  263. } else if (slots_per_op) /* wait for group completion */
  264. continue;
  265. /* write back zero sum results (single descriptor case) */
  266. if (iter->xor_check_result && iter->async_tx.cookie)
  267. *iter->xor_check_result =
  268. iop_desc_get_zero_result(iter);
  269. cookie = iop_adma_run_tx_complete_actions(
  270. iter, iop_chan, cookie);
  271. if (iop_adma_clean_slot(iter, iop_chan))
  272. break;
  273. }
  274. if (cookie > 0) {
  275. iop_chan->common.completed_cookie = cookie;
  276. pr_debug("\tcompleted cookie %d\n", cookie);
  277. }
  278. }
  279. static void
  280. iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan)
  281. {
  282. spin_lock_bh(&iop_chan->lock);
  283. __iop_adma_slot_cleanup(iop_chan);
  284. spin_unlock_bh(&iop_chan->lock);
  285. }
  286. static void iop_adma_tasklet(unsigned long data)
  287. {
  288. struct iop_adma_chan *iop_chan = (struct iop_adma_chan *) data;
  289. /* lockdep will flag depedency submissions as potentially
  290. * recursive locking, this is not the case as a dependency
  291. * submission will never recurse a channels submit routine.
  292. * There are checks in async_tx.c to prevent this.
  293. */
  294. spin_lock_nested(&iop_chan->lock, SINGLE_DEPTH_NESTING);
  295. __iop_adma_slot_cleanup(iop_chan);
  296. spin_unlock(&iop_chan->lock);
  297. }
  298. static struct iop_adma_desc_slot *
  299. iop_adma_alloc_slots(struct iop_adma_chan *iop_chan, int num_slots,
  300. int slots_per_op)
  301. {
  302. struct iop_adma_desc_slot *iter, *_iter, *alloc_start = NULL;
  303. LIST_HEAD(chain);
  304. int slots_found, retry = 0;
  305. /* start search from the last allocated descrtiptor
  306. * if a contiguous allocation can not be found start searching
  307. * from the beginning of the list
  308. */
  309. retry:
  310. slots_found = 0;
  311. if (retry == 0)
  312. iter = iop_chan->last_used;
  313. else
  314. iter = list_entry(&iop_chan->all_slots,
  315. struct iop_adma_desc_slot,
  316. slot_node);
  317. list_for_each_entry_safe_continue(
  318. iter, _iter, &iop_chan->all_slots, slot_node) {
  319. prefetch(_iter);
  320. prefetch(&_iter->async_tx);
  321. if (iter->slots_per_op) {
  322. /* give up after finding the first busy slot
  323. * on the second pass through the list
  324. */
  325. if (retry)
  326. break;
  327. slots_found = 0;
  328. continue;
  329. }
  330. /* start the allocation if the slot is correctly aligned */
  331. if (!slots_found++) {
  332. if (iop_desc_is_aligned(iter, slots_per_op))
  333. alloc_start = iter;
  334. else {
  335. slots_found = 0;
  336. continue;
  337. }
  338. }
  339. if (slots_found == num_slots) {
  340. struct iop_adma_desc_slot *alloc_tail = NULL;
  341. struct iop_adma_desc_slot *last_used = NULL;
  342. iter = alloc_start;
  343. while (num_slots) {
  344. int i;
  345. dev_dbg(iop_chan->device->common.dev,
  346. "allocated slot: %d "
  347. "(desc %p phys: %#x) slots_per_op %d\n",
  348. iter->idx, iter->hw_desc,
  349. iter->async_tx.phys, slots_per_op);
  350. /* pre-ack all but the last descriptor */
  351. if (num_slots != slots_per_op)
  352. async_tx_ack(&iter->async_tx);
  353. list_add_tail(&iter->chain_node, &chain);
  354. alloc_tail = iter;
  355. iter->async_tx.cookie = 0;
  356. iter->slot_cnt = num_slots;
  357. iter->xor_check_result = NULL;
  358. for (i = 0; i < slots_per_op; i++) {
  359. iter->slots_per_op = slots_per_op - i;
  360. last_used = iter;
  361. iter = list_entry(iter->slot_node.next,
  362. struct iop_adma_desc_slot,
  363. slot_node);
  364. }
  365. num_slots -= slots_per_op;
  366. }
  367. alloc_tail->group_head = alloc_start;
  368. alloc_tail->async_tx.cookie = -EBUSY;
  369. list_splice(&chain, &alloc_tail->tx_list);
  370. iop_chan->last_used = last_used;
  371. iop_desc_clear_next_desc(alloc_start);
  372. iop_desc_clear_next_desc(alloc_tail);
  373. return alloc_tail;
  374. }
  375. }
  376. if (!retry++)
  377. goto retry;
  378. /* perform direct reclaim if the allocation fails */
  379. __iop_adma_slot_cleanup(iop_chan);
  380. return NULL;
  381. }
  382. static void iop_adma_check_threshold(struct iop_adma_chan *iop_chan)
  383. {
  384. dev_dbg(iop_chan->device->common.dev, "pending: %d\n",
  385. iop_chan->pending);
  386. if (iop_chan->pending >= IOP_ADMA_THRESHOLD) {
  387. iop_chan->pending = 0;
  388. iop_chan_append(iop_chan);
  389. }
  390. }
  391. static dma_cookie_t
  392. iop_adma_tx_submit(struct dma_async_tx_descriptor *tx)
  393. {
  394. struct iop_adma_desc_slot *sw_desc = tx_to_iop_adma_slot(tx);
  395. struct iop_adma_chan *iop_chan = to_iop_adma_chan(tx->chan);
  396. struct iop_adma_desc_slot *grp_start, *old_chain_tail;
  397. int slot_cnt;
  398. int slots_per_op;
  399. dma_cookie_t cookie;
  400. dma_addr_t next_dma;
  401. grp_start = sw_desc->group_head;
  402. slot_cnt = grp_start->slot_cnt;
  403. slots_per_op = grp_start->slots_per_op;
  404. spin_lock_bh(&iop_chan->lock);
  405. cookie = dma_cookie_assign(tx);
  406. old_chain_tail = list_entry(iop_chan->chain.prev,
  407. struct iop_adma_desc_slot, chain_node);
  408. list_splice_init(&sw_desc->tx_list,
  409. &old_chain_tail->chain_node);
  410. /* fix up the hardware chain */
  411. next_dma = grp_start->async_tx.phys;
  412. iop_desc_set_next_desc(old_chain_tail, next_dma);
  413. BUG_ON(iop_desc_get_next_desc(old_chain_tail) != next_dma); /* flush */
  414. /* check for pre-chained descriptors */
  415. iop_paranoia(iop_desc_get_next_desc(sw_desc));
  416. /* increment the pending count by the number of slots
  417. * memcpy operations have a 1:1 (slot:operation) relation
  418. * other operations are heavier and will pop the threshold
  419. * more often.
  420. */
  421. iop_chan->pending += slot_cnt;
  422. iop_adma_check_threshold(iop_chan);
  423. spin_unlock_bh(&iop_chan->lock);
  424. dev_dbg(iop_chan->device->common.dev, "%s cookie: %d slot: %d\n",
  425. __func__, sw_desc->async_tx.cookie, sw_desc->idx);
  426. return cookie;
  427. }
  428. static void iop_chan_start_null_memcpy(struct iop_adma_chan *iop_chan);
  429. static void iop_chan_start_null_xor(struct iop_adma_chan *iop_chan);
  430. /**
  431. * iop_adma_alloc_chan_resources - returns the number of allocated descriptors
  432. * @chan - allocate descriptor resources for this channel
  433. * @client - current client requesting the channel be ready for requests
  434. *
  435. * Note: We keep the slots for 1 operation on iop_chan->chain at all times. To
  436. * avoid deadlock, via async_xor, num_descs_in_pool must at a minimum be
  437. * greater than 2x the number slots needed to satisfy a device->max_xor
  438. * request.
  439. * */
  440. static int iop_adma_alloc_chan_resources(struct dma_chan *chan)
  441. {
  442. char *hw_desc;
  443. int idx;
  444. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  445. struct iop_adma_desc_slot *slot = NULL;
  446. int init = iop_chan->slots_allocated ? 0 : 1;
  447. struct iop_adma_platform_data *plat_data =
  448. dev_get_platdata(&iop_chan->device->pdev->dev);
  449. int num_descs_in_pool = plat_data->pool_size/IOP_ADMA_SLOT_SIZE;
  450. /* Allocate descriptor slots */
  451. do {
  452. idx = iop_chan->slots_allocated;
  453. if (idx == num_descs_in_pool)
  454. break;
  455. slot = kzalloc(sizeof(*slot), GFP_KERNEL);
  456. if (!slot) {
  457. printk(KERN_INFO "IOP ADMA Channel only initialized"
  458. " %d descriptor slots", idx);
  459. break;
  460. }
  461. hw_desc = (char *) iop_chan->device->dma_desc_pool_virt;
  462. slot->hw_desc = (void *) &hw_desc[idx * IOP_ADMA_SLOT_SIZE];
  463. dma_async_tx_descriptor_init(&slot->async_tx, chan);
  464. slot->async_tx.tx_submit = iop_adma_tx_submit;
  465. INIT_LIST_HEAD(&slot->tx_list);
  466. INIT_LIST_HEAD(&slot->chain_node);
  467. INIT_LIST_HEAD(&slot->slot_node);
  468. hw_desc = (char *) iop_chan->device->dma_desc_pool;
  469. slot->async_tx.phys =
  470. (dma_addr_t) &hw_desc[idx * IOP_ADMA_SLOT_SIZE];
  471. slot->idx = idx;
  472. spin_lock_bh(&iop_chan->lock);
  473. iop_chan->slots_allocated++;
  474. list_add_tail(&slot->slot_node, &iop_chan->all_slots);
  475. spin_unlock_bh(&iop_chan->lock);
  476. } while (iop_chan->slots_allocated < num_descs_in_pool);
  477. if (idx && !iop_chan->last_used)
  478. iop_chan->last_used = list_entry(iop_chan->all_slots.next,
  479. struct iop_adma_desc_slot,
  480. slot_node);
  481. dev_dbg(iop_chan->device->common.dev,
  482. "allocated %d descriptor slots last_used: %p\n",
  483. iop_chan->slots_allocated, iop_chan->last_used);
  484. /* initialize the channel and the chain with a null operation */
  485. if (init) {
  486. if (dma_has_cap(DMA_MEMCPY,
  487. iop_chan->device->common.cap_mask))
  488. iop_chan_start_null_memcpy(iop_chan);
  489. else if (dma_has_cap(DMA_XOR,
  490. iop_chan->device->common.cap_mask))
  491. iop_chan_start_null_xor(iop_chan);
  492. else
  493. BUG();
  494. }
  495. return (idx > 0) ? idx : -ENOMEM;
  496. }
  497. static struct dma_async_tx_descriptor *
  498. iop_adma_prep_dma_interrupt(struct dma_chan *chan, unsigned long flags)
  499. {
  500. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  501. struct iop_adma_desc_slot *sw_desc, *grp_start;
  502. int slot_cnt, slots_per_op;
  503. dev_dbg(iop_chan->device->common.dev, "%s\n", __func__);
  504. spin_lock_bh(&iop_chan->lock);
  505. slot_cnt = iop_chan_interrupt_slot_count(&slots_per_op, iop_chan);
  506. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  507. if (sw_desc) {
  508. grp_start = sw_desc->group_head;
  509. iop_desc_init_interrupt(grp_start, iop_chan);
  510. grp_start->unmap_len = 0;
  511. sw_desc->async_tx.flags = flags;
  512. }
  513. spin_unlock_bh(&iop_chan->lock);
  514. return sw_desc ? &sw_desc->async_tx : NULL;
  515. }
  516. static struct dma_async_tx_descriptor *
  517. iop_adma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dma_dest,
  518. dma_addr_t dma_src, size_t len, unsigned long flags)
  519. {
  520. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  521. struct iop_adma_desc_slot *sw_desc, *grp_start;
  522. int slot_cnt, slots_per_op;
  523. if (unlikely(!len))
  524. return NULL;
  525. BUG_ON(len > IOP_ADMA_MAX_BYTE_COUNT);
  526. dev_dbg(iop_chan->device->common.dev, "%s len: %u\n",
  527. __func__, len);
  528. spin_lock_bh(&iop_chan->lock);
  529. slot_cnt = iop_chan_memcpy_slot_count(len, &slots_per_op);
  530. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  531. if (sw_desc) {
  532. grp_start = sw_desc->group_head;
  533. iop_desc_init_memcpy(grp_start, flags);
  534. iop_desc_set_byte_count(grp_start, iop_chan, len);
  535. iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest);
  536. iop_desc_set_memcpy_src_addr(grp_start, dma_src);
  537. sw_desc->unmap_src_cnt = 1;
  538. sw_desc->unmap_len = len;
  539. sw_desc->async_tx.flags = flags;
  540. }
  541. spin_unlock_bh(&iop_chan->lock);
  542. return sw_desc ? &sw_desc->async_tx : NULL;
  543. }
  544. static struct dma_async_tx_descriptor *
  545. iop_adma_prep_dma_xor(struct dma_chan *chan, dma_addr_t dma_dest,
  546. dma_addr_t *dma_src, unsigned int src_cnt, size_t len,
  547. unsigned long flags)
  548. {
  549. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  550. struct iop_adma_desc_slot *sw_desc, *grp_start;
  551. int slot_cnt, slots_per_op;
  552. if (unlikely(!len))
  553. return NULL;
  554. BUG_ON(len > IOP_ADMA_XOR_MAX_BYTE_COUNT);
  555. dev_dbg(iop_chan->device->common.dev,
  556. "%s src_cnt: %d len: %u flags: %lx\n",
  557. __func__, src_cnt, len, flags);
  558. spin_lock_bh(&iop_chan->lock);
  559. slot_cnt = iop_chan_xor_slot_count(len, src_cnt, &slots_per_op);
  560. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  561. if (sw_desc) {
  562. grp_start = sw_desc->group_head;
  563. iop_desc_init_xor(grp_start, src_cnt, flags);
  564. iop_desc_set_byte_count(grp_start, iop_chan, len);
  565. iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest);
  566. sw_desc->unmap_src_cnt = src_cnt;
  567. sw_desc->unmap_len = len;
  568. sw_desc->async_tx.flags = flags;
  569. while (src_cnt--)
  570. iop_desc_set_xor_src_addr(grp_start, src_cnt,
  571. dma_src[src_cnt]);
  572. }
  573. spin_unlock_bh(&iop_chan->lock);
  574. return sw_desc ? &sw_desc->async_tx : NULL;
  575. }
  576. static struct dma_async_tx_descriptor *
  577. iop_adma_prep_dma_xor_val(struct dma_chan *chan, dma_addr_t *dma_src,
  578. unsigned int src_cnt, size_t len, u32 *result,
  579. unsigned long flags)
  580. {
  581. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  582. struct iop_adma_desc_slot *sw_desc, *grp_start;
  583. int slot_cnt, slots_per_op;
  584. if (unlikely(!len))
  585. return NULL;
  586. dev_dbg(iop_chan->device->common.dev, "%s src_cnt: %d len: %u\n",
  587. __func__, src_cnt, len);
  588. spin_lock_bh(&iop_chan->lock);
  589. slot_cnt = iop_chan_zero_sum_slot_count(len, src_cnt, &slots_per_op);
  590. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  591. if (sw_desc) {
  592. grp_start = sw_desc->group_head;
  593. iop_desc_init_zero_sum(grp_start, src_cnt, flags);
  594. iop_desc_set_zero_sum_byte_count(grp_start, len);
  595. grp_start->xor_check_result = result;
  596. pr_debug("\t%s: grp_start->xor_check_result: %p\n",
  597. __func__, grp_start->xor_check_result);
  598. sw_desc->unmap_src_cnt = src_cnt;
  599. sw_desc->unmap_len = len;
  600. sw_desc->async_tx.flags = flags;
  601. while (src_cnt--)
  602. iop_desc_set_zero_sum_src_addr(grp_start, src_cnt,
  603. dma_src[src_cnt]);
  604. }
  605. spin_unlock_bh(&iop_chan->lock);
  606. return sw_desc ? &sw_desc->async_tx : NULL;
  607. }
  608. static struct dma_async_tx_descriptor *
  609. iop_adma_prep_dma_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
  610. unsigned int src_cnt, const unsigned char *scf, size_t len,
  611. unsigned long flags)
  612. {
  613. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  614. struct iop_adma_desc_slot *sw_desc, *g;
  615. int slot_cnt, slots_per_op;
  616. int continue_srcs;
  617. if (unlikely(!len))
  618. return NULL;
  619. BUG_ON(len > IOP_ADMA_XOR_MAX_BYTE_COUNT);
  620. dev_dbg(iop_chan->device->common.dev,
  621. "%s src_cnt: %d len: %u flags: %lx\n",
  622. __func__, src_cnt, len, flags);
  623. if (dmaf_p_disabled_continue(flags))
  624. continue_srcs = 1+src_cnt;
  625. else if (dmaf_continue(flags))
  626. continue_srcs = 3+src_cnt;
  627. else
  628. continue_srcs = 0+src_cnt;
  629. spin_lock_bh(&iop_chan->lock);
  630. slot_cnt = iop_chan_pq_slot_count(len, continue_srcs, &slots_per_op);
  631. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  632. if (sw_desc) {
  633. int i;
  634. g = sw_desc->group_head;
  635. iop_desc_set_byte_count(g, iop_chan, len);
  636. /* even if P is disabled its destination address (bits
  637. * [3:0]) must match Q. It is ok if P points to an
  638. * invalid address, it won't be written.
  639. */
  640. if (flags & DMA_PREP_PQ_DISABLE_P)
  641. dst[0] = dst[1] & 0x7;
  642. iop_desc_set_pq_addr(g, dst);
  643. sw_desc->unmap_src_cnt = src_cnt;
  644. sw_desc->unmap_len = len;
  645. sw_desc->async_tx.flags = flags;
  646. for (i = 0; i < src_cnt; i++)
  647. iop_desc_set_pq_src_addr(g, i, src[i], scf[i]);
  648. /* if we are continuing a previous operation factor in
  649. * the old p and q values, see the comment for dma_maxpq
  650. * in include/linux/dmaengine.h
  651. */
  652. if (dmaf_p_disabled_continue(flags))
  653. iop_desc_set_pq_src_addr(g, i++, dst[1], 1);
  654. else if (dmaf_continue(flags)) {
  655. iop_desc_set_pq_src_addr(g, i++, dst[0], 0);
  656. iop_desc_set_pq_src_addr(g, i++, dst[1], 1);
  657. iop_desc_set_pq_src_addr(g, i++, dst[1], 0);
  658. }
  659. iop_desc_init_pq(g, i, flags);
  660. }
  661. spin_unlock_bh(&iop_chan->lock);
  662. return sw_desc ? &sw_desc->async_tx : NULL;
  663. }
  664. static struct dma_async_tx_descriptor *
  665. iop_adma_prep_dma_pq_val(struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
  666. unsigned int src_cnt, const unsigned char *scf,
  667. size_t len, enum sum_check_flags *pqres,
  668. unsigned long flags)
  669. {
  670. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  671. struct iop_adma_desc_slot *sw_desc, *g;
  672. int slot_cnt, slots_per_op;
  673. if (unlikely(!len))
  674. return NULL;
  675. BUG_ON(len > IOP_ADMA_XOR_MAX_BYTE_COUNT);
  676. dev_dbg(iop_chan->device->common.dev, "%s src_cnt: %d len: %u\n",
  677. __func__, src_cnt, len);
  678. spin_lock_bh(&iop_chan->lock);
  679. slot_cnt = iop_chan_pq_zero_sum_slot_count(len, src_cnt + 2, &slots_per_op);
  680. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  681. if (sw_desc) {
  682. /* for validate operations p and q are tagged onto the
  683. * end of the source list
  684. */
  685. int pq_idx = src_cnt;
  686. g = sw_desc->group_head;
  687. iop_desc_init_pq_zero_sum(g, src_cnt+2, flags);
  688. iop_desc_set_pq_zero_sum_byte_count(g, len);
  689. g->pq_check_result = pqres;
  690. pr_debug("\t%s: g->pq_check_result: %p\n",
  691. __func__, g->pq_check_result);
  692. sw_desc->unmap_src_cnt = src_cnt+2;
  693. sw_desc->unmap_len = len;
  694. sw_desc->async_tx.flags = flags;
  695. while (src_cnt--)
  696. iop_desc_set_pq_zero_sum_src_addr(g, src_cnt,
  697. src[src_cnt],
  698. scf[src_cnt]);
  699. iop_desc_set_pq_zero_sum_addr(g, pq_idx, src);
  700. }
  701. spin_unlock_bh(&iop_chan->lock);
  702. return sw_desc ? &sw_desc->async_tx : NULL;
  703. }
  704. static void iop_adma_free_chan_resources(struct dma_chan *chan)
  705. {
  706. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  707. struct iop_adma_desc_slot *iter, *_iter;
  708. int in_use_descs = 0;
  709. iop_adma_slot_cleanup(iop_chan);
  710. spin_lock_bh(&iop_chan->lock);
  711. list_for_each_entry_safe(iter, _iter, &iop_chan->chain,
  712. chain_node) {
  713. in_use_descs++;
  714. list_del(&iter->chain_node);
  715. }
  716. list_for_each_entry_safe_reverse(
  717. iter, _iter, &iop_chan->all_slots, slot_node) {
  718. list_del(&iter->slot_node);
  719. kfree(iter);
  720. iop_chan->slots_allocated--;
  721. }
  722. iop_chan->last_used = NULL;
  723. dev_dbg(iop_chan->device->common.dev, "%s slots_allocated %d\n",
  724. __func__, iop_chan->slots_allocated);
  725. spin_unlock_bh(&iop_chan->lock);
  726. /* one is ok since we left it on there on purpose */
  727. if (in_use_descs > 1)
  728. printk(KERN_ERR "IOP: Freeing %d in use descriptors!\n",
  729. in_use_descs - 1);
  730. }
  731. /**
  732. * iop_adma_status - poll the status of an ADMA transaction
  733. * @chan: ADMA channel handle
  734. * @cookie: ADMA transaction identifier
  735. * @txstate: a holder for the current state of the channel or NULL
  736. */
  737. static enum dma_status iop_adma_status(struct dma_chan *chan,
  738. dma_cookie_t cookie,
  739. struct dma_tx_state *txstate)
  740. {
  741. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  742. int ret;
  743. ret = dma_cookie_status(chan, cookie, txstate);
  744. if (ret == DMA_SUCCESS)
  745. return ret;
  746. iop_adma_slot_cleanup(iop_chan);
  747. return dma_cookie_status(chan, cookie, txstate);
  748. }
  749. static irqreturn_t iop_adma_eot_handler(int irq, void *data)
  750. {
  751. struct iop_adma_chan *chan = data;
  752. dev_dbg(chan->device->common.dev, "%s\n", __func__);
  753. tasklet_schedule(&chan->irq_tasklet);
  754. iop_adma_device_clear_eot_status(chan);
  755. return IRQ_HANDLED;
  756. }
  757. static irqreturn_t iop_adma_eoc_handler(int irq, void *data)
  758. {
  759. struct iop_adma_chan *chan = data;
  760. dev_dbg(chan->device->common.dev, "%s\n", __func__);
  761. tasklet_schedule(&chan->irq_tasklet);
  762. iop_adma_device_clear_eoc_status(chan);
  763. return IRQ_HANDLED;
  764. }
  765. static irqreturn_t iop_adma_err_handler(int irq, void *data)
  766. {
  767. struct iop_adma_chan *chan = data;
  768. unsigned long status = iop_chan_get_status(chan);
  769. dev_err(chan->device->common.dev,
  770. "error ( %s%s%s%s%s%s%s)\n",
  771. iop_is_err_int_parity(status, chan) ? "int_parity " : "",
  772. iop_is_err_mcu_abort(status, chan) ? "mcu_abort " : "",
  773. iop_is_err_int_tabort(status, chan) ? "int_tabort " : "",
  774. iop_is_err_int_mabort(status, chan) ? "int_mabort " : "",
  775. iop_is_err_pci_tabort(status, chan) ? "pci_tabort " : "",
  776. iop_is_err_pci_mabort(status, chan) ? "pci_mabort " : "",
  777. iop_is_err_split_tx(status, chan) ? "split_tx " : "");
  778. iop_adma_device_clear_err_status(chan);
  779. BUG();
  780. return IRQ_HANDLED;
  781. }
  782. static void iop_adma_issue_pending(struct dma_chan *chan)
  783. {
  784. struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
  785. if (iop_chan->pending) {
  786. iop_chan->pending = 0;
  787. iop_chan_append(iop_chan);
  788. }
  789. }
  790. /*
  791. * Perform a transaction to verify the HW works.
  792. */
  793. #define IOP_ADMA_TEST_SIZE 2000
  794. static int iop_adma_memcpy_self_test(struct iop_adma_device *device)
  795. {
  796. int i;
  797. void *src, *dest;
  798. dma_addr_t src_dma, dest_dma;
  799. struct dma_chan *dma_chan;
  800. dma_cookie_t cookie;
  801. struct dma_async_tx_descriptor *tx;
  802. int err = 0;
  803. struct iop_adma_chan *iop_chan;
  804. dev_dbg(device->common.dev, "%s\n", __func__);
  805. src = kmalloc(IOP_ADMA_TEST_SIZE, GFP_KERNEL);
  806. if (!src)
  807. return -ENOMEM;
  808. dest = kzalloc(IOP_ADMA_TEST_SIZE, GFP_KERNEL);
  809. if (!dest) {
  810. kfree(src);
  811. return -ENOMEM;
  812. }
  813. /* Fill in src buffer */
  814. for (i = 0; i < IOP_ADMA_TEST_SIZE; i++)
  815. ((u8 *) src)[i] = (u8)i;
  816. /* Start copy, using first DMA channel */
  817. dma_chan = container_of(device->common.channels.next,
  818. struct dma_chan,
  819. device_node);
  820. if (iop_adma_alloc_chan_resources(dma_chan) < 1) {
  821. err = -ENODEV;
  822. goto out;
  823. }
  824. dest_dma = dma_map_single(dma_chan->device->dev, dest,
  825. IOP_ADMA_TEST_SIZE, DMA_FROM_DEVICE);
  826. src_dma = dma_map_single(dma_chan->device->dev, src,
  827. IOP_ADMA_TEST_SIZE, DMA_TO_DEVICE);
  828. tx = iop_adma_prep_dma_memcpy(dma_chan, dest_dma, src_dma,
  829. IOP_ADMA_TEST_SIZE,
  830. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  831. cookie = iop_adma_tx_submit(tx);
  832. iop_adma_issue_pending(dma_chan);
  833. msleep(1);
  834. if (iop_adma_status(dma_chan, cookie, NULL) !=
  835. DMA_SUCCESS) {
  836. dev_err(dma_chan->device->dev,
  837. "Self-test copy timed out, disabling\n");
  838. err = -ENODEV;
  839. goto free_resources;
  840. }
  841. iop_chan = to_iop_adma_chan(dma_chan);
  842. dma_sync_single_for_cpu(&iop_chan->device->pdev->dev, dest_dma,
  843. IOP_ADMA_TEST_SIZE, DMA_FROM_DEVICE);
  844. if (memcmp(src, dest, IOP_ADMA_TEST_SIZE)) {
  845. dev_err(dma_chan->device->dev,
  846. "Self-test copy failed compare, disabling\n");
  847. err = -ENODEV;
  848. goto free_resources;
  849. }
  850. free_resources:
  851. iop_adma_free_chan_resources(dma_chan);
  852. out:
  853. kfree(src);
  854. kfree(dest);
  855. return err;
  856. }
  857. #define IOP_ADMA_NUM_SRC_TEST 4 /* must be <= 15 */
  858. static int
  859. iop_adma_xor_val_self_test(struct iop_adma_device *device)
  860. {
  861. int i, src_idx;
  862. struct page *dest;
  863. struct page *xor_srcs[IOP_ADMA_NUM_SRC_TEST];
  864. struct page *zero_sum_srcs[IOP_ADMA_NUM_SRC_TEST + 1];
  865. dma_addr_t dma_srcs[IOP_ADMA_NUM_SRC_TEST + 1];
  866. dma_addr_t dest_dma;
  867. struct dma_async_tx_descriptor *tx;
  868. struct dma_chan *dma_chan;
  869. dma_cookie_t cookie;
  870. u8 cmp_byte = 0;
  871. u32 cmp_word;
  872. u32 zero_sum_result;
  873. int err = 0;
  874. struct iop_adma_chan *iop_chan;
  875. dev_dbg(device->common.dev, "%s\n", __func__);
  876. for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) {
  877. xor_srcs[src_idx] = alloc_page(GFP_KERNEL);
  878. if (!xor_srcs[src_idx]) {
  879. while (src_idx--)
  880. __free_page(xor_srcs[src_idx]);
  881. return -ENOMEM;
  882. }
  883. }
  884. dest = alloc_page(GFP_KERNEL);
  885. if (!dest) {
  886. while (src_idx--)
  887. __free_page(xor_srcs[src_idx]);
  888. return -ENOMEM;
  889. }
  890. /* Fill in src buffers */
  891. for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) {
  892. u8 *ptr = page_address(xor_srcs[src_idx]);
  893. for (i = 0; i < PAGE_SIZE; i++)
  894. ptr[i] = (1 << src_idx);
  895. }
  896. for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++)
  897. cmp_byte ^= (u8) (1 << src_idx);
  898. cmp_word = (cmp_byte << 24) | (cmp_byte << 16) |
  899. (cmp_byte << 8) | cmp_byte;
  900. memset(page_address(dest), 0, PAGE_SIZE);
  901. dma_chan = container_of(device->common.channels.next,
  902. struct dma_chan,
  903. device_node);
  904. if (iop_adma_alloc_chan_resources(dma_chan) < 1) {
  905. err = -ENODEV;
  906. goto out;
  907. }
  908. /* test xor */
  909. dest_dma = dma_map_page(dma_chan->device->dev, dest, 0,
  910. PAGE_SIZE, DMA_FROM_DEVICE);
  911. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST; i++)
  912. dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i],
  913. 0, PAGE_SIZE, DMA_TO_DEVICE);
  914. tx = iop_adma_prep_dma_xor(dma_chan, dest_dma, dma_srcs,
  915. IOP_ADMA_NUM_SRC_TEST, PAGE_SIZE,
  916. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  917. cookie = iop_adma_tx_submit(tx);
  918. iop_adma_issue_pending(dma_chan);
  919. msleep(8);
  920. if (iop_adma_status(dma_chan, cookie, NULL) !=
  921. DMA_SUCCESS) {
  922. dev_err(dma_chan->device->dev,
  923. "Self-test xor timed out, disabling\n");
  924. err = -ENODEV;
  925. goto free_resources;
  926. }
  927. iop_chan = to_iop_adma_chan(dma_chan);
  928. dma_sync_single_for_cpu(&iop_chan->device->pdev->dev, dest_dma,
  929. PAGE_SIZE, DMA_FROM_DEVICE);
  930. for (i = 0; i < (PAGE_SIZE / sizeof(u32)); i++) {
  931. u32 *ptr = page_address(dest);
  932. if (ptr[i] != cmp_word) {
  933. dev_err(dma_chan->device->dev,
  934. "Self-test xor failed compare, disabling\n");
  935. err = -ENODEV;
  936. goto free_resources;
  937. }
  938. }
  939. dma_sync_single_for_device(&iop_chan->device->pdev->dev, dest_dma,
  940. PAGE_SIZE, DMA_TO_DEVICE);
  941. /* skip zero sum if the capability is not present */
  942. if (!dma_has_cap(DMA_XOR_VAL, dma_chan->device->cap_mask))
  943. goto free_resources;
  944. /* zero sum the sources with the destintation page */
  945. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST; i++)
  946. zero_sum_srcs[i] = xor_srcs[i];
  947. zero_sum_srcs[i] = dest;
  948. zero_sum_result = 1;
  949. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST + 1; i++)
  950. dma_srcs[i] = dma_map_page(dma_chan->device->dev,
  951. zero_sum_srcs[i], 0, PAGE_SIZE,
  952. DMA_TO_DEVICE);
  953. tx = iop_adma_prep_dma_xor_val(dma_chan, dma_srcs,
  954. IOP_ADMA_NUM_SRC_TEST + 1, PAGE_SIZE,
  955. &zero_sum_result,
  956. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  957. cookie = iop_adma_tx_submit(tx);
  958. iop_adma_issue_pending(dma_chan);
  959. msleep(8);
  960. if (iop_adma_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
  961. dev_err(dma_chan->device->dev,
  962. "Self-test zero sum timed out, disabling\n");
  963. err = -ENODEV;
  964. goto free_resources;
  965. }
  966. if (zero_sum_result != 0) {
  967. dev_err(dma_chan->device->dev,
  968. "Self-test zero sum failed compare, disabling\n");
  969. err = -ENODEV;
  970. goto free_resources;
  971. }
  972. /* test for non-zero parity sum */
  973. zero_sum_result = 0;
  974. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST + 1; i++)
  975. dma_srcs[i] = dma_map_page(dma_chan->device->dev,
  976. zero_sum_srcs[i], 0, PAGE_SIZE,
  977. DMA_TO_DEVICE);
  978. tx = iop_adma_prep_dma_xor_val(dma_chan, dma_srcs,
  979. IOP_ADMA_NUM_SRC_TEST + 1, PAGE_SIZE,
  980. &zero_sum_result,
  981. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  982. cookie = iop_adma_tx_submit(tx);
  983. iop_adma_issue_pending(dma_chan);
  984. msleep(8);
  985. if (iop_adma_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
  986. dev_err(dma_chan->device->dev,
  987. "Self-test non-zero sum timed out, disabling\n");
  988. err = -ENODEV;
  989. goto free_resources;
  990. }
  991. if (zero_sum_result != 1) {
  992. dev_err(dma_chan->device->dev,
  993. "Self-test non-zero sum failed compare, disabling\n");
  994. err = -ENODEV;
  995. goto free_resources;
  996. }
  997. free_resources:
  998. iop_adma_free_chan_resources(dma_chan);
  999. out:
  1000. src_idx = IOP_ADMA_NUM_SRC_TEST;
  1001. while (src_idx--)
  1002. __free_page(xor_srcs[src_idx]);
  1003. __free_page(dest);
  1004. return err;
  1005. }
  1006. #ifdef CONFIG_RAID6_PQ
  1007. static int
  1008. iop_adma_pq_zero_sum_self_test(struct iop_adma_device *device)
  1009. {
  1010. /* combined sources, software pq results, and extra hw pq results */
  1011. struct page *pq[IOP_ADMA_NUM_SRC_TEST+2+2];
  1012. /* ptr to the extra hw pq buffers defined above */
  1013. struct page **pq_hw = &pq[IOP_ADMA_NUM_SRC_TEST+2];
  1014. /* address conversion buffers (dma_map / page_address) */
  1015. void *pq_sw[IOP_ADMA_NUM_SRC_TEST+2];
  1016. dma_addr_t pq_src[IOP_ADMA_NUM_SRC_TEST+2];
  1017. dma_addr_t *pq_dest = &pq_src[IOP_ADMA_NUM_SRC_TEST];
  1018. int i;
  1019. struct dma_async_tx_descriptor *tx;
  1020. struct dma_chan *dma_chan;
  1021. dma_cookie_t cookie;
  1022. u32 zero_sum_result;
  1023. int err = 0;
  1024. struct device *dev;
  1025. dev_dbg(device->common.dev, "%s\n", __func__);
  1026. for (i = 0; i < ARRAY_SIZE(pq); i++) {
  1027. pq[i] = alloc_page(GFP_KERNEL);
  1028. if (!pq[i]) {
  1029. while (i--)
  1030. __free_page(pq[i]);
  1031. return -ENOMEM;
  1032. }
  1033. }
  1034. /* Fill in src buffers */
  1035. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST; i++) {
  1036. pq_sw[i] = page_address(pq[i]);
  1037. memset(pq_sw[i], 0x11111111 * (1<<i), PAGE_SIZE);
  1038. }
  1039. pq_sw[i] = page_address(pq[i]);
  1040. pq_sw[i+1] = page_address(pq[i+1]);
  1041. dma_chan = container_of(device->common.channels.next,
  1042. struct dma_chan,
  1043. device_node);
  1044. if (iop_adma_alloc_chan_resources(dma_chan) < 1) {
  1045. err = -ENODEV;
  1046. goto out;
  1047. }
  1048. dev = dma_chan->device->dev;
  1049. /* initialize the dests */
  1050. memset(page_address(pq_hw[0]), 0 , PAGE_SIZE);
  1051. memset(page_address(pq_hw[1]), 0 , PAGE_SIZE);
  1052. /* test pq */
  1053. pq_dest[0] = dma_map_page(dev, pq_hw[0], 0, PAGE_SIZE, DMA_FROM_DEVICE);
  1054. pq_dest[1] = dma_map_page(dev, pq_hw[1], 0, PAGE_SIZE, DMA_FROM_DEVICE);
  1055. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST; i++)
  1056. pq_src[i] = dma_map_page(dev, pq[i], 0, PAGE_SIZE,
  1057. DMA_TO_DEVICE);
  1058. tx = iop_adma_prep_dma_pq(dma_chan, pq_dest, pq_src,
  1059. IOP_ADMA_NUM_SRC_TEST, (u8 *)raid6_gfexp,
  1060. PAGE_SIZE,
  1061. DMA_PREP_INTERRUPT |
  1062. DMA_CTRL_ACK);
  1063. cookie = iop_adma_tx_submit(tx);
  1064. iop_adma_issue_pending(dma_chan);
  1065. msleep(8);
  1066. if (iop_adma_status(dma_chan, cookie, NULL) !=
  1067. DMA_SUCCESS) {
  1068. dev_err(dev, "Self-test pq timed out, disabling\n");
  1069. err = -ENODEV;
  1070. goto free_resources;
  1071. }
  1072. raid6_call.gen_syndrome(IOP_ADMA_NUM_SRC_TEST+2, PAGE_SIZE, pq_sw);
  1073. if (memcmp(pq_sw[IOP_ADMA_NUM_SRC_TEST],
  1074. page_address(pq_hw[0]), PAGE_SIZE) != 0) {
  1075. dev_err(dev, "Self-test p failed compare, disabling\n");
  1076. err = -ENODEV;
  1077. goto free_resources;
  1078. }
  1079. if (memcmp(pq_sw[IOP_ADMA_NUM_SRC_TEST+1],
  1080. page_address(pq_hw[1]), PAGE_SIZE) != 0) {
  1081. dev_err(dev, "Self-test q failed compare, disabling\n");
  1082. err = -ENODEV;
  1083. goto free_resources;
  1084. }
  1085. /* test correct zero sum using the software generated pq values */
  1086. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST + 2; i++)
  1087. pq_src[i] = dma_map_page(dev, pq[i], 0, PAGE_SIZE,
  1088. DMA_TO_DEVICE);
  1089. zero_sum_result = ~0;
  1090. tx = iop_adma_prep_dma_pq_val(dma_chan, &pq_src[IOP_ADMA_NUM_SRC_TEST],
  1091. pq_src, IOP_ADMA_NUM_SRC_TEST,
  1092. raid6_gfexp, PAGE_SIZE, &zero_sum_result,
  1093. DMA_PREP_INTERRUPT|DMA_CTRL_ACK);
  1094. cookie = iop_adma_tx_submit(tx);
  1095. iop_adma_issue_pending(dma_chan);
  1096. msleep(8);
  1097. if (iop_adma_status(dma_chan, cookie, NULL) !=
  1098. DMA_SUCCESS) {
  1099. dev_err(dev, "Self-test pq-zero-sum timed out, disabling\n");
  1100. err = -ENODEV;
  1101. goto free_resources;
  1102. }
  1103. if (zero_sum_result != 0) {
  1104. dev_err(dev, "Self-test pq-zero-sum failed to validate: %x\n",
  1105. zero_sum_result);
  1106. err = -ENODEV;
  1107. goto free_resources;
  1108. }
  1109. /* test incorrect zero sum */
  1110. i = IOP_ADMA_NUM_SRC_TEST;
  1111. memset(pq_sw[i] + 100, 0, 100);
  1112. memset(pq_sw[i+1] + 200, 0, 200);
  1113. for (i = 0; i < IOP_ADMA_NUM_SRC_TEST + 2; i++)
  1114. pq_src[i] = dma_map_page(dev, pq[i], 0, PAGE_SIZE,
  1115. DMA_TO_DEVICE);
  1116. zero_sum_result = 0;
  1117. tx = iop_adma_prep_dma_pq_val(dma_chan, &pq_src[IOP_ADMA_NUM_SRC_TEST],
  1118. pq_src, IOP_ADMA_NUM_SRC_TEST,
  1119. raid6_gfexp, PAGE_SIZE, &zero_sum_result,
  1120. DMA_PREP_INTERRUPT|DMA_CTRL_ACK);
  1121. cookie = iop_adma_tx_submit(tx);
  1122. iop_adma_issue_pending(dma_chan);
  1123. msleep(8);
  1124. if (iop_adma_status(dma_chan, cookie, NULL) !=
  1125. DMA_SUCCESS) {
  1126. dev_err(dev, "Self-test !pq-zero-sum timed out, disabling\n");
  1127. err = -ENODEV;
  1128. goto free_resources;
  1129. }
  1130. if (zero_sum_result != (SUM_CHECK_P_RESULT | SUM_CHECK_Q_RESULT)) {
  1131. dev_err(dev, "Self-test !pq-zero-sum failed to validate: %x\n",
  1132. zero_sum_result);
  1133. err = -ENODEV;
  1134. goto free_resources;
  1135. }
  1136. free_resources:
  1137. iop_adma_free_chan_resources(dma_chan);
  1138. out:
  1139. i = ARRAY_SIZE(pq);
  1140. while (i--)
  1141. __free_page(pq[i]);
  1142. return err;
  1143. }
  1144. #endif
  1145. static int iop_adma_remove(struct platform_device *dev)
  1146. {
  1147. struct iop_adma_device *device = platform_get_drvdata(dev);
  1148. struct dma_chan *chan, *_chan;
  1149. struct iop_adma_chan *iop_chan;
  1150. struct iop_adma_platform_data *plat_data = dev_get_platdata(&dev->dev);
  1151. dma_async_device_unregister(&device->common);
  1152. dma_free_coherent(&dev->dev, plat_data->pool_size,
  1153. device->dma_desc_pool_virt, device->dma_desc_pool);
  1154. list_for_each_entry_safe(chan, _chan, &device->common.channels,
  1155. device_node) {
  1156. iop_chan = to_iop_adma_chan(chan);
  1157. list_del(&chan->device_node);
  1158. kfree(iop_chan);
  1159. }
  1160. kfree(device);
  1161. return 0;
  1162. }
  1163. static int iop_adma_probe(struct platform_device *pdev)
  1164. {
  1165. struct resource *res;
  1166. int ret = 0, i;
  1167. struct iop_adma_device *adev;
  1168. struct iop_adma_chan *iop_chan;
  1169. struct dma_device *dma_dev;
  1170. struct iop_adma_platform_data *plat_data = dev_get_platdata(&pdev->dev);
  1171. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1172. if (!res)
  1173. return -ENODEV;
  1174. if (!devm_request_mem_region(&pdev->dev, res->start,
  1175. resource_size(res), pdev->name))
  1176. return -EBUSY;
  1177. adev = kzalloc(sizeof(*adev), GFP_KERNEL);
  1178. if (!adev)
  1179. return -ENOMEM;
  1180. dma_dev = &adev->common;
  1181. /* allocate coherent memory for hardware descriptors
  1182. * note: writecombine gives slightly better performance, but
  1183. * requires that we explicitly flush the writes
  1184. */
  1185. if ((adev->dma_desc_pool_virt = dma_alloc_writecombine(&pdev->dev,
  1186. plat_data->pool_size,
  1187. &adev->dma_desc_pool,
  1188. GFP_KERNEL)) == NULL) {
  1189. ret = -ENOMEM;
  1190. goto err_free_adev;
  1191. }
  1192. dev_dbg(&pdev->dev, "%s: allocated descriptor pool virt %p phys %p\n",
  1193. __func__, adev->dma_desc_pool_virt,
  1194. (void *) adev->dma_desc_pool);
  1195. adev->id = plat_data->hw_id;
  1196. /* discover transaction capabilites from the platform data */
  1197. dma_dev->cap_mask = plat_data->cap_mask;
  1198. adev->pdev = pdev;
  1199. platform_set_drvdata(pdev, adev);
  1200. INIT_LIST_HEAD(&dma_dev->channels);
  1201. /* set base routines */
  1202. dma_dev->device_alloc_chan_resources = iop_adma_alloc_chan_resources;
  1203. dma_dev->device_free_chan_resources = iop_adma_free_chan_resources;
  1204. dma_dev->device_tx_status = iop_adma_status;
  1205. dma_dev->device_issue_pending = iop_adma_issue_pending;
  1206. dma_dev->dev = &pdev->dev;
  1207. /* set prep routines based on capability */
  1208. if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask))
  1209. dma_dev->device_prep_dma_memcpy = iop_adma_prep_dma_memcpy;
  1210. if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
  1211. dma_dev->max_xor = iop_adma_get_max_xor();
  1212. dma_dev->device_prep_dma_xor = iop_adma_prep_dma_xor;
  1213. }
  1214. if (dma_has_cap(DMA_XOR_VAL, dma_dev->cap_mask))
  1215. dma_dev->device_prep_dma_xor_val =
  1216. iop_adma_prep_dma_xor_val;
  1217. if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) {
  1218. dma_set_maxpq(dma_dev, iop_adma_get_max_pq(), 0);
  1219. dma_dev->device_prep_dma_pq = iop_adma_prep_dma_pq;
  1220. }
  1221. if (dma_has_cap(DMA_PQ_VAL, dma_dev->cap_mask))
  1222. dma_dev->device_prep_dma_pq_val =
  1223. iop_adma_prep_dma_pq_val;
  1224. if (dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask))
  1225. dma_dev->device_prep_dma_interrupt =
  1226. iop_adma_prep_dma_interrupt;
  1227. iop_chan = kzalloc(sizeof(*iop_chan), GFP_KERNEL);
  1228. if (!iop_chan) {
  1229. ret = -ENOMEM;
  1230. goto err_free_dma;
  1231. }
  1232. iop_chan->device = adev;
  1233. iop_chan->mmr_base = devm_ioremap(&pdev->dev, res->start,
  1234. resource_size(res));
  1235. if (!iop_chan->mmr_base) {
  1236. ret = -ENOMEM;
  1237. goto err_free_iop_chan;
  1238. }
  1239. tasklet_init(&iop_chan->irq_tasklet, iop_adma_tasklet, (unsigned long)
  1240. iop_chan);
  1241. /* clear errors before enabling interrupts */
  1242. iop_adma_device_clear_err_status(iop_chan);
  1243. for (i = 0; i < 3; i++) {
  1244. irq_handler_t handler[] = { iop_adma_eot_handler,
  1245. iop_adma_eoc_handler,
  1246. iop_adma_err_handler };
  1247. int irq = platform_get_irq(pdev, i);
  1248. if (irq < 0) {
  1249. ret = -ENXIO;
  1250. goto err_free_iop_chan;
  1251. } else {
  1252. ret = devm_request_irq(&pdev->dev, irq,
  1253. handler[i], 0, pdev->name, iop_chan);
  1254. if (ret)
  1255. goto err_free_iop_chan;
  1256. }
  1257. }
  1258. spin_lock_init(&iop_chan->lock);
  1259. INIT_LIST_HEAD(&iop_chan->chain);
  1260. INIT_LIST_HEAD(&iop_chan->all_slots);
  1261. iop_chan->common.device = dma_dev;
  1262. dma_cookie_init(&iop_chan->common);
  1263. list_add_tail(&iop_chan->common.device_node, &dma_dev->channels);
  1264. if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) {
  1265. ret = iop_adma_memcpy_self_test(adev);
  1266. dev_dbg(&pdev->dev, "memcpy self test returned %d\n", ret);
  1267. if (ret)
  1268. goto err_free_iop_chan;
  1269. }
  1270. if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
  1271. ret = iop_adma_xor_val_self_test(adev);
  1272. dev_dbg(&pdev->dev, "xor self test returned %d\n", ret);
  1273. if (ret)
  1274. goto err_free_iop_chan;
  1275. }
  1276. if (dma_has_cap(DMA_PQ, dma_dev->cap_mask) &&
  1277. dma_has_cap(DMA_PQ_VAL, dma_dev->cap_mask)) {
  1278. #ifdef CONFIG_RAID6_PQ
  1279. ret = iop_adma_pq_zero_sum_self_test(adev);
  1280. dev_dbg(&pdev->dev, "pq self test returned %d\n", ret);
  1281. #else
  1282. /* can not test raid6, so do not publish capability */
  1283. dma_cap_clear(DMA_PQ, dma_dev->cap_mask);
  1284. dma_cap_clear(DMA_PQ_VAL, dma_dev->cap_mask);
  1285. ret = 0;
  1286. #endif
  1287. if (ret)
  1288. goto err_free_iop_chan;
  1289. }
  1290. dev_info(&pdev->dev, "Intel(R) IOP: ( %s%s%s%s%s%s)\n",
  1291. dma_has_cap(DMA_PQ, dma_dev->cap_mask) ? "pq " : "",
  1292. dma_has_cap(DMA_PQ_VAL, dma_dev->cap_mask) ? "pq_val " : "",
  1293. dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "xor " : "",
  1294. dma_has_cap(DMA_XOR_VAL, dma_dev->cap_mask) ? "xor_val " : "",
  1295. dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask) ? "cpy " : "",
  1296. dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask) ? "intr " : "");
  1297. dma_async_device_register(dma_dev);
  1298. goto out;
  1299. err_free_iop_chan:
  1300. kfree(iop_chan);
  1301. err_free_dma:
  1302. dma_free_coherent(&adev->pdev->dev, plat_data->pool_size,
  1303. adev->dma_desc_pool_virt, adev->dma_desc_pool);
  1304. err_free_adev:
  1305. kfree(adev);
  1306. out:
  1307. return ret;
  1308. }
  1309. static void iop_chan_start_null_memcpy(struct iop_adma_chan *iop_chan)
  1310. {
  1311. struct iop_adma_desc_slot *sw_desc, *grp_start;
  1312. dma_cookie_t cookie;
  1313. int slot_cnt, slots_per_op;
  1314. dev_dbg(iop_chan->device->common.dev, "%s\n", __func__);
  1315. spin_lock_bh(&iop_chan->lock);
  1316. slot_cnt = iop_chan_memcpy_slot_count(0, &slots_per_op);
  1317. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  1318. if (sw_desc) {
  1319. grp_start = sw_desc->group_head;
  1320. list_splice_init(&sw_desc->tx_list, &iop_chan->chain);
  1321. async_tx_ack(&sw_desc->async_tx);
  1322. iop_desc_init_memcpy(grp_start, 0);
  1323. iop_desc_set_byte_count(grp_start, iop_chan, 0);
  1324. iop_desc_set_dest_addr(grp_start, iop_chan, 0);
  1325. iop_desc_set_memcpy_src_addr(grp_start, 0);
  1326. cookie = dma_cookie_assign(&sw_desc->async_tx);
  1327. /* initialize the completed cookie to be less than
  1328. * the most recently used cookie
  1329. */
  1330. iop_chan->common.completed_cookie = cookie - 1;
  1331. /* channel should not be busy */
  1332. BUG_ON(iop_chan_is_busy(iop_chan));
  1333. /* clear any prior error-status bits */
  1334. iop_adma_device_clear_err_status(iop_chan);
  1335. /* disable operation */
  1336. iop_chan_disable(iop_chan);
  1337. /* set the descriptor address */
  1338. iop_chan_set_next_descriptor(iop_chan, sw_desc->async_tx.phys);
  1339. /* 1/ don't add pre-chained descriptors
  1340. * 2/ dummy read to flush next_desc write
  1341. */
  1342. BUG_ON(iop_desc_get_next_desc(sw_desc));
  1343. /* run the descriptor */
  1344. iop_chan_enable(iop_chan);
  1345. } else
  1346. dev_err(iop_chan->device->common.dev,
  1347. "failed to allocate null descriptor\n");
  1348. spin_unlock_bh(&iop_chan->lock);
  1349. }
  1350. static void iop_chan_start_null_xor(struct iop_adma_chan *iop_chan)
  1351. {
  1352. struct iop_adma_desc_slot *sw_desc, *grp_start;
  1353. dma_cookie_t cookie;
  1354. int slot_cnt, slots_per_op;
  1355. dev_dbg(iop_chan->device->common.dev, "%s\n", __func__);
  1356. spin_lock_bh(&iop_chan->lock);
  1357. slot_cnt = iop_chan_xor_slot_count(0, 2, &slots_per_op);
  1358. sw_desc = iop_adma_alloc_slots(iop_chan, slot_cnt, slots_per_op);
  1359. if (sw_desc) {
  1360. grp_start = sw_desc->group_head;
  1361. list_splice_init(&sw_desc->tx_list, &iop_chan->chain);
  1362. async_tx_ack(&sw_desc->async_tx);
  1363. iop_desc_init_null_xor(grp_start, 2, 0);
  1364. iop_desc_set_byte_count(grp_start, iop_chan, 0);
  1365. iop_desc_set_dest_addr(grp_start, iop_chan, 0);
  1366. iop_desc_set_xor_src_addr(grp_start, 0, 0);
  1367. iop_desc_set_xor_src_addr(grp_start, 1, 0);
  1368. cookie = dma_cookie_assign(&sw_desc->async_tx);
  1369. /* initialize the completed cookie to be less than
  1370. * the most recently used cookie
  1371. */
  1372. iop_chan->common.completed_cookie = cookie - 1;
  1373. /* channel should not be busy */
  1374. BUG_ON(iop_chan_is_busy(iop_chan));
  1375. /* clear any prior error-status bits */
  1376. iop_adma_device_clear_err_status(iop_chan);
  1377. /* disable operation */
  1378. iop_chan_disable(iop_chan);
  1379. /* set the descriptor address */
  1380. iop_chan_set_next_descriptor(iop_chan, sw_desc->async_tx.phys);
  1381. /* 1/ don't add pre-chained descriptors
  1382. * 2/ dummy read to flush next_desc write
  1383. */
  1384. BUG_ON(iop_desc_get_next_desc(sw_desc));
  1385. /* run the descriptor */
  1386. iop_chan_enable(iop_chan);
  1387. } else
  1388. dev_err(iop_chan->device->common.dev,
  1389. "failed to allocate null descriptor\n");
  1390. spin_unlock_bh(&iop_chan->lock);
  1391. }
  1392. static struct platform_driver iop_adma_driver = {
  1393. .probe = iop_adma_probe,
  1394. .remove = iop_adma_remove,
  1395. .driver = {
  1396. .owner = THIS_MODULE,
  1397. .name = "iop-adma",
  1398. },
  1399. };
  1400. module_platform_driver(iop_adma_driver);
  1401. MODULE_AUTHOR("Intel Corporation");
  1402. MODULE_DESCRIPTION("IOP ADMA Engine Driver");
  1403. MODULE_LICENSE("GPL");
  1404. MODULE_ALIAS("platform:iop-adma");