crypto: talitos - Preempt overflow interrupts

add requests pending/submit count to prevent request queue full
condition by preempting h/w overflow interrupts in software.
We do this due to the delay in the delivery and handling of the
channel overflow error interrupt.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: Lee Nipper <lee.nipper@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Kim Phillips and committed by
Herbert Xu
ec6644d6 695ad589

+22 -5
+22 -5
drivers/crypto/talitos.c
··· 99 99 /* next channel to be assigned next incoming descriptor */ 100 100 atomic_t last_chan; 101 101 102 + /* per-channel number of requests pending in channel h/w fifo */ 103 + atomic_t *submit_count; 104 + 102 105 /* per-channel request fifo */ 103 106 struct talitos_request **fifo; 104 107 ··· 266 263 267 264 spin_lock_irqsave(&priv->head_lock[ch], flags); 268 265 269 - head = priv->head[ch]; 270 - request = &priv->fifo[ch][head]; 271 - 272 - if (request->desc) { 273 - /* request queue is full */ 266 + if (!atomic_inc_not_zero(&priv->submit_count[ch])) { 267 + /* h/w fifo is full */ 274 268 spin_unlock_irqrestore(&priv->head_lock[ch], flags); 275 269 return -EAGAIN; 276 270 } 271 + 272 + head = priv->head[ch]; 273 + request = &priv->fifo[ch][head]; 277 274 278 275 /* map descriptor and save caller data */ 279 276 request->dma_desc = dma_map_single(dev, desc, sizeof(*desc), ··· 338 335 priv->tail[ch] = (tail + 1) & (priv->fifo_len - 1); 339 336 340 337 spin_unlock_irqrestore(&priv->tail_lock[ch], flags); 338 + 339 + atomic_dec(&priv->submit_count[ch]); 340 + 341 341 saved_req.callback(dev, saved_req.desc, saved_req.context, 342 342 status); 343 343 /* channel may resume processing in single desc error case */ ··· 1343 1337 if (hw_supports(dev, DESC_HDR_SEL0_RNG)) 1344 1338 talitos_unregister_rng(dev); 1345 1339 1340 + kfree(priv->submit_count); 1346 1341 kfree(priv->tail); 1347 1342 kfree(priv->head); 1348 1343 ··· 1507 1500 goto err_out; 1508 1501 } 1509 1502 } 1503 + 1504 + priv->submit_count = kmalloc(sizeof(int) * priv->num_channels, 1505 + GFP_KERNEL); 1506 + if (!priv->submit_count) { 1507 + dev_err(dev, "failed to allocate fifo submit count space\n"); 1508 + err = -ENOMEM; 1509 + goto err_out; 1510 + } 1511 + for (i = 0; i < priv->num_channels; i++) 1512 + atomic_set(&priv->submit_count[i], -priv->chfifo_len); 1510 1513 1511 1514 priv->head = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL); 1512 1515 priv->tail = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL);