2 * Copyright © 2006, Intel Corporation.
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.
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
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.
20 #include <linux/dmaengine.h>
21 #include <linux/spinlock.h>
22 #include <linux/interrupt.h>
25 * dma_chan_ref - object used to manage dma channels received from the
27 * @chan - the channel being tracked
28 * @node - node for the channel to be placed on async_tx_master_list
29 * @rcu - for list_del_rcu
30 * @count - number of times this channel is listed in the pool
31 * (for channels with multiple capabiities)
34 struct dma_chan
*chan
;
35 struct list_head node
;
41 * async_tx_flags - modifiers for the async_* calls
42 * @ASYNC_TX_XOR_ZERO_DST: this flag must be used for xor operations where the
43 * the destination address is not a source. The asynchronous case handles this
44 * implicitly, the synchronous case needs to zero the destination block.
45 * @ASYNC_TX_XOR_DROP_DST: this flag must be used if the destination address is
46 * also one of the source addresses. In the synchronous case the destination
47 * address is an implied source, whereas the asynchronous case it must be listed
48 * as a source. The destination address must be the first address in the source
50 * @ASYNC_TX_ACK: immediately ack the descriptor, precludes setting up a
52 * @ASYNC_TX_DEP_ACK: ack the dependency descriptor. Useful for chaining.
55 ASYNC_TX_XOR_ZERO_DST
= (1 << 0),
56 ASYNC_TX_XOR_DROP_DST
= (1 << 1),
57 ASYNC_TX_ACK
= (1 << 3),
58 ASYNC_TX_DEP_ACK
= (1 << 4),
61 #ifdef CONFIG_DMA_ENGINE
62 void async_tx_issue_pending_all(void);
63 enum dma_status
dma_wait_for_async_tx(struct dma_async_tx_descriptor
*tx
);
64 void async_tx_run_dependencies(struct dma_async_tx_descriptor
*tx
);
65 #ifdef CONFIG_ARCH_HAS_ASYNC_TX_FIND_CHANNEL
66 #include <asm/async_tx.h>
68 #define async_tx_find_channel(dep, type, dst, dst_count, src, src_count, len) \
69 __async_tx_find_channel(dep, type)
71 __async_tx_find_channel(struct dma_async_tx_descriptor
*depend_tx
,
72 enum dma_transaction_type tx_type
);
73 #endif /* CONFIG_ARCH_HAS_ASYNC_TX_FIND_CHANNEL */
75 static inline void async_tx_issue_pending_all(void)
80 static inline enum dma_status
81 dma_wait_for_async_tx(struct dma_async_tx_descriptor
*tx
)
87 async_tx_run_dependencies(struct dma_async_tx_descriptor
*tx
,
88 struct dma_chan
*host_chan
)
93 static inline struct dma_chan
*
94 async_tx_find_channel(struct dma_async_tx_descriptor
*depend_tx
,
95 enum dma_transaction_type tx_type
, struct page
**dst
, int dst_count
,
96 struct page
**src
, int src_count
, size_t len
)
103 * async_tx_sync_epilog - actions to take if an operation is run synchronously
104 * @flags: async_tx flags
105 * @depend_tx: transaction depends on depend_tx
106 * @cb_fn: function to call when the transaction completes
107 * @cb_fn_param: parameter to pass to the callback routine
110 async_tx_sync_epilog(unsigned long flags
,
111 struct dma_async_tx_descriptor
*depend_tx
,
112 dma_async_tx_callback cb_fn
, void *cb_fn_param
)
117 if (depend_tx
&& (flags
& ASYNC_TX_DEP_ACK
))
118 async_tx_ack(depend_tx
);
122 async_tx_submit(struct dma_chan
*chan
, struct dma_async_tx_descriptor
*tx
,
123 enum async_tx_flags flags
, struct dma_async_tx_descriptor
*depend_tx
,
124 dma_async_tx_callback cb_fn
, void *cb_fn_param
);
126 struct dma_async_tx_descriptor
*
127 async_xor(struct page
*dest
, struct page
**src_list
, unsigned int offset
,
128 int src_cnt
, size_t len
, enum async_tx_flags flags
,
129 struct dma_async_tx_descriptor
*depend_tx
,
130 dma_async_tx_callback cb_fn
, void *cb_fn_param
);
132 struct dma_async_tx_descriptor
*
133 async_xor_zero_sum(struct page
*dest
, struct page
**src_list
,
134 unsigned int offset
, int src_cnt
, size_t len
,
135 u32
*result
, enum async_tx_flags flags
,
136 struct dma_async_tx_descriptor
*depend_tx
,
137 dma_async_tx_callback cb_fn
, void *cb_fn_param
);
139 struct dma_async_tx_descriptor
*
140 async_memcpy(struct page
*dest
, struct page
*src
, unsigned int dest_offset
,
141 unsigned int src_offset
, size_t len
, enum async_tx_flags flags
,
142 struct dma_async_tx_descriptor
*depend_tx
,
143 dma_async_tx_callback cb_fn
, void *cb_fn_param
);
145 struct dma_async_tx_descriptor
*
146 async_memset(struct page
*dest
, int val
, unsigned int offset
,
147 size_t len
, enum async_tx_flags flags
,
148 struct dma_async_tx_descriptor
*depend_tx
,
149 dma_async_tx_callback cb_fn
, void *cb_fn_param
);
151 struct dma_async_tx_descriptor
*
152 async_trigger_callback(enum async_tx_flags flags
,
153 struct dma_async_tx_descriptor
*depend_tx
,
154 dma_async_tx_callback cb_fn
, void *cb_fn_param
);
155 #endif /* _ASYNC_TX_H_ */