diff mbox

[RFC,09/11] crypto: caam - Fix incorrect size when DMA unmapping buffer

Message ID 1434412379-11623-10-git-send-email-vicki.milhoan@freescale.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Victoria Milhoan June 15, 2015, 11:52 p.m. UTC
The CAAM driver uses two data buffers to store data for a hashing operation,
with one buffer defined as active. This change forces switching of the
active buffer when executing a hashing operation to avoid a later DMA unmap
using the length of the opposite buffer.

Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
---
 drivers/crypto/caam/caamhash.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Herbert Xu June 16, 2015, 6:41 a.m. UTC | #1
On Mon, Jun 15, 2015 at 04:52:57PM -0700, Victoria Milhoan wrote:
> The CAAM driver uses two data buffers to store data for a hashing operation,
> with one buffer defined as active. This change forces switching of the
> active buffer when executing a hashing operation to avoid a later DMA unmap
> using the length of the opposite buffer.
> 
> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>

Applied.
diff mbox

Patch

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index f2f1e87..6720332 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -843,17 +843,17 @@  static int ahash_update_ctx(struct ahash_request *req)
 			src_map_to_sec4_sg(jrdev, req->src, src_nents,
 					   edesc->sec4_sg + sec4_sg_src_index,
 					   chained);
-			if (*next_buflen) {
+			if (*next_buflen)
 				scatterwalk_map_and_copy(next_buf, req->src,
 							 to_hash - *buflen,
 							 *next_buflen, 0);
-				state->current_buf = !state->current_buf;
-			}
 		} else {
 			(edesc->sec4_sg + sec4_sg_src_index - 1)->len |=
 							SEC4_SG_LEN_FIN;
 		}
 
+		state->current_buf = !state->current_buf;
+
 		sh_len = desc_len(sh_desc);
 		desc = edesc->hw_desc;
 		init_job_desc_shared(desc, ptr, sh_len, HDR_SHARE_DEFER |
@@ -1276,9 +1276,10 @@  static int ahash_update_no_ctx(struct ahash_request *req)
 			scatterwalk_map_and_copy(next_buf, req->src,
 						 to_hash - *buflen,
 						 *next_buflen, 0);
-			state->current_buf = !state->current_buf;
 		}
 
+		state->current_buf = !state->current_buf;
+
 		sh_len = desc_len(sh_desc);
 		desc = edesc->hw_desc;
 		init_job_desc_shared(desc, ptr, sh_len, HDR_SHARE_DEFER |