1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
25
26
27
28
29
30
31
32
33struct dma_chan_ref {
34 struct dma_chan *chan;
35 struct list_head node;
36 struct rcu_head rcu;
37 atomic_t count;
38};
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54enum async_tx_flags {
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),
59};
60
61#ifdef CONFIG_DMA_ENGINE
62void async_tx_issue_pending_all(void);
63enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
64void 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>
67#else
68#define async_tx_find_channel(dep, type, dst, dst_count, src, src_count, len) \
69 __async_tx_find_channel(dep, type)
70struct dma_chan *
71__async_tx_find_channel(struct dma_async_tx_descriptor *depend_tx,
72 enum dma_transaction_type tx_type);
73#endif
74#else
75static inline void async_tx_issue_pending_all(void)
76{
77 do { } while (0);
78}
79
80static inline enum dma_status
81dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
82{
83 return DMA_SUCCESS;
84}
85
86static inline void
87async_tx_run_dependencies(struct dma_async_tx_descriptor *tx,
88 struct dma_chan *host_chan)
89{
90 do { } while (0);
91}
92
93static inline struct dma_chan *
94async_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)
97{
98 return NULL;
99}
100#endif
101
102
103
104
105
106
107
108
109static inline void
110async_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)
113{
114 if (cb_fn)
115 cb_fn(cb_fn_param);
116
117 if (depend_tx && (flags & ASYNC_TX_DEP_ACK))
118 async_tx_ack(depend_tx);
119}
120
121void
122async_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);
125
126struct dma_async_tx_descriptor *
127async_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);
131
132struct dma_async_tx_descriptor *
133async_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);
138
139struct dma_async_tx_descriptor *
140async_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);
144
145struct dma_async_tx_descriptor *
146async_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);
150
151struct dma_async_tx_descriptor *
152async_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
156