2 * Intel I/OAT DMA Linux driver
3 * Copyright(c) 2004 - 2015 Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * The full GNU General Public License is included in this distribution in
15 * the file called "COPYING".
18 #include <linux/module.h>
19 #include <linux/pci.h>
20 #include <linux/gfp.h>
21 #include <linux/dmaengine.h>
22 #include <linux/dma-mapping.h>
23 #include <linux/prefetch.h>
24 #include "../dmaengine.h"
25 #include "registers.h"
31 /* provide a lookup table for setting the source address in the base or
32 * extended descriptor of an xor or pq descriptor
34 static const u8 xor_idx_to_desc
= 0xe0;
35 static const u8 xor_idx_to_field
[] = { 1, 4, 5, 6, 7, 0, 1, 2 };
36 static const u8 pq_idx_to_desc
= 0xf8;
37 static const u8 pq16_idx_to_desc
[] = { 0, 0, 1, 1, 1, 1, 1, 1, 1,
38 2, 2, 2, 2, 2, 2, 2 };
39 static const u8 pq_idx_to_field
[] = { 1, 4, 5, 0, 1, 2, 4, 5 };
40 static const u8 pq16_idx_to_field
[] = { 1, 4, 1, 2, 3, 4, 5, 6, 7,
41 0, 1, 2, 3, 4, 5, 6 };
43 static void xor_set_src(struct ioat_raw_descriptor
*descs
[2],
44 dma_addr_t addr
, u32 offset
, int idx
)
46 struct ioat_raw_descriptor
*raw
= descs
[xor_idx_to_desc
>> idx
& 1];
48 raw
->field
[xor_idx_to_field
[idx
]] = addr
+ offset
;
51 static dma_addr_t
pq_get_src(struct ioat_raw_descriptor
*descs
[2], int idx
)
53 struct ioat_raw_descriptor
*raw
= descs
[pq_idx_to_desc
>> idx
& 1];
55 return raw
->field
[pq_idx_to_field
[idx
]];
58 static dma_addr_t
pq16_get_src(struct ioat_raw_descriptor
*desc
[3], int idx
)
60 struct ioat_raw_descriptor
*raw
= desc
[pq16_idx_to_desc
[idx
]];
62 return raw
->field
[pq16_idx_to_field
[idx
]];
65 static void pq_set_src(struct ioat_raw_descriptor
*descs
[2],
66 dma_addr_t addr
, u32 offset
, u8 coef
, int idx
)
68 struct ioat_pq_descriptor
*pq
= (struct ioat_pq_descriptor
*) descs
[0];
69 struct ioat_raw_descriptor
*raw
= descs
[pq_idx_to_desc
>> idx
& 1];
71 raw
->field
[pq_idx_to_field
[idx
]] = addr
+ offset
;
75 static void pq16_set_src(struct ioat_raw_descriptor
*desc
[3],
76 dma_addr_t addr
, u32 offset
, u8 coef
, unsigned idx
)
78 struct ioat_pq_descriptor
*pq
= (struct ioat_pq_descriptor
*)desc
[0];
79 struct ioat_pq16a_descriptor
*pq16
=
80 (struct ioat_pq16a_descriptor
*)desc
[1];
81 struct ioat_raw_descriptor
*raw
= desc
[pq16_idx_to_desc
[idx
]];
83 raw
->field
[pq16_idx_to_field
[idx
]] = addr
+ offset
;
88 pq16
->coef
[idx
- 8] = coef
;
91 static struct ioat_sed_ent
*
92 ioat3_alloc_sed(struct ioatdma_device
*ioat_dma
, unsigned int hw_pool
)
94 struct ioat_sed_ent
*sed
;
95 gfp_t flags
= __GFP_ZERO
| GFP_ATOMIC
;
97 sed
= kmem_cache_alloc(ioat_sed_cache
, flags
);
101 sed
->hw_pool
= hw_pool
;
102 sed
->hw
= dma_pool_alloc(ioat_dma
->sed_hw_pool
[hw_pool
],
105 kmem_cache_free(ioat_sed_cache
, sed
);
112 struct dma_async_tx_descriptor
*
113 ioat_dma_prep_memcpy_lock(struct dma_chan
*c
, dma_addr_t dma_dest
,
114 dma_addr_t dma_src
, size_t len
, unsigned long flags
)
116 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(c
);
117 struct ioat_dma_descriptor
*hw
;
118 struct ioat_ring_ent
*desc
;
119 dma_addr_t dst
= dma_dest
;
120 dma_addr_t src
= dma_src
;
121 size_t total_len
= len
;
122 int num_descs
, idx
, i
;
124 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
127 num_descs
= ioat_xferlen_to_descs(ioat_chan
, len
);
128 if (likely(num_descs
) &&
129 ioat_check_space_lock(ioat_chan
, num_descs
) == 0)
130 idx
= ioat_chan
->head
;
135 size_t copy
= min_t(size_t, len
, 1 << ioat_chan
->xfercap_log
);
137 desc
= ioat_get_ring_ent(ioat_chan
, idx
+ i
);
148 dump_desc_dbg(ioat_chan
, desc
);
149 } while (++i
< num_descs
);
151 desc
->txd
.flags
= flags
;
152 desc
->len
= total_len
;
153 hw
->ctl_f
.int_en
= !!(flags
& DMA_PREP_INTERRUPT
);
154 hw
->ctl_f
.fence
= !!(flags
& DMA_PREP_FENCE
);
155 hw
->ctl_f
.compl_write
= 1;
156 dump_desc_dbg(ioat_chan
, desc
);
157 /* we leave the channel locked to ensure in order submission */
163 static struct dma_async_tx_descriptor
*
164 __ioat_prep_xor_lock(struct dma_chan
*c
, enum sum_check_flags
*result
,
165 dma_addr_t dest
, dma_addr_t
*src
, unsigned int src_cnt
,
166 size_t len
, unsigned long flags
)
168 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(c
);
169 struct ioat_ring_ent
*compl_desc
;
170 struct ioat_ring_ent
*desc
;
171 struct ioat_ring_ent
*ext
;
172 size_t total_len
= len
;
173 struct ioat_xor_descriptor
*xor;
174 struct ioat_xor_ext_descriptor
*xor_ex
= NULL
;
175 struct ioat_dma_descriptor
*hw
;
176 int num_descs
, with_ext
, idx
, i
;
178 u8 op
= result
? IOAT_OP_XOR_VAL
: IOAT_OP_XOR
;
182 num_descs
= ioat_xferlen_to_descs(ioat_chan
, len
);
183 /* we need 2x the number of descriptors to cover greater than 5
192 /* completion writes from the raid engine may pass completion
193 * writes from the legacy engine, so we need one extra null
194 * (legacy) descriptor to ensure all completion writes arrive in
197 if (likely(num_descs
) &&
198 ioat_check_space_lock(ioat_chan
, num_descs
+1) == 0)
199 idx
= ioat_chan
->head
;
204 struct ioat_raw_descriptor
*descs
[2];
205 size_t xfer_size
= min_t(size_t,
206 len
, 1 << ioat_chan
->xfercap_log
);
209 desc
= ioat_get_ring_ent(ioat_chan
, idx
+ i
);
212 /* save a branch by unconditionally retrieving the
213 * extended descriptor xor_set_src() knows to not write
214 * to it in the single descriptor case
216 ext
= ioat_get_ring_ent(ioat_chan
, idx
+ i
+ 1);
217 xor_ex
= ext
->xor_ex
;
219 descs
[0] = (struct ioat_raw_descriptor
*) xor;
220 descs
[1] = (struct ioat_raw_descriptor
*) xor_ex
;
221 for (s
= 0; s
< src_cnt
; s
++)
222 xor_set_src(descs
, src
[s
], offset
, s
);
223 xor->size
= xfer_size
;
224 xor->dst_addr
= dest
+ offset
;
227 xor->ctl_f
.src_cnt
= src_cnt_to_hw(src_cnt
);
231 dump_desc_dbg(ioat_chan
, desc
);
232 } while ((i
+= 1 + with_ext
) < num_descs
);
234 /* last xor descriptor carries the unmap parameters and fence bit */
235 desc
->txd
.flags
= flags
;
236 desc
->len
= total_len
;
238 desc
->result
= result
;
239 xor->ctl_f
.fence
= !!(flags
& DMA_PREP_FENCE
);
241 /* completion descriptor carries interrupt bit */
242 compl_desc
= ioat_get_ring_ent(ioat_chan
, idx
+ i
);
243 compl_desc
->txd
.flags
= flags
& DMA_PREP_INTERRUPT
;
247 hw
->ctl_f
.int_en
= !!(flags
& DMA_PREP_INTERRUPT
);
248 hw
->ctl_f
.compl_write
= 1;
249 hw
->size
= NULL_DESC_BUFFER_SIZE
;
250 dump_desc_dbg(ioat_chan
, compl_desc
);
252 /* we leave the channel locked to ensure in order submission */
253 return &compl_desc
->txd
;
256 struct dma_async_tx_descriptor
*
257 ioat_prep_xor(struct dma_chan
*chan
, dma_addr_t dest
, dma_addr_t
*src
,
258 unsigned int src_cnt
, size_t len
, unsigned long flags
)
260 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(chan
);
262 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
265 return __ioat_prep_xor_lock(chan
, NULL
, dest
, src
, src_cnt
, len
, flags
);
268 struct dma_async_tx_descriptor
*
269 ioat_prep_xor_val(struct dma_chan
*chan
, dma_addr_t
*src
,
270 unsigned int src_cnt
, size_t len
,
271 enum sum_check_flags
*result
, unsigned long flags
)
273 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(chan
);
275 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
278 /* the cleanup routine only sets bits on validate failure, it
279 * does not clear bits on validate success... so clear it here
283 return __ioat_prep_xor_lock(chan
, result
, src
[0], &src
[1],
284 src_cnt
- 1, len
, flags
);
288 dump_pq_desc_dbg(struct ioatdma_chan
*ioat_chan
, struct ioat_ring_ent
*desc
,
289 struct ioat_ring_ent
*ext
)
291 struct device
*dev
= to_dev(ioat_chan
);
292 struct ioat_pq_descriptor
*pq
= desc
->pq
;
293 struct ioat_pq_ext_descriptor
*pq_ex
= ext
? ext
->pq_ex
: NULL
;
294 struct ioat_raw_descriptor
*descs
[] = { (void *) pq
, (void *) pq_ex
};
295 int src_cnt
= src_cnt_to_sw(pq
->ctl_f
.src_cnt
);
298 dev_dbg(dev
, "desc[%d]: (%#llx->%#llx) flags: %#x"
299 " sz: %#10.8x ctl: %#x (op: %#x int: %d compl: %d pq: '%s%s'"
301 desc_id(desc
), (unsigned long long) desc
->txd
.phys
,
302 (unsigned long long) (pq_ex
? pq_ex
->next
: pq
->next
),
303 desc
->txd
.flags
, pq
->size
, pq
->ctl
, pq
->ctl_f
.op
,
304 pq
->ctl_f
.int_en
, pq
->ctl_f
.compl_write
,
305 pq
->ctl_f
.p_disable
? "" : "p", pq
->ctl_f
.q_disable
? "" : "q",
307 for (i
= 0; i
< src_cnt
; i
++)
308 dev_dbg(dev
, "\tsrc[%d]: %#llx coef: %#x\n", i
,
309 (unsigned long long) pq_get_src(descs
, i
), pq
->coef
[i
]);
310 dev_dbg(dev
, "\tP: %#llx\n", pq
->p_addr
);
311 dev_dbg(dev
, "\tQ: %#llx\n", pq
->q_addr
);
312 dev_dbg(dev
, "\tNEXT: %#llx\n", pq
->next
);
315 static void dump_pq16_desc_dbg(struct ioatdma_chan
*ioat_chan
,
316 struct ioat_ring_ent
*desc
)
318 struct device
*dev
= to_dev(ioat_chan
);
319 struct ioat_pq_descriptor
*pq
= desc
->pq
;
320 struct ioat_raw_descriptor
*descs
[] = { (void *)pq
,
323 int src_cnt
= src16_cnt_to_sw(pq
->ctl_f
.src_cnt
);
327 descs
[1] = (void *)desc
->sed
->hw
;
328 descs
[2] = (void *)desc
->sed
->hw
+ 64;
331 dev_dbg(dev
, "desc[%d]: (%#llx->%#llx) flags: %#x"
332 " sz: %#x ctl: %#x (op: %#x int: %d compl: %d pq: '%s%s'"
334 desc_id(desc
), (unsigned long long) desc
->txd
.phys
,
335 (unsigned long long) pq
->next
,
336 desc
->txd
.flags
, pq
->size
, pq
->ctl
,
337 pq
->ctl_f
.op
, pq
->ctl_f
.int_en
,
338 pq
->ctl_f
.compl_write
,
339 pq
->ctl_f
.p_disable
? "" : "p", pq
->ctl_f
.q_disable
? "" : "q",
341 for (i
= 0; i
< src_cnt
; i
++) {
342 dev_dbg(dev
, "\tsrc[%d]: %#llx coef: %#x\n", i
,
343 (unsigned long long) pq16_get_src(descs
, i
),
346 dev_dbg(dev
, "\tP: %#llx\n", pq
->p_addr
);
347 dev_dbg(dev
, "\tQ: %#llx\n", pq
->q_addr
);
350 static struct dma_async_tx_descriptor
*
351 __ioat_prep_pq_lock(struct dma_chan
*c
, enum sum_check_flags
*result
,
352 const dma_addr_t
*dst
, const dma_addr_t
*src
,
353 unsigned int src_cnt
, const unsigned char *scf
,
354 size_t len
, unsigned long flags
)
356 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(c
);
357 struct ioatdma_device
*ioat_dma
= ioat_chan
->ioat_dma
;
358 struct ioat_ring_ent
*compl_desc
;
359 struct ioat_ring_ent
*desc
;
360 struct ioat_ring_ent
*ext
;
361 size_t total_len
= len
;
362 struct ioat_pq_descriptor
*pq
;
363 struct ioat_pq_ext_descriptor
*pq_ex
= NULL
;
364 struct ioat_dma_descriptor
*hw
;
366 u8 op
= result
? IOAT_OP_PQ_VAL
: IOAT_OP_PQ
;
367 int i
, s
, idx
, with_ext
, num_descs
;
368 int cb32
= (ioat_dma
->version
< IOAT_VER_3_3
) ? 1 : 0;
370 dev_dbg(to_dev(ioat_chan
), "%s\n", __func__
);
371 /* the engine requires at least two sources (we provide
372 * at least 1 implied source in the DMA_PREP_CONTINUE case)
374 BUG_ON(src_cnt
+ dmaf_continue(flags
) < 2);
376 num_descs
= ioat_xferlen_to_descs(ioat_chan
, len
);
377 /* we need 2x the number of descriptors to cover greater than 3
378 * sources (we need 1 extra source in the q-only continuation
379 * case and 3 extra sources in the p+q continuation case.
381 if (src_cnt
+ dmaf_p_disabled_continue(flags
) > 3 ||
382 (dmaf_continue(flags
) && !dmaf_p_disabled_continue(flags
))) {
388 /* completion writes from the raid engine may pass completion
389 * writes from the legacy engine, so we need one extra null
390 * (legacy) descriptor to ensure all completion writes arrive in
393 if (likely(num_descs
) &&
394 ioat_check_space_lock(ioat_chan
, num_descs
+ cb32
) == 0)
395 idx
= ioat_chan
->head
;
400 struct ioat_raw_descriptor
*descs
[2];
401 size_t xfer_size
= min_t(size_t, len
,
402 1 << ioat_chan
->xfercap_log
);
404 desc
= ioat_get_ring_ent(ioat_chan
, idx
+ i
);
407 /* save a branch by unconditionally retrieving the
408 * extended descriptor pq_set_src() knows to not write
409 * to it in the single descriptor case
411 ext
= ioat_get_ring_ent(ioat_chan
, idx
+ i
+ with_ext
);
414 descs
[0] = (struct ioat_raw_descriptor
*) pq
;
415 descs
[1] = (struct ioat_raw_descriptor
*) pq_ex
;
417 for (s
= 0; s
< src_cnt
; s
++)
418 pq_set_src(descs
, src
[s
], offset
, scf
[s
], s
);
420 /* see the comment for dma_maxpq in include/linux/dmaengine.h */
421 if (dmaf_p_disabled_continue(flags
))
422 pq_set_src(descs
, dst
[1], offset
, 1, s
++);
423 else if (dmaf_continue(flags
)) {
424 pq_set_src(descs
, dst
[0], offset
, 0, s
++);
425 pq_set_src(descs
, dst
[1], offset
, 1, s
++);
426 pq_set_src(descs
, dst
[1], offset
, 0, s
++);
428 pq
->size
= xfer_size
;
429 pq
->p_addr
= dst
[0] + offset
;
430 pq
->q_addr
= dst
[1] + offset
;
433 /* we turn on descriptor write back error status */
434 if (ioat_dma
->cap
& IOAT_CAP_DWBES
)
435 pq
->ctl_f
.wb_en
= result
? 1 : 0;
436 pq
->ctl_f
.src_cnt
= src_cnt_to_hw(s
);
437 pq
->ctl_f
.p_disable
= !!(flags
& DMA_PREP_PQ_DISABLE_P
);
438 pq
->ctl_f
.q_disable
= !!(flags
& DMA_PREP_PQ_DISABLE_Q
);
442 } while ((i
+= 1 + with_ext
) < num_descs
);
444 /* last pq descriptor carries the unmap parameters and fence bit */
445 desc
->txd
.flags
= flags
;
446 desc
->len
= total_len
;
448 desc
->result
= result
;
449 pq
->ctl_f
.fence
= !!(flags
& DMA_PREP_FENCE
);
450 dump_pq_desc_dbg(ioat_chan
, desc
, ext
);
453 pq
->ctl_f
.int_en
= !!(flags
& DMA_PREP_INTERRUPT
);
454 pq
->ctl_f
.compl_write
= 1;
457 /* completion descriptor carries interrupt bit */
458 compl_desc
= ioat_get_ring_ent(ioat_chan
, idx
+ i
);
459 compl_desc
->txd
.flags
= flags
& DMA_PREP_INTERRUPT
;
463 hw
->ctl_f
.int_en
= !!(flags
& DMA_PREP_INTERRUPT
);
464 hw
->ctl_f
.compl_write
= 1;
465 hw
->size
= NULL_DESC_BUFFER_SIZE
;
466 dump_desc_dbg(ioat_chan
, compl_desc
);
470 /* we leave the channel locked to ensure in order submission */
471 return &compl_desc
->txd
;
474 static struct dma_async_tx_descriptor
*
475 __ioat_prep_pq16_lock(struct dma_chan
*c
, enum sum_check_flags
*result
,
476 const dma_addr_t
*dst
, const dma_addr_t
*src
,
477 unsigned int src_cnt
, const unsigned char *scf
,
478 size_t len
, unsigned long flags
)
480 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(c
);
481 struct ioatdma_device
*ioat_dma
= ioat_chan
->ioat_dma
;
482 struct ioat_ring_ent
*desc
;
483 size_t total_len
= len
;
484 struct ioat_pq_descriptor
*pq
;
487 int i
, s
, idx
, num_descs
;
489 /* this function is only called with 9-16 sources */
490 op
= result
? IOAT_OP_PQ_VAL_16S
: IOAT_OP_PQ_16S
;
492 dev_dbg(to_dev(ioat_chan
), "%s\n", __func__
);
494 num_descs
= ioat_xferlen_to_descs(ioat_chan
, len
);
497 * 16 source pq is only available on cb3.3 and has no completion
500 if (num_descs
&& ioat_check_space_lock(ioat_chan
, num_descs
) == 0)
501 idx
= ioat_chan
->head
;
508 struct ioat_raw_descriptor
*descs
[4];
509 size_t xfer_size
= min_t(size_t, len
,
510 1 << ioat_chan
->xfercap_log
);
512 desc
= ioat_get_ring_ent(ioat_chan
, idx
+ i
);
515 descs
[0] = (struct ioat_raw_descriptor
*) pq
;
517 desc
->sed
= ioat3_alloc_sed(ioat_dma
, (src_cnt
-2) >> 3);
519 dev_err(to_dev(ioat_chan
),
520 "%s: no free sed entries\n", __func__
);
524 pq
->sed_addr
= desc
->sed
->dma
;
525 desc
->sed
->parent
= desc
;
527 descs
[1] = (struct ioat_raw_descriptor
*)desc
->sed
->hw
;
528 descs
[2] = (void *)descs
[1] + 64;
530 for (s
= 0; s
< src_cnt
; s
++)
531 pq16_set_src(descs
, src
[s
], offset
, scf
[s
], s
);
533 /* see the comment for dma_maxpq in include/linux/dmaengine.h */
534 if (dmaf_p_disabled_continue(flags
))
535 pq16_set_src(descs
, dst
[1], offset
, 1, s
++);
536 else if (dmaf_continue(flags
)) {
537 pq16_set_src(descs
, dst
[0], offset
, 0, s
++);
538 pq16_set_src(descs
, dst
[1], offset
, 1, s
++);
539 pq16_set_src(descs
, dst
[1], offset
, 0, s
++);
542 pq
->size
= xfer_size
;
543 pq
->p_addr
= dst
[0] + offset
;
544 pq
->q_addr
= dst
[1] + offset
;
547 pq
->ctl_f
.src_cnt
= src16_cnt_to_hw(s
);
548 /* we turn on descriptor write back error status */
549 if (ioat_dma
->cap
& IOAT_CAP_DWBES
)
550 pq
->ctl_f
.wb_en
= result
? 1 : 0;
551 pq
->ctl_f
.p_disable
= !!(flags
& DMA_PREP_PQ_DISABLE_P
);
552 pq
->ctl_f
.q_disable
= !!(flags
& DMA_PREP_PQ_DISABLE_Q
);
556 } while (++i
< num_descs
);
558 /* last pq descriptor carries the unmap parameters and fence bit */
559 desc
->txd
.flags
= flags
;
560 desc
->len
= total_len
;
562 desc
->result
= result
;
563 pq
->ctl_f
.fence
= !!(flags
& DMA_PREP_FENCE
);
565 /* with cb3.3 we should be able to do completion w/o a null desc */
566 pq
->ctl_f
.int_en
= !!(flags
& DMA_PREP_INTERRUPT
);
567 pq
->ctl_f
.compl_write
= 1;
569 dump_pq16_desc_dbg(ioat_chan
, desc
);
571 /* we leave the channel locked to ensure in order submission */
575 static int src_cnt_flags(unsigned int src_cnt
, unsigned long flags
)
577 if (dmaf_p_disabled_continue(flags
))
579 else if (dmaf_continue(flags
))
585 struct dma_async_tx_descriptor
*
586 ioat_prep_pq(struct dma_chan
*chan
, dma_addr_t
*dst
, dma_addr_t
*src
,
587 unsigned int src_cnt
, const unsigned char *scf
, size_t len
,
590 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(chan
);
592 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
595 /* specify valid address for disabled result */
596 if (flags
& DMA_PREP_PQ_DISABLE_P
)
598 if (flags
& DMA_PREP_PQ_DISABLE_Q
)
601 /* handle the single source multiply case from the raid6
604 if ((flags
& DMA_PREP_PQ_DISABLE_P
) && src_cnt
== 1) {
605 dma_addr_t single_source
[2];
606 unsigned char single_source_coef
[2];
608 BUG_ON(flags
& DMA_PREP_PQ_DISABLE_Q
);
609 single_source
[0] = src
[0];
610 single_source
[1] = src
[0];
611 single_source_coef
[0] = scf
[0];
612 single_source_coef
[1] = 0;
614 return src_cnt_flags(src_cnt
, flags
) > 8 ?
615 __ioat_prep_pq16_lock(chan
, NULL
, dst
, single_source
,
616 2, single_source_coef
, len
,
618 __ioat_prep_pq_lock(chan
, NULL
, dst
, single_source
, 2,
619 single_source_coef
, len
, flags
);
622 return src_cnt_flags(src_cnt
, flags
) > 8 ?
623 __ioat_prep_pq16_lock(chan
, NULL
, dst
, src
, src_cnt
,
625 __ioat_prep_pq_lock(chan
, NULL
, dst
, src
, src_cnt
,
630 struct dma_async_tx_descriptor
*
631 ioat_prep_pq_val(struct dma_chan
*chan
, dma_addr_t
*pq
, dma_addr_t
*src
,
632 unsigned int src_cnt
, const unsigned char *scf
, size_t len
,
633 enum sum_check_flags
*pqres
, unsigned long flags
)
635 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(chan
);
637 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
640 /* specify valid address for disabled result */
641 if (flags
& DMA_PREP_PQ_DISABLE_P
)
643 if (flags
& DMA_PREP_PQ_DISABLE_Q
)
646 /* the cleanup routine only sets bits on validate failure, it
647 * does not clear bits on validate success... so clear it here
651 return src_cnt_flags(src_cnt
, flags
) > 8 ?
652 __ioat_prep_pq16_lock(chan
, pqres
, pq
, src
, src_cnt
, scf
, len
,
654 __ioat_prep_pq_lock(chan
, pqres
, pq
, src
, src_cnt
, scf
, len
,
658 struct dma_async_tx_descriptor
*
659 ioat_prep_pqxor(struct dma_chan
*chan
, dma_addr_t dst
, dma_addr_t
*src
,
660 unsigned int src_cnt
, size_t len
, unsigned long flags
)
662 unsigned char scf
[MAX_SCF
];
664 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(chan
);
666 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
669 if (src_cnt
> MAX_SCF
)
672 memset(scf
, 0, src_cnt
);
674 flags
|= DMA_PREP_PQ_DISABLE_Q
;
675 pq
[1] = dst
; /* specify valid address for disabled result */
677 return src_cnt_flags(src_cnt
, flags
) > 8 ?
678 __ioat_prep_pq16_lock(chan
, NULL
, pq
, src
, src_cnt
, scf
, len
,
680 __ioat_prep_pq_lock(chan
, NULL
, pq
, src
, src_cnt
, scf
, len
,
684 struct dma_async_tx_descriptor
*
685 ioat_prep_pqxor_val(struct dma_chan
*chan
, dma_addr_t
*src
,
686 unsigned int src_cnt
, size_t len
,
687 enum sum_check_flags
*result
, unsigned long flags
)
689 unsigned char scf
[MAX_SCF
];
691 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(chan
);
693 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
696 if (src_cnt
> MAX_SCF
)
699 /* the cleanup routine only sets bits on validate failure, it
700 * does not clear bits on validate success... so clear it here
704 memset(scf
, 0, src_cnt
);
706 flags
|= DMA_PREP_PQ_DISABLE_Q
;
707 pq
[1] = pq
[0]; /* specify valid address for disabled result */
709 return src_cnt_flags(src_cnt
, flags
) > 8 ?
710 __ioat_prep_pq16_lock(chan
, result
, pq
, &src
[1], src_cnt
- 1,
712 __ioat_prep_pq_lock(chan
, result
, pq
, &src
[1], src_cnt
- 1,
716 struct dma_async_tx_descriptor
*
717 ioat_prep_interrupt_lock(struct dma_chan
*c
, unsigned long flags
)
719 struct ioatdma_chan
*ioat_chan
= to_ioat_chan(c
);
720 struct ioat_ring_ent
*desc
;
721 struct ioat_dma_descriptor
*hw
;
723 if (test_bit(IOAT_CHAN_DOWN
, &ioat_chan
->state
))
726 if (ioat_check_space_lock(ioat_chan
, 1) == 0)
727 desc
= ioat_get_ring_ent(ioat_chan
, ioat_chan
->head
);
734 hw
->ctl_f
.int_en
= 1;
735 hw
->ctl_f
.fence
= !!(flags
& DMA_PREP_FENCE
);
736 hw
->ctl_f
.compl_write
= 1;
737 hw
->size
= NULL_DESC_BUFFER_SIZE
;
741 desc
->txd
.flags
= flags
;
744 dump_desc_dbg(ioat_chan
, desc
);
746 /* we leave the channel locked to ensure in order submission */