All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] crypto: ccp - minor code fixes
@ 2014-02-24 14:41 Tom Lendacky
  2014-02-24 14:42 ` [PATCH 1/3] crypto: ccp - Prevent a possible lost CCP command request Tom Lendacky
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tom Lendacky @ 2014-02-24 14:41 UTC (permalink / raw)
  To: linux-crypto, herbert, davem; +Cc: linux-kernel

The following series implements some fixes to some code paths executed
during crypto API request processing.  These fixes address processing of
requests when the CCP driver returns -EBUSY and freeing memory in error
paths.

This patch series is based on the cryptodev-2.6 kernel tree.

---

Tom Lendacky (3):
      crypto: ccp - Prevent a possible lost CCP command request
      crypto: ccp - Invoke context callback when there is a backlog error
      crypto: ccp - Account for CCP backlog processing


 drivers/crypto/ccp/ccp-crypto-main.c |   25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

-- 
Tom Lendacky

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] crypto: ccp - Prevent a possible lost CCP command request
  2014-02-24 14:41 [PATCH 0/3] crypto: ccp - minor code fixes Tom Lendacky
@ 2014-02-24 14:42 ` Tom Lendacky
  2014-02-24 14:42 ` [PATCH 2/3] crypto: ccp - Invoke context callback when there is a backlog error Tom Lendacky
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2014-02-24 14:42 UTC (permalink / raw)
  To: linux-crypto, herbert, davem; +Cc: linux-kernel

If a CCP command has been queued for processing at the
crypto layer then, when dequeueing it for processing, the
"can backlog" flag must be set so that the request isn't
lost if the CCP backlog queue limit is reached.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/ccp-crypto-main.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c
index 010fded..9d30d6f 100644
--- a/drivers/crypto/ccp/ccp-crypto-main.c
+++ b/drivers/crypto/ccp/ccp-crypto-main.c
@@ -174,6 +174,10 @@ static void ccp_crypto_complete(void *data, int err)
 
 	/* Submit the next cmd */
 	while (held) {
+		/* Since we have already queued the cmd, we must indicate that
+		 * we can backlog so as not to "lose" this request.
+		 */
+		held->cmd->flags |= CCP_CMD_MAY_BACKLOG;
 		ret = ccp_enqueue_cmd(held->cmd);
 		if (ccp_crypto_success(ret))
 			break;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] crypto: ccp - Invoke context callback when there is a backlog error
  2014-02-24 14:41 [PATCH 0/3] crypto: ccp - minor code fixes Tom Lendacky
  2014-02-24 14:42 ` [PATCH 1/3] crypto: ccp - Prevent a possible lost CCP command request Tom Lendacky
