-static inline dma_addr_t buf_map_to_sec4_sg(struct device *jrdev,
- struct sec4_sg_entry *sec4_sg,
- u8 *buf, int buflen)
+-{
+- dma_addr_t buf_dma;
+/* Map current buffer in state (if length > 0) and put it in link table */
+static inline int buf_map_to_sec4_sg(struct device *jrdev,
+ struct sec4_sg_entry *sec4_sg,
+ struct caam_hash_state *state)
- {
-- dma_addr_t buf_dma;
++{
+ int buflen = *current_buflen(state);
-
-- buf_dma = dma_map_single(jrdev, buf, buflen, DMA_TO_DEVICE);
-- dma_to_sec4_sg_one(sec4_sg, buf_dma, buflen, 0);
++
+ if (!buflen)
+ return 0;
-
-- return buf_dma;
--}
++
+ state->buf_dma = dma_map_single(jrdev, current_buf(state), buflen,
+ DMA_TO_DEVICE);
+ if (dma_mapping_error(jrdev, state->buf_dma)) {
+ return -ENOMEM;
+ }
+- buf_dma = dma_map_single(jrdev, buf, buflen, DMA_TO_DEVICE);
+- dma_to_sec4_sg_one(sec4_sg, buf_dma, buflen, 0);
++ dma_to_sec4_sg_one(sec4_sg, state->buf_dma, buflen, 0);
+
+- return buf_dma;
+-}
+-
-/*
- * Only put buffer in link table if it contains data, which is possible,
- * since a buffer has previously been used, and needs to be unmapped,
- buf_dma = buf_map_to_sec4_sg(jrdev, sec4_sg, buf, buflen);
- else
- buf_dma = 0;
-+ dma_to_sec4_sg_one(sec4_sg, state->buf_dma, buflen, 0);
-
+-
- return buf_dma;
+ return 0;
}
u32 *desc;
int digestsize = crypto_ahash_digestsize(ahash);
struct ahash_edesc *edesc;
-@@ -1246,7 +1083,6 @@ static int ahash_final_no_ctx(struct aha
+@@ -1249,7 +1086,6 @@ static int ahash_final_no_ctx(struct aha
dev_err(jrdev, "unable to map dst\n");
goto unmap;
}
#ifdef DEBUG
print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
-@@ -1276,13 +1112,12 @@ static int ahash_update_no_ctx(struct ah
+@@ -1279,13 +1115,12 @@ static int ahash_update_no_ctx(struct ah
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
struct caam_hash_state *state = ahash_request_ctx(req);
struct device *jrdev = ctx->jrdev;
int in_len = *buflen + req->nbytes, to_hash;
int sec4_sg_bytes, src_nents, mapped_nents;
struct ahash_edesc *edesc;
-@@ -1329,10 +1164,11 @@ static int ahash_update_no_ctx(struct ah
+@@ -1332,10 +1167,11 @@ static int ahash_update_no_ctx(struct ah
edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes;
sg_to_sec4_sg_last(req->src, mapped_nents,
edesc->sec4_sg + 1, 0);
-@@ -1342,8 +1178,6 @@ static int ahash_update_no_ctx(struct ah
+@@ -1345,8 +1181,6 @@ static int ahash_update_no_ctx(struct ah
*next_buflen, 0);
}
desc = edesc->hw_desc;
edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,
-@@ -1403,12 +1237,9 @@ static int ahash_finup_no_ctx(struct aha
+@@ -1406,12 +1240,9 @@ static int ahash_finup_no_ctx(struct aha
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
struct caam_hash_state *state = ahash_request_ctx(req);
struct device *jrdev = ctx->jrdev;
u32 *desc;
int sec4_sg_bytes, sec4_sg_src_index, src_nents, mapped_nents;
int digestsize = crypto_ahash_digestsize(ahash);
-@@ -1450,9 +1281,9 @@ static int ahash_finup_no_ctx(struct aha
+@@ -1453,9 +1284,9 @@ static int ahash_finup_no_ctx(struct aha
edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes;
ret = ahash_edesc_add_src(ctx, edesc, req, mapped_nents, 1, buflen,
req->nbytes);
-@@ -1496,11 +1327,10 @@ static int ahash_update_first(struct aha
+@@ -1499,11 +1330,10 @@ static int ahash_update_first(struct aha
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
struct caam_hash_state *state = ahash_request_ctx(req);
struct device *jrdev = ctx->jrdev;
int to_hash;
u32 *desc;
int src_nents, mapped_nents;
-@@ -1545,7 +1375,6 @@ static int ahash_update_first(struct aha
+@@ -1548,7 +1378,6 @@ static int ahash_update_first(struct aha
}
edesc->src_nents = src_nents;
ret = ahash_edesc_add_src(ctx, edesc, req, mapped_nents, 0, 0,
to_hash);
-@@ -1582,6 +1411,7 @@ static int ahash_update_first(struct aha
+@@ -1585,6 +1414,7 @@ static int ahash_update_first(struct aha
state->final = ahash_final_no_ctx;
scatterwalk_map_and_copy(next_buf, req->src, 0,
req->nbytes, 0);
}
#ifdef DEBUG
print_hex_dump(KERN_ERR, "next buf@"__stringify(__LINE__)": ",
-@@ -1688,7 +1518,6 @@ struct caam_hash_template {
+@@ -1691,7 +1521,6 @@ struct caam_hash_template {
unsigned int blocksize;
struct ahash_alg template_ahash;
u32 alg_type;
};
/* ahash descriptors */
-@@ -1714,7 +1543,6 @@ static struct caam_hash_template driver_
+@@ -1717,7 +1546,6 @@ static struct caam_hash_template driver_
},
},
.alg_type = OP_ALG_ALGSEL_SHA1,
}, {
.name = "sha224",
.driver_name = "sha224-caam",
-@@ -1736,7 +1564,6 @@ static struct caam_hash_template driver_
+@@ -1739,7 +1567,6 @@ static struct caam_hash_template driver_
},
},
.alg_type = OP_ALG_ALGSEL_SHA224,
}, {
.name = "sha256",
.driver_name = "sha256-caam",
-@@ -1758,7 +1585,6 @@ static struct caam_hash_template driver_
+@@ -1761,7 +1588,6 @@ static struct caam_hash_template driver_
},
},
.alg_type = OP_ALG_ALGSEL_SHA256,
}, {
.name = "sha384",
.driver_name = "sha384-caam",
-@@ -1780,7 +1606,6 @@ static struct caam_hash_template driver_
+@@ -1783,7 +1609,6 @@ static struct caam_hash_template driver_
},
},
.alg_type = OP_ALG_ALGSEL_SHA384,
}, {
.name = "sha512",
.driver_name = "sha512-caam",
-@@ -1802,7 +1627,6 @@ static struct caam_hash_template driver_
+@@ -1805,7 +1630,6 @@ static struct caam_hash_template driver_
},
},
.alg_type = OP_ALG_ALGSEL_SHA512,
}, {
.name = "md5",
.driver_name = "md5-caam",
-@@ -1824,14 +1648,12 @@ static struct caam_hash_template driver_
+@@ -1827,14 +1651,12 @@ static struct caam_hash_template driver_
},
},
.alg_type = OP_ALG_ALGSEL_MD5,
struct ahash_alg ahash_alg;
};
-@@ -1853,6 +1675,7 @@ static int caam_hash_cra_init(struct cry
+@@ -1856,6 +1678,7 @@ static int caam_hash_cra_init(struct cry
HASH_MSG_LEN + SHA256_DIGEST_SIZE,
HASH_MSG_LEN + 64,
HASH_MSG_LEN + SHA512_DIGEST_SIZE };
/*
* Get a Job ring from Job Ring driver to ensure in-order
-@@ -1863,11 +1686,31 @@ static int caam_hash_cra_init(struct cry
+@@ -1866,11 +1689,31 @@ static int caam_hash_cra_init(struct cry
pr_err("Job Ring Device allocation for transform failed\n");
return PTR_ERR(ctx->jrdev);
}
OP_ALG_ALGSEL_SHIFT];
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
-@@ -1879,30 +1722,10 @@ static void caam_hash_cra_exit(struct cr
+@@ -1882,30 +1725,10 @@ static void caam_hash_cra_exit(struct cr
{
struct caam_hash_ctx *ctx = crypto_tfm_ctx(tfm);
caam_jr_free(ctx->jrdev);
}
-@@ -1961,7 +1784,6 @@ caam_hash_alloc(struct caam_hash_templat
+@@ -1964,7 +1787,6 @@ caam_hash_alloc(struct caam_hash_templat
alg->cra_type = &crypto_ahash_type;
t_alg->alg_type = template->alg_type;