Skip to content

Commit 636bdea

Browse files
committed
dmaengine: ack to flags: make use of the unused bits in the 'ack' field
'ack' is currently a simple integer that flags whether or not a client is done touching fields in the given descriptor. It is effectively just a single bit of information. Converting this to a flags parameter allows the other bits to be put to use to control completion actions, like dma-unmap, and capture results, like xor-zero-sum == 0. Changes are one of: 1/ convert all open-coded ->ack manipulations to use async_tx_ack and async_tx_test_ack. 2/ set the ack bit at prep time where possible 3/ make drivers store the flags at prep time 4/ add flags to the device_prep_dma_interrupt prototype Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent c4fe155 commit 636bdea

8 files changed

Lines changed: 69 additions & 54 deletions

File tree

‎crypto/async_tx/async_memcpy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
7777
/* if ack is already set then we cannot be sure
7878
* we are referring to the correct operation
7979
*/
80-
BUG_ON(depend_tx->ack);
80+
BUG_ON(async_tx_test_ack(depend_tx));
8181
if (dma_wait_for_async_tx(depend_tx) == DMA_ERROR)
8282
panic("%s: DMA_ERROR waiting for depend_tx\n",
8383
__func__);

‎crypto/async_tx/async_tx.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ async_tx_channel_switch(struct dma_async_tx_descriptor *depend_tx,
446446
* otherwise poll for completion
447447
*/
448448
if (dma_has_cap(DMA_INTERRUPT, device->cap_mask))
449-
intr_tx = device->device_prep_dma_interrupt(chan);
449+
intr_tx = device->device_prep_dma_interrupt(chan, 0);
450450
else
451451
intr_tx = NULL;
452452

@@ -515,7 +515,8 @@ async_tx_submit(struct dma_chan *chan, struct dma_async_tx_descriptor *tx,
515515
* 2/ dependencies are 1:1 i.e. two transactions can
516516
* not depend on the same parent
517517
*/
518-
BUG_ON(depend_tx->ack || depend_tx->next || tx->parent);
518+
BUG_ON(async_tx_test_ack(depend_tx) || depend_tx->next ||
519+
tx->parent);
519520

520521
/* the lock prevents async_tx_run_dependencies from missing
521522
* the setting of ->next when ->parent != NULL
@@ -594,7 +595,7 @@ async_trigger_callback(enum async_tx_flags flags,
594595
if (device && !dma_has_cap(DMA_INTERRUPT, device->cap_mask))
595596
device = NULL;
596597

597-
tx = device ? device->device_prep_dma_interrupt(chan) : NULL;
598+
tx = device ? device->device_prep_dma_interrupt(chan, 0) : NULL;
598599
} else
599600
tx = NULL;
600601

@@ -610,7 +611,7 @@ async_trigger_callback(enum async_tx_flags flags,
610611
/* if ack is already set then we cannot be sure
611612
* we are referring to the correct operation
612613
*/
613-
BUG_ON(depend_tx->ack);
614+
BUG_ON(async_tx_test_ack(depend_tx));
614615
if (dma_wait_for_async_tx(depend_tx) == DMA_ERROR)
615616
panic("%s: DMA_ERROR waiting for depend_tx\n",
616617
__func__);

‎crypto/async_tx/async_xor.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ async_xor(struct page *dest, struct page **src_list, unsigned int offset,
191191
/* if ack is already set then we cannot be sure
192192
* we are referring to the correct operation
193193
*/
194-
BUG_ON(depend_tx->ack);
194+
BUG_ON(async_tx_test_ack(depend_tx));
195195
if (dma_wait_for_async_tx(depend_tx) ==
196196
DMA_ERROR)
197197
panic("%s: DMA_ERROR waiting for "

‎drivers/dma/dmaengine.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,15 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
478478

479479
dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
480480
dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE);
481-
tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 0);
481+
tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len,
482+
DMA_CTRL_ACK);
482483

483484
if (!tx) {
484485
dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
485486
dma_unmap_single(dev->dev, dma_dest, len, DMA_FROM_DEVICE);
486487
return -ENOMEM;
487488
}
488489

489-
tx->ack = 1;
490490
tx->callback = NULL;
491491
cookie = tx->tx_submit(tx);
492492

@@ -524,15 +524,15 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
524524

525525
dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
526526
dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE);
527-
tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 0);
527+
tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len,
528+
DMA_CTRL_ACK);
528529

529530
if (!tx) {
530531
dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
531532
dma_unmap_page(dev->dev, dma_dest, len, DMA_FROM_DEVICE);
532533
return -ENOMEM;
533534
}
534535

535-
tx->ack = 1;
536536
tx->callback = NULL;
537537
cookie = tx->tx_submit(tx);
538538

@@ -573,15 +573,15 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
573573
dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
574574
dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len,
575575
DMA_FROM_DEVICE);
576-
tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 0);
576+
tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len,
577+
DMA_CTRL_ACK);
577578

578579
if (!tx) {
579580
dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE);
580581
dma_unmap_page(dev->dev, dma_dest, len, DMA_FROM_DEVICE);
581582
return -ENOMEM;
582583
}
583584

584-
tx->ack = 1;
585585
tx->callback = NULL;
586586
cookie = tx->tx_submit(tx);
587587

‎drivers/dma/fsldma.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void fsl_dma_free_chan_resources(struct dma_chan *chan)
412412
}
413413