@ 2014-02-24 14:42 ` Tom Lendacky
  2014-02-24 14:42 ` [PATCH 3/3] crypto: ccp - Account for CCP backlog processing Tom Lendacky
  2014-02-25 12:19 ` [PATCH 0/3] crypto: ccp - minor code fixes Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2014-02-24 14:42 UTC (permalink / raw)
  To: linux-crypto, herbert, davem; +Cc: linux-kernel

Invoke the callback routine associated with the crypto context
if an error is encountered sending the command to the CCP during
backlog processing.  This is needed to free any resources used
by the command.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/ccp-crypto-main.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c
index 9d30d6f..7d98635 100644
--- a/drivers/crypto/ccp/ccp-crypto-main.c
+++ b/drivers/crypto/ccp/ccp-crypto-main.c
@@ -183,6 +183,9 @@ static void ccp_crypto_complete(void *data, int err)
 			break;
 
 		/* Error occurred, report it and get the next entry */
+		ctx = crypto_tfm_ctx(held->req->tfm);
+		if (ctx->complete)
+			ret = ctx->complete(held->req, ret);
 		held->req->complete(held->req, ret);
 
 		next = ccp_crypto_cmd_complete(held, &backlog);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] crypto: ccp - Account for CCP backlog processing
  2014-02-24 14:41 [PATCH 0/3] crypto: ccp - minor code fixes Tom Lendacky
  2014-02-24 14:42 ` [PATCH 1/3] crypto: ccp - Prevent a possible lost CCP command request Tom Lendacky
  2014-02-24 14:42 ` [PATCH 2/3] crypto: ccp - Invoke context callback when there is a backlog error Tom Lendacky
@ 2014-02-24 14:42 ` Tom Lendacky
  2014-02-25 12:19 ` [PATCH 0/3] crypto: ccp - minor code fixes Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2014-02-24 14:42 UTC (permalink / raw)
  To: linux-crypto, herbert, davem; +Cc: linux-kernel

When the crypto layer is able to queue up a command for processing
by the CCP on the initial call to ccp_crypto_enqueue_request and
the CCP returns -EBUSY, then if the backlog flag is not set the
command needs to be freed and not added to the active command list.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/ccp-crypto-main.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c
index 7d98635..20dc848 100644
--- a/drivers/crypto/ccp/ccp-crypto-main.c
+++ b/drivers/crypto/ccp/ccp-crypto-main.c
@@ -205,6 +205,7 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd)
 {
 	struct ccp_crypto_cmd *active = NULL, *tmp;
 	unsigned long flags;
+	bool free_cmd = true;
 	int ret;
 
 	spin_lock_irqsave(&req_queue_lock, flags);
@@ -231,7 +232,10 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd)
 	if (!active) {
 		ret = ccp_enqueue_cmd(crypto_cmd->cmd);
 		if (!ccp_crypto_success(ret))
-			goto e_lock;
+			goto e_lock;	/* Error, don't queue it */
+		if ((ret == -EBUSY) &&
+		    !(crypto_cmd->cmd->flags & CCP_CMD_MAY_BACKLOG))
+			goto e_lock;	/* Not backlogging, don't queue it */
 	}
 
 	if (req_queue.cmd_count >= CCP_CRYPTO_MAX_QLEN) {
@@ -244,9 +248,14 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd)
 	req_queue.cmd_count++;
 	list_add_tail(&crypto_cmd->entry, &req_queue.cmds);
 
+	free_cmd = false;
+
 e_lock:
 	spin_unlock_irqrestore(&req_queue_lock, flags);
 
+	if (free_cmd)
+		kfree(crypto_cmd);
+
 	return ret;
 }
 
@@ -262,7 +271,6 @@ int ccp_crypto_enqueue_request(struct crypto_async_request *req,
 {
 	struct ccp_crypto_cmd *crypto_cmd;
 	gfp_t gfp;
-	int ret;
 
 	gfp = req->flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC;
 
@@ -287,11 +295,7 @@ int ccp_crypto_enqueue_request(struct crypto_async_request *req,
 	else
 		cmd->flags &= ~CCP_CMD_MAY_BACKLOG;
 
-	ret = ccp_crypto_enqueue_cmd(crypto_cmd);
-	if (!ccp_crypto_success(ret))
-		kfree(crypto_cmd);
-
-	return ret;
+	return ccp_crypto_enqueue_cmd(crypto_cmd);
 }
 
 struct scatterlist *ccp_crypto_sg_table_add(struct sg_table *table,

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] crypto: ccp - minor code fixes
  2014-02-24 14:41 [PATCH 0/3] crypto: ccp - minor code fixes Tom Lendacky
                   ` (2 preceding siblings ...)
  2014-02-24 14:42 ` [PATCH 3/3] crypto: ccp - Account for CCP backlog processing Tom Lendacky
@ 2014-02-25 12:19 ` Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2014-02-25 12:19 UTC (permalink / raw)
  To: Tom Lendacky; +Cc: linux-crypto, davem, linux-kernel

On Mon, Feb 24, 2014 at 08:41:56AM -0600, Tom Lendacky wrote:
> The following series implements some fixes to some code paths executed
> during crypto API request processing.  These fixes address processing of
> requests when the CCP driver returns -EBUSY and freeing memory in error
> paths.
> 
> This patch series is based on the cryptodev-2.6 kernel tree.

All applied.  Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-02-25 12:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 14:41 [PATCH 0/3] crypto: ccp - minor code fixes Tom Lendacky
2014-02-24 14:42 ` [PATCH 1/3] crypto: ccp - Prevent a possible lost CCP command request Tom Lendacky
2014-02-24 14:42 ` [PATCH 2/3] crypto: ccp - Invoke context callback when there is a backlog error Tom Lendacky
2014-02-24 14:42 ` [PATCH 3/3] crypto: ccp - Account for CCP backlog processing Tom Lendacky
2014-02-25 12:19 ` [PATCH 0/3] crypto: ccp - minor code fixes Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.