aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary R Hook <gary.hook@amd.com>2017-01-27 18:09:04 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-14 18:25:33 -0500
commitf77e7b119ff18d4732b6e08b3d10c4e324de9442 (patch)
treefe964174e9ec9892571d6b4f4d1f78cc3eb5ed05
parent1105ccf25118894ffde5b50d43c52b9e39fe3fc9 (diff)
crypto: ccp - Fix double add when creating new DMA command
commit e5da5c5667381d2772374ee6a2967b3576c9483d upstream. Eliminate a double-add by creating a new list to manage command descriptors when created; move the descriptor to the pending list when the command is submitted. Signed-off-by: Gary R Hook <gary.hook@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/crypto/ccp/ccp-dev.h1
-rw-r--r--drivers/crypto/ccp/ccp-dmaengine.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index da5f4a678083..340aef14d616 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -238,6 +238,7 @@ struct ccp_dma_chan {
238 struct ccp_device *ccp; 238 struct ccp_device *ccp;
239 239
240 spinlock_t lock; 240 spinlock_t lock;
241 struct list_head created;
241 struct list_head pending; 242 struct list_head pending;
242 struct list_head active; 243 struct list_head active;
243 struct list_head complete; 244 struct list_head complete;
diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
index 6553912804f7..e5d9278f4019 100644
--- a/drivers/crypto/ccp/ccp-dmaengine.c
+++ b/drivers/crypto/ccp/ccp-dmaengine.c
@@ -63,6 +63,7 @@ static void ccp_free_chan_resources(struct dma_chan *dma_chan)
63 ccp_free_desc_resources(chan->ccp, &chan->complete); 63 ccp_free_desc_resources(chan->ccp, &chan->complete);
64 ccp_free_desc_resources(chan->ccp, &chan->active); 64 ccp_free_desc_resources(chan->ccp, &chan->active);
65 ccp_free_desc_resources(chan->ccp, &chan->pending); 65 ccp_free_desc_resources(chan->ccp, &chan->pending);
66 ccp_free_desc_resources(chan->ccp, &chan->created);
66 67
67 spin_unlock_irqrestore(&chan->lock, flags); 68 spin_unlock_irqrestore(&chan->lock, flags);
68} 69}
@@ -273,6 +274,7 @@ static dma_cookie_t ccp_tx_submit(struct dma_async_tx_descriptor *tx_desc)
273 spin_lock_irqsave(&chan->lock, flags); 274 spin_lock_irqsave(&chan->lock, flags);
274 275
275 cookie = dma_cookie_assign(tx_desc); 276 cookie = dma_cookie_assign(tx_desc);
277 list_del(&desc->entry);
276 list_add_tail(&desc->entry, &chan->pending); 278 list_add_tail(&desc->entry, &chan->pending);
277 279
278 spin_unlock_irqrestore(&chan->lock, flags); 280 spin_unlock_irqrestore(&chan->lock, flags);
@@ -426,7 +428,7 @@ static struct ccp_dma_desc *ccp_create_desc(struct dma_chan *dma_chan,
426 428
427 spin_lock_irqsave(&chan->lock, sflags); 429 spin_lock_irqsave(&chan->lock, sflags);
428 430
429 list_add_tail(&desc->entry, &chan->pending); 431 list_add_tail(&desc->entry, &chan->created);
430 432
431 spin_unlock_irqrestore(&chan->lock, sflags); 433 spin_unlock_irqrestore(&chan->lock, sflags);
432 434
@@ -610,6 +612,7 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)
610 /*TODO: Purge the complete list? */ 612 /*TODO: Purge the complete list? */
611 ccp_free_desc_resources(chan->ccp, &chan->active); 613 ccp_free_desc_resources(chan->ccp, &chan->active);
612 ccp_free_desc_resources(chan->ccp, &chan->pending); 614 ccp_free_desc_resources(chan->ccp, &chan->pending);
615 ccp_free_desc_resources(chan->ccp, &chan->created);
613 616
614 spin_unlock_irqrestore(&chan->lock, flags); 617 spin_unlock_irqrestore(&chan->lock, flags);
615 618
@@ -679,6 +682,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
679 chan->ccp = ccp; 682 chan->ccp = ccp;
680 683
681 spin_lock_init(&chan->lock); 684 spin_lock_init(&chan->lock);
685 INIT_LIST_HEAD(&chan->created);
682 INIT_LIST_HEAD(&chan->pending); 686 INIT_LIST_HEAD(&chan->pending);
683 INIT_LIST_HEAD(&chan->active); 687 INIT_LIST_HEAD(&chan->active);
684 INIT_LIST_HEAD(&chan->complete); 688 INIT_LIST_HEAD(&chan->complete);