414414
static struct dma_async_tx_descriptor *
415-
fsl_dma_prep_interrupt(struct dma_chan *chan)
415+
fsl_dma_prep_interrupt(struct dma_chan *chan, unsigned long flags)
416416
{
417417
struct fsl_dma_chan *fsl_chan;
418418
struct fsl_desc_sw *new;
@@ -429,7 +429,7 @@ fsl_dma_prep_interrupt(struct dma_chan *chan)
429429
}
430430

431431
new->async_tx.cookie = -EBUSY;
432-
new->async_tx.ack = 0;
432+
new->async_tx.flags = flags;
433433

434434
/* Insert the link descriptor to the LD ring */
435435
list_add_tail(&new->node, &new->async_tx.tx_list);
@@ -482,7 +482,7 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
482482
set_desc_next(fsl_chan, &prev->hw, new->async_tx.phys);
483483

484484
new->async_tx.cookie = 0;
485-
new->async_tx.ack = 1;
485+
async_tx_ack(&new->async_tx);
486486

487487
prev = new;
488488
len -= copy;
@@ -493,7 +493,7 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
493493
list_add_tail(&new->node, &first->async_tx.tx_list);
494494
} while (len);
495495

496-
new->async_tx.ack = 0; /* client is in control of this ack */
496+
new->async_tx.flags = flags; /* client is in control of this ack */
497497
new->async_tx.cookie = -EBUSY;
498498

499499
/* Set End-of-link to the last link descriptor of new list*/
@@ -874,7 +874,7 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)
874874
async_tx_ack(tx3);
875875

876876
/* Interrupt tx test */
877-
tx1 = fsl_dma_prep_interrupt(chan);
877+
tx1 = fsl_dma_prep_interrupt(chan, 0);
878878
async_tx_ack(tx1);
879879
cookie = fsl_dma_tx_submit(tx1);
880880

‎drivers/dma/ioat_dma.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
212212
u32 copy;
213213
size_t len;
214214
dma_addr_t src, dst;
215-
int orig_ack;
215+
unsigned long orig_flags;
216216
unsigned int desc_count = 0;
217217

218218
/* src and dest and len are stored in the initial descriptor */
219219
len = first->len;
220220
src = first->src;
221221
dst = first->dst;
222-
orig_ack = first->async_tx.ack;
222+
orig_flags = first->async_tx.flags;
223223
new = first;
224224

225225
spin_lock_bh(&ioat_chan->desc_lock);
@@ -228,7 +228,7 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
228228
do {
229229
copy = min_t(size_t, len, ioat_chan->xfercap);
230230

231-
new->async_tx.ack = 1;
231+
async_tx_ack(&new->async_tx);
232232

233233
hw = new->hw;
234234
hw->size = copy;
@@ -264,7 +264,7 @@ static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
264264
}
265265

266266
new->tx_cnt = desc_count;
267-
new->async_tx.ack = orig_ack; /* client is in control of this ack */
267+
new->async_tx.flags = orig_flags; /* client is in control of this ack */
268268

269269
/* store the original values for use in later cleanup */
270270
if (new != first) {
@@ -304,14 +304,14 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
304304
u32 copy;
305305
size_t len;
306306
dma_addr_t src, dst;
307-
int orig_ack;
307+
unsigned long orig_flags;
308308
unsigned int desc_count = 0;
309309

310310
/* src and dest and len are stored in the initial descriptor */
311311
len = first->len;
312312
src = first->src;
313313
dst = first->dst;
314-
orig_ack = first->async_tx.ack;
314+
orig_flags = first->async_tx.flags;
315315
new = first;
316316

317317
/*
@@ -321,7 +321,7 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
321321
do {
322322
copy = min_t(size_t, len, ioat_chan->xfercap);
323323

324-
new->async_tx.ack = 1;
324+
async_tx_ack(&new->async_tx);
325325

326326
hw = new->hw;
327327
hw->size = copy;
@@ -349,7 +349,7 @@ static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
349349
}
350350

351351
new->tx_cnt = desc_count;
352-
new->async_tx.ack = orig_ack; /* client is in control of this ack */
352+
new->async_tx.flags = orig_flags; /* client is in control of this ack */
353353

354354
/* store the original values for use in later cleanup */
355355
if (new != first) {
@@ -714,7 +714,7 @@ static struct dma_async_tx_descriptor *ioat1_dma_prep_memcpy(
714714
new->len = len;
715715
new->dst = dma_dest;
716716
new->src = dma_src;
717-
new->async_tx.ack = 0;
717+
new->async_tx.flags = flags;
718718
return &new->async_tx;
719719
} else
720720
return NULL;
@@ -742,7 +742,7 @@ static struct dma_async_tx_descriptor *ioat2_dma_prep_memcpy(
742742
new->len = len;
743743
new->dst = dma_dest;
744744
new->src = dma_src;
745-
new->async_tx.ack = 0;
745+
new->async_tx.flags = flags;
746746
return &new->async_tx;
747747
} else
748748
return NULL;
@@ -842,7 +842,7 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
842842
* a completed entry, but not the last, so clean
843843
* up if the client is done with the descriptor
844844
*/
845-
if (desc->async_tx.ack) {
845+
if (async_tx_test_ack(&desc->async_tx)) {
846846
list_del(&desc->node);
847847
list_add_tail(&desc->node,
848848
&ioat_chan->free_desc);
@@ -979,7 +979,7 @@ static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan)
979979
desc->hw->size = 0;
980980
desc->hw->src_addr = 0;
981981
desc->hw->dst_addr = 0;
982-
desc->async_tx.ack = 1;
982+
async_tx_ack(&desc->async_tx);
983983
switch (ioat_chan->device->version) {
984984
case IOAT_VER_1_2:
985985
desc->hw->next = 0;

0 commit comments

Comments
 (0)