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