浏览代码

crypto: ccp - Fix double add when creating new DMA command

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.

Cc: <stable@vger.kernel.org>
Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Gary R Hook 8 年之前
父节点
当前提交
e5da5c5667
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 1 0
      drivers/crypto/ccp/ccp-dev.h
  2. 5 1
      drivers/crypto/ccp/ccp-dmaengine.c

+ 1 - 0
drivers/crypto/ccp/ccp-dev.h

@@ -238,6 +238,7 @@ struct ccp_dma_chan {
 	struct ccp_device *ccp;
 	struct ccp_device *ccp;
 
 
 	spinlock_t lock;
 	spinlock_t lock;
+	struct list_head created;
 	struct list_head pending;
 	struct list_head pending;
 	struct list_head active;
 	struct list_head active;
 	struct list_head complete;
 	struct list_head complete;

+ 5 - 1
drivers/crypto/ccp/ccp-dmaengine.c

@@ -63,6 +63,7 @@ static void ccp_free_chan_resources(struct dma_chan *dma_chan)
 	ccp_free_desc_resources(chan->ccp, &chan->complete);
 	ccp_free_desc_resources(chan->ccp, &chan->complete);
 	ccp_free_desc_resources(chan->ccp, &chan->active);
 	ccp_free_desc_resources(chan->ccp, &chan->active);
 	ccp_free_desc_resources(chan->ccp, &chan->pending);
 	ccp_free_desc_resources(chan->ccp, &chan->pending);
+	ccp_free_desc_resources(chan->ccp, &chan->created);
 
 
 	spin_unlock_irqrestore(&chan->lock, flags);
 	spin_unlock_irqrestore(&chan->lock, flags);
 }
 }
@@ -273,6 +274,7 @@ static dma_cookie_t ccp_tx_submit(struct dma_async_tx_descriptor *tx_desc)
 	spin_lock_irqsave(&chan->lock, flags);
 	spin_lock_irqsave(&chan->lock, flags);
 
 
 	cookie = dma_cookie_assign(tx_desc);
 	cookie = dma_cookie_assign(tx_desc);
+	list_del(&desc->entry);
 	list_add_tail(&desc->entry, &chan->pending);
 	list_add_tail(&desc->entry, &chan->pending);
 
 
 	spin_unlock_irqrestore(&chan->lock, flags);
 	spin_unlock_irqrestore(&chan->lock, flags);
@@ -426,7 +428,7 @@ static struct ccp_dma_desc *ccp_create_desc(struct dma_chan *dma_chan,
 
 
 	spin_lock_irqsave(&chan->lock, sflags);
 	spin_lock_irqsave(&chan->lock, sflags);
 
 
-	list_add_tail(&desc->entry, &chan->pending);
+	list_add_tail(&desc->entry, &chan->created);
 
 
 	spin_unlock_irqrestore(&chan->lock, sflags);
 	spin_unlock_irqrestore(&chan->lock, sflags);
 
 
@@ -610,6 +612,7 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)
 	/*TODO: Purge the complete list? */
 	/*TODO: Purge the complete list? */
 	ccp_free_desc_resources(chan->ccp, &chan->active);
 	ccp_free_desc_resources(chan->ccp, &chan->active);
 	ccp_free_desc_resources(chan->ccp, &chan->pending);
 	ccp_free_desc_resources(chan->ccp, &chan->pending);
+	ccp_free_desc_resources(chan->ccp, &chan->created);
 
 
 	spin_unlock_irqrestore(&chan->lock, flags);
 	spin_unlock_irqrestore(&chan->lock, flags);
 
 
@@ -679,6 +682,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
 		chan->ccp = ccp;
 		chan->ccp = ccp;
 
 
 		spin_lock_init(&chan->lock);
 		spin_lock_init(&chan->lock);
+		INIT_LIST_HEAD(&chan->created);
 		INIT_LIST_HEAD(&chan->pending);
 		INIT_LIST_HEAD(&chan->pending);
 		INIT_LIST_HEAD(&chan->active);
 		INIT_LIST_HEAD(&chan->active);
 		INIT_LIST_HEAD(&chan->complete);
 		INIT_LIST_HEAD(&chan->complete);