diff options
Diffstat (limited to 'target/linux/layerscape/patches-4.9/804-crypto-support-layerscape.patch')
-rw-r--r-- | target/linux/layerscape/patches-4.9/804-crypto-support-layerscape.patch | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/target/linux/layerscape/patches-4.9/804-crypto-support-layerscape.patch b/target/linux/layerscape/patches-4.9/804-crypto-support-layerscape.patch index 0252713480..6c91543e6f 100644 --- a/target/linux/layerscape/patches-4.9/804-crypto-support-layerscape.patch +++ b/target/linux/layerscape/patches-4.9/804-crypto-support-layerscape.patch @@ -21630,21 +21630,18 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> -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)) { @@ -21653,6 +21650,13 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> + 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, @@ -21668,8 +21672,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> - 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; } @@ -22259,7 +22262,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; } @@ -22267,7 +22270,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> #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; @@ -22287,7 +22290,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; @@ -22302,7 +22305,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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); } @@ -22311,7 +22314,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; @@ -22327,7 +22330,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; @@ -22340,7 +22343,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; @@ -22356,7 +22359,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; @@ -22364,7 +22367,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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); @@ -22372,7 +22375,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> } #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; @@ -22380,7 +22383,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> }; /* 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, @@ -22388,7 +22391,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> }, { .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, @@ -22396,7 +22399,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> }, { .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, @@ -22404,7 +22407,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> }, { .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, @@ -22412,7 +22415,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> }, { .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, @@ -22420,7 +22423,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> }, { .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, @@ -22435,7 +22438,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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 }; @@ -22443,7 +22446,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> /* * 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); } @@ -22478,7 +22481,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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); @@ -22513,7 +22516,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> 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; |