iop-adma.c 46 KB

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