async_tx.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright © 2006, Intel Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. */
  18. #ifndef _ASYNC_TX_H_
  19. #define _ASYNC_TX_H_
  20. #include <linux/dmaengine.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/interrupt.h>
  23. /**
  24. * dma_chan_ref - object used to manage dma channels received from the
  25. * dmaengine core.
  26. * @chan - the channel being tracked
  27. * @node - node for the channel to be placed on async_tx_master_list
  28. * @rcu - for list_del_rcu
  29. * @count - number of times this channel is listed in the pool
  30. * (for channels with multiple capabiities)
  31. */
  32. struct dma_chan_ref {
  33. struct dma_chan *chan;
  34. struct list_head node;
  35. struct rcu_head rcu;
  36. atomic_t count;
  37. };
  38. /**
  39. * async_tx_flags - modifiers for the async_* calls
  40. * @ASYNC_TX_XOR_ZERO_DST: this flag must be used for xor operations where the
  41. * the destination address is not a source. The asynchronous case handles this
  42. * implicitly, the synchronous case needs to zero the destination block.
  43. * @ASYNC_TX_XOR_DROP_DST: this flag must be used if the destination address is
  44. * also one of the source addresses. In the synchronous case the destination
  45. * address is an implied source, whereas the asynchronous case it must be listed
  46. * as a source. The destination address must be the first address in the source
  47. * array.
  48. * @ASYNC_TX_ACK: immediately ack the descriptor, precludes setting up a
  49. * dependency chain
  50. * @ASYNC_TX_DEP_ACK: ack the dependency descriptor. Useful for chaining.
  51. */
  52. enum async_tx_flags {
  53. ASYNC_TX_XOR_ZERO_DST = (1 << 0),
  54. ASYNC_TX_XOR_DROP_DST = (1 << 1),
  55. ASYNC_TX_ACK = (1 << 3),
  56. ASYNC_TX_DEP_ACK = (1 << 4),
  57. };
  58. #ifdef CONFIG_DMA_ENGINE
  59. #define async_tx_issue_pending_all dma_issue_pending_all
  60. #ifdef CONFIG_ARCH_HAS_ASYNC_TX_FIND_CHANNEL
  61. #include <asm/async_tx.h>
  62. #else
  63. #define async_tx_find_channel(dep, type, dst, dst_count, src, src_count, len) \
  64. __async_tx_find_channel(dep, type)
  65. struct dma_chan *
  66. __async_tx_find_channel(struct dma_async_tx_descriptor *depend_tx,
  67. enum dma_transaction_type tx_type);
  68. #endif /* CONFIG_ARCH_HAS_ASYNC_TX_FIND_CHANNEL */
  69. #else
  70. static inline void async_tx_issue_pending_all(void)
  71. {
  72. do { } while (0);
  73. }
  74. static inline struct dma_chan *
  75. async_tx_find_channel(struct dma_async_tx_descriptor *depend_tx,
  76. enum dma_transaction_type tx_type, struct page **dst, int dst_count,
  77. struct page **src, int src_count, size_t len)
  78. {
  79. return NULL;
  80. }
  81. #endif
  82. /**
  83. * async_tx_sync_epilog - actions to take if an operation is run synchronously
  84. * @cb_fn: function to call when the transaction completes
  85. * @cb_fn_param: parameter to pass to the callback routine
  86. */
  87. static inline void
  88. async_tx_sync_epilog(dma_async_tx_callback cb_fn, void *cb_fn_param)
  89. {
  90. if (cb_fn)
  91. cb_fn(cb_fn_param);
  92. }
  93. void
  94. async_tx_submit(struct dma_chan *chan, struct dma_async_tx_descriptor *tx,
  95. enum async_tx_flags flags, struct dma_async_tx_descriptor *depend_tx,
  96. dma_async_tx_callback cb_fn, void *cb_fn_param);
  97. struct dma_async_tx_descriptor *
  98. async_xor(struct page *dest, struct page **src_list, unsigned int offset,
  99. int src_cnt, size_t len, enum async_tx_flags flags,
  100. struct dma_async_tx_descriptor *depend_tx,
  101. dma_async_tx_callback cb_fn, void *cb_fn_param);
  102. struct dma_async_tx_descriptor *
  103. async_xor_zero_sum(struct page *dest, struct page **src_list,
  104. unsigned int offset, int src_cnt, size_t len,
  105. u32 *result, enum async_tx_flags flags,
  106. struct dma_async_tx_descriptor *depend_tx,
  107. dma_async_tx_callback cb_fn, void *cb_fn_param);
  108. struct dma_async_tx_descriptor *
  109. async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
  110. unsigned int src_offset, size_t len, enum async_tx_flags flags,
  111. struct dma_async_tx_descriptor *depend_tx,
  112. dma_async_tx_callback cb_fn, void *cb_fn_param);
  113. struct dma_async_tx_descriptor *
  114. async_memset(struct page *dest, int val, unsigned int offset,
  115. size_t len, enum async_tx_flags flags,
  116. struct dma_async_tx_descriptor *depend_tx,
  117. dma_async_tx_callback cb_fn, void *cb_fn_param);
  118. struct dma_async_tx_descriptor *
  119. async_trigger_callback(enum async_tx_flags flags,
  120. struct dma_async_tx_descriptor *depend_tx,
  121. dma_async_tx_callback cb_fn, void *cb_fn_param);
  122. void async_tx_quiesce(struct dma_async_tx_descriptor **tx);
  123. #endif /* _ASYNC_TX_H_ */