Skip to content

Commit b62ffd8

Browse files
horiagherbertx
authored andcommitted
crypto: talitos - fix locating offending descriptor in error path
Commit 3e721ae ("crypto: talitos - handle descriptor not found in error path") tried to address the fact that CDPR (Current Descriptor Pointer Register) is unreliable. As it turns out, there are still issues in the function detecting the offending descriptor: -only 32 bits of the descriptor address are read, however the address is 36-bit - since reset_channel() initializes channels with EAE (extended address) bit set -reading CDPR can return zero in cur_desc; when searching the channel fifo for this address, cur_desc == dma_desc (= 0) case might happen, leading to an oops when trying to return desc->hdr (desc is zero) -read channel's .tail only once; the tail is a moving target; use a local variable for the end of search condition Signed-off-by: Lei Xu <Lei.Xu@freescale.com> Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Tested-by: Kalyani Chowdhury <Kalyani.Chowdhury@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent f13ab86 commit b62ffd8

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎drivers/crypto/talitos.c‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,20 +338,29 @@ DEF_TALITOS_DONE(ch1_3, TALITOS_ISR_CH_1_3_DONE)
338338
static u32 current_desc_hdr(struct device *dev, int ch)
339339
{
340340
struct talitos_private *priv = dev_get_drvdata(dev);
341-
int tail = priv->chan[ch].tail;
341+
int tail, iter;
342342
dma_addr_t cur_desc;
343343

344-
cur_desc = in_be32(priv->chan[ch].reg + TALITOS_CDPR_LO);
344+
cur_desc = ((u64)in_be32(priv->chan[ch].reg + TALITOS_CDPR)) << 32;
345+
cur_desc |= in_be32(priv->chan[ch].reg + TALITOS_CDPR_LO);
345346

346-
while (priv->chan[ch].fifo[tail].dma_desc != cur_desc) {
347-
tail = (tail + 1) & (priv->fifo_len - 1);
348-
if (tail == priv->chan[ch].tail) {
347+
if (!cur_desc) {
348+
dev_err(dev, "CDPR is NULL, giving up search for offending descriptor\n");
349+
return 0;
350+
}
351+
352+
tail = priv->chan[ch].tail;
353+
354+
iter = tail;
355+
while (priv->chan[ch].fifo[iter].dma_desc != cur_desc) {
356+
iter = (iter + 1) & (priv->fifo_len - 1);
357+
if (iter == tail) {
349358
dev_err(dev, "couldn't locate current descriptor\n");
350359
return 0;
351360
}
352361
}
353362

354-
return priv->chan[ch].fifo[tail].desc->hdr;
363+
return priv->chan[ch].fifo[iter].desc->hdr;
355364
}
356365

357366
/*

0 commit comments

Comments
 (0)