Skip to content

Commit a009902

Browse files
djbwgregkh
authored andcommitted
ioatdma: fix selection of 16 vs 8 source path
commit 21e96c7 upstream. When performing continuations there are implied sources that need to be added to the source count. Quoting dma_set_maxpq: /* dma_maxpq - reduce maxpq in the face of continued operations * @dma - dma device with PQ capability * @flags - to check if DMA_PREP_CONTINUE and DMA_PREP_PQ_DISABLE_P are set * * When an engine does not support native continuation we need 3 extra * source slots to reuse P and Q with the following coefficients: * 1/ {00} * P : remove P from Q', but use it as a source for P' * 2/ {01} * Q : use Q to continue Q' calculation * 3/ {00} * Q : subtract Q from P' to cancel (2) * * In the case where P is disabled we only need 1 extra source: * 1/ {01} * Q : use Q to continue Q' calculation */ ...fix the selection of the 16 source path to take these implied sources into account. Note this also kills the BUG_ON(src_cnt < 9) check in __ioat3_prep_pq16_lock(). Besides not accounting for implied sources the check is redundant given we already made the path selection. Cc: Dave Jiang <dave.jiang@intel.com> Acked-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1bb87f9 commit a009902

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

‎drivers/dma/ioat/dma_v3.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,9 +1116,6 @@ __ioat3_prep_pq16_lock(struct dma_chan *c, enum sum_check_flags *result,
11161116
u8 op;
11171117
int i, s, idx, num_descs;
11181118

1119-
/* this function only handles src_cnt 9 - 16 */
1120-
BUG_ON(src_cnt < 9);
1121-
11221119
/* this function is only called with 9-16 sources */
11231120
op = result ? IOAT_OP_PQ_VAL_16S : IOAT_OP_PQ_16S;
11241121

@@ -1204,13 +1201,21 @@ __ioat3_prep_pq16_lock(struct dma_chan *c, enum sum_check_flags *result,
12041201
return &desc->txd;
12051202
}
12061203

1204+
static int src_cnt_flags(unsigned int src_cnt, unsigned long flags)
1205+
{
1206+
if (dmaf_p_disabled_continue(flags))
1207+
return src_cnt + 1;
1208+
else if (dmaf_continue(flags))
1209+
return src_cnt + 3;
1210+
else
1211+
return src_cnt;
1212+
}
1213+
12071214
static struct dma_async_tx_descriptor *
12081215
ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
12091216
unsigned int src_cnt, const unsigned char *scf, size_t len,
12101217
unsigned long flags)
12111218
{
1212-
struct dma_device *dma = chan->device;
1213-
12141219
/* specify valid address for disabled result */
12151220
if (flags & DMA_PREP_PQ_DISABLE_P)
12161221
dst[0] = dst[1];
@@ -1230,15 +1235,15 @@ ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
12301235
single_source_coef[0] = scf[0];
12311236
single_source_coef[1] = 0;
12321237

1233-
return (src_cnt > 8) && (dma->max_pq > 8) ?
1238+
return src_cnt_flags(src_cnt, flags) > 8 ?
12341239
__ioat3_prep_pq16_lock(chan, NULL, dst, single_source,
12351240
2, single_source_coef, len,
12361241
flags) :
12371242
__ioat3_prep_pq_lock(chan, NULL, dst, single_source, 2,
12381243
single_source_coef, len, flags);
12391244

12401245
} else {
1241-
return (src_cnt > 8) && (dma->max_pq > 8) ?
1246+
return src_cnt_flags(src_cnt, flags) > 8 ?
12421247
__ioat3_prep_pq16_lock(chan, NULL, dst, src, src_cnt,
12431248
scf, len, flags) :
12441249
__ioat3_prep_pq_lock(chan, NULL, dst, src, src_cnt,
@@ -1251,8 +1256,6 @@ ioat3_prep_pq_val(struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
12511256
unsigned int src_cnt, const unsigned char *scf, size_t len,
12521257
enum sum_check_flags *pqres, unsigned long flags)
12531258
{
1254-
struct dma_device *dma = chan->device;
1255-
12561259
/* specify valid address for disabled result */
12571260
if (flags & DMA_PREP_PQ_DISABLE_P)
12581261
pq[0] = pq[1];
@@ -1264,7 +1267,7 @@ ioat3_prep_pq_val(struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
12641267
*/
12651268
*pqres = 0;
12661269

1267-
return (src_cnt > 8) && (dma->max_pq > 8) ?
1270+
return src_cnt_flags(src_cnt, flags) > 8 ?
12681271
__ioat3_prep_pq16_lock(chan, pqres, pq, src, src_cnt, scf, len,
12691272
flags) :
12701273
__ioat3_prep_pq_lock(chan, pqres, pq, src, src_cnt, scf, len,
@@ -1275,7 +1278,6 @@ static struct dma_async_tx_descriptor *
12751278
ioat3_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src,
12761279
unsigned int src_cnt, size_t len, unsigned long flags)
12771280
{
1278-
struct dma_device *dma = chan->device;
12791281
unsigned char scf[src_cnt];
12801282
dma_addr_t pq[2];
12811283

@@ -1284,7 +1286,7 @@ ioat3_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src,
12841286
flags |= DMA_PREP_PQ_DISABLE_Q;
12851287
pq[1] = dst; /* specify valid address for disabled result */
12861288

1287-
return (src_cnt > 8) && (dma->max_pq > 8) ?
1289+
return src_cnt_flags(src_cnt, flags) > 8 ?
12881290
__ioat3_prep_pq16_lock(chan, NULL, pq, src, src_cnt, scf, len,
12891291
flags) :
12901292
__ioat3_prep_pq_lock(chan, NULL, pq, src, src_cnt, scf, len,
@@ -1296,7 +1298,6 @@ ioat3_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
12961298
unsigned int src_cnt, size_t len,
12971299
enum sum_check_flags *result, unsigned long flags)
12981300
{
1299-
struct dma_device *dma = chan->device;
13001301
unsigned char scf[src_cnt];
13011302
dma_addr_t pq[2];
13021303

@@ -1310,8 +1311,7 @@ ioat3_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
13101311
flags |= DMA_PREP_PQ_DISABLE_Q;
13111312
pq[1] = pq[0]; /* specify valid address for disabled result */
13121313

1313-
1314-
return (src_cnt > 8) && (dma->max_pq > 8) ?
1314+
return src_cnt_flags(src_cnt, flags) > 8 ?
13151315
__ioat3_prep_pq16_lock(chan, result, pq, &src[1], src_cnt - 1,
13161316
scf, len, flags) :
13171317
__ioat3_prep_pq_lock(chan, result, pq, &src[1], src_cnt - 1,

0 commit comments

Comments
 (0)