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#ifdef CONFIG_HAS_DMA
28#define __async_inline
29#else
30#define __async_inline __always_inline
31#endif
32
33
34
35
36
37
38
39
40
41
42struct dma_chan_ref {
43 struct dma_chan *chan;
44 struct list_head node;
45 struct rcu_head rcu;
46 atomic_t count;
47};
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64enum async_tx_flags {
65 ASYNC_TX_XOR_ZERO_DST = (1 << 0),
66 ASYNC_TX_XOR_DROP_DST = (1 << 1),
67 ASYNC_TX_ACK = (1 << 2),
68 ASYNC_TX_FENCE = (1 << 3),
69};
70
71
72
73
74
75
76
77
78
79struct async_submit_ctl {
80 enum async_tx_flags flags;
81 struct dma_async_tx_descriptor *depend_tx;
82 dma_async_tx_callback cb_fn;
83 void *cb_param;
84 void *scribble;
85};
86
87#ifdef CONFIG_DMA_ENGINE
88#define async_tx_issue_pending_all dma_issue_pending_all
89
90
91
92
93
94
95
96
97
98static inline void async_tx_issue_pending(struct dma_async_tx_descriptor *tx)
99{
100 if (likely(tx)) {
101 struct dma_chan *chan = tx->chan;
102 struct dma_device *dma = chan->device;
103
104 dma->device_issue_pending(chan);
105 }
106}
107#ifdef CONFIG_ARCH_HAS_ASYNC_TX_FIND_CHANNEL
108#include <asm/async_tx.h>
109#else
110#define async_tx_find_channel(dep, type, dst, dst_count, src, src_count, len) \
111 __async_tx_find_channel(dep, type)
112struct dma_chan *
113__async_tx_find_channel(struct async_submit_ctl *submit,
114 enum dma_transaction_type tx_type);
115#endif
116#else
117static inline void async_tx_issue_pending_all(void)
118{
119 do { } while (0);
120}
121
122static inline void async_tx_issue_pending(struct dma_async_tx_descriptor *tx)
123{
124 do { } while (0);
125}
126
127static inline struct dma_chan *
128async_tx_find_channel(struct async_submit_ctl *submit,
129 enum dma_transaction_type tx_type, struct page **dst,
130 int dst_count, struct page **src, int src_count,
131 size_t len)
132{
133 return NULL;
134}
135#endif
136
137
138
139
140
141
142static inline void
143async_tx_sync_epilog(struct async_submit_ctl *submit)
144{
145 if (submit->cb_fn)
146 submit->cb_fn(submit->cb_param);
147}
148
149typedef union {
150 unsigned long addr;
151 struct page *page;
152 dma_addr_t dma;
153} addr_conv_t;
154
155static inline void
156init_async_submit(struct async_submit_ctl *args, enum async_tx_flags flags,
157 struct dma_async_tx_descriptor *tx,
158 dma_async_tx_callback cb_fn, void *cb_param,
159 addr_conv_t *scribble)
160{
161 args->flags = flags;
162 args->depend_tx = tx;
163 args->cb_fn = cb_fn;
164 args->cb_param = cb_param;
165 args->scribble = scribble;
166}
167
168void async_tx_submit(struct dma_chan *chan, struct dma_async_tx_descriptor *tx,
169 struct async_submit_ctl *submit);
170
171struct dma_async_tx_descriptor *
172async_xor(struct page *dest, struct page **src_list, unsigned int offset,
173 int src_cnt, size_t len, struct async_submit_ctl *submit);
174
175struct dma_async_tx_descriptor *
176async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,
177 int src_cnt, size_t len, enum sum_check_flags *result,
178 struct async_submit_ctl *submit);
179
180struct dma_async_tx_descriptor *
181async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
182 unsigned int src_offset, size_t len,
183 struct async_submit_ctl *submit);
184
185struct dma_async_tx_descriptor *async_trigger_callback(struct async_submit_ctl *submit);
186
187struct dma_async_tx_descriptor *
188async_gen_syndrome(struct page **blocks, unsigned int offset, int src_cnt,
189 size_t len, struct async_submit_ctl *submit);
190
191struct dma_async_tx_descriptor *
192async_syndrome_val(struct page **blocks, unsigned int offset, int src_cnt,
193 size_t len, enum sum_check_flags *pqres, struct page *spare,
194 struct async_submit_ctl *submit);
195
196struct dma_async_tx_descriptor *
197async_raid6_2data_recov(int src_num, size_t bytes, int faila, int failb,
198 struct page **ptrs, struct async_submit_ctl *submit);
199
200struct dma_async_tx_descriptor *
201async_raid6_datap_recov(int src_num, size_t bytes, int faila,
202 struct page **ptrs, struct async_submit_ctl *submit);
203
204void async_tx_quiesce(struct dma_async_tx_descriptor **tx);
205#endif
206