Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106495
b: refs/heads/master
c: ec6644d
h: refs/heads/master
i:
  106493: 5d65a79
  106491: 74de1d2
  106487: 71697cc
  106479: 0de8ae5
  106463: 036e73e
  106431: 5f5367d
  106367: 736060b
  106239: a129d42
  105983: 9be9cc8
  105471: dd60764
  104447: 36ecbd6
  102399: 63fdcda
  98303: 8d3fd52
v: v3
  • Loading branch information
Kim Phillips authored and Herbert Xu committed Jul 17, 2008
1 parent 2412b42 commit 875b556
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 695ad589698571046d42a4450c2d801486905535
refs/heads/master: ec6644d6325b5a38525f1d5b20fd4bf7db05cf2a
27 changes: 22 additions & 5 deletions trunk/drivers/crypto/talitos.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ struct talitos_private {
/* next channel to be assigned next incoming descriptor */
atomic_t last_chan;

/* per-channel number of requests pending in channel h/w fifo */
atomic_t *submit_count;

/* per-channel request fifo */
struct talitos_request **fifo;

Expand Down Expand Up @@ -263,15 +266,15 @@ static int talitos_submit(struct device *dev, struct talitos_desc *desc,

spin_lock_irqsave(&priv->head_lock[ch], flags);

head = priv->head[ch];
request = &priv->fifo[ch][head];

if (request->desc) {
/* request queue is full */
if (!atomic_inc_not_zero(&priv->submit_count[ch])) {
/* h/w fifo is full */
spin_unlock_irqrestore(&priv->head_lock[ch], flags);
return -EAGAIN;
}

head = priv->head[ch];
request = &priv->fifo[ch][head];

/* map descriptor and save caller data */
request->dma_desc = dma_map_single(dev, desc, sizeof(*desc),
DMA_BIDIRECTIONAL);
Expand Down Expand Up @@ -335,6 +338,9 @@ static void flush_channel(struct device *dev, int ch, int error, int reset_ch)
priv->tail[ch] = (tail + 1) & (priv->fifo_len - 1);

spin_unlock_irqrestore(&priv->tail_lock[ch], flags);

atomic_dec(&priv->submit_count[ch]);

saved_req.callback(dev, saved_req.desc, saved_req.context,
status);
/* channel may resume processing in single desc error case */
Expand Down Expand Up @@ -1337,6 +1343,7 @@ static int __devexit talitos_remove(struct of_device *ofdev)
if (hw_supports(dev, DESC_HDR_SEL0_RNG))
talitos_unregister_rng(dev);

kfree(priv->submit_count);
kfree(priv->tail);
kfree(priv->head);

Expand Down Expand Up @@ -1501,6 +1508,16 @@ static int talitos_probe(struct of_device *ofdev,
}
}

priv->submit_count = kmalloc(sizeof(int) * priv->num_channels,
GFP_KERNEL);
if (!priv->submit_count) {
dev_err(dev, "failed to allocate fifo submit count space\n");
err = -ENOMEM;
goto err_out;
}
for (i = 0; i < priv->num_channels; i++)
atomic_set(&priv->submit_count[i], -priv->chfifo_len);

priv->head = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL);
priv->tail = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL);
if (!priv->head || !priv->tail) {
Expand Down

0 comments on commit 875b556

Please sign in to comment.